Hello Guest it is March 28, 2024, 09:01:18 AM

Author Topic: Tool Table and Tool Changer question  (Read 941 times)

0 Members and 1 Guest are viewing this topic.

Offline jevs

*
  •  315 315
    • View Profile
Tool Table and Tool Changer question
« on: August 06, 2019, 12:20:17 PM »
In working on my M6 script it gave me some questions about how the tool table will work and how that may affect how I write the script.

My machine can only hold 7 tools and a tool cannot be used unless it is in the tool changer. I cannot manually add a tool in the spindle without the changer holding the tool. The tool is actually still in the changer when it is working. It is a turret setup.

So does this mean I can only have 7 tools in my tool table and I have to change all that data and reset the tool heights and all of that each time I setup for a different job?

Or, is there a way to make my tool table in Mach4 have all of my tools matching with my CAM tool table, but then assign the tool table tool number to a tool changer position as needed or something?

Next will bring up the question of what happens if you need more than 7 tools for a job?

Re: Tool Table and Tool Changer question
« Reply #1 on: August 06, 2019, 03:11:17 PM »
Hi,
you might be trying to run before you can walk.

In the first instance get your toolchanger to work with just seven tools. Then maybe later you can extend that to
a larger number, maybe aligned with the tool table.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline jevs

*
  •  315 315
    • View Profile
Re: Tool Table and Tool Changer question
« Reply #2 on: August 07, 2019, 01:15:56 AM »
The tool changer is working good now. I just finished and live tested the M6 tonight :)

I just have to decide if I want to change anything for auto tool height setting or dealing with more than 7 tools. I have never done either of these scenarios.

I will probably move on to figuring out the pokeys 57e conversion next.

Code: [Select]
function m6()

local inst = mc.mcGetInstance()
local selectedTool = mc.mcToolGetSelected(inst) --Gets selected tool
selectedTool = math.tointeger(selectedTool) --Converts selected tool to integer
local currentTool = mc.mcToolGetCurrent(inst) --Gets currently loaded tool
currentTool = math.tointeger(currentTool) --Converts currenlty loaded tool to integer

--Get positions before moving to do tool change
local valX, rc = mc.mcAxisGetMachinePos(inst, 0, mc.X_AXIS) --Get the position of the X axis in Machine Position
local valY, rc = mc.mcAxisGetMachinePos(inst, 1, mc.Y_AXIS) --Get the position of the Y axis in Machine Position
local valZ, rc = mc.mcAxisGetMachinePos(inst, 2, mc.Z_AXIS) --Get the position of the Z axis in Machine Position

--Turns off the spindle (includes decel time)
rc = mc.mcCntlGcodeExecuteWait(inst, "M05")

--Checks current tool to make sure it is a valid tool (1-7)
--Displays error and leaves M6 if not.
if (currentTool < 1) or (currentTool > 7) then
mc.mcCntlSetLastError(inst, "Current Tool Number Is Not Valid - Set To Current Tool Position (1-7)")
return
end

--Checks selected tool to make sure it is a valid tool (1-7)
--Displays error and leaves M6 if not.
if (selectedTool < 1) or (selectedTool > 7) then
mc.mcCntlSetLastError(inst, "Requested Tool Number Is Invalid - Select Valid Tool (1-7)")
return
end

--Displaces message if no tool change is needed
if selectedTool == currentTool then
mc.mcCntlSetLastError(inst, "This Tool Is Already Loaded - No Action Taken")

--Changes tool if needed
else
--Move the Z axis up
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 Z0.0")

--Move the X & Y to tool height setter area
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X19.53 Y14.45")

-- turn off Z soft limit
    mc.mcSoftLimitSetState(inst, mc.Z_AXIS, mc.MC_OFF)

--Create variable for cycles
local changeNums=0

--Cycles the tool changer the correct number of times if selected tool is lower than current tool
if selectedTool > currentTool then
for changeNums = 1,(selectedTool-currentTool) do

--Moves Z to the top of the tool change area
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 F70 Z5.775")

--Moves Z to the bottom of the tool change area
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 F70 Z3.750")
end

-- Move back to Z home
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 F70 Z0")

-- turn Z soft limit back on
mc.mcSoftLimitSetState(inst, mc.Z_AXIS, mc.MC_ON)

--Move back to X & Y initial location
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X" .. tonumber(valX) .. "Y" .. tonumber(valY))

--Message display tool status
mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedTool) .. "   Previous Tool == " .. tostring(currentTool))

--Sets the current tool to the new tool value
mc.mcToolSetCurrent(inst, selectedTool)

--Cycles the tool changer the correct number of times if selected tool is higher than current tool
else
for changeNums = (currentTool-selectedTool),6 do

--Moves Z to the top of the tool change area
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 F70 Z5.750")

--Moves Z to the bottom of the tool change area
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 F70 Z3.800")
end

-- Move back to Z home
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G1 F70 Z0")

-- turn Z soft limit back on
mc.mcSoftLimitSetState(inst, mc.Z_AXIS, mc.MC_ON)

--Move back to X & Y initial location
mc.mcCntlGcodeExecuteWait(inst, "G90 G53 G0 X" .. tonumber(valX) .. "Y" .. tonumber(valY))

--Message displace tool status
mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedTool) .. "   Previous Tool == " .. tostring(currentTool))

--Sets the current tool to the new tool value
mc.mcToolSetCurrent(inst, selectedTool)
end
end

end

if (mc.mcInEditor() == 1) then
m6()
end
Re: Tool Table and Tool Changer question
« Reply #3 on: August 07, 2019, 05:03:02 AM »
Hi,
kool!

When Mach interprets Gcode it reduces all letters to lowercase and deletes leading zeros.

Thus 'M05' is actually interpreted m5 and G01 X0.25 is interpreted g1x.25. Note it also strips out blanks but can make
code too hard to read. Mostly if you use uppercase everything works but there are times when it does not, particularly when
Mach searches for a macro, if it doesn't find your M06 it WILL find m6, the built in macro. It pays therefore to use the
format that Mach expects otherwise you'll end up with some extremely hard to find bugs.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'