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

    M42 S -Value for Relay Control

    Scheduled Pinned Locked Moved Solved
    Using Duet Controllers
    3
    8
    286
    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.
    • JRCLundefined
      JRCL
      last edited by JRCL

      Hello all,

      I'm using GPIO pins on my Duex to control a relay with the M42 command. However, I'm not sure what S-Value is suitable for a relay (or maybe mine specifically)?

      I tried with an S value of both 0, 0.5, & 1 and got no reaction out of the relay. I have the positive terminal of my relay input to the GPIO4 pin on my Duex and the negative terminal to GND on the same header pin row as the GPIO4.

      It's currently in my config.g as:

      M950 P3 C"duex.gp4" Q500  
      

      and then I've been attempting to control with

      M42 P3 SX
      

      where X was attempted with 0, 0.5, & 1

      1 Reply Last reply Reply Quote 0
      • JRCLundefined JRCL marked this topic as a question
      • Phaedruxundefined
        Phaedrux Moderator
        last edited by

        I would think you would want 0 and 1 to turn it off and on.

        If you send M98 P"config.g" do you get any syntax errors?

        Z-Bot CoreXY Build | Thingiverse Profile

        JRCLundefined 1 Reply Last reply Reply Quote 1
        • JRCLundefined
          JRCL @Phaedrux
          last edited by

          @phaedrux That was my thinking as well. M98 on my config returns only a warning about heater 1 being potentially overpowered but I haven't had any issues with that outside this warning.

          infiniteloopundefined 1 Reply Last reply Reply Quote 0
          • infiniteloopundefined
            infiniteloop @JRCL
            last edited by

            @jrcl I’m not sure about the fanout of the GPIO pins on the DUEX, but it may be less than needed to drive an SSR which typically requires 6-12 mA. With luck, you can get along if you use the pin to pull the relay to GND, I.e. connect the positive relay terminal to +5V.

            The better way is to use a transistor like this:

            Transistor.jpg

            A suitable NPN transistor is the BC547C or 2N3904. For the diode, use a 1N4148 or BAT48 (ore something similar, it is not critical).

            The S parameter of M42 is either 1 or 0 (to set the relay’s state on or off), or it can be any value in between to control PWM.

            JRCLundefined 2 Replies Last reply Reply Quote 2
            • JRCLundefined
              JRCL @infiniteloop
              last edited by JRCL

              @infiniteloop I see, appreciate the diagram too! Any clue if there are relays more fit for this sort of application that can support such a 120VAC load with that sort of signal or internalize the transistor and additional diode?

              Additionally what sort of diode would you recommend or is that uneeded?

              JRCLundefined infiniteloopundefined 2 Replies Last reply Reply Quote 0
              • JRCLundefined
                JRCL @JRCL
                last edited by JRCL

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • JRCLundefined
                  JRCL @infiniteloop
                  last edited by

                  @infiniteloop Pulling it through GND and putting the positive terminal on the 5V pin did fix it though! Thank you!

                  1 Reply Last reply Reply Quote 1
                  • JRCLundefined JRCL has marked this topic as solved
                  • infiniteloopundefined
                    infiniteloop @JRCL
                    last edited by

                    @jrcl said in M42 S -Value for Relay Control:

                    Any clue if there are relays more fit for this sort of application that can support such a 120VAC load with that sort of signal or internalize the transistor and additional diode?

                    There are many offers like these.

                    But, especially for relays applicable to mains voltages with high currents, I don't know of any.

                    @jrcl said in M42 S -Value for Relay Control:

                    Additionally what sort of diode would you recommend or is that uneeded?

                    For the diode, use a 1N4148 or BAT48. Some SSRs are equipped with a diode, some are not. If you are in doubt, provide one.

                    Pulling it through GND and putting the positive terminal on the 5V pin did fix it though! Thank you!

                    Just got that post. Great!

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post
                    Unless otherwise noted, all forum content is licensed under CC-BY-SA