Hello Guest it is April 23, 2024, 10:55:23 PM

Author Topic: 24 Position Side Mount Tool Change Macro  (Read 2179 times)

0 Members and 1 Guest are viewing this topic.

24 Position Side Mount Tool Change Macro
« 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!
Chad Byrd

Offline smurph

*
  • *
  •  1,546 1,546
  • "That there... that's an RV."
    • View Profile
Re: 24 Position Side Mount Tool Change Macro
« Reply #1 on: January 23, 2017, 03:20:32 PM »
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
 
Re: 24 Position Side Mount Tool Change Macro
« Reply #2 on: January 23, 2017, 03:44:50 PM »
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!
Chad Byrd

Offline smurph

*
  • *
  •  1,546 1,546
  • "That there... that's an RV."
    • View Profile
Re: 24 Position Side Mount Tool Change Macro
« Reply #3 on: January 23, 2017, 04:22:25 PM »
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