Additional Pin Assignments for Duet2 in RRF 3?
-
How many heaters does your machine have?
-
And which/how many of the stepper drivers on the expansion do you need as steppers?
-
@dc42 said in Additional Pin Assignments for Duet2 in RRF 3?:
How many heaters does your machine have?
Three.
However all the heater outputs are used for other outputs currently, except for Heater 5 and
Thermistor 6.@bearer said in Additional Pin Assignments for Duet2 in RRF 3?:
And which/how many of the stepper drivers on the expansion do you need as steppers?
Four. (E3, E4, E5, E6)
This is for that industrial 3D printer retrofit with all kinds of features like locking doors, emergency alarms, LED lighting, dual extruder, articulating head.. etc. It just has a lot of inputs and outputs to deal with.
-
For now at least I suggest that you continue to use your own firmware variant. The only fileI think you need to change is Pins_DuetNG.h.
An alternative solution might be to add a SX1509B expander board (available from Sparkfun and Adafruit and their resellers) and use that to provide the additional I/O.
-
If this is for the custom board for the uPrint the expansion might be better idea than maintaining a fork if you're going to respin the board anyway
-
@dc42 said in Additional Pin Assignments for Duet2 in RRF 3?:
For now at least I suggest that you continue to use your own firmware variant. The only fileI think you need to change is Pins_DuetNG.h.
An alternative solution might be to add a SX1509B expander board (available from Sparkfun and Adafruit and their resellers) and use that to provide the additional I/O.
Am I correct in understanding the SX1509B gives 16 additional inputs or outputs? The SX1509B page only seems to make reference to using it for outputs.
Right now I have 23 general I/O, 4 pairs of step/dir and one SPI device (ADC for thermocouples). It appears if I add the SX chip, I can accomplish all of that from one EXP header and reduce the BOM which is a huge plus. And no need for custom firmware!
Looks like I'll be doing that now.
Oh and SX1509B allows for 5V I/O? SOLD!
Any way I can connect two SX1509B? Are there any extra addresses available?
-
@AJ-Quick said in Additional Pin Assignments for Duet2 in RRF 3?:
Any way I can connect two SX1509B? Are there any extra addresses available?
I think you can do...But it is a hassle to adress the second one....
For the first one you can use the build in G-Codes and pin assignments but for the second one you have to write the registers directly.
https://forum.duet3d.com/topic/13911/sx1509-on-maestro-does-it-work
It has take me days to figure out how the registers are adressed.... -
Follow up regarding SX1509. I now see that the DueX board uses the other expansion address, so if I were to have two SX1509, it would make the firmware believe the DueX is connected. Is there any problem with that?
I would be using the I/O with the high open drain, which is what the DueX already seems to use by default. This actually leads into a problem I may be seeing:
If I want to use the SX1509 as high open drain, it cannot be configured in the code?
I see:
read, write, pwm, servo
Do I configure the pin as "write" and then use M260: i2c Send and/or request Data as @DIY-O-Sphere just pointed out to manually set the mode to OUTPUT_HIGH_OPEN_DRAIN?
Actually wouldn't I need to use M260 every time since WriteDigital and therefore M42 is only going to output a low/high and overwrite the open drain?
Looking at the SX1509 addresses:
0x3E: Duex2/5
0x3F: Un-used?
0x70: Un-used?
0x71: SX1509Pins 120 - Pins 135.Pins 220-235Let's say I use address 0x3E address for my outputs that need to be pulled up to 5V (standard behavior for the Duex on 0x3E) and then use the 0x71 address for my 0-5V inputs. Would that work?
Would this cause the duet to freakout because it isn't actually a Duex attached?
-
Actually. If I were to pull up all pins to 5V at the beginning, I would be letting all of my heaters, be set to ON until the SX1509 is intiailized and configured. That's not safe for me to do.
I'll just keep my logic level shifters.
My question about using two SX1509 still stands though.
Can I use 0x3E for my inputs and 0x71 for my outputs for example? Is 0x3E always configured to expect an INPUT_PULL up?
Could 0x3F be added for pins
136-152236-251 and 0x70 for153-169252-267? -
Here is what my expansion board could look like with two SX1509:
By having two SX1509 it allowed me to remove all additional connectors and now I'm able to run everything through the EXT connector. Traces are a lot simpler now too. The only things running to the EXT connector are now: Four sets of Step / Dir pins, SPI for Thermocouple ADC, and the two I2C lines plus power / ground.
There is also a bonus safety feature here because it uses the logic level shifting chips. If the SX1509 is not yet configured (or is in diagnostic mode), the connection to the printer is effectively severed and the printer will go into standby.
Now what I'm wondering if it would be worthwhile to do one of the following:
Expand DueXn.cpp so that an additional 32 I/O pins can be available on 0x3F and 0x70.
Or:
Write and / or extend DueXn.cpp to check for 0x3F & 0x70 and if present, assume the "Stratadue" is connected and configure the pins automatically in the same way the Duex2/5 currently do. I'd like to avoid doing that, as it will make upgrading to future firmware releases harder and my C programming skills are lacking. I am also not sure how many others may be interested in using this board and retrofitting their own machines.
-
Here is the problem with adding two more SX1509B or 32 more pins. Where do you put them?
My initial thought was to put them between: 236-267. However, since the pins are 1-byte, anything over 256 cannot be added. As RRF3 now uses pin names, we do not really care about what the pin numbers are any longer.
Perhaps 1 set of pins could be placed at 236-251 and the other can be at 183-199? I can't find anything being assigned to those pin numbers, but I didn't look overly hard. It seems much of 120-199 is un-used.
For logical names, I was thinking the numbering could continue on: sx1509b.16, sx1509b.17, sx1509b.18.. etc. But could also alias: sx1509b2.0, sx1509b2.1, sx1509b2.2.. etc.
Addresses
0x3E = Duex2/5 (Pins 200-215)
0x71 = SB1509B #1 (Pins 220-235)
0x3F = SB1509B #2 (Pins 236-251 OR 168-183)
0x70 = SB1509B #3 (Pins 184-199)The function GetAdditionalExpansionBoardName would return "SX1509B expander (0x71)" to differentiate between the various channels when looking at the Firmware configuration.
My lazy method of writing the code was to just duplicate the code for each SX1509B. This is not a good code practice. Would it be possible to place the AdditionalExpansionBoards into their own class or to create a struct of each SX1509B to promote code re-use?
For those that write the firmware: Is any of this worthwhile to do?
-
We already have it in mind to support a "DueX0" board. This would be like a DueX5 but with no on-board stepper drivers. It would be recognised by the SX1509B being configured at address 0x70 instead of at 0x3E. So you could use two SX1509b chips on your board, configured at addresses 0x70 and 0x71. The one at 0x70 would be configured by the Duet in the same way as a DueX, i.e. with 9 inputs and 6 outputs. Would this give you enough I/O?
-
@dc42 said in Additional Pin Assignments for Duet2 in RRF 3?:
We already have it in mind to support a "DueX0" board. This would be like a DueX5 but with no on-board stepper drivers. It would be recognised by the SX1509B being configured at address 0x70 instead of at 0x3E. So you could use two SX1509b chips on your board, configured at addresses 0x70 and 0x71. The one at 0x70 would be configured by the Duet in the same way as a DueX, i.e. with 9 inputs and 6 outputs. Would this give you enough I/O?
In my opinion: I wouldn't want to see expansion boards taking up the SX1509B addresses and forcing 16 I/O to be locked to 9 inputs and 6 outputs. I think rather than hardcoding the pins for the Duex0/2/5 the pins should be set in a configuration file that can be provided to the end user. Want to use the Duex E4 stop as an output? You should be able to do that by changing the configuration file.
Alternatively. Rather than using the SX1509B address and a check bit (14 on Duex2/5?) to identify which board is connected, I would suggest having a separate i2c eprom added to the expansion board hardware. Something like a AT24C01 can be added for pennies. If the Duet can communicate with what device, it can inform the duet what is connected (Duex 0 or 2 or 5), what hardware version it is (0.7, 0.8, or 0.9a) and then hardcode the pins for the expansion board accordingly.
That way, all SX1509B chips' addresses can be accessible for 16 I/O unless the AT24C01 eeprom identifies which board is actually connected. For all others, they can set the pins through a configuration file.
Keep in mind I'm only suggesting this for RRF V3 and onward. Since the Duex 2/5 are already out, lets leave them hardcoded. But let's open up the other 2 SX1509B addresses for use by anyone.
@dc42 said in Additional Pin Assignments for Duet2 in RRF 3?:
Would this give you enough I/O?
Honestly. Probably not. The pins that are locked to input or output may not be the pins that I want to be used as inputs or outputs. Design wise, it makes sense for the I/O pins to go directly to the nearest pin it can. By saying one pin can only be used as an input and another can only be used as an output is placing greater limitations that hinders development of expansion boards.
I totally get it though if you want the official firmware releases to only support official Duet produced expansion boards. It just could become a problem if you start having multiple expansion boards with different revision designs and you need to account for all of them.
Far better to just allow everything to be setup in a config file. Provide the default settings and allow the end user the option to modify them for their installation.
-
The design changes for the next batch of DueX PCBs are already complete. Even with our proposed DueX0 support, there are still two addresses free for SX1509B expansion: 0x3F and 0x71.
-
@dc42 When will those addresses be accessible in the firmware?
I'll plan on using those two addresses on my hardware.
Just to doublecheck:
0x3E is Duex2/5
0x3F will be available for SX1509
0x70 will be Duex0
0x71 is currently available for SX1509Correct?
-
I have created my PCB with the two SX1509B chips at addresses 0x3F and 0x71.
I know I can access them directly with M260, but are there any plans for adding the 2nd SX1509B chip to the logical pins so they can be accessed through M574, M670 and M950? Actually I don't think I can use M260 for a lot of things, because I do need end stops and heaters to be specified and can't rely upon M260 for that.
I would be able to duplicate the existing SX1509B code in the firmware for 0x3F and submit a pull request, but that would be sloppy.
-
I've submitted a pull request to have two SX1509 boards available:
https://github.com/dc42/RepRapFirmware/pull/379
Just built the binaries and I am going to go test it with my Duet2.