• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

Duet Maestro and controlling 16-port relay

Scheduled Pinned Locked Moved
Duet Hardware and wiring
4
14
628
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    spegelius
    last edited by spegelius 24 Nov 2019, 16:32

    I'm trying to replicate a configuration for controlling a relay to switch active extruder, like I've done here: https://forum.duet3d.com/topic/5302/fw-compilation-and-relay-control. With Duet2Wifi and 8-port Sainsmart relay the configuration has been working without problems, but with Duet Maestro and 16-port Sainsmart relay, something is not working right.
    So first, here are the relays I'm using:
    https://www.sainsmart.com/products/8-channel-5v-relay-module
    https://www.sainsmart.com/products/16-channel-12v-relay-module

    The 8-port relay uses 5V from that ATX power I use to power my printer. For I/O-pins I use logical pins 60-63 on Duet2Wifi to control the relay, directly from Duet to the relay. https://duet3d.dozuki.com/Wiki/Using_servos_and_controlling_unused_IO_pins

    The 16-port relay needs both 5V and 12V. I use 2 small step-down DC-converters to convert same 24V the printer uses to 5V and 12V and the relay itself seems to work fine this way. For I/O control I use logical pins 60-64 on Duet Maestro, directly from Duet to the relay.

    Now the problem: when I start the printer with Duet Maestro, I can issue M42 Px Sx command once for pins 60-63, which will toggle the corresponding relay port on the relay board. The S value doesn't seem to have any difference, I can use 0-255 and it will always toggle the port on but only once. Subsequent M42 commands to those ports do nothing, the relay ports stay activated. Pin 64 however works as intended, I can use M42 P64 S0 to toggle the relay port off and M42 P64 S1 (or 255) to turn it on.

    So why aren't pins 60-63 working as intended? Do I need to disable something in Duet config that's using the pins? The wiring seems to be correct since the correct relay port activates when issuing the M42 command first time.

    I upgraded FW on both Duets to 2.04, nothing changed. Duet2Wifi keeps on working, Maestro doesn't work.

    I use a 16-port relay mostly because I happen to have one. 8-port would have enough ports for my needs, but I guess having the option for controlling 9 extrudes has it's appeal ;)...

    Pic of the relay thingy

    1 Reply Last reply Reply Quote 0
    • undefined
      DIY-O-Sphere
      last edited by DIY-O-Sphere 24 Nov 2019, 16:46

      The pins are incapable for PWM or switching
      You have to remap fan or heater pins

      (UTC+1)

      1 Reply Last reply Reply Quote 0
      • undefined
        spegelius
        last edited by 24 Nov 2019, 17:35

        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.

        1 Reply Last reply Reply Quote 0
        • undefined
          spegelius
          last edited by 25 Nov 2019, 07:56

          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 = 111111

          With 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 :)...

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User
            last edited by 25 Nov 2019, 08:27

            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.

            1 Reply Last reply Reply Quote 0
            • undefined
              dc42 administrators
              last edited by dc42 25 Nov 2019, 08:48

              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.

              Duet WiFi hardware designer and firmware engineer
              Please do not ask me for Duet support via PM or email, use the forum
              http://www.escher3d.com, https://miscsolutions.wordpress.com

              1 Reply Last reply Reply Quote 0
              • undefined
                spegelius
                last edited by 25 Nov 2019, 10:03

                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.

                1 Reply Last reply Reply Quote 0
                • undefined
                  spegelius
                  last edited by 25 Nov 2019, 19:10

                  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.

                  undefined 1 Reply Last reply 25 Nov 2019, 19:14 Reply Quote 0
                  • undefined
                    dc42 administrators @spegelius
                    last edited by 25 Nov 2019, 19:14

                    @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.

                    Duet WiFi hardware designer and firmware engineer
                    Please do not ask me for Duet support via PM or email, use the forum
                    http://www.escher3d.com, https://miscsolutions.wordpress.com

                    undefined 1 Reply Last reply 25 Nov 2019, 20:16 Reply Quote 0
                    • undefined
                      spegelius @dc42
                      last edited by 25 Nov 2019, 20:16

                      @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.

                      1 Reply Last reply Reply Quote 0
                      • undefined
                        DIY-O-Sphere
                        last edited by 25 Nov 2019, 21:31

                        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?

                        (UTC+1)

                        1 Reply Last reply Reply Quote 0
                        • undefined
                          spegelius
                          last edited by 26 Nov 2019, 17:54

                          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.

                          1 Reply Last reply Reply Quote 0
                          • undefined
                            dc42 administrators
                            last edited by dc42 28 Nov 2019, 09:32

                            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.

                            Duet WiFi hardware designer and firmware engineer
                            Please do not ask me for Duet support via PM or email, use the forum
                            http://www.escher3d.com, https://miscsolutions.wordpress.com

                            1 Reply Last reply Reply Quote 0
                            • undefined
                              spegelius
                              last edited by 29 Nov 2019, 09:21

                              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.

                              Fidget Widget
                              4-color print ongoing
                              Tronxy X5S with 4 extruders

                              1 Reply Last reply Reply Quote 0
                              6 out of 14
                              • First post
                                6/14
                                Last post
                              Unless otherwise noted, all forum content is licensed under CC-BY-SA