Creating a pin for trigger#.g
-
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 macroM150 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
-
Where are you getting E2 from?
Review the gcode wiki for M950 and M581.
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 -
@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, is
J1
is not a pin number itself, just a controller for the function ofC"^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 theH2
come from? -
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.gIn 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.
-
@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 upexp.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!
-
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.
-
@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.
-
@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!