Full shutdown after prints
Like many others I had been using octoprint with optically issolated relays to control my 24VDC supply prior to upgrading to the Duet2. I had also integrated a power shim that handled a full shutdown of the system when a print was finished and removed power from the pi as well.
Pimoroni on/off shim link
I have since implemented the same setup with the Duet minus the shim. I power the Duet with a 2.5a raspberry pu USB supply. Currently after a print finishes the 24VDC supply is shutdown via sleep macro M81 but it leaves the Duet powered to include all accessories (BLtouch, filament sensor, and paneldue 7i). These are pretty low powered devices but in some cases they stay powered for a few days before I flip the printer to off.
I wonder if we could use the same pimoroni shim but with the duet 2. It accepts the same 2.5a USB supply and it could pass the 5VDC through to the duet. The HW seems simple enough but I don't know how I would implement the discrete monitoring on the Duet firmware. Essentially, the duet would need to recognize an M command and assert a discrete through the expansion connector to signal the shim to remove power.
Seems like we just need something to set gpio7 to low on the pimoroni that would in turn kill power to the duet. This would need to happen at the end of the sleep macro to ensure everything has cooled before killing power.
Danal last edited by
You can scan for almost any event in the system log via:
sudo journalctl -fu duetcontrolserver
A more elegant script / scan could run as a service and look for the end of the sleep, and perform any Pi task imaginable, such as raising a GPIO
Essentially, the duet would need to recognize an M command and assert a discrete through the expansion connector to signal the shim to remove power.
The command you need is M42. See https://duet3d.dozuki.com/Wiki/Using_servos_and_controlling_unused_IO_pins.
I am using the following command at the end of my gcode to turn off the 24VDC to the printer after the temps have cooled and it has been working great! However, the BL Touch, Filament Sensor, and Paneldue still remain powered on. In some cases this is OK, but in other situations I want to be able to command a full shutdown of the board remotely/automatically.
M81 S1 ; Turn off the 24VDC supply after temps have cooled
This weekend I wanted to finish installing my paneldue and took it as an opportunity to install the pimoroni OnOffShim I mentioned above. The installs went fine but I now I need to figure out the GPIO and scripting.
How the OnOffShim works is that monitors pin 7 (on the shim) and waits for it to be pulled low. Once detected it then it cuts the 5VDC power which in turn shuts off the Duet2 Wifi board.
To operate the printer I have a momentary switch that connects to the OnOffShim "BTN" inputs. When the printer is off and the momentary button is pressed, the shim will latch the 5VDC supply to the Duet allowing it to power on. So far the thing works great. However, to power down we need to use some GPIO from the Duet expansion port.
I will need two GPIO from the Duet2 expansion port.
- Input to monitor the OnOffShim "Status" on pin 11. When the duet2 is powered on and while the momentary power button is pressed, the shim will to pull the pin 11 low. This is intended to signal to the duet2 input pin (p0) that a full shutdown is being requested. I will need the Duet2 to monitor this pin as an input and then trigger a macro to send the M42 P1 S0 shutdown command.
M950 P0 C"exp.24" ; create GPIO input pin 0 attached to Estop6 expansion connector
- Output to signal to the OnOffShim that a shutdown is being requested which will be read by the OnOffShim pin 7. When Pin 7 is pulled low the shim will cut the 5VC power which in turn shuts power off to the Deut2 (full shutdown).
M950 P1 C"exp.29" ; create GPIO output pin 1 attached to PB6 on expansion connector
To shutdown the Duet2 ext 5VDC power from the shim I would need to issue the following command that should in turn be read by pin 7 of the shim:
M42 P1 S0 ; Turn Off Duet Power (set OnOffShim Pin 7 to Low)
How do I create a script to monitor P0 so that when a low is detected I can send the M42 P1 S0 command to complete the shutdown?
OwenD last edited by
@mitch you can assign a trigger macro to a pin.
There’s info in this thread
Great advice. I have my GPIO up and working but I am having trouble with the trigger.
- I originally setup E6 as a GPIO but after reading about M581 it seems the P parameter is reserved. So I commented it out and I am attempting to use it as E6 in the M581 command
- I had to invert the P1 GPIO because the OnOffShim expects the board to boot with that pin starting at 3.3v and w/o the inversion I guess it was starting up at logic low preventing the shim latch
; Soft Power Control ;M950 P0 C"exp.24" ; create GPIO input pin 0 attached to Estop6 expansion connector - Senses Power Button, Low=Button Pressed M950 P1 C"!exp.31" ; create GPIO output pin 1 attached to heater7 on expansion connector - Controls Duet2 On=S0 (default), Off=S1 M581 E6 S1 T2 C0 ; When E6 goes Low, execute trigger2.g to complete shutdown
I can successfully power the system down with the following command
M42 P1 S1
I setup a trigger2.g file:
I have commented out several of the nice to haves until I can get this to work correctly.
;tigger2.g ;M18 ; Disable Steppers ;M104 S0; Set Hot-end to 0C (off) ;M140 S0; Set bed to 0C (off) ;M81 S1 ; Turn off printer once cooled down M42 P1 S1 ; Turn Off Duet Power (inverted logic)
When I press my button connected to pin 26 (Estop 6), my trigger file is not executed???
Ok, a bit confused on the Input pin and trigger syntax:
Board: Duet Ethernet 1.02 or later
Firmware: RepRapFirmware for Duet 2 WiFi/Ethernet 3.01-RC3 (2020-02-29b4)
- Not sure if I need the pullup resistor or not "^"?
- I gather that I must first declare estop6 Exp Pin 24 as in input via the M950 J command per instructions here
The docs list the variable name here as "exp.e6stop"
I am then attempting to trigger sys/tigger2.g file when a button that pulls estop6 low to ground. I can't seem to get the trigger file to execute.
- Per the M581 description it looks like you always use the "P" parameter regardless if the variable is an input "J" or output "P"
"P Specify one or more input pin numbers that you created using M950 with the J parameter"
; Soft Power Control M950 J0 C"^exp.e6stop" ; create GPIO input pin 0 attached to Estop6 exp connector M950 P1 C"!exp.31" ; create GPIO output pin 1 attached to heater7 on expansion connector - Controls Duet2 On=S1 (default), Off=S0 M581 P0 S1 T2 C0 ; When E6 goes Low, execute trigger2.g to complete shutdown
Any ideas on where I may be going wrong?
mitch last edited by
Well, Can't explain it but it all works perfectly now. I wonder if I failed to restart after a firmware update as the M581 and M590 seemed to have some different behavior.
Now for another question;
M81 S1 ; waits until fans stop before shutting off 24VDC PSU
If I put the following commands in sequence will the 2nd command wait until M81 is complete before shutting off the 5VDC power
M81 S1 ; Shut off 24VDC supply once cooling fans stop (everything has cooled off)
M42 P1 S1 ; Shut off 5VDC supply
if not, what command do I need to put between them to get this type of behavior?