G Codes Commands
G Codes Commands
Table of Contents
1. Conventions
2. G Code Quick Reference Table
3. G0 Rapid Move
3.1. Rapid Velocity Rate
4. G1 Linear Move
5. G2, G3 Arc Move
5.1. Center Format Arcs
5.2. Center Format Examples
5.3. Radius Format Arcs
6. G4 Dwell
7. G5 Cubic Spline
8. G5.1 Quadratic Spline
9. G5.2 G5.3 NURBS Block
10. G7 Lathe Diameter Mode
11. G8 Lathe Radius Mode
12. G10 L1 Set Tool Table
13. G10 L2 Set Coordinate System
14. G10 L10 Set Tool Table
15. G10 L11 Set Tool Table
16. G10 L20 Set Coordinate System
17. G17 - G19.1 Plane Select
18. G20, G21 Units
19. G28, G28.1 Go/Set Predefined Position
20. G30, G30.1 Go/Set Predefined Position
21. G33 Spindle Synchronized Motion
22. G33.1 Rigid Tapping
23. G38.n Straight Probe
24. G40 Compensation Off
25. G41, G42 Cutter Compensation
26. G41.1, G42.1 Dynamic Cutter Compensation
27. G43 Tool Length Offset
28. G43.1: Dynamic Tool Length Offset
29. G43.2: Apply additional Tool Length Offset
30. G49: Cancel Tool Length Compensation
31. G53 Move in Machine Coordinates
32. G54-G59.3 Select Coordinate System
33. G61, G61.1 Exact Path Mode
34. G64 Path Blending
35. G73 Drilling Cycle with Chip Breaking
36. G76 Threading Cycle
37. Canned Cycles
37.1. Common Words
37.2. Sticky Words
37.3. Repeat Cycle
37.4. Retract Mode
37.5. Canned Cycle Errors
37.6. Preliminary and In-Between Motion
37.7. Why use a canned cycle?
38. G80 Cancel Canned Cycle
39. G81 Drilling Cycle
40. G82 Drilling Cycle, Dwell
41. G83 Peck Drilling Cycle
42. G84 Right-Hand Tapping Cycle
43. G85 Boring Cycle, Feed Out
44. G86 Boring Cycle, Spindle Stop, Rapid Move Out
45. G87 Back Boring Cycle
46. G88 Boring Cycle, Spindle Stop, Manual Out
47. G89 Boring Cycle, Dwell, Feed Out
48. G90, G91 Distance Mode
49. G90.1, G91.1 Arc Distance Mode
50. G92 Coordinate System Offset
51. G92.1, G92.2 Reset G92 Offsets
52. G92.3 Restore G92 Offsets
53. G93, G94, G95: Feed Rate Mode
54. G96, G97 Spindle Control Mode
55. G98, G99 Canned Cycle Return Level
1. Conventions
Conventions used in this section
In the G code prototypes the hyphen (-) stands for a real value and (<>) denotes an
optional item.
If L- is written in a prototype the - will often be referred to as the L number, and so on for
any other letter.
In the G code prototypes the word axes stands for any axis as defined in your configuration.
An optional value will be written like this <L->.
A real value may be:
An explicit number, 4
An expression, [2+2]
A parameter value, #88
A unary function value, acos[0]
In most cases, if axis words are given (any or all of X Y Z A B C U V W), they specify a
destination point.
Axis numbers are in the currently active coordinate system, unless explicitly described as
being in the absolute coordinate system.
Where axis words are optional, any omitted axes will retain their original value.
Any items in the G code prototypes not explicitly described as optional are required.
The values following letters are often given as explicit numbers. Unless stated otherwise,
the explicit numbers can be real values. For example, G10 L2 could equally well be written
G[2*5] L[1+1]. If the value of parameter 100 were 2, G10 L#100 would also mean the same.
If L- is written in a prototype the - will often be referred to as the L number, and so on for
any other letter.
G4 Dwell
G5 Cubic Spline
3. G0 Rapid Move
G0 axes
For rapid motion, program G0 axes, where all the axis words are optional. The G0 is
optional if the current motion mode is G0. This will produce coordinated motion to the
destination point at the maximum rapid rate (or slower). G0 is typically used as a
positioning move.
3.1. Rapid Velocity Rate
The MAX_VELOCITY setting in the ini file [TRAJ] section defines the maximum rapid
traverse rate. The maximum rapid traverse rate can be higher than the individual axes
MAX_VELOCITY setting during a coordinated move. The maximum rapid traverse rate
can be slower than the MAX_VELOCITY setting in the [TRAJ] section if an axis
MAX_VELOCITY or trajectory constraints limit it.
G0 Example
If cutter compensation is active, the motion will differ from the above; see the Cutter
Compensation Section.
If G53 is programmed on the same line, the motion will also differ; see the G53 Section for
more information.
The path of a G0 rapid motion can be rounded at direction changes and depends on the
trajectory control settings and maximum acceleration of the axes.
It is an error if:
An axis letter is without a real value.
An axis letter is used that is not configured
4. G1 Linear Move
G1 axes
For linear (straight line) motion at programed feed rate (for cutting or not), program G1
'axes', where all the axis words are optional. The G1 is optional if the current motion mode
is G1. This will produce coordinated motion to the destination point at the current feed rate
(or slower).
G1 Example
If cutter compensation is active, the motion will differ from the above; see the Cutter
Compensation Section.
If G53 is programmed on the same line, the motion will also differ; see the G53 Section for
more information.
It is an error if:
No feed rate has been set.
An axis letter is without a real value.
An axis letter is used that is not configured
XY-plane (G17)
G2 or G3 <X- Y- Z- I- J- P->
Z - helix
I - X offset
J - Y offset
P - number of turns
XZ-plane (G18)
G2 or G3 <X- Z- Y- I- K- P->
Y - helix
I - X offset
K - Z offset
P - number of turns
YZ-plane (G19)
G2 or G3 <Y- Z- X- J- K- P->
X - helix
J - Y offset
K - Z offset
P - number of turns
It is an error if:
No feed rate is set with the F word.
No offsets are programmed.
When the arc is projected on the selected plane, the distance from the current point
to the center differs from the distance from the end point to the center by more than
(.05 inch/.5 mm) OR ((.0005 inch/.005mm) AND .1% of radius).
Deciphering the Error message Radius to end of arc differs from radius to start:
start - the current position
center - the center position as calculated using the i, j, or k words
end - the programmed end point
r1 - radius from the start position to the center
r2 - radius from the end position to the center
G2 Example Line
G0 X0 Y0
G2 X1 Y1 I1 F10 (clockwise arc in the XY plane)
Figure 1. G2 Example
In the next example we see the difference between the offsets for Y if we are doing a G2 or a
G3 move. For the G2 move the start position is X0 Y0, for the G3 move it is X0 Y1. The arc
center is at X1 Y0.5 for both moves. The G2 move the J offset is 0.5 and the G3 move the J
offset is -0.5.
G0 X0 Y0
G2 X0 Y1 I1 J0.5 F25 (clockwise arc in the XY plane)
G3 X0 Y0 I1 J-0.5 F25 (counterclockwise arc in the XY plane)
Figure 2. G2-G3 Example
In the next example we show how the arc can make a helix in the Z axis by adding the Z
word.
G2 Example Helix
G0 X0 Y0 Z0
G17 G2 X10 Y16 I3 J4 Z-1 (helix arc with Z added)
In the next example we show how to make more than one turn using the P word.
P word Example
G0 X0 Y0 Z0
G2 X0 Y1 Z-1 I1 J0.5 P2 F25
In the center format, the radius of the arc is not specified, but it may be found easily as the
distance from the center of the circle to either the current point or the end point of the arc.
G2 or G3 axes R- <P->
G2 Example Line
The above example makes a clockwise (as viewed from the positive Z-axis) circular or
helical arc whose axis is parallel to the Z-axis, ending where X=10, Y=15, and Z=5, with a
radius of 20. If the starting value of Z is 5, this is an arc of a circle parallel to the XY-plane;
otherwise it is a helical arc.
6. G4 Dwell
G4 P-
The P number is the time in seconds that all axes will remain unmoving. The P number is a
floating point number so fractions of a second may be used. G4 does not affect spindle,
coolant and any I/O.
G4 Example Line
It is an error if:
the P number is negative or not specified.
7. G5 Cubic Spline
G5 X- Y- <I- J-> P- Q-
G5 creates a cubic B-spline in the XY plane with the X and Y axes only. P and Q must both
be specified for every G5 command.
For the first G5 command in a series of G5 commands, I and J must both be specified. For
subsequent G5 commands, either both I and J must be specified, or neither. If I and J are
unspecified, the starting direction of this cubic will automatically match the ending
direction of the previous cubic (as if I and J are the negation of the previous P and Q).
For example, to program a curvy N shape:
G90 G17
G0 X0 Y0
G5 I0 J3 P0 Q-3 X1 Y1
A second curvy N that attaches smoothly to this one can now be made without specifying I
and J:
G5 P0 Q-3 X2 Y2
It is an error if:
P and Q are not both specified
Just one of I or J are specified
I or J are unspecified in the first of a series of G5 commands
An axis other than X or Y is specified
The active plane is not G17
G5.1 X- Y- I- J-
G5.1 creates a quadratic B-spline in the XY plane with the X and Y axis only. Not specifying
I or J gives zero offset for the unspecified axis, so one or both must be given.
For example, to program a parabola, through the origin, from X-2 Y4 to X2 Y4:
G90 G17
G0 X-2 Y4
G5.1 X2 I2 J-8
It is an error if:
both I and J offset are unspecified or zero
An axis other than X or Y is specified
The active plane is not G17
G5.2 Example
G0 X0 Y0 (rapid move)
F10 (set feed rate)
G5.2 P1 L3
X0 Y1 P1
X2 Y2 P1
X2 Y0 P1
X0 Y0 P2
G5.3
; The rapid moves show the same path without the NURBS Block
G0 X0 Y1
X2 Y2
X2 Y0
X0 Y0
M2
G7
Program G7 to enter the diameter mode for axis X on a lathe. When in the diameter mode
the X axis moves on a lathe will be 1/2 the distance to the center of the lathe. For example
X1 would move the cutter to 0.500” from the center of the lathe thus giving a 1” diameter
part.
G8
Program G8 to enter the radius mode for axis X on a lathe. When in Radius mode the X
axis moves on a lathe will be the distance from the center. Thus a cut at X1 would result in a
part that is 2" in diameter. G8 is default at power up.
P - tool number
R - radius of tool
I - front angle (lathe)
J - back angle (lathe)
Q - orientation (lathe)
G10 L1 sets the tool table for the P tool number to the values of the words.
A valid G10 L1 rewrites and reloads the tool table.
G10 L1 P1 Z1.5 (set tool 1 Z offset from the machine origin to 1.5)
G10 L1 P2 R0.015 Q3 (lathe example setting tool 2 radius to 0.015 and orientation to 3)
It is an error if:
Cutter Compensation is on
The P number is unspecified
The P number is not a valid tool number from the tool table
The P number is 0
For more information on cutter orientation used by the Q word, see the Lathe Tool
Orientation diagram.
G10 L2 offsets the origin of the axes in the coordinate system specified to the value of the
axis word. The offset is from the machine origin established during homing. The offset
value will replace any current offsets in effect for the coordinate system specified. Axis
words not used will not be changed.
Program P0 to P9 to specify which coordinate system to change.
2 2 G55
3 3 G56
4 4 G57
5 5 G58
6 6 G59
7 7 G59.1
8 8 G59.2
9 9 G59.3
Optionally program R to indicate the rotation of the XY axis around the Z axis. The
direction of rotation is CCW as viewed from the positive end of the Z axis.
All axis words are optional.
Being in incremental distance mode (G91) has no effect on G10 L2.
Important Concepts:
G10 L2 Pn does not change from the current coordinate system to the one specified
by P, you have to use G54-59.3 to select a coordinate system.
When a rotation is in effect jogging an axis will only move that axis in a positive or
negative direction and not along the rotated axis.
If a G92 origin offset was in effect before G10 L2, it will continue to be in effect
afterwards.
The coordinate system whose origin is set by a G10 command may be active or
inactive at the time the G10 is executed. If it is currently active, the new coordinates
take effect immediately.
It is an error if:
The P number does not evaluate to an integer in the range 0 to 9.
An axis is programmed that is not defined in the configuration.
In the above example the origin of the first coordinate system (the one selected by G54) is
set to be X=3.5 and Y=17.2. Because only X and Y are specified, the origin point is only
moved in X and Y; the other coordinates are not changed.
The above example sets the XYZ coordinates of the coordinate system 1 to the machine
origin.
The coordinate system is described in the Coordinate System Section.
P - tool number
R - radius of tool
I - front angle (lathe)
J - back angle (lathe)
Q - orientation (lathe)
G10 L10 changes the tool table entry for tool P so that if the tool offset is reloaded, with the
machine in its current position and with the current G5x and G92 offsets active, the current
coordinates for the given axes will become the given values. The axes that are not specified
in the G10 L10 command will not be changed. This could be useful with a probe move as
described in the G38 section.
It is an error if:
Cutter Compensation is on
The P number is unspecified
The P number is not a valid tool number from the tool table
The P number is 0
P - tool number
R - radius of tool
I - front angle (lathe)
J - back angle (lathe)
Q - orientation (lathe)
G10 L11 is just like G10 L10 except that instead of setting the entry according to the current
offsets, it is set so that the current coordinates would become the given value if the new tool
offset is reloaded and the machine is placed in the G59.3 coordinate system without any
G92 offset active.
This allows the user to set the G59.3 coordinate system according to a fixed point on the
machine, and then use that fixture to measure tools without regard to other currently-
active offsets.
It is an error if:
Cutter Compensation is on
The P number is unspecified
The P number is not a valid tool number from the tool table
The P number is 0
G10 L20 is similar to G10 L2 except that instead of setting the offset/entry to the given
value, it is set to a calculated value that makes the current coordinates become the given
value.
G10 L20 P1 X1.5 (set the X axis current location in coordinate system 1 to 1.5)
It is an error if:
The P number does not evaluate to an integer in the range 0 to 9.
An axis is programmed that is not defined in the configuration.
Warning Only use G28 when your machine is homed to a repeatable position
and the desired G28 position has been stored with G28.1.
G28 uses the values stored in parameters 5161-5169 as the X Y Z A B C U V W final point to
move to. The parameter values are absolute machine coordinates in the native machine
units as specified in the ini file. All axes defined in the ini file will be moved when a G28 is
issued. If no positions are stored with G28.1 then all axes will go to the machine origin.
G28 - makes a rapid move from the current position to the absolute position of the
values in parameters 5161-5166.
G28 axes - makes a rapid move to the position specified by axes including any offsets,
then will make a rapid move to the absolute position of the values in parameters
5161-5166 for all axes specified. Any axis not specified will not move.
G28.1 - stores the current absolute position into parameters 5161-5166.
It is an error if :
Cutter Compensation is turned on
Warning Only use G30 when your machine is homed to a repeatable position
and the desired G30 position has been stored with G30.1.
G30 functions the same as G28 but uses the values stored in parameters 5181-5189 as the X
Y Z A B C U V W final point to move to. The parameter values are absolute machine
coordinates in the native machine units as specified in the ini file. All axes defined in the ini
file will be moved when a G30 is issued. If no positions are stored with G30.1 then all axes
will go to the machine origin.
Note G30 parameters will be used to move the tool when a M6 is programmed
if TOOL_CHANGE_AT_G30=1 is in the [EMCIO] section of the ini file.
G30 - makes a rapid move from the current position to the absolute position of the
values in parameters 5181-5189.
G30 axes - makes a rapid move to the position specified by axes including any offsets,
then will make a rapid move to the absolute position of the values in parameters
5181-5189 for all axes specified. Any axis not specified will not move.
G30.1 - stores the current absolute position into parameters 5181-5186.
It is an error if :
Cutter Compensation is turned on
G33 X- Y- Z- K-
For spindle-synchronized motion in one direction, code G33 X- Y- Z- K- where K gives the
distance moved in XYZ for each revolution of the spindle. For instance, if starting at Z=0,
G33 Z-1 K.0625 produces a 1 inch motion in Z over 16 revolutions of the spindle. This
command might be part of a program to produce a 16TPI thread. Another example in
metric, G33 Z-15 K1.5 produces a movement of 15mm while the spindle rotates 10 times for
a thread of 1.5mm.
Spindle-synchronized motion waits for the spindle index and spindle at speed pins, so
multiple passes line up. G33 moves end at the programmed endpoint. G33 could be used to
cut tapered threads or a fusee.
All the axis words are optional, except that at least one must be used.
Note K follows the drive line described by X- Y- Z-. K is not parallel to the Z
axis if X or Y endpoints are used for example when cutting tapered
threads.
Technical Info
At the beginning of each G33 pass, LinuxCNC uses the spindle speed and the machine
acceleration limits to calculate how long it will take Z to accelerate after the index pulse,
and determines how many degrees the spindle will rotate during that time. It then adds
that angle to the index position and computes the Z position using the corrected spindle
angle. That means that Z will reach the correct position just as it finishes accelerating to the
proper speed, and can immediately begin cutting a good thread.
HAL Connections
The pins motion.spindle-at-speed and the encoder.n.phase-Z for the spindle must be
connected in your HAL file before G33 will work. See the Integrators Manual for more
information on spindle synchronized motion.
G33 Example
It is an error if:
All axis words are omitted.
The spindle is not turning when this command is executed
The requested linear motion exceeds machine velocity limits due to the spindle speed
G33.1 X- Y- Z- K-
Warning For Z only tapping preposition the XY location prior to calling G33.1
and only use a Z word in the G33.1. If the coordinates specified are
not the current coordinates when calling G33.1 for tapping the move
will not be along the Z axis but will be a coordinated, spindle-
synchronized move from the current location to the location
specified and back.
For rigid tapping (spindle synchronized motion with return), code G33.1 X- Y- Z- K- where
K- gives the distance moved for each revolution of the spindle.
A rigid tapping move consists of the following sequence:
1. A move from the current coordinate to the specified coordinate, synchronized with
the spindle at the given ratio and starting from the current coordinate with a spindle
index pulse.
2. When reaching the endpoint, a command to reverse the spindle (e.g., from clockwise
to counterclockwise).
3. Continued synchronized motion beyond the specified end coordinate until the spindle
actually stops and reverses.
4. Continued synchronized motion back to the original coordinate.
5. When reaching the original coordinate, a command to reverse the spindle a second
time (e.g., from counterclockwise to clockwise).
6. Continued synchronized motion beyond the original coordinate until the spindle
actually stops and reverses.
7. An unsynchronized move back to the original coordinate.
Spindle-synchronized motions wait for spindle index, so multiple passes line up.G33.1
moves end at the original coordinate.
All the axis words are optional, except that at least one must be used.
G33.1 Example
It is an error if:
All axis words are omitted.
The spindle is not turning when this command is executed
The requested linear motion exceeds machine velocity limits due to the spindle speed
G38.n axes
Important You will not be able to use a probe move until your machine has
been set up to provide a probe input signal. The probe input signal
must be connected to motion.probe-input in a .hal file. G38.n uses
motion.probe-input to determine when the probe has made (or
lost) contact. TRUE for probe contact closed (touching), FALSE for
probe contact open.
Program G38.n axes to perform a straight probe operation. The axis words are optional,
except that at least one of them must be used. The axis words together define the
destination point that the probe will move towards, starting from the current location. If
the probe is not tripped before the destination is reached G38.2 and G38.4 will signal an
error.
The tool in the spindle must be a probe or contact a probe switch.
In response to this command, the machine moves the controlled point (which should be at
the center of the probe ball) in a straight line at the current feed rate toward the
programmed point. In inverse time feed mode, the feed rate is such that the whole motion
from the current point to the programmed point would take the specified time. The move
stops (within machine acceleration limits) when the programmed point is reached, or when
the requested change in the probe input takes place, whichever occurs first.
After successful probing, parameters #5061 to #5069 will be set to the X, Y, Z, A, B, C, U, V,
W coordinates of the location of the controlled point at the time the probe changed state (in
the current work coordinate system). After unsuccessful probing, they are set to the
coordinates of the programmed point. Parameter 5070 is set to 1 if the probe succeeded
and 0 if the probe failed. If the probing operation failed, G38.2 and G38.4 will signal an
error by posting an message on screen if the selected GUI supports that. And by halting
program execution.
A comment of the form (PROBEOPEN filename.txt) will open filename.txt and store the 9-
number coordinate consisting of XYZABCUVW of each successful straight probe in it. The
file must be closed with (PROBECLOSE). For more information see the Comments Section.
An example file smartprobe.ngc is included (in the examples directory) to demonstrate
using probe moves to log to a file the coordinates of a part. The program smartprobe.ngc
could be used with ngcgui with minimal changes.
It is an error if:
the current point is the same as the programmed point.
no axis word is used
cutter compensation is enabled
the feed rate is zero
the probe is already in the target state
G40 Example
D - tool number
The D word is optional; if there is no D word the radius of the currently loaded tool will be
used (if no tool is loaded and no D word is given, a radius of 0 will be used).
If supplied, the D word is the tool number to use. This would normally be the number of
the tool in the spindle (in which case the D word is redundant and need not be supplied),
but it may be any valid tool number.
To start cutter compensation to the left of the part profile, use G41. G41 starts cutter
compensation to the left of the programmed line as viewed from the positive end of the axis
perpendicular to the plane.
To start cutter compensation to the right of the part profile, use G42. G42 starts cutter
compensation to the right of the programmed line as viewed from the positive end of the
axis perpendicular to the plane.
The lead in move must be at least as long as the tool radius. The lead in move can be a rapid
move.
Cutter compensation may be performed if the XY-plane or XZ-plane is active.
User M100-M199 commands are allowed when Cutter Compensation is on.
The behavior of the machining center when cutter compensation is on is described in the
Cutter Compensation Section along with code examples.
It is an error if:
The D number is not a valid tool number or 0.
The YZ plane is active.
Cutter compensation is commanded to turn on when it is already on.
D - cutter diameter
L - tool orientation (see lathe tool orientation)
G41.1 & G42.1 function the same as G41 & G42 with the added scope of being able to
program the tool diameter. The L word defaults to 0 if unspecified.
It is an error if:
The YZ plane is active.
The L number is not in the range from 0 to 9 inclusive.
The L number is used when the XZ plane is not active.
Cutter compensation is commanded to turn on when it is already on.
G43 <H->
G43 enables tool length compensation. G43 changes subsequent motions by offsetting the
axis coordinates by the length of the offset. G43 does not cause any motion. The next time a
compensated axis is moved, that axis’s endpoint is the compensated location.
G43 without an H word uses the currently loaded tool from the last Tn M6.
G43 Hn uses the offset for tool n.
Note G43 H0 is a little special. Its behavior is different on random tool changer
machines and nonrandom tool changer machines (see the Tool Changers
section). On nonrandom tool changer machines, G43 H0 applies the TLO
of the tool currently in the spindle, or a TLO of 0 if no tool is in the
spindle. On random tool changer machines, G43 H0 applies the TLO of
the tool T0 defined in the tool table file (or causes an error if T0 is not
defined in the tool table).
G43 H1 (set tool offsets using the values from tool 1 in the tool table)
It is an error if:
the H number is not an integer, or
the H number is negative, or
the H number is not a valid tool number (though note that 0 is a valid tool number on
nonrandom tool changer machines, it means "the tool currently in the spindle")
28. G43.1: Dynamic Tool Length Offset
G43.1 axes
G43.1 axes - change subsequent motions by replacing the current offset(s) of axes.
G43.1 does not cause any motion. The next time a compensated axis is moved, that
axis’s endpoint is the compensated location.
G43.1 Example
It is an error if:
motion is commanded on the same line as G43.1
G43.2 H-
H - tool number
G43.2 Example
You can sum together an arbitrary number of offsets by calling G43.2 more times. There
are no built-in assumptions about which numbers are geometry offsets and which are wear
offsets, or that you should have only one of each.
Like the other G43 commands, G43.2 does not cause any motion. The next time a
compensated axis is moved, that axis’s endpoint is the compensated location.
It is an error if:
H is unspecified, or
the given tool number does not exist in the tool table
It is OK to program using the same offset already in use. It is also OK to program using no
tool length offset if none is currently being used.
G53 axes
To move in the machine coordinate system, program G53 on the same line as a linear
move. G53 is not modal and must be programmed on each line. G0 or G1 does not have to
be programmed on the same line if one is currently active.
For example G53 G0 X0 Y0 Z0 will move the axes to the home position even if the
currently selected coordinate system has offsets in effect.
G53 Example
It is an error if:
G53 is used without G0 or G1 being active,
or G53 is used while cutter compensation is on.
The coordinate systems store the axis values and the XY rotation angle around the Z axis in
the parameters shown in the following table.
Select CS X Y Z A B C U V W R
G54 1 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230
G55 2 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250
G56 3 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270
G57 4 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290
G58 5 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310
G59 6 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330
G59.1 7 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350
G59.2 8 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370
G59.3 9 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390
It is an error if:
selecting a coordinate system is used while cutter compensation is on.
G64 P0.015 (set path following to be within 0.015 of the actual path)
It is a good idea to include a path control specification in the preamble of each G code file.
G73 X- Y- Z- R- Q- <L->
The G73 cycle is drilling or milling with chip breaking. This cycle takes a Q number which
represents a delta increment along the Z axis.
1. Preliminary motion.
If the current Z position is below the R position, The Z axis does a rapid move to
the R position.
Move to the X Y coordinates
2. Move the Z-axis only at the current feed rate downward by delta or to the Z position,
whichever is less deep.
3. Rapid up a bit.
4. Repeat steps 2 and 3 until the Z position is reached at step 2.
5. The Z axis does a rapid move to the R position.
It is an error if:
the Q number is negative or zero.
the R number is not specified
36. G76 Threading Cycle
G76 P- Z- I- J- R- K- Q- H- E- L-
Note When G7 Lathe Diameter Mode is in force the values for I, J and K are
diameter measurements. When G8 Lathe Radius Mode is in force the
values for I, J and K are radius measurements.
I- - The thread peak offset from the drive line. Negative I values are external threads,
and positive I values are internal threads. Generally the material has been turned to
this size before the G76 cycle.
J- - A positive value specifying the initial cut depth. The first threading cut will be J
beyond the thread peak position.
K- - A positive value specifying the full thread depth. The final threading cut will be K
beyond the thread peak position.
Optional settings
R- - The depth degression. R1.0 selects constant depth on successive threading
passes. R2.0 selects constant area. Values between 1.0 and 2.0 select decreasing
depth but increasing area. Values above 2.0 select decreasing area. Beware that
unnecessarily high degression values will cause a large number of passes to be used.
(degression = a descent by stages or steps.)
Q- - The compound slide angle is the angle (in degrees) describing to what extent
successive passes should be offset along the drive line. This is used to cause one side
of the tool to remove more material than the other. A positive Q value causes the
leading edge of the tool to cut more heavily. Typical values are 29, 29.5 or 30.
H- - The number of spring passes. Spring passes are additional passes at full thread
depth. If no additional passes are desired, program H0.
E- - Specifies the distance along the drive line used for the taper. The angle of the
taper will be so the last pass tapers to the thread crest over the distance specified with
E.' E0.2' will give a taper for the first/last 0.2 length units along the thread. For a 45
degree taper program E the same as K
L- - Specifies which ends of the thread get the taper. Program L0 for no taper (the
default), L1 for entry taper, L2 for exit taper, or L3 for both entry and exit tapers.
Entry tapers will pause at the drive line to synchronize with the index pulse then
move at the feed rate in to the beginning of the taper. No entry taper and the tool will
rapid to the cut depth then synchronize and begin the cut.
The tool is moved to the initial X and Z positions prior to issuing the G76. The X position is
the drive line and the Z position is the start of the threads.
The tool will pause briefly for synchronization before each threading pass, so a relief groove
will be required at the entry unless the beginning of the thread is past the end of the
material or an entry taper is used.
Unless using an exit taper, the exit move is not synchronized to the spindle speed and will
be a rapid move. With a slow spindle, the exit move might take only a small fraction of a
revolution. If the spindle speed is increased after several passes are complete, subsequent
exit moves will require a larger portion of a revolution, resulting in a very heavy cut during
the exit move. This can be avoided by providing a relief groove at the exit, or by not
changing the spindle speed while threading.
The final position of the tool will be at the end of the drive line. A safe Z move will be
needed with an internal thread to remove the tool from the hole.
It is an error if:
The active plane is not the ZX plane
Other axis words, such as X- or Y-, are specified
The R- degression value is less than 1.0.
All the required words are not specified
P-, J-, K- or H- is negative
E- is greater than half the drive line length
HAL Connections
The pins motion.spindle-at-speed and the encoder.n.phase-Z for the spindle must be
connected in your HAL file before G76 will work. See the spindle pins in the Motion section
for more information.
Technical Info
The G76 canned cycle is based on the G33 Spindle Synchronized Motion. For more
information see the G33 Technical Info.
The sample program g76.ngc shows the use of the G76 canned cycle, and can be previewed
and executed on any machine using the sim/lathe.ini configuration.
G76 Example
G0 Z-0.5 X0.2
G76 P0.05 Z-1 I-.075 J0.008 K0.045 Q29.5 L2 E0.045
In the figure the tool is in the final position after the G76 cycle is completed. You can see
the entry path on the right from the Q29.5 and the exit path on the left from the L2 E0.045.
The white lines are the cutting moves.
If other planes are active, the error conditions are analogous to the XY conditions above.
If another plane is active, the preliminary and in-between motions are analogous.
Note Line numbers are not needed but help clarify these examples
Eight Holes
The G98 to the second line above means that the return move will be to the value of Z in
the first line since it is higher that the R value specified.
The second reason to use a canned cycle is that they all produce preliminary moves and
returns that you can anticipate and control regardless of the start point of the canned cycle.
It is an error if:
Axis words are programmed when G80 is active.
G80 Example
The following code produces the same final position and machine state as the previous
code.
G0 Example
The advantage of the first set is that, the G80 line clearly turns off the G81 canned cycle.
With the first set of blocks, the programmer must turn motion back on with G0, as is done
in the next line, or any other motion mode G word.
If a canned cycle is not turned off with G80 or another motion word, the canned cycle will
attempt to repeat itself using the next block of code that contains an X, Y, or Z word. The
following file drills (G81) a set of eight holes as shown in the following caption.
G80 Example 1
N100 G90 G0 X0 Y0 Z0 (coordinate home)
N110 G1 X0 G4 P0.1
N120 G81 X1 Y0 Z0 R1 (canned drill cycle)
N130 X2
N140 X3
N150 X4
N160 Y1 Z0.5
N170 X3
N180 X2
N190 X1
N200 G80 (turn off canned cycle)
N210 G0 X0 (rapid move home)
N220 Y0
N230 Z0
N240 M2 (program end)
Note Notice the z position change after the first four holes. Also, this is one of
the few places where line numbers have some value, being able to point a
reader to a specific line of code.
The use of G80 in line N200 is optional because the G0 on the next line will turn off the
G81 cycle. But using the G80 as shown in Example 1, will provide for easier to read canned
cycle. Without it, it is not so obvious that all of the blocks between N120 and N200 belong
to the canned cycle.
This calls for absolute distance mode (G90) and OLD_Z retract mode (G98) and calls for
the G81 drilling cycle to be performed once.
The X value and X position are 4.
The Y value and Y position are 5.
The Z value and Z position are 1.5.
The R value and clear Z are 2.8. OLD_Z is 3.
The following moves take place:
1. a rapid move parallel to the XY plane to (X4, Y5)
2. a rapid move move parallel to the Z-axis to (Z2.8).
3. move parallel to the Z-axis at the feed rate to (Z1.5)
4. a rapid move parallel to the Z-axis to (Z3)
This calls for incremental distance mode (G91) and OLD_Z retract mode (G98). It also calls
for the G81 drilling cycle to be repeated three times. The X value is 4, the Y value is 5, the Z
value is -0.6 and the R value is 1.8. The initial X position is 5 (=1+4), the initial Y position is
7 (=2+5), the clear Z position is 4.8 (=1.8+3), and the Z position is 4.2 (=4.8-0.6). OLD_Z
is 3.
The first preliminary move is a maximum rapid move along the Z axis to (X1,Y2,Z4.8),
since OLD_Z < clear Z.
The first repeat consists of 3 moves.
1. a rapid move parallel to the XY-plane to (X5, Y7)
2. move parallel to the Z-axis at the feed rate to (Z4.2)
3. a rapid move parallel to the Z-axis to (X5, Y7, Z4.8)
The second repeat consists of 3 moves. The X position is reset to 9 (=5+4) and the Y
position to 12 (=7+5).
1. a rapid move parallel to the XY-plane to (X9, Y12, Z4.8)
2. move parallel to the Z-axis at the feed rate to (X9, Y12, Z4.2)
3. a rapid move parallel to the Z-axis to (X9, Y12, Z4.8)
The third repeat consists of 3 moves. The X position is reset to 13 (=9+4) and the Y position
to 17 (=12+5).
1. a rapid move parallel to the XY-plane to (X13, Y17, Z4.8)
2. move parallel to the Z-axis at the feed rate to (X13, Y17, Z4.2)
3. a rapid move parallel to the Z-axis to (X13, Y17, Z4.8)
Since OLD_Z is below the R value, it adds nothing for the motion but since the initial value
of Z is less than the value specified in R, there will be an initial Z move during the
preliminary moves.
Example 4 - Absolute G81 R > Z
This is a plot of the path of motion for the second g81 block of code.
Since this plot starts with (X0, Y0, Z0), the interpreter adds the initial Z0 and R1.8 and
rapid moves to that location. After that initial Z move, the repeat feature works the same as
it did in example 3 with the final Z depth being 0.6 below the R value.
Since this plot starts with (X0, Y0, Z0), the interpreter adds the initial Z0 and R1.8 and
rapid moves to that location as in Example 4. After that initial Z move, the rapid move to
X4 Y5 is done. Then the final Z depth being 0.6 below the R value. The repeat function
would make the Z move in the same location again.
The G82 cycle is intended for drilling with a dwell at the bottom of the hole.
1. Preliminary motion, as described in the Preliminary and In-Between Motion section.
2. Move the Z-axis at the current feed rate to the Z position.
3. Dwell for the P number of seconds.
4. The Z-axis does a rapid move to clear Z.
The motion of a G82 canned cycle looks just like G81 with the addition of a dwell at the
bottom of the Z move. The length of the dwell is specified by a P- word in the G82 block.
The G83 cycle (often called peck drilling) is intended for deep drilling or milling with chip
breaking. The retracts in this cycle clear the hole of chips and cut off any long stringers
(which are common when drilling in aluminum). This cycle takes a Q number which
represents a delta increment along the Z-axis. The retract before final depth will always be
to the retract plane even if G98 is in effect. The final retract will honor the G98/99 in
effect. G83 functions the same as G81 with the addition of retracts during the drilling
operation.
1. Preliminary motion, as described in the Preliminary and In-Between Motion section.
2. Move the Z-axis at the current feed rate downward by delta or to the Z position,
whichever is less deep.
3. Rapid move back out to the retract plane specified by the R word.
4. Rapid move back down to the current hole bottom, backed off a bit.
5. Repeat steps 2, 3, and 4 until the Z position is reached at step 2.
6. The Z-axis does a rapid move to clear Z.
It is an error if:
the Q number is negative or zero.
The G85 cycle is intended for boring or reaming, but could be used for drilling or milling.
1. Preliminary motion, as described in the Preliminary and In-Between Motion section.
2. Move the Z-axis only at the current feed rate to the Z position.
3. Retract the Z-axis at the current feed rate to the R plane if it is lower than the initial
Z.
4. Retract at the traverse rate to clear Z.
44. G86 Boring Cycle, Spindle Stop, Rapid Move Out
The G86 cycle is intended for boring. This cycle uses a P number for the number of seconds
to dwell.
1. Preliminary motion, as described in the Preliminary and In-Between Motion section.
2. Move the Z-axis only at the current feed rate to the Z position.
3. Dwell for the P number of seconds.
4. Stop the spindle turning.
5. The Z-axis does a rapid move to clear Z.
6. Restart the spindle in the direction it was going.
It is an error if:
the spindle is not turning before this cycle is executed.
The G89 cycle is intended for boring. This cycle uses a P number, where P specifies the
number of seconds to dwell.
1. Preliminary motion, as described in the Preliminary and In-Between Motion section.
2. Move the Z-axis only at the current feed rate to the Z position.
3. Dwell for the P number of seconds.
4. Retract the Z-axis at the current feed rate to clear Z.
G90 Example
G91 Example
G92 axes
Warning Only use G92 after your machine has been positioned to the desired
point.
G92 makes the current point have the coordinates you want (without motion), where the
axis words contain the axis numbers you want. All axis words are optional, except that at
least one must be used. If an axis word is not used for a given axis, the offset for that axis
will be zero.
When G92 is executed, the origins of all coordinate systems move. They move such that the
value of the current controlled point, in the currently active coordinate system, becomes
the specified value. All of the coordinate system’s origins (G53-G59.3) are offset this same
distance.
G92 uses the values stored in parameters 5211-5219 as the X Y Z A B C U V W offset values
for each axis. The parameter values are absolute machine coordinates in the native
machine units as specified in the ini file. All axes defined in the ini file will be offset when
G92 is active. If an axis was not entered following the G92, that axis' offset will be zero.
For example, suppose the current point is at X=4 and there is currently no G92 offset
active. Then G92 X7
Being in incremental distance mode (G91 instead of G90) has no effect on the action of
G92.
G92 offsets may be already be in effect when the G92 is called. If this is the case, the offset
is replaced with a new offset that makes the current point become the specified value.
It is an error if:
all axis words are omitted.
LinuxCNC stores the G92 offsets and reuses them on the next run of a program. To prevent
this, one can program a G92.1 (to erase them), or program a G92.2 (to remove them - they
are still stored).
See the Coordinate System Section for an overview of coordinate systems.
See the Offsets Section for more information.
See the Parameters Section for more information.
Note G92.1 only clears G92 offsets, to change G53-G59.3 coordinate system
offsets in G code use either G10 L2 or G10 L20.
You can set axis offsets in one program and use the same offsets in another program.
Program G92 in the first program. This will set parameters 5211 to 5219. Do not use G92.1
in the remainder of the first program. The parameter values will be saved when the first
program exits and restored when the second one starts up. Use G92.3 near the beginning of
the second program. That will restore the offsets saved in the first program.
It is an error if:
Inverse time feed mode is active and a line with G1, G2, or G3 (explicitly or implicitly)
does not have an F word.
A new feed rate is not specified after switching to G94 or G95
G96 D2500 S250 (set CSS with a max rpm of 2500 and a surface speed of 250)
It is an error if:
S is not specified with G96
A feed move is specified in G96 mode while the spindle is not turning
Program a G98 and the canned cycle will use the Z position prior to the canned cycle as the
Z return position if it is higher than the R value specified in the cycle. If it is lower, the R
value will be used. The R word has different meanings in absolute distance mode and
incremental distance mode.
The G98 to the second line above means that the return move will be to the value of Z in
the first line since it is higher that the R value specified.
The initial (G98) plane is reset any time cycle motion mode is abandoned, whether
explicitly (G80) or implicitly (any motion code that is not a cycle). Switching among cycle
modes (say G81 to G83) does NOT reset the initial plane. It is possible to switch between
G98 and G99 during a series of cycles.