Static relay control with GPIO pin
-
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 S0I 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
-
@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.
-
@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.
-
-
-
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.
-
@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
-
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 -
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.
-
thanks for this quality reply. I going to try this evening.