Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: Cbyrdtopper on January 23, 2017, 12:02:11 PM
-
We've got a Hurco with an arm tool changer. I want to change the tool and put up the current tool in one operation, to do this we need to keep track of each tool's "carousel position"
We're doing this on an Johnford VMC using Mach3, that M6 macro is very long and is running multiple tests; it has to go through each tool with an "if" statement to figure out which tool is requested so it will move to the correct carousel position; and then again to change the previous tool's carousel position to the current carousel position.
I was curious to know if there was a way to shorten up this macro. Attached is a crude version of my Mach4 Macro. I'm going to attempt to use a PLC to run the tool change so it will send and receive registers via modbus to know which position to go to and, when finished, which position it is at to change the current tool's carousel position. I'm using registers to keep track of the Tool's Carousel Positions and the Current Carousel position.
Any insight would be greatly appreciated!
-
For machines that don't have a 1:1 for tool number to pod, use the tool table's pocket feature.
pocket , rc = mc.mcToolGetData(Inst, mc.MTOOL_MILL_POCKET, tool);
and
rc = mc.mcToolSetData(Inst, mc.MTOOL_MILL_POCKET, tool, pocket);
pseudo code:
RequestedTool, rc = mc.mcToolGetSelected(inst)
CurrentTool, rc = mc.mcToolGetCurrent(inst)
pocket , rc = mc.mcToolGetData(Inst, mc.MTOOL_MILL_POCKET, RequestedTool);
retrieve tool from pocket
rc = mc.mcToolSetData(Inst, mc.MTOOL_MILL_POCKET, RequestedTool , 0); -- tool is in spindle.
put current tool in the requested tool's old pocket
rc = mc.mcToolSetData(Inst, mc.MTOOL_MILL_POCKET, CurrentTool , pocket); -- old tool is in the new pocket.
Before the first run, make sure the tool table has the correct pocket numbers for eash tool.
Steve
-
Thanks Steve! I had no idea that was even an option in the Tool Table.
I know this is probably bad programming, but I don't use the "rc" on anything. Can you tell me what it is and what it is used for? Or point me to a forum that talks about it?
This will make it much easier to code!! Thanks!
-
rc is the function return code. Ideally, you should check the rc to determine success or failure of the API call instead of assuming that it worked. You know what they say about assumptions. :) f an API function succeeds, it will return a rc of mc.MERROR_NOERROR.
For example:
RequestedTool, rc = mc.mcToolGetSelected(inst)
if (rc ~= mc.MERROR_NOERROR) then
mc.mcCntlSetLastError(inst, "Error getting selected tool!")
end
Steve