Skip to content

G51 / G50: applying and canceling a scaling factor

G51 multiplies all program dimensions by a factor from that point on, using as origin a scaling center that you specify, and G50 cancels it. It is used to machine the same geometry in several sizes, to compensate for shrinkage on a casting pattern or to run a reduced-size test before the final part. It is a powerful and little-used function, and that is exactly why it is dangerous: a forgotten active scale silently distorts everything that comes after it.

For reference only: syntax changes with the control, the post-processor and the machine parameters. Check the official manual and run a simulation before cutting. Legal notice.

The brands and control names mentioned belong to their owners and are used only to identify the equipment. GetGCode is not affiliated with or endorsed by any manufacturer, ISO or ASME: this is our own content, not official documentation. Legal notice.

Family
Coordinate equivalences
Machine
Milling, Mill-turn
Risk
High
Example
G51 X0 Y0 P0.5 / G50

Syntax by control

Fanuc (milling)
G51 X0. Y0. Z0. P2000
X, Y and Z are the scaling center and P is the factor, in a format that depends on a machine parameter: in the usual configuration, P2000 means factor 2 and P500 factor 0.5. Check the parameter before trusting the number.
Fanuc with per-axis scaling
G51 X0. Y0. Z0. I2000 J2000 K1000
When the machine has per-axis scaling enabled, I, J and K give different factors for X, Y and Z. This variant is an option and is not on every control; with different factors per axis, a circle becomes an ellipse that circular interpolation cannot describe.
Haas (milling)
G51 X0. Y0. Z0. P2.0
On Haas the factor is written as a direct decimal value and can also be set from the machine settings. As on Fanuc, it depends on installed options: if your control does not have it, the block gives an invalid code alarm.
Siemens 840D / 828D
SCALE X2 Y2 Z1 / ASCALE X0.5
Siemens does not use G51: SCALE applies an absolute scale as a frame and ASCALE applies it additively on top of whatever was already there. It is canceled by writing SCALE with no arguments or with the corresponding frame.
Heidenhain TNC (Klartext)
CYCL DEF 11.0 FACTOR ESCALA / CYCL DEF 11.1 SCL2
On Heidenhain, scaling is cycle 11, and the factor is given with SCL, not with a Q parameter. It is a modal transformation just like rotation or mirroring, and it is canceled by reprogramming the cycle with a factor of 1.

Address letters used with it

LetterWhat it setsUnit
X Y ZCoordinates of the scaling center. Everything moves toward or away from that point: it decides where the geometry ends up, not just its size.mm / in
PUniform scaling factor for all three axes. The format, with or without a decimal point, depends on a machine parameter on Fanuc and on the version on Haas.dimensionless factor
I J KIndependent scaling factors for X, Y and Z when the machine has the per-axis scaling option. With different factors, arcs stop being circles and the control may alarm.dimensionless factor
G50Cancels the active scale. On a lathe, that same G50 is the spindle speed limiter, a completely different function: the machine context decides which one it is.no arguments

Worked example

A nameplate with a rounded rectangular contour that has to be machined in two sizes, the nominal one and another at 60% for a small version. The contour is written only once as a subprogram and called twice, the second time with scaling active and with the scaling center at X150 Y0. With P600 the Z values are scaled too.

O0510 (PLACA EN DOS TAMANOS CON G51)
( Main program header. )
G21 G17 G40 G49 G80
( Millimeters, XY plane and a clean state. )
G91 G28 Z0.
( Z to the reference point before the tool change. )
T1 M06
( Contouring end mill. )
G90 G54 G00 X0. Y0.
( Absolute, work offset and positioning at the origin. )
G43 H01 Z50. M03 S4000
( Tool length offset and spindle on. )
M98 P1000
( First call to the contour subprogram, at nominal size with no scaling active. )
G00 X150. Y0.
( Move to the area of the second plate, with Z still up. )
G51 X150. Y0. Z0. P600
( Turns on scaling at 60% with the center at the point where the small plate goes. Putting the center here and not at part zero is what keeps the geometry from shifting as well as shrinking. )
M98 P1000
( Second call to the same subprogram: the control scales every dimension on the fly. )
G50
( Cancels scaling. This block is not optional: without it, everything after it comes out at 60%. )
G00 Z50.
( Retract. )
G91 G28 Z0. M05
( Z to the reference point and spindle stop. )
G90 M30
( Back to absolute and end. )
Open the simulator to check the example

