I have written a couple of quick gcode files to position the spindle to specific places. As an example I have a macro to move the spindle to the back left to get it out of the. It works correctly about 90% of the time. The last 10% it does random things (at least random to me) including moving to expected positions and once in a while it will actually spin up the spindle. I am sure this is something simple that I do not understand about gcode. Here is the code:
(Park Left Rear)
M70 ; Save modal state
G21 ; Set units to millimeters
G53 G0 Z-10 ; Raise Z safely in machine coordinates
G53 G0 X180 Y750 ; Move to tool park position (machine coords)
The next time it happens, after you have hit pause or stop, look at the gcode area below. Hopefully you can read gcode enough to follow just the first few lines to see if that’s what the spindle did.
This happens rarely, but often enough to be aware of. When you press a macro button, it does not always execute that macro.it will reexecute the thing that was running just before you pressed that macro. I always keep my left thumb poised above the pause button and press the macro button with my right finger.
My understanding is that saves the model states of certain modes. It is considered a safety feature when you do position moves. The M72 restore the save model states. Definitely not an expert though.
The M70, M72 lets them modify the modal state of the machine without those changes persisting after the macro has finished. In this case, they can set the machine units to mm and then revert back to whatever was in use prior.
After fiddling with some more to find some consistency I have found that it will break every time if I run the macro immediately after a boot and home. After arguing with Chatgpt for while we arrived at this code:
(Revised Park Left Rear)
G21 (mm)
M5 (Spindle OFF)
S0 (Speed 0)
G90 (Absolute)
G90
G53 G0 Z0 (SAFE machine Z - confirm Z0 is up/clear)
G90
G53 G0 X180 Y750
M5
S0
G90
I have been running this for day and it has not done any weird things yet. So promising. Chatgpt concluded that the Buildbotics does not work and play well with M70/72. I am not smart enough to know but it does seem to work.
Some of that code is redundant. After M5( spindle off) you don’t need to tell the spindle speed to be 0, it’s already off. G90 (absolute is modal) only need to be mentioned once until you change it to incremental.