The Basics Of Computer Numerical Control
Key concept number four: You must Understand the forms of compensation
All types of CNC machine tools require some form/s of compensation. Though applied for different reasons on different machine types, all forms of compensation allow the CNC user to allow for unpredictable conditions related to tooling as the program is developed. Before discussing how compensation applies to CNC usage, let's look at compensation in general terms.
Compensation is used in many facets of everyday life. The airplane pilot must compensate for wind velocity and direction as a heading is set. The race car driver must compensate for weather and track conditions as a turn is negotiated. A bowler must compensate for the spin of the bowling ball as the ball rolls down the alley. A marksman firing a rifle must compensate for the distance to the target. The marksman analogy is amazingly similar to what happens with many forms of compensation on CNC equipment, so let's discuss it further.
Say a marksman is standing 50 yards from a target. By one means or another, the marksman would adjust the sight on the rifle to allow for the 50 yard distance. The marksman would make the necessary adjustment, but until the first shot is fired, the marksman will not know for sure whether the initial sight adjustment was perfectly correct. Once the first shot is fired and the marksman can see the resulting hole location, the sight may have to be fine tuned to adjust for minor imperfections with the initial adjustment.
In similar fashion, the CNC user will be faced with several situations when it will be impossible to predict the result of certain tooling related problems. So one form or another of compensation will have to be used to handle the problem. But just as the marksman may have to fine tune after the initial shot, so may the CNC user have to fine tune the initial compensation entry. More on how and why in a little while.
What are offsets?
All forms of compensation work with offsets. You can think of CNC offsets as like memories on an electronic calculator. If your calculator has memories, you know you can store a constant value into each memory for use during a calculation. This keeps you from having to enter the number over and over again with redundant calculations.
Like the memories of an electronic calculator, offsets in the CNC control are storage locations into which numerical values can be placed. Just as the value within the memory of a calculator has no meaning until referenced by its user within a calculation, neither does the value within an offset of the CNC control have any meaning until it is referenced by a CNC program.
From the marksman analogy, you can think of the values stored in CNC offsets as like the amount of adjustment required on the sight of the rifle necessary to compensate for the distance to the target. Keep in mind that the rifle only needed adjustment for one purpose, to adjust for the distance to the target. With most CNC machine tools, there is a need for at least one offset per tool.
Reasons for tool offsets
Offsets can be used for several purposes depending on the style of machine tool and type of compensation being used. Here are some of the more common applications for offsets.
To specify tool each tool's length
For machining center applications, it would be very difficult for the programmer to predict the precise length of each tool used in the program. For this reason, the feature tool length compensation allows the programmer to ignore each tool's length as the program is written. At the time of setup, the setup person measures the length of each tool and inputs the tool length value into the corresponding offset.
To specify the radius of the cutting tool
When milling on the periphery of the cutter (contour milling), it can be cumbersome and difficult for the programmer to program the cutter's path based on the size of the milling cutter being used. Also, if the cutter size must change (possibly due to re-sharpening), it would be infeasible to change the program based on the new cutter size. For this reason, the feature cutter radius compensation allows the programmer to ignore the cutter size as the program is written. The setup person inputs the size of each milling cutter into its corresponding tool offset. In similar fashion, turning centers have a feature called tool nose radius compensation. With this feature, an offset is used to specify the radius of the very tip of the turning or boring tool.
To assign program zero
Machining centers that have fixture offsets (also called coordinate system shifting) allow the user to specify the position of the program zero point within offsets, keeping the assignment of program zero separate from the program. In similar fashion many turning centers allow the assignment of program zero with offsets (this feature is commonly called geometry offsets).
To allow sizing on turning centers
Tool offsets are used on all turning centers to allow the operator to hold size with tools used within their programs. This allows the operator to adjust for imperfections with tool placement during setup. It also allows the operator to adjust the tool's movements to allow for tool wear during each tool's life.
With some CNC controls, the organization of offsets is very obvious. Some machining center controls, for example, automatically make the offset number correspond to the tool station number. With this kind of machine, when tool station number one is commanded, the control will automatically invoke offset number one. Within offset number one, the operator can store a tool length value as well as a tool radius value.
Unfortunately, not all controls make it this simple. In many controls, each offset contains only one value and the offset number has no real relationship to the tool station number. In this case, the programmer must cautiously organize which offset/s are used with each tool.
For example, the tool length compensation offset numbers can be made the same as tool station numbers. Cutter radius compensation offset numbers can be made equal to the tool station number PLUS a constant value larger than the number of tools the machine can hold. If the machine can hold 25 tools, tool station number one could be made to use offset number one to store its length compensation value and offset number thirty-one could be used to store its cutter radius compensation value. With this method of offset organization, the programmer and operator are constantly in sync.
The offset table on most turning centers incorporate at least two values per offset. Generally speaking, the programmer will instate the offset number corresponding to the tool station number for each tool offset used. That is, tool number one will use (only) offset number one, tool two will use offset two, and so on. Additionally, most turning center offset tables allow the user to enter data related to the tool's radius (for tool nose radius compensation). Typically the radius (R column of the offset table) and the tool type (the T column of the offset table) can be specified within the turning center's offset table.
Types of compensation
Now let's discuss the compensation types for the two most popular forms of CNC machine tools, machining centers and turning centers. Keep in mind that while the actual use of these functions vary dramatically from one machine to the next, the basic reasoning behind each compensation type remains remarkably similar. With an understanding of why the compensation type is required, and with an elementary understanding of how it is applied to one specific control, you should be able to adapt to any variations that you come across.
Tool length compensation
This machining center compensation type allows the programmer to forget about each tool's length as the program is written. Instead of having to know the exact length of each tool and tediously calculating Z axis positions based on the tool's length, the programmer simply instates tool length compensation on each tool's first Z axis approach movement to the workpiece.
At the machine during setup, the operator will input the tool length compensation value for each tool in the corresponding offset. This, of course, means the tool length compensation value must first be measured.
If tool length compensation is used wisely, the tool length compensation value can be measured off line (in a tool length measurement gage) to minimize setup time. With this method, the tool length compensation value is simply the length of the tool.
Many CNC controls allow the length of the tool to be used as the offset value. One popular command to instate tool length compensation is G43. Within the G43 command, the programmer includes an H word that specifies the number of the offset containing the tool's length value. Here is an example program that utilizes tool length compensation with two tools. The program simply drills two holes (one with each tool). Notice that tool length compensation is being instated in lines N015 and N055.
- O0001 (Program number)
- N005 T01 M06 (Place tool number one in the spindle)
- N010 G54 G90 S400 M03 T02 (Select coordinate system, absolute mode, start spindle CW at 400 RPM, get tool number two ready)
- N013 G00 X1.0 Y1.0 (Rapid to first XY position)
- N015 G43 H01 Z.1 M08 (Instate tool length compensation on first Z move, turn on coolant)
- N020 G01 Z-1.5 F4. (Drill hole)
- N025 G00 Z.1 M09 (Rapid out of hole, turn off coolant)
- N030 G91 G28 Z0 M19 (Return to tool change position, orient spindle)
- N035 M01 (Optional stop) N040 T02 M06 (Place tool number two in spindle)
- N045 G54 G90 S400 M03 T01 (Select coordinate system, absolute mode, start spindle at 400 RPM, get tool number one ready)
- N050 G00 X2. Y1. (Rapid to first XY position)
- N055 G43 H02 Z.1 M08 (Instate tool length compensation on tool's first Z move, turn on coolant)
- N060 G01 Z-1.2 F5.5 (Drill hole)
- N065 G00 Z.1 M08 (Rapid out of hole, turn off coolant)
- N070 G91 G28 Z0 M19 (Return to tool change position, orient spindle)
- N075 M30 (End of program)
As stated, this feature varies dramatically in use from one control model to the next. You must reference your control manufacturer's programming manual to learn more about how tool length compensation applies to your particular machining center. Sizing with tool length compensation
In the marksman analogy, we said that the marksman would not know for sure whether the initial sight adjustment is perfectly correct until the first shot is fired. In similar fashion, the CNC operator will not know for certain whether the tool length compensation value is perfectly correct until the first workpiece is machined. Say for example, the tool length measurement was made incorrectly. During the measurement, the operator finds the tool to be 6.5372 in long. But the actual tool length is 6.5355 in. In this case, the tool would machine slightly shallower in Z that it is supposed to. After machining, the minor depth change can be made by adjusting the offset, NOT THE PROGRAM.
In some cases, even if the tool length value is measured perfectly, other problems may cause the tool not to machine to the proper depth. If, for example, the workpiece or setup is quite weak, tool pressure may cause the workpiece to tend to push away from the tool doing the machining.
For critical surfaces or when tool pressure is unpredictable, the operator can even trial cut the workpiece under the influence of an offset slightly LARGER than the measured value to ensure that some excess stock will be left. After machining, the operator can measure the surface to determine precisely how much offset change is necessary to machine the workpiece to size.
Cutter radius compensation
Just as tool length compensation allows the machining center programmer to forget about the tool's length, so does cutter radius compensation allow the programmer to forget about the cutter's radius as contours are programmed. While it may be obvious, let us point out that cutter radius compensation is ONLY used for milling cutters and only when milling on the periphery of the cutter. You would NEVER consider using cutter radius compensation for a drill, tap, reamer, or other hole machining tool.
Reasons for cutter radius compensation
Let's begin by discussing four reasons why cutter radius compensation is not only required, but also very helpful to the CNC user.
Program coordinates are easier to calculate
Without cutter radius compensation, machining center programmers must program the centerline path of all milling cutters. An example program using this technique was shown during our discussion of motion types (key concept number three). When programming centerline path, the programmer must know the precise diameter of the milling cutter and calculate program movements based on the tool's centerline path.
With cutter radius compensation, the programmer can program the coordinates of the work surface, NOT the tool's centerline path. This eliminates the need for many calculations.
Keep in mind that we are now talking about manual programming. If you have a CAM (computer aided manufacturing) system, your CAM system can probably generate centerline path just as easily as work surface path.
Range of cutter sizes
Say you do program centerline path for a given workpiece contour and do not use cutter radius compensation. Say you have programmed based on a one inch diameter tool. But when the job is to be run, you find that your company does not have any one inch end mills. Say the closest you have is a 0.875 in cutter. In this case, the entire cutter path would have to be changed in the program to match the new cutter size. With cutter radius compensation, handling this problem is as simple as changing an offset value.
As with tool length compensation, the operator can use the cutter radius compensation offset to help with sizing. If the contour is not coming out to size (possibly due to tool pressure), an offset can be changed to allow for the imperfection.
Roughing and finishing
This is also a manual programming related reason for using cutter radius compensation. If contours must be rough and finish milled, cutter radius compensation allows the programmer to used the same programmed coordinates needed to finish mill the workpiece to rough mill the workpiece. This keeps the programmer from having to calculate to sets of milling coordinates (one for roughing and one for finishing). To leave stock for finishing during the rough milling, the operator will simply make the cutter radius compensation offset value slightly larger than the cutter's actual size. This will keep the cutter away from the surface being milled and leave the desired finishing stock.
How to program cutter radius compensation
The usage of cutter radius compensation does vary from one control to the next. Additionally, each control will have a set of strict rules that specify how cutter radius compensation is instated, used, and cancelled. Here we just show the basics of how it is programmed and give an example for how it is used on one popular control model. You must refer to your CNC control manufacturer's manual for more on your particular control.
Most controls use three G codes with cutter radius compensation. G41 is used to instate a cutter left condition (climb milling with a right hand cutter). G42 is used to instate a cutter right condition (conventional milling). G40 is used to cancel cutter radius compensation. Additionally, many controls use a D word to specify the offset number used with cutter radius compensation.
To determine whether to use G41 or G42, simply look in the direction the cutter is moving during machining and ask yourself if the cutter is on the left or right side of the surface being machined. If on the left, use G41. If on the right, use G42. Figure 4.6 shows some examples that should help you understand how to determine whether to use G41 or G42 to instate. Figure 4.6 - Drawings show how to determine whether to use G41 or G42 to instate cutter radius compensation.
Once cutter radius compensation is properly instated, it the cutter will be kept on the left side or right side (depending on whether G41 or G42 is used to instate) of all surfaces until the G40 command to cancel compensation.
Dimensional tool (wear) offsets
This compensation type applies only to turning centers. When setting up tools, it is infeasible to expect the setup person to perfectly set each tool into position. It is likely that some minor positioning problem will exist. And even if all tools could be perfectly positioned, as any single point turning or boring tool begins cutting, it will begin to wear. As a turning or boring tool wears, the tool wear will affect the size of the workpiece being machined.
For these reasons, and to allow easy sizing of turned workpieces, dimensional tool offsets are required (also called simply tool offsets). Tool offsets are instated as part of a four digit T word. The first two digits command the tool station number and the second two digits command the offset number to be instated. The command T0101, for example, rotates the turret to station number one and instates offset number one. It is wise to always make the number of the primary offset used with a tool the same as the tool station number.
When a tool offset is instated, the control actually shifts the entire coordinate system by the amount of the offset. It will be as if the operator could actually move the tool in the turret by the amount of the offset.
Each dimensional offset has two values, one for X and one for Z. The operator will have control of what the tool does in both axes as the workpiece is being machined. Here's an example that should help you understand how dimensional tool offsets work. Say you have written a program to use tool number one (with offset number one) to turn a three inch diameter. After machining the three inch diameter, it is measured and found to be 3.005 in. That is, the workpiece is 0.005 in oversize. In this case, the X value of offset number one will be reduced by 0.005 in. When the program is run again, tool number one will machine the workpiece 0.005 smaller.
How to guarantee your first workpiece comes out on size
If working on an engine lathe, manually turning a precise diameter, you would first allow the tool to skim cut to find out exactly where the tool is located. After skim cutting, you can determine precisely how much to turn the crank or handle to make the tool turn the desired diameter.
In the same way, you can use dimensional tool offsets to ensure that any tool will not violate the workpiece on its first cut. Outside diameter turning tools, for example, could be offset slightly plus in X to ensure that some excess stock is left. Inside diameter bored holes could be offset slightly minus in X for the same purpose. In either case, the first time the tool is run, the operator can rest assured that the workpiece will come out with some excess finishing stock (it will NOT be scrapped). After machining the first time, the surface can be measured. The operator will then adjust the corresponding offset accordingly and re-machine with the tool This time the surface will be machined perfectly to size. Using this technique on each tool in the program will almost guarantee that the first workpiece will not be scrapped.
Tool nose radius compensation
This turning center compensation type is very similar to cutter radius compensation. In fact the same three G codes are used. G41 instates tool nose radius compensation in a tool left condition. G42 instates with a tool right condition. G40 cancels tool nose radius compensation. For this reason, minimize our discussion of tool nose radius compensation to avoid repeating information. Just as cutter radius compensation allows the programmer to program work surface coordinates (not allowing for tool radius), so does tool nose radius compensation.
To determine G41 or G42, simply look in the direction the tool is moving during the cut and ask yourself which side of the workpiece the tool is on. If the tool is on the left, use G41 (this would be the case when boring toward the chuck). If the tool is on the right, use G42 (turning toward the chuck). Once you determine which to use, include the proper G code in the tool's first approach to the workpiece. Once tool nose radius compensation is instated, it remains in effect until cancelled.
Keep in mind that the tool nose radius is quite small (usually 1/64, 1/32, 3/64, or 1/16 in), meaning the deviation from the work surface will also be quite small. It is possible that if you are only chamfering corners to break sharp edges, you may not need tool nose radius compensation. However, if the surfaces being machined are critical (Morse taper, for example), you must compensate for the radius of the tool. Also, you should only need tool nose radius compensation when finishing. You should not use it for roughing operations.
Other types of compensation
The compensation types shown have been for machining centers and turning centers. But all forms of CNC equipment have some form of compensation to allow for unpredictable situations. Here are some other brief examples.
CNC Wire EDM machines have two kinds of compensation. One, called wire offset works in a very similar way to cutter radius compensation to keep the wire centerline away from the work surface by the wire radius plus the overburn amount. It is also used to help make trim (finishing) passes using the same series of motion coordinates.
The second form of compensation for wire EDM machines is taper cutting. For machining the clearance angle needed with dies and form tools, the programmer can easily specify the direction of the taper (left or right) and the angle desired. The operator fills in some offsets to tell the control the position of the upper guide relative to the workpiece and the control does the rest.
Laser cutting machines also have a feature like cutter radius compensation to keep the laser the radius of the laser beam away from the surface being machined. CNC press breaks have a form of compensation to allow for bend allowances based on the workpiece material and thickness. Generally speaking, if the CNC user is faced with any unpredictable situations during programming, it is likely that the CNC control manufacturer has come up with a form of compensation to deal with the problem.