Hello all!
I built a CNC router for my shop class about 14 years ago. The windows XP computer we were using to run Mach3 died a couple of weeks ago. I can't find another computer with windows xp and a parallel port so I'm trying to move over and use Mach4. I can't seem to get the M6 function to work like it did in Mach 3. I've been searching but I can't seem to find the answer to my question. Any help you can provide would be much appreciated by me and my students who are waiting to use the machine!
What I would like the M6 command to do is as follows:
1. Stop the spindle
2. Allow us to manually jog the machine to a tool change location.
3. Run the probing script to reset Z zero when I press a button on the screen. ( My script does not allow me to press the touch button on the screen)
4. Press cycle start
5. Move the machine to a safe z location
6. Start the spindle
6. Move the machine back the the starting x,y,z location
7. Resume the program
function m6()
local inst = mc.mcGetInstance()
local selectedTool = mc.mcToolGetSelected(inst)
selectedTool = math.tointeger(selectedTool)
local currentTool = mc.mcToolGetCurrent(inst)
currentTool = math.tointeger(currentTool)
local SpindleDwell = 20000
local xstart = mc.mcAxisGetPos (inst, 0)
local ystart = mc.mcAxisGetPos (inst, 1)
if selectedTool == currentTool then
mc.mcCntlSetLastError(inst, "Current tool == Selected tool so there is nothing to do")
else
--Remove this line if you would not like the Z axis to move
mc.mcCntlGcodeExecute(inst, "G90 G0 Z0.0");--Move the Z axis all the way up
mc.mcCntlGcodeExecute(inst, "M5 G4 P"..SpindleDwell) --Turn off spindle
mc.mcCntlSetLastError(inst, "Change to tool " .. tostring(selectedTool) .. " and press start to continue") --Message at beginning of tool change
mc.mcCntlToolChangeManual(inst, true) --This will pause the tool change here and wait for a press of cycle start to continue
--What code is needed to allow me to jog the machine and use the tool touch plate function?
mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedTool) .. " Previous Tool == " .. tostring(currentTool)) --Message that shows after Cycle Start
mc.mcToolSetCurrent(inst, selectedTool)
mc.mcCntlGcodeExecuteWait(inst,"G90 G0 X"..xstart.."Y"..ystart)--Move to start location
mc.mcCntlGcodeExecute(inst, "M3 G4 P"..SpindleDwell)--Turn spindle on and wait for dwell
mc.mcCntlGcodeExecuteWait(inst, "G90 G0 Z0")--Move to Z0
end
end
if (mc.mcInEditor() == 1) then
m6()
end