5
« on: August 11, 2022, 03:45:07 PM »
Got it, still needs a bit of cleanup, just had to get the way a function works in this thing
thanks
function TchgStation(SelectedTool, CurrentTool)
local Tsig1 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT2)
local Tsig2 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT3)
local Tsig3 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT4)
local Tsig4 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT5)
if (SelectedTool == 1) then
TsigSout = Tsig1
elseif (SelectedTool == 2) then
TsigSout = Tsig2
elseif (SelectedTool == 3) then
TsigSout = Tsig3
elseif (SelectedTool == 4) then
TsigSout = Tsig4
end
if (CurrentTool == 1) then
TsigCout = Tsig1
elseif (CurrentTool == 2) then
TsigCout = Tsig2
elseif (CurrentTool == 3) then
TsigCout = Tsig3
elseif (CurrentTool == 4) then
TsigCout = Tsig4
end
return TsigSout, TsigCout;
end
TchgStation(SelectedTool, CurrentTool)
------ Move to current tool change position ------
local GCode = ""
GCode = GCode .. "G00 G90 G53 Z0.0\n"
GCode = GCode .. string.format("G00 G90 G53 X%.4f Y%.4f\n", XPos1 + 1.3, YPos1)
GCode = GCode .. string.format("G00 G90 G53 Z%.4f\n", ZPos1 + 1.0)
GCode = GCode .. string.format("G01 G90 G53 Z%.4f F15.0\n", ZPos1)
mc.mcCntlGcodeExecuteWait(inst, GCode)
---Raise tool change holder #1
mc.mcSignalSetState(TsigCout, 1)
---Move x axis to place too in change holder
GCode = ""
GCode = GCode .. string.format("G00 G90 G53 X%.4f\n", XPos1)
mc.mcCntlGcodeExecuteWait(inst, GCode)
------ Release drawbar ------
local DrawBarOut = mc.OSIG_OUTPUT7
local hsig = mc.mcSignalGetHandle(inst, DrawBarOut)
mc.mcSignalSetState(hsig, 1)
---drop tool change holder #1
mc.mcSignalSetState(TsigCout, 0)
------ Move to next tool change position ------
GCode = ""
GCode = GCode .. string.format("G00 G90 G53 X%.4f Y%.4f\n", XPos2, YPos2)
mc.mcCntlGcodeExecuteWait(inst, GCode)
----Raise tool change holder #2
mc.mcSignalSetState(TsigSout, 1)
--- give it a bit of time
wx.wxSleep(1)
------ Clamp drawbar ------
mc.mcSignalSetState(hsig, 0)
---- move x axis to slide tool out of holder #2
GCode = ""
GCode = GCode .. string.format("G00 G90 G53 X%.4f\n", XPos1 + 1.3)
mc.mcCntlGcodeExecuteWait(inst, GCode)
----- lower tool change holder #2
mc.mcSignalSetState(TsigSout, 0)
------ Move Z to home position ------
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z0.0\n")