Welcome! Log In Create A New Profile


Turning a printer off using G-code

Posted by HugoW 
Turning a printer off using G-code
April 25, 2018 06:21AM

Although we should never leave a printer print unattended, I sometimes doze off a bit during 48+hr prints. This usually occurs just before the print end, as by that time I am getting really tired. The noise of the printer(-fans) doesn’t let me sleep very well, though. So, I am looking for an auto-off function. Makes me sleep better. Unfortunately, I am better at looking for stuff than at actually finding them, so I thought this up for myself.

I would like to switch a port high by default, and switch it low with a G-code (or M-code). This code will be added to the finish-code in my Cura set-up. I will switch on the main power to a power control box. On this box is a push-button which controls a main power relay to the 24V power supply. I need to push and hold the button until the ECU is up and running. By that time I can release the button as the port is high and (via an optocoupler and mosfet) it takes over the push-button function.

Here’s what I came up with:
# Auto power_off switch
switch.power_off.output_pin                            0.23                #pin 0.23 steers the main power relay
switch.power_off.output_type                          digital              # simple on/off
switch.power_off.startup_state                        true                 # set pin high as default
switch.power_off.input_off_command             M6                  # code that sets pin 1.1 low to release power relay

I would add this to the end-gcode in Cura:
M106            # Switches on part cooling fan on if it wasn’t already, to help cool the hotend
G1 S120       # waiting a minute or two for it all to cool down
M6                # and it all switches off

Please be gentle, it’s my first time digging deeper than standard into smoothieware.


Edited 1 time(s). Last edit at 04/25/2018 09:01AM by HugoW.
Re: Turning a printer off using G-code
August 10, 2018 07:21AM
This looks ok, note there is an example for exactly you use case at [smoothieware.org]
Sorry, only registered users may post in this forum.

Click here to login