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

    Creating a pin for trigger#.g

    Scheduled Pinned Locked Moved Solved
    Using Duet Controllers
    2
    8
    477
    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.
    • Topherundefined
      Topher
      last edited by

      Ive been back and forth in the literature for a while now and I think I've grown too tired to make sense of it. Using a duet2 wifi, I'm trying to create a pin on the expansion port Pin.4 to trigger my LED strip to come on with a button.

      Wiring:
      Ive got a normally open switch connected between ground and Pin.4 of the expansion header.

      system files:
      trigger2.g has been created containing my macro M150 R255 U255 B255

      config.g contains the following:

      ;---------------------------------------
      ; External triggers
      ;---------------------------------------
      M950 E2 C"nil" ; Free up pin.4
      M950 E2 C"^exp.e2stop" 
      M581 E2 T2 C1 ; Assign trigger2 
      
      1 Reply Last reply Reply Quote 0
      • Phaedruxundefined
        Phaedrux Moderator
        last edited by Phaedrux

        Where are you getting E2 from?

        Review the gcode wiki for M950 and M581.

        https://duet3d.dozuki.com/Wiki/Gcode?revisionid=HEAD#Section_M950_Create_heater_fan_spindle_or_GPIO_servo_pin

        https://duet3d.dozuki.com/Wiki/Gcode?revisionid=HEAD#Section_M581_RepRapFirmware_3_01_and_later

        M950 J1 C"^exp.e2stop" ; Create trigger pin 1 on e2stop
        M581 P1 T2 ; watch trigger pin 1 and execute trigger2.g

        Z-Bot CoreXY Build | Thingiverse Profile

        Topherundefined 1 Reply Last reply Reply Quote 0
        • Topherundefined
          Topher @Phaedrux
          last edited by

          @phaedrux I was getting the E2 from this community projects page

          https://duet3d.dozuki.com/Wiki/Using_M581_-_External_Triggers_and_Building_a_Control_Panel

          So, isJ1 is not a pin number itself, just a controller for the function of C"^exp.e2stop"? Where is the J1 coming from? There is no reference to it anywhere on the Pins page other than one example:

          https://duet3d.dozuki.com/Wiki/RepRapFirmware_3_overview#Section_Pin_names

          I am really confused with this example on the wiki for M950 that actually got me here
          M950 H2 C"nil" ; disable heater 2 and free up the associated pin
          H2 appears to be the designated pin for heater 2 => e1heat but where did the H2 come from?

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

            Read the wiki for M950 again.

            M950 is used to create heaters, fans and GPIO ports and to assign pins to them. Each M950 command assigns a pin or pins to a single device. So every M950 command must have exactly one of the H, F, J, P or S parameters.

            The H/F/J/P/S values are the index number for a specific pin type. Your other commands that reference that pin will target that index number.

            @leckietech said in Creating a pin for trigger#.g:

            https://duet3d.dozuki.com/Wiki/Using_M581_-_External_Triggers_and_Building_a_Control_Panel

            This is pretty old and only relevant for RRF2. How pins are handled with M950 is new in RRF3.

            @phaedrux said in Creating a pin for trigger#.g:

            M950 J1 C"^exp.e2stop" ; Create trigger pin 1 on e2stop
            M581 P1 T2 ; watch trigger pin 1 and execute trigger2.g

            In this example J1 = P1. M950 creates the J1 target index for a trigger pin using the board physical pin e2stop. Then the M581 P1 targets that pin.

            Z-Bot CoreXY Build | Thingiverse Profile

            Topherundefined 1 Reply Last reply Reply Quote 0
            • Topherundefined
              Topher @Phaedrux
              last edited by

              @phaedrux
              Ok, I now get all of that, I think where I have been getting stuck in my thinking is; what if I wanted to free up an end stop switch or motor step/direction pin?
              In the example:
              M950 H2 C"nil" ; disable heater 2 and free up the associated pin
              I understand H2 is the heater 2 and C"nil" undefined the pin of H2. What would I enter if I wanted to free up exp.e2stop?
              I couldn't send:
              M950 J"exp.e2stop" C"nil"or can that particular digital pin only be used for 1/0 input for exp 2 end stop?

              Thanks for taking the time with me!

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

                You only need to use nil to free up a pin if it's already been assigned to something else specifically. There are no pre-defined pins in RRF3.1 and up.

                So you'd only need to use M950 H2 C"nil" if you'd already bound H2 to a pin previously and wanted to use it for something else now.

                Z-Bot CoreXY Build | Thingiverse Profile

                Topherundefined 2 Replies Last reply Reply Quote 0
                • Topherundefined
                  Topher @Phaedrux
                  last edited by

                  @phaedrux ok, that makes so much more sense. I didnt read anything that suggested this and Ive been looking to do this project for a few years so I already had it in my mind the pin needed to be released before it could be assigned to a different function! Really appreciate the effort. Im going to try it right now with a spare board I have here at home.

                  1 Reply Last reply Reply Quote 0
                  • Topherundefined
                    Topher @Phaedrux
                    last edited by

                    @phaedrux Ha, it works. Cant wait to apply this at work tomorrow. What I am using it for: we have 4k nest cameras on each rack of 12 printers. In the middle of the night if I need to check on them the room is too dark so Ive got a wifi switch that ill connect a 12v supply to and trigger a micro relay at the duet board closing this contact thus turning on the lights of each printer for any given rack. I wish we could just connect the printers together with CAN BUS and send global messages to do things like this or tell all 60 of my current duet printers to preheat, or send a command over the internet to stop any one print. Ive already got our main supplies wired to a smoke detector to immediately disconnect the power and battery backup at the first sign of smoke. With safety out of the way, now I just need some other features for production. Thanks again for the help!

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