Duet 2 IDLE State Power Off - Solution
-
I have rebuilt a 3D Systems CubePro Trio 3D Printer around a Duet 2 WiFi controller board, into a dual nozzle printer with an auto bed levelling sensor where the 3rd nozzle was originally. The CubePro Trio's mechanical build quality is superb, 2nd to none however, the software was atrocious. The whole package was far too proprietary down to the even the filament size of 1.60mm.
I wanted the machine to power off automatically if left Idle for too long.
Below is the code I have come up with and it seems to work OK. In fact it worked the first time I ran it. I decided to do a bit of a tweek, but managed break it and it took 2 hours to get it going again.Below is the code I came up with.
; PW 3D Printer AutoShutdown GCode meta Command Program V001.1 ; This program is placed in a file called daemon.g in the main /sys root directory ; it will automatically be run by the system every 10 secs. ; The program will automatically cool the heaters and shutdown the printer ; if it has been left powered but idle for a predetermined period of time. ; Global variables, Idletime and AutoShutdownCall to be declared ; and set to 0 in config.g file. ;is AutoShutdownCall=10 if it is, then proceed to shutting down the printer if global.AutoShutdownCall=10 echo global.AutoShutdownCall ;echo value to screen M291 P"Auto shutdown has started - To abort, select MACROS/Shutdown Printer/Cancel Shutdown" R"Auto Shutdown" S1 T8 ;autoshutdown message M98 P"sleep.g" ; Run the sleep Macro, which is the auto shutdown program it will also ;reset the printer and thus reset the global variables back to 0. else if ((state.status=="busy") | (state.status=="processing")) ; checking current the status of the printer set global.IdleTime = 0 ; reset IdleTime variable count ;echo "Resetting Idletime Count" ;M117 "Cooldown Cancelled" else set global.IdleTime=global.IdleTime+1 ; to increment the idletime counter if global.IdleTime=90 ;daemon.g runs 6 times a min, 90 allows 15 min of idle time then cooldown ;reduce time for testing purposes if required M291 P"Printer Has Been Idle For Too Long - All Heaters Have Been Set To OFF" R"Cool Down" S1 T8 ;cool down before auto shutdown message M117 "Cooling Down" ; print to screen ;Starting Cooldown ;sound three beeps to indicate cooldown starting, total duration = 6.5 secs M300 S100 P1500 ; Beep 1kHZ for 1 1/2 seconds G4 P1500 ; Wait 1 1/2 sec before next beep M300 S100 P1500 ; Beep 1kHZ for 1 1/2 seconds G4 P1500 ; Wait 1 1/2 sec before next beep M300 S100 P1500 ; Beep 1kHZ for 1 1/2 seconds M104 T0 S0 ; Set Tool 0 to 0C (off) ;turn off all heaters M104 T1 S0 ; Set Tool 1 to 0C (off) M140 S0 ; Set bed to 0C (off) else if global.IdleTime=120 ;daemon.g runs 6 times a min, 120 allows 20 min for cooldown, then power off printer set global.AutoShutdownCall=10 ;now on next daemon.g pass the printer will proceed to shutdown else ;end ;place below in config.g remove semicolons at start of lines ;if !exists(global.IdleTime) ;check to see if the global IdleTime variable has been set ;global IdleTime=0 ;declare Idletime variable for use in daemon.g and set it to 0 ;if !exists(global.AutoShutdownCall) ;check to see if the global AutoShutdownCall variable has bee set ;global AutoShutdownCall=0 ;declare AutoShutdownCall variable for use in daemon.g and set it to 0
-
@Cubiceye I've edited this so it's in one code box. It turns out four spaces at the beginning of a line also sets a code block. Putting three backticks ``` at the beginning and end fixed it.
indented with four spaces also this line
but not this line
Ian
-
@droftarts Hi
Thanks I understand what you ment now.