Practical keys to using G51/G50 in the workshop

The scaling center matters as much as the factor

Scaling is not just making the part bigger or smaller: it is moving every point toward or away from a center. If the center is at part zero and the geometry sits 150 mm away, with a factor of 0.5 the geometry moves to 75 mm as well as shrinking. So when all you want is to change the size without moving anything, the scaling center has to be at the center of the geometry itself. This is the point that throws people most the first time they use the function, and it explains most parts that come out the right size but in the wrong place.

What gets scaled and what does not

Scaling affects path dimensions, but not tool radii or offsets. That has a practical consequence you need to think through beforehand: if you scale a contour machined with cutter compensation to 50%, the end mill keeps the same diameter and may not fit into the inside corners of the small version. Work offsets and dimensions given with G53, which are machine coordinates, are not scaled either. As for canned cycles, how depths and planes behave varies by control, so with cycles it is best to check in a dry run before cutting.

G50 on a mill and G50 on a lathe are not the same

The same code has two completely different meanings depending on the machine. On a mill, G50 cancels the scaling turned on with G51. On a lathe, G50 is the spindle speed limiter that goes with constant surface speed and, on older controls, it was also used to set the work coordinate system. There is no real risk of mixing them up at the machine, because each control only implements the one that applies to it, but there is when reading generic documentation or translating programs between machine types.

Mistakes that cost you a part (or a tool)

  • Leaving scaling active at the end of an operation: everything after it, including cycles and retracts, comes out multiplied by the factor.
  • Putting the scaling center at part zero when the geometry is far from it: the part comes out the right size but shifted toward or away from the center.
  • Writing the factor in the wrong format: depending on the machine parameter, P2 can mean factor 2 or factor 0.002.
  • Using different factors per axis with arcs in the program: an unevenly scaled circle is an ellipse and circular interpolation cannot cut it.
  • Assuming the cutter radius gets scaled too: it does not, and on the reduced version the tool may not fit in the corners.
  • Applying scaling over canned cycles without checking how your control treats the depth and the R plane.
  • Turning on G51 on a machine that does not have the option installed and finding out from the alarm in the middle of production.

Frequently asked questions

Is G50 on a mill the same as G50 on a lathe?

No. On a mill it cancels the G51 scaling factor. On a lathe it is the spindle speed limiter programmed before G96, and on older controls it was also used to set the coordinate system. They are different functions that share a number, and each machine implements its own according to its type.

Does scaling affect the tool radius?

No. Radius and length offsets stay outside the transformation, so the end mill keeps its real diameter. If you shrink a contour a lot with compensation active, check that the tool fits in the inside radii of the scaled version, because the control will give an overcut alarm or gouge the corner.

Can I scale just one axis?

Only if your machine has the per-axis scaling option, with I, J and K. When it does, it is useful for compensating different shrinkage in each direction, but you have to take interpolated arcs out of the program, because an unevenly scaled circle stops being circular.

Can G51 compensate for casting shrinkage?

It is one of its classic uses: you machine the pattern at a factor slightly above one so that when the metal contracts on cooling, the part comes out to size. The factor comes from the material and the casting process, not from the control. Even so, in real production many shops prefer to apply the correction in CAM, where it stays documented in the file.

How do I know if scaling is active?

The control's modal codes screen shows G51 as active, and many machines also show the factor. Check it when a part comes out with all its dimensions proportionally wrong, which is the typical signature of a forgotten scale. Putting G50 in the program's safety block heads off the problem at the root.

Related codes

Siemens MIRROR/AMIRRORHeidenhain CYCL DEF 7-11Haas G100/G101G52/G92G50

Other codes in Coordinate equivalences

See the full list of G and M codes

Related apps