"Any help would be appreciated"
Hi
I have just translated your m6start.mls (for MACH3)
to m6.mcs (for MACH4)
It is an OFF THE CUFF draft, so you need to check for syntax errors with the zerobrane editor and do all the debugging by yourself and/or with the help of others.
Without knowing what will be your MACH4 motion controller, I can only do this much.
‘m6.mcs - untested
function m6()
local inst = mc.mcGetInstance()
local hsig = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEFWD)
local spinstate = mc.mcSignalGetState(hsig)
[mc.ISIG_INPUT2]=function(input2State)
local SelectedTool = mc.mcToolGetSelected(inst)
local CurrentTool = mc.mcToolGetCurrent(inst)
local TurretClickOut = mc.mcSignalGetHandle (inst,mc.OSIG_OUTPUT2)
local Turretsig = mc.mcSignalGetHandle(inst, TurretClickOut)
------ Get current state ------
local CurFeed = mc.mcCntlGetPoundVar(inst, 2134)
local CurFeedMode = mc.mcCntlGetPoundVar(inst, 4001)
local CurAbsMode = mc.mcCntlGetPoundVar(inst, 4003)
if input2State ==1 then
mc.mcCntlSetLastError(inst, string.format(‘Connect Air Pressure to Turret!!'))
else
mc.mcCntlSetLastError(inst, string.format(‘Turret Index Warning '))
end
end
currentFace = (currentTool - 1) % 4
targetFace = (selectedTool - 1) % 4
'rotate turret required number of "clicks"
For click = 1, (targetFace - currentFace + 4) % 4,1 'rotate accounting for rollover
Do
mc.mcSignalSetState(Turretsig, 1)
wx.wxMilliSleep(500)
mc.mcSignalSetState(Turretsig, 0)
wx.wxMilliSleep(1500)
if input2State ==1 then
wx.wxMilliSleep(100)
end
end
return