this is weird !!!
i have 3 profiles
my Router had the ATC script
my Plasma had the same ATC script
the Mach4 Plasma example that i was not using had the Macro who was operating the simple touch down
i renamed it other than M6
Loaded my Router profile and tried M6T2 and it started the movement to the tool location ......... so now reading the correct script
Why ????? Why was it reading the macro of a different profile ?????
Mach4 is cool but a can of worms !
now trying to change tools and it goes not perfect now ....
Got CurrentTool2 in
at Homed position
write command M6T4
It goes to the Tool2 position , goes down , release the Drawbar and back up would be a drop off tool good
Then goes to T3 position and turns off the Drawbar relay but doesnt get back up
The Current Tool is still #2 on the screen
some work to be done on the script ....
we can see some more action in the videos
Current Tool #2 , asking for T3 , drops T2 and picks T3 not going up , Current Tool stays T2
Current Tool #2 , asking for T1 in MDI , drops T2 and picks T3 again , not T1 , Current Tool stays T2
And i noticed compared to Mach3 it doesnt reminds the coordinates when closing the Mach4 , it made me "Crash it" a bit . Even when homed , X-0 i closed Mach , opened it back , press Homing and X crashed himself because he was already just next to the stoppers
now the Script is this
---modified by cncprint.blogspot.com
---Roman Batz 03.09.2019
local inst = mc.mcGetInstance()
package.path = wx.wxGetCwd() .. "\\Modules\\?.lua"
if (package.loaded.ToolChangePositions == nil) then
tcp = require "ToolChangePositions"
end
function m6()
------ Get and compare current and next tools ------
local SelectedTool = mc.mcToolGetSelected(inst)
local CurrentTool = mc.mcToolGetCurrent(inst)
if (SelectedTool == CurrentTool) then
mc.mcCntlSetLastError(inst, "Next tool = Current tool")
do return end
end
------ Get current machine state ------
local CurFeed = mc.mcCntlGetPoundVar(inst, 2134)
local CurFeedMode = mc.mcCntlGetPoundVar(inst, 4001)
local CurAbsMode = mc.mcCntlGetPoundVar(inst, 4003)
------ Get Position data for current tool ------
ToolData = tcp.GetToolData(CurrentTool)
if (ToolData ~= nil) then
Num1 = ToolData.Tool_Number
XPos1 = ToolData.X_Position
YPos1 = ToolData.Y_Position
ZPos1 = ToolData.Z_Position
else
mc.mcCntlEStop(inst)
mc.mcCntlSetLastError(inst, "ERROR: Tool number out of range!")
do return end
end
------ Get position data for next tool ------
ToolData = tcp.GetToolData(SelectedTool)
if (ToolData ~= nil) then
Num2 = ToolData.Tool_Number
XPos2 = ToolData.X_Position
YPos2 = ToolData.Y_Position
ZPos2 = ToolData.Z_Position
else
mc.mcCntlEStop(inst)
mc.mcCntlSetLastError(inst, "ERROR: Tool number out of range!")
do return end
end
------ 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, YPos1)
GCode = GCode .. string.format("G00 G90 G53 Z%.4f\n", ZPos1 + 1.0) -- Ab +1 mm über Ablagehöhe wird mit G01 verfahren, hier Wert einstellen.
GCode = GCode .. string.format("G01 G90 G53 Z%.4f F15.0\n", ZPos1)
mc.mcCntlGcodeExecuteWait(inst, GCode)
------ Release drawbar ------
local DrawBarOut = mc.OSIG_OUTPUT4 -- Set your output in Mach4 here
local hsig = mc.mcSignalGetHandle(inst, DrawBarOut)
mc.mcSignalSetState(hsig, 1)
------ Move to next tool change position ------
GCode = ""
GCode = GCode .. "G00 G90 G53 Z0.0\n"
GCode = GCode .. string.format("G00 G90 G53 X%.4f Y%.4f\n", XPos2, YPos2)
GCode = GCode .. string.format("G00 G90 G53 Z%.4f\n", ZPos2 +1) -- Ab +1 mm Move over the storage height with G01, set the value here
GCode = GCode .. string.format("G01 G90 G53 Z%.4f F250.0\n", ZPos2)
mc.mcCntlGcodeExecuteWait(inst, GCode)
------ Clamp drawbar ------
mc.mcSignalSetState(hsig,0)
GCode = ""
GCode = GCode .. "G04 P2000\n" --Wartezeit 2000 milisekunden, nur optional
mc.mcCntlGcodeExecuteWait(inst, GCode)
mc.mcSignalSetState(hsig1,0)
---------------- Here the script stops -----------------
------ Move to Safe Z UP & in front of last change position ------
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z0.0\n") ------------------------ Not moving back up the Z
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Y200\n") --Drive here to a safe distance from the tool changer with X = last tool. before!
------ Reset state ------
mc.mcCntlSetPoundVar(inst, 2134, CurFeed)
mc.mcCntlSetPoundVar(inst, 4001, CurFeedMode)
mc.mcCntlSetPoundVar(inst, 4003, CurAbsMode)
------ Set new tool ------
mc.mcToolSetCurrent (inst, SelectedTool)
mc.mcCntlSetLastError(inst, string.format("Tool change - Tool: %.0f", SelectedTool)) --------------- New Current Tool is not set , stays #2
end
if (mc.mcInEditor() == 1) then
m6()
end