I am relatively new to CNC and certainly a novice at coding...
I have watched Daz's M6 tool change videos several times and believe I have grasped the concepts. Thank you for posting those
I have a gantry mill with an ER collet and want to automate z-zeroing my tools. I do not use M6. I use separate gcodes at each tool change. This is a hobby, so production efficiency is not needed.
With that, I want to create a Button on my main screen which will run an auto Z-zeroing sequence. All of my tool lengths are 1.75 - 2 inches and I do not want to use the tool table.
I would rather provide enough space below my longest tool and the height sensor which will cover me.
My basic work process today:
Reference all axis Home, Load gcode into M4, manually set Work Coord X0 Y0, install tool and manually set Work Coord Z0, run gcode, when complete I change the tool for the next procedure, manually re-zero Work Coord Z for new tool, return to Work Coord X0 Y0, load new gcode and run, repeat as necessary...
This is what I came up with for the coding. It is fairly basic. If anyone has suggestions, sees any glaring mistakes, or if I missed a step, please let me know. I appreciate it!
local inst = mc.mcGetInstance();
-- set height of Z axis at start of probe in Machine coordinates
local probestart = -2.5
-- move Z to safe location = Z0 in Machine Coords
mc.mcCntrlGcodeExecuteWait(inst, "G90 G53 G0 Z0")
-- move to probe location in Machine coordinates
mc.mcCntrlGcodeExecuteWait(inst, "G90 G53 G0 X3 Y0")
-- Move to probe start position, begin probe move, save Z Work coordinate value
mc.mcCntrlGcodeExecuteWait(inst, "G90 G53 G0 Z"..probestart)
mc.mcCntrlGcodeExecuteWait(inst, "G91 G31 Z-1 F2")
local toolz = mc.mcAxisGetPos(inst,2)
-- Move to tool change location in Machine coordinates
mc.mcCntrlGcodeExecuteWait(inst, "G90 G53 G0 Z0")
mc.mcCntrlGcodeExecuteWait(inst, "G90 G53 G0 X12")
wx.wxMessageBox("Change Tool and Press OK to Continue")
-- Move back to probe location and probe again, set new Work Z coord to previous measurement = toolz
mc.mcCntrlGcodeExecuteWait(inst, "G90 G53 G0 X3 Y0")
mc.mcCntrlGcodeExecuteWait(inst, "G90 G53 G0 Z"..probestart)
mc.mcCntrlGcodeExecuteWait(inst, "G91 G31 Z-1 F2")
mc.mcAxisSetPos(inst,2,toolz)
-- Move to Machine Coord Z0 and return to Work Coord X0 Y0
mc.mcCntrlGcodeExecuteWait(inst, "G90 G53 G0 Z0")
mc.mcCntrlGcodeExecuteWait(inst, "G90 G54 G0 X0 Y0")
wx.wxMessageBox("Tool Change Complete")