76
« on: August 11, 2022, 02:01:47 PM »
Just a matter of opinion, but I personally don't make a "GCode" string variable, I just have lines of mc.mcCntlGcodeExecuteWait with the code inside of it. You are doing just that in some cases. Just keep it going.
Also, I don't think it is necessary to have %.4f every time you call a position. Also, I'm assuming you are declaring your XPos1, YPos1 etc as local variables at the top of your macro?
Just declare each position as a variable and call it later in your mc.mcCntlGcodeExecuteWait.
I'm also attaching the m6 I've been working on for my current mill in progress.
Here is how I would do what you've done.
local inst = mc.mcGetInstance()
local selectedTool = mc.mcToolGetSelected(inst)
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)
local DrawBarOut = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT7)
local ZPos = 1.2345
local XPos1 = 1.2345
local YPos1 = 1.2345
local XPos2 = 2.3456
local YPos2 = 2.3456
--Tool 1 Position
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z0.0")
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 X" .. (XPos1 + 1.3) .. "Y" .. YPos1)
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z" .. (ZPos1 + 1.0))
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z" .. Zpos1)
--Raise tool change holder #1
mc.mcSignalSetState(TSig1, 1)
--Move x axis to place too in change holder
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 X" .. XPos1)
--Release the drawbar
mc.mcSignalSetState(DrawBarOut, 1)
--drop tool change holder #1
mc.mcSignalSetState(TSig1, 0)
--Tool 2 Position
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z0.0")
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 X" .. (XPos2 + 1.3) "Y" .. YPos2)
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z" .. (ZPos2 + 1.0))
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z" .. ZPos)
--Raise tool change holder #1
mc.mcSignalSetState(TSig2, 1)
--Release the drawbar
mc.mcSignalSetState(DrawBarOut, 0)
wx.wxMilliSleep(1000)--1 Second
--Move X Axis to grab tool.
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 X" .. (XPos2 + 1.3))
--Drop tool change holder #2
mc.mcSignalSetState(TSig2, 0)
--Move to Z Clearance
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z0.0")