Declaring variables in config.g
-
@owend So the original line should be changed to this:
if {state.currentTool >= 0} & {tools[state.currentTool].spindleRpm >= 0} set {global.savedSpindleSpeed} = {tools[state.currentTool].SpindleRpm} ...
... or should the lower line be enclosed within a single pair of curly parentheses?
As an aside, is "SpindleRPM" the same as "spindlerpm" and SPINDLERPM?
Thanks
-
@nightowl999
No, you only need the curly brackets when doing a comparison using OR or AND
This groups and separates the parts of the equations
You don't need them when setting the value of the variable.if {global.A = global.B} & {global.B<global.C} set global.D = global.B
if {global.A = global.B} || {global.B<global.C} set global.D = global.B
You also need them when you must calculate something as part of a standard command such as using a variable in a speed setting
G1 X100 Y100 F{global.D}
-
@nightowl999 said in Declaring variables in config.g:
As an aside, is "SpindleRPM" the same as "spindlerpm" and SPINDLERPM?
No they are not the same.
The object model values and variable names are case sensitive. -
@owend Well, I'm definitely missing something, because the resume.g file doesn't restart the spindle, when I expect it should.
This is the declared variable in config.g:
global savedSpindleSpeed = 0
This is my pause.g file:
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" ; spindle speed saved
...and this my resume.g:
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 ", global.savedSpindleSpeed, "RPM" G1 R1 X0 Y0 F2400 ; go above the paused XY position
This should be easy with all the help I've had, but what have I missed..?
-
@nightowl999 said in Declaring variables in config.g:
Can you try this to ensure that the condition is being met.
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 ", global.savedSpindleSpeed, "RPM" G1 R1 X0 Y0 F2400 else echo "condition not met. Spindle speed remains at " ^ tools[state.currentTool].spindleRpm ^ "RPM"
-
I can, @owend, but running pause.g indicates the spindle speed of 0RPM is saved, not the 18,000RPM it's running at, so it seems to be an issue with pause.g?
-
@OwenD here we are, the text from the Console:
27/05/2022, 19:43:24 M0 Printing paused at X128.8 Y168.9 Z64.0 Cancelled printing file 0:/gcodes/Calibration Toolpath.gcode, print time was 0h 0m 27/05/2022, 19:43:12 Spindle speed saved at 0 RPM 27/05/2022, 19:43:10 M25 Resume state saved 27/05/2022, 19:43:08 Printing resumed 27/05/2022, 19:42:56 M24 Error: in file macro line 14 column 63: meta command: array index out of bounds 27/05/2022, 19:42:52 Printing paused at X125.6 Y125.8 Z65.0 27/05/2022, 19:42:40 Spindle speed saved at 0 RPM 27/05/2022, 19:42:37 M25 Resume state saved 27/05/2022, 19:42:29 M32 "0:/gcodes/Calibration Toolpath.gcode" File 0:/gcodes/Calibration Toolpath.gcode selected for printing 27/05/2022, 19:42:16 File 0:/gcodes/Calibration Toolpath.gcode will print in 0h 3m plus heating time 27/05/2022, 19:42:15 M37 P"0:/gcodes/Calibration Toolpath.gcode" Simulating print of file 0:/gcodes/Calibration Toolpath.gcode 27/05/2022, 19:42:04 G10 L20 P1 Origin of workplace 1: X97.00 Y94.00 Z67.00 27/05/2022, 19:41:37 g1 x147 27/05/2022, 19:41:20 g1 y84 27/05/2022, 19:41:06 g1 y660 27/05/2022, 19:40:34 Connected to weeble
-
@nightowl999 said in Declaring variables in config.g:
Error: in file macro line 14 column 63: meta command: array index out of bounds
This will be the problem.
See the other thread. -
This is Line 14 from resume.g...
echo "condition not met. Spindle speed remains at " ^ tools[state.currentTool].spindleRpm ^ "RPM"
with the same error when I changed it to:
echo "condition not met. Spindle speed remains at ", tools[state.currentTool].spindleRpm, "RPM"
-
@nightowl999
See the other thread.
I suspect you have no tool defined when the resume starts.