I tried myself, and after first tests the M6 macro for the emco pc turn 50 works.
local inst = mc.mcGetInstance()
local profile = mc.mcProfileGetName(inst)
local path = mc.mcCntlGetMachDir(inst)
package.path = path .. "\\Modules\\?.lua;" .. path .. "\\Profiles\\" .. profile .. "\\Modules\\?.lua;"
function m6()
local selectedtool = mc.mcToolGetSelected(inst)
local currenttool = mc.mcToolGetCurrent(inst)
local function turretrotate()
local handle = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT6)
local rc = mc.mcSignalSetState(handle, 1)
mc.mcCntlSetLastError(inst, "Turret started")
end
local function turretstop()
local handle = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT6)
local rc = mc.mcSignalSetState(handle, 0)
mc.mcCntlSetLastError(inst, "Turret stopped")
end
if (selectedtool < 1) or (selectedtool > 6) then
rc = mc.mcCntlSetLastError(inst, "Tool no. out of range")
return "Tool change Error."
elseif (selectedtool >= 1) and (selectedtool <= 6) then
if (selectedtool == currenttool) then
mc.mcCntlSetLastError(inst, "Current tool == Selected tool, so there is nothing to do")
return "nothing to do"
else
rc = mc.mcCntlSetLastError(inst, "Performing tool change")
turretrotate()
while (selectedtool ~= currenttool) do
--repeat
local SensorState = mc.mcSignalGetState(inst, mc.ISIG_INPUT7) and "Active" or "Inactive"
if SensorState == "Active" then
currenttool = currenttool + 1
print(string.format("Found Tool No: %.0f", currenttool))
if (currenttool == 7) then
currenttool = 1
end
end
break
end
wx.wxMilliSleep(5000) -- 5 seconds delay
turretstop()
mc.mcToolSetCurrent(inst, currenttool)
--mc.mcCntlGcodeExecuteWait(inst, "G43 H" .. newtool)
end
end
end