Post · 3 min read· pp. 362–364

G51: Scaling the CNC Coordinate System

CNCCookbook's G-code Tutorial

What is the Purpose of Scaling, Anyway?

Scaling can be an extremely useful feature when creating a G-code program. For starters, you might have the same shaped feature and just need to repeat it in a different size. Scaling with G51 can make that easy. But, there's an even more clever use for scaling.

Precision measurement tool, 3D touch probe.

Let's say your machine is equipped with an accurate digital touch probe that can measure things very accurately. Let's further assume you need to make a bore that is extremely accurate and that your part is held in a fixture that has a bore right on the fixture that you have painstakingly made accurate to extreme tolerances. Lastly, let's say that bore has to be 2.000 inches, plus 0.0001 and minus 0.0000. That's pretty tight!

Now here is a neat trick you can perform with the probe:

  • Measure the bore with the probe. You know it measures within your tolerances to 2 inches at the normal inspection temperatures your customer will use. Let's say the probe reports a measurement of 1.9993. The hole is allowed to be a tenth larger, but cannot be smaller than 2 inches. So you're off by 0.0007" and need the hole to be larger.
  • So, your G-code performs a little calculation. 0.0007" / 2.0000" is 0.00035. Now you know the correction factor that's needed.
  • When you make your finish pass, use G51 to scale the finish pass to 1.00035x the coordinates that are in the G-code program.

Your part should come out much closer than it would have without the feedback the probe supplies on how to correct for errors due to temperature changes and other factors. Very cool, eh?

That's the technique used in Renishaw's RAMTIC manufacturing, and it's a very powerful way to increase the accuracy of your machining operations.

G51: Apply the Same Scale Factor to All Axes

Scaling is pretty straightforward on Fanuc. The syntax for G51 looks like this:

G51 X_ Y_ Z_ P_

Where the XYZ words specify the absolute coordinates for the center of the scaling and P specifies the scaling factor or magnification to be applied. If XYZ are not specified, the coordinates of the current tool position are used.

G51: Apply a Different Scale Factor to Each Axis

In this version, you can scale all axes with a constant magnification, but Fanuc also allows you to scale with a different factor on each exis:

G51 X_ Y_ Z_ I_ J_ K_

In this case, the I-Word specifies magnification for the X-Axis, J for the Y, and K for the Z.

There are some neat tricks you can play when you can set the scaling independently for each axis. For example, set a negative value and you can create a mirror image.

Here's a sample program that uses G51 to mirror a figure 4 times that's created by a subprogram:

N10 G00 G90 N20 M98 P9000 N30 G51 X50 Y50 I-1000 J1000 N40 M98 P9000 N50 G51 X50 Y50 I-1000 J-1000 N60 M98 P9000 N70 G51 X50.0 Y50.0 I1000 J-1000 N80 M98 P9000 N90 G50 N100 M30 O9000 G00 G90 X60 Y60 G01 X100.0 F100 G01 Y100.0 G01 X60.0 Y60.0 M99

Scaling, Arcs, and Circular Interpolation

I'm sure some of you immediately wondered if you could create ellipses by applying a scale factor to just one axis of an arc or circle move. The answer is, "No", you won't get any ellipses out of these controls.

Canceling Scaling

You use the G50 command to cancel scaling when you're done with it.

Next Article: Rotating the Coordinate System with G68 and G69