Hello,

I have a machine with both a spindle and a laser mounted on it. I am currently trying to create a script that will make the machine switch from one tool head to another (in terms of work coordinate offsets), but also modify three parameters in the spindle settings. Here it is:

O<PlanetCNC> if[[#<_current_tool>] EQ [90]]
M6T1
G49
G01 X0 Y0 F5000
#<_spindle_pin_ccw> = 1
#<_spindle_delay_start> = 5
#<_spindle_pwm_freq> = 3000
(msgdlg,Changed to tool #<_current_tool,0> "$<current_toolname>")
O<PlanetCNC> elseif[[#<_current_tool>] EQ [1]]
M6T90
#<_spindle_pin_ccw> = 2
#<_spindle_delay_start> = 0
#<_spindle_pwm_freq> = 10000
O<offset> if[[#<_tooloff>] EQ [0]]
G43
G01 X0 Y0 F5000
(msgdlg,Changed to tool #<_current_tool,0> "$<current_toolname>")
O<offset> endif
O<PlanetCNC> else
M6T1
G49
G01 X0 Y0 F5000
#<_spindle_pin_ccw> = 1
#<_spindle_delay_start> = 5
#<_spindle_pwm_freq> = 3000
(msgdlg,Changed to tool #<_current_tool,0> "$<current_toolname>")
O<PlanetCNC> endif


Everything works as it should, but something strange happens. If I check the settings after running the script, they were modified, but when I try to turn on the spindle, it still uses the parameters from before (i.e. turn on the wrong tool head). For the changes to take effect, I must open the settings and manually click Save. Then everything works fine.

Is there some command that should be used in the script to save newly modified settings?

Another thing I observed while coding this, is that the parameter <_spindle_pin_ccw> changes the value of "Output Pin - CW" instead of "Output Pin - CCW".

Thanks for the help

Similar Threads: