Timed Heater Shutoff
-
Recently I had an issue where I inadvertently left for the night with my hotend heated and I cooked some polycarbonate in the melt-zone and it was jammed the next time I tried to use it. Is it possible, or could I make a feature request to add a feature such that if the printer is in a standby (non-printing) state, and a heater is left on, after a certain period of time it is shut off?
-
@p8blr You can easily do that with meta commands in your daemon.g.
-
@p8blr
This can be achieved using meta commands and referencing the object model.
Normally it's sufficient to use yourstop.g
file to shut down any active heaters at the end of the print.The code below will give you an idea of how it might be done in daemon.g, but there are risks that you might turn off the heater(s) when you did not intend to.
In the code we are only checking if the printer is "idle" using state.status
If the printer remains in the idle state for more than 3600 seconds, the power is shut down.
If it's not in the idle state, the counter is reset to add a further 3600 seconds to the current time.There are a dozen or so other state.status values that the printer could be in other than idle, and all would reset the counter thus preventing the shutdown.
https://github.com/Duet3D/RepRapFirmware/wiki/Object-Model-Documentation#statestatusThere are also a number o heater states that you can potentially interfere with using this method.
For example, what if you are PID auto-tuning a heater?
state.status will remain at "idle", which would cause the shutdown timer to activate.
This could cause the power too be turned off part way through the PID auto-tune.The heater state values are here
https://github.com/Duet3D/RepRapFirmware/wiki/Object-Model-Documentation#heatheatersstateYou would have to loop through all the heaters and check their state to cover this eventuality if you feel it is necessary.
Or you would need to maybe create a variable that you can use to manually turn on/off teh code that is doing teh shutdown.To use this code you would need to declare some global variables in your config.g
global ShutDownCounterRunning = false global. idleShutdownLimit = 3600 ; set max time in seconds
Then create a daemon.g file and use something like this
If you don't use an ATX power supply you would need to shut down each heater individually instead of just turning off the ATX powerif (state.atxPower == true) ; only run if ATX power is applied if (state.status=="idle") echo "machine is idle and power is on" if global.ShutDownCounterRunning = false set global.ShutDownCounterRunning = true set global.idleShutdownLimit = state.upTime + global.idleShutdownTime echo "timer set" else if (state.upTime > global.idleShutdownLimit) M291 P"Forced power down in 5 seconds" R"Shutting down" S0 T5 M81;turn off ATX else echo "Shutdown active but still counting down" else set global.ShutDownCounterRunning = false set global.idleShutdownLimit = state.upTime + global.idleShutdownTime echo "shutdown timer reset"