CNC Pause and Resume config files
-
@nightowl999 have you declared the savedSpindleSpeed variable in config.g, like this?
global savedSpindleSpeed = 0
Also, if you temporarily remove the M5 command from pause.g does the spindle continue to run?
-
@dc42 said in CNC Pause and Resume config files:
global savedSpindleSpeed = 0
Exactly like that, yes, and way down the file, as you suggested.
@dc42 said in CNC Pause and Resume config files:
Also, if you temporarily remove the M5 command from pause.g does the spindle continue to run?
I'll check that tomorrow and let you know.
Thank you
-
@dc42 A bit of an update...
With the M5 command disabled, the spindle continues to run.
In the DWC, the Current RPM is shown as 10,000rpm but the Set RPM is 18,000rpm.
The first lines of code within the gcode file are...
1 ; VECTRIC POST REVISION
2 ; A long string of random letters and numbers
3 T1
4 G17
5 G21
6 G90
7 G0Z5.090
8 G0X0.000Y0.000
9 M3P0S18000
... and so onWhen I click Pause, I get this in the Console:
26/05/2022, 12:20:07 Printing paused at X155.3 Y188.6 Z66.0
26/05/2022, 12:19:56 Spindle speed saved at 0 RPM
26/05/2022, 12:19:54 M25
Resume state savedThank you
-
@nightowl999 said in CNC Pause and Resume config files:
; resume.g
if state.currentTool >= 0 & tools[state.currentTool].spindle >= 0
M3 S{global.savedSpindleSpeed} ; resume saved spindle speedThis won't resolve to true because you have a couple of errors
Tryif {state.currentTool >= 0} & {tools[state.currentTool].spindleRpm >= 0} M3 S{global.savedSpindleSpeed} ; resume saved spindle speed
-
@owend Whoops, sorry. I kinda progressed this in the other thread you've responded to
Thank you, anyway
-
@nightowl999
Probably better to keep this here as it's more specific than the other thread as it's become messy.I'm not really familiar with all requirements of CNC mode but it may be prudent to do some more checks in your macro.
Also I note that there are some other spindle related object model values.
These might help trace what's going on; first ensure we have an active tool if state.currentTool =-1 echo "No tool active. Selecting tool zero" T0 ; select tool zero if state.currentTool >= 0 echo "Spindle state on tool " , state.currentTool , " is " , spindles[state.currentTool].active if {state.currentTool >= 0} & {tools[state.currentTool].spindleRpm >= 0} M3 S{global.savedSpindleSpeed} ; resume saved spindle speed G4 S1 ; wait 1 second to allow the spindle to spin up echo "Spindle speed resumed at ", spindles[state.currentTool].active, "RPM" ; this should show that the setting was successful G1 R1 X0 Y0 F2400 else echo "condition not met. Spindle speed remains at " , tools[state.currentTool].spindleRpm , "RPM"
EDIT
I noticed an error here. Code amended above
echo "Spindle speed resumed at ", spindles[].active, "RPM"
-
@owend This is the text from the console after changing the resume.g file...
27/05/2022, 20:02:40 M0 Printing paused at X125.6 Y125.8 Z65.0 Cancelled printing file 0:/gcodes/Calibration Toolpath.gcode, print time was 0h 0m 27/05/2022, 20:02:27 Spindle speed saved at 0 RPM 27/05/2022, 20:02:24 M25 Resume state saved 27/05/2022, 20:02:22 Printing resumed 27/05/2022, 20:02:09 Spindle speed resumed at 0 RPM 27/05/2022, 20:02:09 M24 No tool active. Selecting tool zero Spindle state on tool 0 is 5000 27/05/2022, 20:02:00 Printing paused at X128.8 Y122.6 Z66.0 27/05/2022, 20:01:47 Spindle speed saved at 0 RPM 27/05/2022, 20:01:46 M25 Resume state saved 27/05/2022, 20:01:29 M32 "0:/gcodes/Calibration Toolpath.gcode" File 0:/gcodes/Calibration Toolpath.gcode selected for printing
-
@nightowl999
OK,
We are getting close.
It seems there is no tool selected after the pause.
If you have multiple tools then it may be necessary to record which was selected.
I made a small error on one part that didn't give me the value I wanted in one of tehechos.Please change both files
; pause.g 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
and
resume.g ; first ensure we have an active tool if state.currentTool =-1 echo "No tool active. Selecting tool zero" T0 ; select tool zero if state.currentTool >= 0 echo "Spindle state on tool " , state.currentTool , " is " , spindles[state.currentTool].state if {state.currentTool >= 0} & {tools[state.currentTool].spindleRpm >= 0} M3 S{global.savedSpindleSpeed} ; resume saved spindle speed G4 S1 ; wait 1 second to allow the spindle to spin up echo "Spindle speed resumed at ", spindles[state.currentTool].active, "RPM" ; this should show that the setting was successful G1 R1 X0 Y0 F2400 else echo "condition not met. Spindle speed remains at " , tools[state.currentTool].spindleRpm , "RPM"
EDIT:
Apologies.
I got the indenting on pause.g all wrong. (lack of sleep). Corrected above -
@owend I'm happy to leave this for now, if you need to get some beauty sleep!
Here's the console text:
27/05/2022, 20:25:40 M0 Cancelled printing file 0:/gcodes/Calibration Toolpath.gcode, print time was 0h 0m 27/05/2022, 20:25:27 Printing paused at X128.8 Y122.6 Z66.0 27/05/2022, 20:25:26 Error: in file macro line 20 column 81: meta command: array index out of bounds 27/05/2022, 20:25:24 M25 Resume state saved 27/05/2022, 20:25:19 M32 "0:/gcodes/Calibration Toolpath.gcode" File 0:/gcodes/Calibration Toolpath.gcode selected for printing
PS You have nothing to apologise for!
-
@nightowl999
All good.Can you try this pause.g
I can't understand the index out of bounds if there's a tool selected.
There is no line 20, but you're probably getting extra carriage returns when copy/pasting; pause.g if state.currentTool = -1 echo "No tool selected" 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
-
@owend Doing that now, but I REMd out the other lines, so that's why there's a line 20.
Not any more, though!
-
@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.