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

    Static relay control with GPIO pin

    Scheduled Pinned Locked Moved
    Using Duet Controllers
    4
    17
    851
    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.
    • Rodrigue Richallandundefined
      Rodrigue Richalland @Rodrigue Richalland
      last edited by

      @Phaedrux
      The M950 & M42 need to be writted in config.g ? Or in a standalone config file ?

      Phaedruxundefined 1 Reply Last reply Reply Quote 0
      • Phaedruxundefined
        Phaedrux Moderator @Rodrigue Richalland
        last edited by

        @rodrigue-richalland M950 would go in config.g to define the pin you want to use. And then you would use M42 to control the pin in whatever macro you want to use to activate the relay.

        Z-Bot CoreXY Build | Thingiverse Profile

        Rodrigue Richallandundefined 1 Reply Last reply Reply Quote 0
        • Rodrigue Richallandundefined
          Rodrigue Richalland @Phaedrux
          last edited by

          @phaedrux

          I've write this in config.g

          M950 P1 C"duex.gp1" Q500
          if <"ystop" = 1 >
          M98 P"Fermeture_Porte"
          else
          M98 P"Ouverture_Porte"

          The macros are

          "Fermeture_Porte"
          M42 P1 S1

          "Ouverture_Porte"
          M42 P1 S0

          I think my program is dont correct in config.g. Because the macros works one by one.

          I use the ystop for the test. I will change for a other stop after.

          Thanks

          Phaedruxundefined dc42undefined 2 Replies Last reply Reply Quote 0
          • Phaedruxundefined
            Phaedrux Moderator @Rodrigue Richalland
            last edited by

            @Rodrigue-Richalland said in Static relay control with GPIO pin:

            I've write this in config.g

            If you want your expression to be checked continuously you need to put it in the daemon.g file which gets run every 10 seconds in the background.

            Z-Bot CoreXY Build | Thingiverse Profile

            1 Reply Last reply Reply Quote 0
            • dc42undefined
              dc42 administrators @Rodrigue Richalland
              last edited by

              @Rodrigue-Richalland alternatively, as it looks like you wan to open/close the door depending on the state of the Y endstop pin, use a M581 trigger to monitor the state of that pin.

              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

              Rodrigue Richallandundefined 1 Reply Last reply Reply Quote 0
              • Rodrigue Richallandundefined
                Rodrigue Richalland @dc42
                last edited by

                @dc42 @Phaedrux Tanks for your help. I will try

                Rodrigue Richallandundefined 1 Reply Last reply Reply Quote 0
                • Rodrigue Richallandundefined
                  Rodrigue Richalland @Rodrigue Richalland
                  last edited by

                  @dc42 @Phaedrux
                  Do you know how it's possible to make infinite loop ?

                  9fc98239-c307-41e4-9cdd-ef3ed34e80f5-image.png

                  bf6bbbd2-6647-4b90-acac-919858cfb6b4-image.png

                  Phaedruxundefined T3P3Tonyundefined 2 Replies Last reply Reply Quote 0
                  • Phaedruxundefined
                    Phaedrux Moderator @Rodrigue Richalland
                    last edited by

                    I think you'd be better off using a trigger and M581

                    https://docs.duet3d.com/User_manual/Reference/Gcodes#m581-configure-external-trigger

                    When the endstop status changes, execute a macro.

                    Z-Bot CoreXY Build | Thingiverse Profile

                    1 Reply Last reply Reply Quote 0
                    • T3P3Tonyundefined
                      T3P3Tony administrators @Rodrigue Richalland
                      last edited by

                      @Rodrigue-Richalland I agree with @Phaedrux that a trigger is a much better way to do this. If you want something that runs continously then

                      while 1
                      ...

                      is sufficient

                      www.duet3d.com

                      Rodrigue Richallandundefined 1 Reply Last reply Reply Quote 0
                      • Rodrigue Richallandundefined
                        Rodrigue Richalland @T3P3Tony
                        last edited by

                        Ok thanks for your reply.
                        Can you explain me how configure my trigger for :

                        do "duex.fan3" outpout = 1 when "e2stop" enstop = 1 ?

                        with "duex.fan3" outpout, i will manage door of the chamber. So this program need to be usable during print as well.

                        I've dont understand how to do it with trigger.let me know is what file is needed to writte the code. Config.g ? macros ? others ?

                        Thanks,
                        Rodrigue

                        1 Reply Last reply Reply Quote 0
                        • Phaedruxundefined
                          Phaedrux Moderator
                          last edited by

                          First you would need to define the pin you want to monitor with an M950 command.

                          https://docs.duet3d.com/User_manual/Reference/Gcodes#m950-create-heater-fan-spindle-or-gpioservo-pin

                          Then you would need an M581 command to tell it to watch that pin, and define what to do when it triggers.

                          https://docs.duet3d.com/User_manual/Reference/Gcodes#m581-configure-external-trigger

                          In config.g you would have something like

                          M950 J1 C"e2stop" ; define trigger 1 on e2stop pin
                          M581 P1 T2 ; watch trigger 1, execute trigger2.g
                          

                          Then you would need a macro file called trigger2.g in the sys folder. In that macro you would have the commands you want executed when the switch is triggered.

                          I don't know exactly what you want to happen when the switch is triggered.

                          Z-Bot CoreXY Build | Thingiverse Profile

                          Rodrigue Richallandundefined 1 Reply Last reply Reply Quote 0
                          • Rodrigue Richallandundefined
                            Rodrigue Richalland @Phaedrux
                            last edited by

                            @Phaedrux

                            thanks for this quality reply. I going to try this evening.

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