A Custom Macro For Tool Change Format
Much of CNC manual programming is redundant. Similar commands must be repeated on a fairly regular basis, especially when tool changes must be made.
Founder and President, CNC Concepts Inc.
Much of CNC manual programming is redundant. Similar commands must be repeated on a fairly regular basis, especially when tool changes must be made. Because these commands are only similar (not identical), subprograms will not help when it comes to minimizing them. But if your control has custom macro B (or any version of parametric programming), you can simplify the commands required for tool changing.
Even if you program with a computer aided manufacturing (CAM) system, you must consider how difficult it is for operators to run your programs. The techniques we show will simplify programming (especially for manual programmers), ensure consistency for tool changing commands, make your programs more fail-safe and make it easier for setup people and operators to rerun tools.
First, consider a typical series of commands that are needed when you make a tool change on a vertical machining center. Of course, the specific commands for your particular machine(s) will vary. Similar commands will be required for turning centers (or any multi-tool CNC machine tool).
N060 M09 (Turn off coolant)
N065 G91 G28 Z0 M19 (return to tool change position, orient spindle)
N070 T02 M06 (Place desired tool in spindle)
N075 G90 G54 S500 M03 T03 (Select absolute mode, fixture offset, start spindle and select next tool)
N080 G00 X1.5 Y2.0 (Rapid to first X and Y position)
N085 G43 H02 Z0.1 (Instate tool length compensation, rapid to first Z position)
N090 M08 (Start coolant)
Note that the structure of these commands will remain the same for every tool change you make. Only the values of the numbers in bold italics will change from tool change to tool change. Again, these commands are redundant and tedious to write. It’s easy for manual programmers to forget key words or commands. Consider this custom macro call statement that can be used to invoke a special tool change custom macro.
N060 G65 P1000 T02 S500 X1.5 Y2.0 Z0.1 (Make tool change)
When the custom macro (O1000) is executed, it will cause the machine to do everything done in the previous series of tool change commands. In our call statement, T represents the tool to be placed in the spindle. Our macro will assume that the tool to be used after this one follows in sequence (tool three in this case). If it does not, a W word (for waiting station) can be included in this command to specify which tool is coming up next in the program. We’ve left W out, so we’re letting the custom macro assume that the next tool will be station three. S specifies the spindle speed, and X, Y and Z specify the tool’s first approach position.
Here is the simple custom macro.
O1000 (Tool change custom macro)
IF [#23 NE #0] GOTO 1 (If W is included in call, skip default)
#23 = #20 +1 (Set next waiting station tool to next number in sequence)
N1 M09 (Turn off coolant)
G91 G28 Z0 M19 (Return to tool change position, orient spindle)
T#20 M06 (Place desired tool in spindle)
G90 G54 S#19 M03 T#23 (Select absolute mode, fixture offset, start spindle and select next tool)
G00 X#24 Y#25 (Rapid to first X and Y position)
G43 H#20 Z#26 (Instate tool length compensation, rapid to first Z position)
M08 (Start coolant)
M99 (End of custom macro)
We’ve taken the set of tool change commands and replaced those hard-and-fixed values that change from tool change to tool change with local variables (T is represented by #20, W by #23, S by #19, X by #24, Y by #25 and Z by #26). We have also set a default value for W (#23) if it’s left out of the call statement. Look at the first two commands of the custom macro. If W is left out of the call statement (as it is in our example), the result of the IF statement will be false (W is vacant), and the next command (the default setting command) will be executed. #23 will be set to a value of whatever T (#20) is plus 1. If W is included in the call statement, #23 will have a value (#23 will not be vacant), the IF statement will be true and the default setting command will be skipped.
Though our example custom macro doesn’t show it, you could also include words and commands in the tool change format custom macro to make your programs more fail-safe. For example, you could include G80 and G40 in line N1 (when the coolant is turned off) to ensure that canned cycles and cutter radius compensation have been canceled. Most manual programmers will not do this, because they assume they’ve programmed correctly. Right after the tool change command (M06), you could include some safety commands to confirm that certain modes are still in their initialized states. Consider these commands.
G17 G20 G40 (Set XY plane, inch mode, cancel cutter radius compensation)
G64 G69 G50.1 (Set normal cutting mode, cancel rotation, cancel mirror image)
G80 G94 (Cancel canned cycle, select feed per minute mode)
Again, these commands can be placed in the custom macro right after the tool change and will ensure that the machine is in appropriate states. This is most important for the first tool the first time the program is run.
What about rerunning tools? One important task that CNC setup people and operators must perform on a regular basis is rerun tools. Our tool change format custom macro still allows rerunning tools. Actually, it will simplify the task. The restart block for rerunning tools is simply the call statement (G65 command) for each tool change. Everything required for restarting tools, including a movement to the appropriate tool change position, is included in the custom macro.
Also, if your setup people and operators are currently restarting tools by scanning to the T word, they have to scan twice (assuming you have a machine with a double arm tool changer). The first time they scan, they find the command in which the tool is being placed in the waiting station. The second time, they find where it is actually being placed in the spindle. With the tool change custom macro, only one scan is required.