m581 and M574 cooperative use
-
I use an M574 to configure a microswitch as a limit switch. After homing, I want to use this same switch to trigger an emergency stop. I've smashed up a number of microswitches when my motor skips steps then crashes the switch.
I believe that I use this command to set my X switch into as emergency stop trigger
M581 T0 X S1 R0
I'm placing this in my homex.g file after I complete homing the X axis.
So far, I think I'm good.
My question is - if I rehome the X axis after setting the trigger, will the trigger be invoked during the homing G1 move? I assume it will and that I should have some command to disable the trigger before the G1 move.
I think I do this with
M581 X T0 P-1
Is this correct? And do I need to test whether the trigger has been set before sending the P-1?
-
What firmware version are you using?
You need to define the input trigger pin with M950 in modern RRF3
https://docs.duet3d.com/en/User_manual/Reference/Gcodes#m581-configure-external-trigger
-
@Phaedrux - thanks for the reply. I'm on the latest release.
I had started as you suggest, defining an input trigger with M950, then setting it with M581. But then I saw the X,Y,Z parameter in the doc page you referenced and that prompted my question. That parameter (and the second example) in the "RRF 3.01 and later" tab doesn't reference an input with a P parameter, only the X parameter.
I'll try my way and if it doesn't work, I'll go the M950 route.
-
@mikeabuilder I believe you are correct. M581 can be used to trigger on a GPIN pin (which must first be set up using M950) and/or an endstop (previously set up by M574). If you enable an emergency stop trigger on an endstop using M581 then homing would trigger this; so you need to disable it temporarily in the homing files before homing the axis, and re-enable it afterwards (ensuring that you move the head away from the endstop first).
-
@DC42 - Thanks for the vote of confidence. It's implemented and works, with one additional change. I put a
G4 P0
into my macro just before enabling the trigger. Without it, the M581 turned on the trigger before the print head moved far enough away from the homing point for the switch to change state. Now it waits for the move to complete before setting the trigger.
-
@mikeabuilder Depending on how you do the homing, you could also use the R parameter in M581. If you home before printing from the SD card, then you could use R1 so that the trigger only works when printing. If you home as part of printing (i.e. you call home all from your slicer start code) then you could use R-1 to disable the trigger at the start of your homing macro then reinstate the trigger by using R0 or R1 at the end of your homing macro.
-
-