single press to power on, long press to power off?
-
I have
Duet 3 with RRF3.3
24v PSU
RPI4 powered off it's own power supply
a momentary on/off button
5v relay
5v PSU to provide Duet3 PS_ON 5vThe RPI is always on and the Duet is in low power mode.
I can power on the Duet 3 with the ATX buttons in DWC
The momentary button is wired to an IO port configured as an external trigger. When the button is pressed it sends M80 to turn the printer on. PS_ON grounds the relay switching the 24v PSU on.I'm wondering if there's a way(maybe with conditional G code) to also configure the same momentary button so if it's held for 3 seconds it will send M81 to shut the printer off?
-
Yes I think that may be possible with conditional. I'll move to the conditional gcode forum.
-
@dhusolo said in single press to power on, long press to power off?:
if it's held for 3 seconds it will send M81 to shut the printer off?
A side note, you may also want to have an high accessible and immediate way to shut down the printer in case of an emergency.
-
@zapta I have an E-stop button setup and there's a master power switch on the side that will cut power off to everything if needed
-
@dhusolo, it seems that you took care of the safety aspect.
-
@dhusolo
I assume you're using a trigger for your button pressSomething like this in the triggerX.g file would be a simplistic approach
M80 ; turn on power G4 S3 ; wait three seconds if sensors.gpIn[0].value = 1 ; check if button still pressed M81 ; turn off power
-
@owend I tried that and this is the response
Error: Failed to read code from macro trigger2.g: Failed to evaluate "sensors.gpIn[0].value = 1": reached null object before end of selector stringtrigger2.g
M80 ; Power on G4 S3 ; if sensors.gpIn[0].value = 1 ; check if button still pressed M81 ; turn off power undefined
config.g
M581 T2 P1 S1 R0 ; T2-Run Trigger 2; P1-J1; S1-When button pressed; R0-trigger any time M582 T2 ; Monitor external trigger 2
-
@dhusolo
My code was meant as an example.
You need to monitor the pin that your you're using.
i.e the The pin you created with M950 and the P parameter you use in M581.
You have M581 T2 P1 S1 R0
tryM80 ; Power on G4 S3 ; if sensors.gpIn[1].value = 1 ; check if button still pressed M81 ; turn off power
Not sure why you're using M582 in config.g
I believe it will cause the trigger to run as if you've pressed the button.