Scaling Function Overview
Normally, a programmed tool motion for a CNC machining center represents drawing dimensions, perhaps with cutter radius offset in effect. Occasionally, there may be a situation when the machining tool path that had already been programmed once must be repeated, but machined as smaller or larger than the original, yet still keep it proportional at the same time. To achieve this goal, a control feature called the Scaling Function can be used. Note the following two important items:
- Scaling function is an option on many controls and may not be available on every machine
- Some system parameters may be used for this function as well
For even greater flexibility in CNC programming, this optional scaling function can be used together with other programming functions, namely with Datum Shift, Mirror Image and Coordinate System Rotation.
CNC Scaling (G51) Description
CNC machine system can apply a specified scaling factor to all programmed motions, which means the programmed value of all axes will change. Scaling process is nothing more than multiplying the programmed axis value by the scaling factor, based on a defined scaling center point. CNC programmer must supply both the scaling center and the scaling factor. Through a control system parameter, scaling can be made effective or ineffective for each of the three main axes, but not for any additional axes. The majority of scaling is applied to the X and Y axes only.
It is important to realize that certain settings and preset amounts are not affected by the scaling function, namely various offsets. The following offset functions will not be changed if the scaling function is active:
- Cutter radius offset amount ( G41-G42 / D )
- Tool length offset amount ( G43-G44 / H )
- Tool position offset amount ( G45-G48 / H )
In fixed cycles, there are two additional situations also not affected by the scaling function:
- X and Y shift amounts in G76 and G87 cycles
- Peck drill depth Q in G83 and G73 cycles
- Stored relief amount for G83 and G73 cycles
Scaling Function Usage
In machine shop work, there are many applications for scaling an existing tool path. The result could be many hours of extra work saved. Here are some typical possibilities when a scaling function can be beneficial in CNC:
- Similar parts in terms of their geometry
- Machining with built-in shrinkage factor
- Mold work
- Imperial to metric and metric to imperial conversion
- Changing size of engraved characters
Regardless of application, scaling is used to make a new tool path larger or smaller than the original one. Scaling is therefore used for magnification (increasing size) or reduction (decreasing size) of an existing tool path – Figure 43-1.
Figure 43-1Comparison of a part reduction (left) and part magnification (right) also showing a part in full scale (middle)
G50 and G51 Codes Format
To supply the control unit with required information, programmer must provide the following data of information:
Scaling center … Pivot point (scaling origin) |
Scaling factor … Reduction or Magnification |
Two typical preparatory commands for scaling function are G51, canceled by another command, G50:
G50 : Scaling mode cancel Scaling OFF |
G51 : Scaling mode active Scaling ON |
Scaling function uses the following program format:
G51 I.. J.. K.. P.. |
Parameters
I = X coordinate of the scaling center (absolute) |
J = Y coordinate of the scaling center (absolute) |
K = Z coordinate of the scaling center (absolute) |
P = Scaling factor (0.001 or 0.00001 increment) |
For best results, the G51 command should always be programmed in a separate block. Commands related to the machine zero return, namely G27, G28, G29 and G30 should always be programmed in scaling OFF mode. If G92 command is used for position register (older controls only), make sure it is also programmed in scaling OFF mode. Cutter radius offset G41/G42 should be canceled by G40 before scaling function is activated. Other commands and functions can be active, including all work offsets commands G54 through G59 as well as the additional ones.
CNC Scaling Function Details
Scaling Center
Scaling center determines the location of the scaled tool path |
Some high end Fanuc controls use I/J/K to specify the center point of scaling in X/Y/Z axes respectively. These values are always programmed as absolute values. As the center point controls the location of the scaled tool path, it is important to know one major principle:
Figure 43-2Comparison of scaled part location based on the scaling center
The scaled part will always expand away from and reduce towards the scaling point equally along all axes, as illustrated in Figure 43-2.
In order to understand a contour shape that is somewhat more complex, compare both the original and the scaled contours shown as an overlap in Figure 43-3. There are two machine tool paths (Aand B) and the scaling center C. Depending on the scaling factor value, the result will be either tool path A1 to A8 or path B1 to B8.
Figure 43-3Effect of scaling point on the scaled part
Points A1 to A8 and points B1 to B8 in the illustration above represent contour change points of the tool path.
- If tool path A1 to A8 is the original path, then tool path B1 to B8 is the scaled tool path about center C, with a scaling factor LESS than 1
- If tool path B1 to B8 is the original path, then tool path A1 to A8 is the scaled tool path about center C, with a scaling factor GREATER than 1
All dashed lines connecting individual points are used for easier visualization of the scaling function. Starting from the scaling center C, each line always connects to the contour change point. The B point is always a midpoint between center point C and the corresponding point A. In practice, for example, it means that the distance between C and B5 and B5 and A5 is exactly the same.
Scaling Factor
Scaling factor determines the size of scaled tool path |
The maximum scaling factor is directly related to the smallest scaling factor. More advanced CNC systems can be set internally – through a system parameter – to preset the smallest scaling factor to either 0.001 or 0.00001. Some older models can only be set to 0.001 as the smallest scaling factor. Scaling factor is always independent of input units used in the program – G20 or G21.
When the smallest scaling factor is set to 0.001, the largest scale that can be programmed is 999.999.When the smallest scaling factor is set to 0.00001, the largest programmable scale is only 9.99999. Given the choice, the programmer has to decide between large scales, at the cost of precision or precision at the cost of large scales. For the majority of scaling applications, the 0.001 scaling factor is more than sufficient. Common terms for calling factors are:
Scaling factor > 1 . . . Magnification |
Scaling factor = 1 . . . No change – full scale |
Scaling factor < 1 . . . Reduction |
If the P address is not provided within G51 block, the system parameter setting will become effective by default.
Rounding Errors in Scaling
Any conversion process should always be expected to return some inaccuracies,mainly due to rounding. For example, imperial-to-metric conversion uses the standard multiplying factor of 25.4, which happens to be an exact conversion factor. In order to convert a programmed value of 1.5 inches to its equivalent in millimeters, the value in inches must be multiplied by the constant of 25.4:
mm = 1.5 inches x 25.4 = 38.1 mm |
In this case, the conversion is 100 percent accurate. Now, convert the value of 1.5625 inches to millimeters:
mm = 1.5625 inches x 25.4 = 39.6875 mm |
So far, there is no problem – the resulting metric value as shown is also 100 percent accurate – within the four decimal places for normal programming in imperial units.
Scaling from millimeters to inches is much different. The scaling factor for millimeters to inches (within a nine place accuracy) is 0.039370079. However, scaling factor may only be programmed with a three or five decimal place accuracy. That means rounding the scaling factor will result in an inaccurate conversion. In many cases, the rounded result will be quite acceptable, but it is very important to consider the possibility of an error, in case it does matter.
Compare the error amount with different rounded scaling factors for 12.7mm, which equals exactly to 0.500 inch:
Using 0.001 minimum scaling factor: |
mm > Inch = 12.7 mm x 0.039 ( preferred ) = 0.4953 inches ( error of 0.0047 ) mm > Inch = 12.7 mm x 0.038 = 0.4826 inches ( error of 0.0174 ) mm > Inch = 12.7 mm x 0.040 = 0.5080 inches ( error of 0.0080 ) |
Using 0.00001 minimum scaling factor: |
mm > Inch = 12.7 mm x 0.03937 ( preferred ) = 0.499999 mm ( error of 0.000001 ) mm > Inch = 12.7 mm x 0.03938 = 0.500126 mm ( error of 0.000126 ) mm > Inch = 12.7 mm x 0.03936 = 0.499872 mm ( error of 0.000128 ) |
These examples are rather extreme applications. If a 5% shrinkage factor is to be applied, for example, the scaling factor of 1.05 (magnification) or 0.95 (reduction) is well within the expected accuracy of the final part precision.
G51 Code Examples
G51 CNC Program Example – 1 – Scaling
This first scaling example is very simple – Figure 43-4.
Figure 43-4Drawing to illustrate scaling function – programs O4301 and O4302
Program O4301 is a basic contouring program, using a single cutting tool and only one cut around the part periphery. It is programmed normally, without any scaling.
Not Scaled Program
O4301 (BASIC PROGRAM USING G54 – NOT SCALED)
N1 G20
N2 G17 G40 G80
N3 G90 G00 G54 X-1.25 Y-1.25 S800 M03
N4 G43 Z1.0 H01 M08
N5 G01 Z-0.7 F50.0
N6 G41 X-0.75 D51 F25.0
N7 Y1.75 F15.0
N8 X1.5
N9 G02 X2.5 Y0.75 I0 J-1.0
N10 G01 Y-0.75
N11 X-1.25
N12 G40 Y-1.25 M09
N13 G00 Z1.0
N14 G28 Z1.0
N15 G28 X-1.25 Y-1.25
N16 M30
%
Program O4302 is a modified version of O4301. It includes a scaling factor value of 1.05 – or 5% magnification – and scaling center at X0Y0Z0. K0 can be omitted in G51.
Scaled Program
O4302 (PROGRAM O4301 SCALED BY 1.05 FACTOR)
N1 G20
N2 G17 G40 G80
N3 G50 (SCALING OFF)
N4 G90 G00 G54 X-1.25 Y-1.25 S800 M03
N5 G43 Z1.0 H01 M08
N6 G51 I0 J0 K0 P1.050 (FROM X0Y0Z0)
N7 G01 Z-0.7 F50.0
N8 G41 X-0.75 D51 F25.0
N9 Y1.75 F15.0
N10 X1.5
N11 G02 X2.5 Y0.75 I0 J-1.0
N12 G01 Y-0.75
N13 X-1.25
N14 G40 Y-1.25 M09
N15 G50 (SCALING OFF)
N16 G00 Z1.0
N17 G28 Z1.0
N18 G28 X-1.25 Y-1.25
N19 M30
%