Duet Maestro and controlling 16-port relay
-
The pins are incapable for PWM or switching
You have to remap fan or heater pins -
Ok, where is this info seen? Looking here: https://duet3d.dozuki.com/Wiki/Using_servos_and_controlling_unused_IO_pins, the pins 60-63 (CS5-CS8) on Duet2Wifi have same characteristics as Maestro's pins 60-63 have. There is a mention of Due2Wifi CS-pins being general purpose I/O pins, though... but no mention of Maestro's pins NOT being general purpose pins. Me confused.
If the pins truly are incapable of controlling the relay, I think I'll need to swap the boards so that I'll be using the Duet2Wifi to control this 16-port relay and Duet Maestro to control the 8-port relay. With the 8-port relay I'm currently only using 4 extruders and I only need 3 I/O pins for that so I can sacrifice heater or fan. But with the machine using the 16-port relay I'm thinking about experimenting with dual hotend-multi extruder hybrid setup and I probably can't spare any heaters or fans.
Last option is to ditch Duet and use MKS Sbase I have on other machine, it has all the pins I need.
-
Tested Maestro's E1 heater output and it works fine controlling the relay. Also I can free one fan header so total 3 pins which would be enough to control 4 extruders with the relay. And using the E1 driver, that's total of 5 extruders.
But I've been thinking that it would be nice to have options in case in future there's need for more fans etc. So to optimize the pin usage, I would need to have a circuit that converts the bit field like so:
000 = 000000
001 = 000001
010 = 000011
011 = 000111
100 = 001111
110 = 011111
111 = 111111With this approach 2 pins could control 4 extruders and with 3 pins, 7.
The problem is that I don't know how to do that with logic components, don't even know the proper search term to use :)... -
a simple decoder logic chip would achieve that, just avoid the bcd to 7 segment decoders which are probably most common, a plain binary decoder like 74LS138 if you can find it in a 3.3v version.
-
Pins 60 to 63 on the Maestro should work with M42. I will investigate this. Can you confirm that you have connected each relay board +input to the Duet output pin concerned, and the relay board -input pin to ground?
Meanwhile, you could try using RepRapFirmware 3 if you don't mind converting your config.g file.
For the decoder, I suggest 74HC138 or 74HC139, depending on whether you want active high or active low outputs. Or if you want 5V outputs instead of 3.3V, use 74HCT138 or 74HCT139 and feed 5V to the Vcc pin. The HCT versions will accept 3.3V inputs when powered from 5V.
-
Thanks for suggestions, I'll check those decoders.
@dc42 : thanks for looking into this. The connections should be correct, as mentioned the M42 command kinda works once with pins 60-63, but after that nothing happens, the relay port stays activated. Also after I moved one wire from pin 60 to Maestro's E1 heater output (pin 2) and disabled the heater, the relay port control works fine with M42 P2 S0 and S1.
I'll try RRF 3 if time permits later.
-
Ok the problem doesn't seem to be Maestro after all; did what I should have done in the first place and measured what the Maestro outputs are after issuing M42 commands and they do change, 0 or 3.3V. My bad, expected the relay to behave as the 8-port version does. So it sees 0 and 3.3V being 'low'.
So I think adding that 5V decoder will fix this issue since it outputs 5V and the relay should be happy with that. And I get full control of the relay if I ever need it.
I did upgrade to RRF3 but I suspect that 2.04 was also working fine. I'll stick with RRF3 for now since I made the config changes.
Btw, how does one free a pin that's already defined? I wanted to try what zprobe_mod outputs, but can't define it with M950 since it's already defined. -
@spegelius said in Duet Maestro and controlling 16-port relay:
Btw, how does one free a pin that's already defined? I wanted to try what zprobe_mod outputs, but can't define it with M950 since it's already defined.
Use M558 to redefine the pins used by the Z probe. The default is C"zprobe.in+zprobe.mod" but you need just C"zprobe.in" to free up the MOD pin.
Does your relay board have a common +5V pin for all its inputs? If so, then you may find it works if you connect that pin to Duet +3.3V instead of to +5V.
-
@dc42 It does have 5V input, I'm feeding it from the step-down regulator. I configured it to output 3.3V, but didn't change anything. Not sure what the relay actually uses since there's the separate 12V input. The datasheet for the relay is here if interested (rar packge): https://www.sainsmart.com/zen/documents/20-018-103/16-relay.rar
Is there a possibility to reset pin to it's original state, as it is when Duet boots? Because the relay board has all ports inactive until the first M42 command and after that the Duet GPIO state is too low for the relay. I tried M950 P0 C"nil", but I could still use M42 on that pin. I measured the voltage from Duet connected to the relay right after Duet boot and it was 3.7V. After using M42 it's either ~0 or ~3.4V, measured on the relay input pins.
I have some transistors so I could rig something to pull the input pins down, I think the relay has pull-ups for the inputs.
-
Now I'm confused too....
I hope David will bring some light into the darkness off I/O pins.
Are they equal to GPIO Pins of a raspberry? Witch current are they capable? -
Made a workaround until I get the decoder chip by adding 1kohm resistor to the input lines. Now the relay port active voltage is 2.8V and not active is 3.7V. Relay seems to be happy with this, the ports change state as they should.
So currently I can control 6 stepper motors with following pin config:; GPIO M558 P0 C"zprobe.in" ; free zprobe.mod M950 P0 C"exp.pa21" M950 P1 C"exp.pa22" M950 P3 C"exp.pa3" M950 P2 C"exp.pa4" M950 P4 C"zprobe.mod"
Only have two extruders mounted on the printer currently, 2 are waiting for installation. I have following tool change gcode:
tfreex.g:M18 E0 G4 P10
tpostx.g
; T0 set relay M42 P0 S1 M42 P1 S1 M42 P2 S1 M42 P3 S1 M42 P4 S1 G4 P300 ; T1 set relay M42 P0 S0 M42 P1 S1 M42 P2 S1 M42 P3 S1 M42 P4 S1 G4 P300 ; T2 set relay M42 P0 S0 M42 P1 S0 M42 P2 S1 M42 P3 S1 M42 P4 S1 G4 P300 ; T3 set relay M42 P0 S0 M42 P1 S0 M42 P2 S0 M42 P3 S1 M42 P4 S1 G4 P300 ; T4 set relay M42 P0 S0 M42 P1 S0 M42 P2 S0 M42 P3 S0 M42 P4 S1 G4 P300 ; T5 set relay M42 P0 S0 M42 P1 S0 M42 P2 S0 M42 P3 S0 M42 P4 S0 G4 P300
Time to print something and see how well this works. The Duet2Wifi and 8-port relay setup has been working flawlessly for over a year so hoping this will too.
-
I downloaded the documents for that relay board. Sadly it is compatible only with 5V logic, not 3.3V. Some other relay boards will work with either 3.3V or 5V.
-
Ok I guess that's expected, the relay isn't something that's specifically selected to work with Duet as I had it from other project. Anyways, it seems to be working fine so far when the inputs signals are fed through 1kohm resistor.
I did a couple of test prints, first with 2 extruders and after adding 2 more.
I'm toying with the idea of adding 2 more extruders, but need to desing a 6-port multiplexer part.