CNC Pause and Resume config files
-
@owend Here you go...
27/05/2022, 20:38:47 M0 Cancelled printing file 0:/gcodes/Calibration Toolpath.gcode, print time was 0h 0m 27/05/2022, 20:38:33 Printing paused at X128.8 Y122.6 Z66.0 27/05/2022, 20:38:32 No tool selected Error: Bad command: {if state.currentTool >= 0} & {tools[state.currentTool].spindleRpm >= 0} Error: in file macro line 6 column 36: meta command: array index out of bounds 27/05/2022, 20:38:30 M25 Resume state saved 27/05/2022, 20:38:24 M32 "0:/gcodes/Calibration Toolpath.gcode" File 0:/gcodes/Calibration Toolpath.gcode selected for printing
-
@owend Should the wriggly brackets be after the second "if"?
I changed it anyway, and now get this in the Console:
27/05/2022, 20:46:49 M0 Cancelled printing file 0:/gcodes/Calibration Toolpath.gcode, print time was 0h 0m 27/05/2022, 20:46:44 Printing paused at X125.6 Y125.8 Z66.0 27/05/2022, 20:46:43 No tool selected Error: in file macro line 11 column 81: meta command: array index out of bounds 27/05/2022, 20:46:40 M25 Resume state saved 27/05/2022, 20:46:35 M32 "0:/gcodes/Calibration Toolpath.gcode" File 0:/gcodes/Calibration Toolpath.gcode selected for printing
BTW, when I click pause, the spinde keeps running and the XY stays where it is, not returning to the safe XY.
-
@nightowl999 said in CNC Pause and Resume config files:
Should the wriggly brackets be after the second "if"?
Yes, I thought I corrected that.
But now it's clear there's no tool selected when you are pausing.
Therefore none of the subsequent code can work as it relies on a tool being selected.
Is this a real job, or a dummy one?I'm willing to bet this would work (if I haven't mage any syntax errors LOL)
; pause.g if state.currentTool = -1 echo "No tool selected - selecting tool zero" T0 G1 Z{max(move.axes[2].userPosition+5,move.axes[2].max-5)} ; move the Z axis to a safe height if {state.currentTool >= 0} & {tools[state.currentTool].spindleRpm >= 0} set global.savedSpindleSpeed = tools[state.currentTool].spindleRpm ; save current spindle speed G1 X273.5 Y560 F2400 ; move XY to a safe place M5 ; turn the spindle off echo "Spindle speed saved at " ^ { global.savedSpindleSpeed } ^ "RPM" else echo "condition not met - Tool is ", state.currentTool, " Spindle RPM is ", tools[state.currentTool].spindleRpm
EDIT
If this works then we need to know how many tools you have. -
@owend I'll try it, but I'm aware you're tired (as am I!)
-
@nightowl999 said in CNC Pause and Resume config files:
but I'm aware you're tired (as am I!)
It's 5:51 AM here. I'm tired because I woke at 3am and couldn't get back to sleep
Try it when you can and report back. -
It works! And the spindle turns off with pause and on with resume!
-
@owend It's only 9pm here, but I've been trying to sort this all day!
-
@nightowl999
OK,
So the problem was there was no tool selected.
I would have thought that was necessary to turn a spindle on, but maybe not.
If you have multiple tools then you'll need to consider how to store which tool was selected when you pause (if RRF doesn't store that in CNC mode) -
@owend This is how my spindle is configured in config.g:
; Makita and relay configuration M950 R0 C"out1+out7" L0:18000 ; enable router relay on out7 M563 P0 S"Makita" R0 ; assign spindle 0 to tool 0 and name it Makita T0 ; select tool 0
This was only configured to turn the spindle off/on via a relay, but I figured I will need this resolved for when my speed-contollable milling motor turns up. My assumption is the speed thing isn't relevant as the DI isn't connected.
-
@nightowl999
What happens in the console when you run
M98 P"0:/sys/config.g"
You're selecting T0, so I'm at a loss why it's not selected in your job.
Somewhere something is turning it off. -
-
@nightowl999
yes -
@owend
Only this:27/05/2022, 21:02:24 M98 P"0:/sys/config.g"
HTTP is enabled on port 80
FTP is disabled
TELNET is disabled
Error: in file macro line 66 column 27: meta command: variable 'savedSpindleSpeed' already existsbut I haven't 'rebooted' the Duet
-
@nightowl999
OK
That error is normal if you haven't rebooted.I'm at a loss why you have no tool selected when pause.g begins unless RRF deselects it when G25 is run.
I've been looking through the object model a bit and I think you can do away with teh global variable and use values from the object model.
I'll post something to try in 5-10 minutes -
@owend If you're sure. I don't want to stress you (or me!) out trying to resolve this. I thought this would be easy
I'm going back to the hous, but I'll update the files when you post the answer ( ) and I'll try it out toorrow morning (my time).
I'm really grateful for your time and help with this, @OwenD
-
@nightowl999
Try these
; pause.g G1 X273.5 Y560 F2400 ; move XY to a safe place M5 ; turn the spindle off
and
;resume.g if state.restorePoints[0].toolNumber =-1 "echo no tool was saved- selecting T0" T0 else T{state.restorePoints[0].toolNumber} ; select the tool that was active if state.restorePoints[0].spindleSpeeds[0] = 0 echo "No resume speed was saved" else M3 S{state.restorePoints[0].spindleSpeeds[0]} ; resume saved spindle speed G4 S1 ; wait 1 second to allow the spindle to spin up echo "Spindle speed resumed at ", state.restorePoints[0].spindleSpeeds[0], "RPM" ; this should show that the setting was successful
Forgot to comment "resume.g" corrected.
Also I have no way of checking what's stored in the restore point arrays. -
@owend I tweaked the first echo, too!
-
@owend I need to call it a night. I've been summoned and the neighbours don't like the noise!
Here's the last bit of Console text...
27/05/2022, 21:28:41 M0 Printing paused at X205.3 Y258.9 Z64.0 Cancelled printing file 0:/gcodes/Calibration Toolpath.gcode, print time was 0h 0m 27/05/2022, 21:28:30 M25 Resume state saved 27/05/2022, 21:28:29 Printing resumed 27/05/2022, 21:28:21 M24 no tool was saved- selecting T0 Error: in file macro line 7 column 4: meta command: unknown value 'spindleSpeeds^' 27/05/2022, 21:28:17 Printing paused at X205.3 Y212.6 Z65.0 27/05/2022, 21:28:07 M25 Resume state saved 27/05/2022, 21:27:48 M32 "0:/gcodes/Calibration Toolpath.gcode" File 0:/gcodes/Calibration Toolpath.gcode selected for printing
Once again, the spindle didn't restart
-
@nightowl999
OK.
As I said, I have no way of checking exactly how the restore points for spindles work.
Perhaps @DC42 could chime in at this point now that it's narrowed down and explain why there's no tool selected when you pause and also whether all the spindle speeds etc are saved in the object model. -