CNC Pause and Resume config files
-
-
@owend said in CNC Pause and Resume config files:
As I said, I have no way of checking exactly how the restore points for spindles work.
I think the issue was only really with saving and restoring the spindle speed of a digitally controlled milling motor.
If I need to pause the CNC, the only real difference between that and a 3D printer is it would be safer to turn the spindle off, and back on at the same speed on resume. Lifting the Z and moving the XY to a predetermined location is my variation on what seems to be the default for a 3D printer, i.e. X0, Y0 and Z0 (but I'm happy to be corrected.
The default pause.g and resume.g files work as they should, even with my 'safe location' amendments, it's just saving and restoring the spindle speed.
@dc42 first helped me with this by showing how to declare a global variable (savedSpindleSpeed) in the config.g file, then setting the variable's value to the actual spindle speed when pause.g is initiated.
It sounded simple, but for some reason - as you've identified @OwenD - something is 'deselecting' the tool or the value of the variable isn't being saved.
-
@nightowl999
I've just found that the restore points are saved to slot 1 in a pause.
So if my last macro was to work it would have to be;resume.g if state.restorePoints[1].toolNumber =-1 "echo no tool was saved- selecting T0" T0 else T{state.restorePoints[1].toolNumber} ; select the tool that was active if state.restorePoints[1].spindleSpeeds[0] = 0 echo "No resume speed was saved" else M3 S{state.restorePoints[1].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[1].spindleSpeeds[0], "RPM" ; this should show that the setting was successful
-
Thank you so much, @OwenD!
I'll update the pause.g and resume.g files, but am I correct in thinking all the save/resume 'stuff' is being carried out in the resume.g file now, rather than the pause.g file?
From what I've gleaned, these are the files I'm going to try out:
; pause.g G1 Z{max(move.axes[2].userPosition+5,move.axes[2].max-5)} F240 ; move the Z axis slowly to a safe height G0 X273.5 Y560 ; move XY to a safe place M5; turn the spindle off
;resume.g if state.restorePoints[1].toolNumber =-1 echo "No tool was saved - selecting T0" T0 else T{state.restorePoints[1].toolNumber} ; select the tool that was active if state.restorePoints[1].spindleSpeeds[0] = 0 echo "No resume speed was saved" else M3 S{state.restorePoints[1].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[1].spindleSpeeds[0], "RPM" ; this should show that the setting was successful G1 R1 X0 Y0 F2400 ; move XY back to last saved location G1 R1 Z0 F240 ; move Z slowly to last saved location
Also, it seems I no longer need the variable to be defined in the config.g file?Thank you
-
I'm wondering if the issue is with the state of the spindle is being saved after it's been turned off with the M5 line in the pause.g file, or does the very act of initiating pause.g save the state of the machine somewhere?
I'll have a look at transposing the files and see how I get on...
-
@nightowl999
When you pause the job RRF saves certain values automatically.
From what I can glean from the docs that should include the spindle state, direction and speed.
If you hit pause and then use the object model browser you should be able to confirm.
I can't as I don't have a spindle configured. -
This post is deleted! -
Well, I think I've got it, but there may be a tweak I could use to improve it, but as I've only got one spindle/tool this will probably do. This pause.g file works and saves the spindle speed to the defined variable:
set global.savedSpindleSpeed = spindles[0].active echo "Spindle speed saved at " ^ {global.savedSpindleSpeed} ^ "RPM" G1 Z{max(move.axes[2].userPosition+5,move.axes[2].max-5)} F2400 ; move the Z axis to a safe height G0 X273.5 Y560 ; move XY to a safe place M5 ; turn the spindle off
...and the resume.g file turns the spindle back on, although I think there are a few spurious lines in it now. I'll deal with that in the morning!
-
This post is deleted! -
This post is deleted!