Machining Codes
The pages below describe G and M and other machining codes with text, graphics, and example files (where applicable). This material is essentially chapter 7 from the Tormach Mill Operator’s manual. You can also download the complete operator’s manual or purchase a bound copy of the manual. For the most complete programming reference, we recommend the CNC Programming Handbook.Download all of the Sample Code Files
G-codes
- G-code Table
- G00 - Rapid Linear Motion
Details:
(a) For rapid linear motion, program: G0 X~ Y~ Z~ A~ where all the axis words are optional, except that at least one must be used. The G00 is optional if the current motion mode is G0. This will produce coordinated linear motion to the destination point at the current traverse rate (or slower if the machine will not go that fast). It is expected that cutting will not take place when a G00 command is executing.
(b) If G16 has been executed to set a Polar Origin then for rapid linear motion to a point described by a radius and angle G0 X~ Y~ can be used. X~ is the radius of the line from the G16 polar origin and Y~ is the angle in degrees measured with increasing values counterclockwise from the 3 o’clock direction (i.e., the conventional four quadrant conventions). Coordinates of the current point at the time of executing the G16 are the polar origin.
If cutter radius compensation is active, the motion will differ from the above; see Cutter Compensation. If G53 is programmed on the same line, the motion will also differ.
Absolute Coordinates. Depending on where the tool is located, there are two basic rules to follow for safety’s sake: If the Z value represents a cutting move in the negative direction, the X and Y axes should be executed first. If the Z value represents a move in the positive direction, the X and Y axes should be executed last.



Example:
Download G00 Code Example
Download ALL of the Code Examples
N25 G00 X2.5 Y4.75 (Rapid to X2.5,Y4.75)
N30 Z0.1 (Rapid down to Z0.1)
- G01 - Linear Motion at Feed Rate
Details:
(a) For linear motion at feed rate (for cutting or not), program: G01 X~ Y~ Z~ A~, where all the axis words are optional, except that at least one must be used. The G01 is optional if the current motion mode is G01. This will produce coordinated linear motion to the destination point at the current feed rate (or slower if the machine will not go that fast).
(b) If G16 has been executed to set a polar origin then linear motion at feed rate to a point described by a radius and angle G00 X~ Y~ can be used. X~ is the radius of the line from the G16 polar origin and Y~ is the angle in degrees measured with increasing values counterclockwise from the 3 o’clock direction (i.e., the conventional four quadrant conventions).
Coordinates of the current point at the time of executing the G16 are the polar origin. It is an error if all axis words are omitted. If cutter radius compensation is active, the motion will differ from the above. If G53 is programmed on the same line, the motion will also differ.

Example:
Download G01 Code Example
Download ALL of the Code Examples
(Sample Program G01EX2:)
(Workpiece Size: X4, Y3, Z1)
(Tool: Tool #3, 3/8" Slot Drill)
(Tool Start Position: X0, Y0, Z1)
N2 G90 G80 G40 G54 G20 G17 G50 G94 G64 (safety block)
N5 G90 G20 (Block #5, absolute in inches)
N10 M06 T3 G43 H3 (Tool change to Tool #3)
N15 M03 S1250 (Spindle on CW at 1250 rpm)
N20 G00 X1.0 Y1.0 (Rapid over to X1,Y1)
N25 Z0.1 (Rapid down to Z0.1)
N30 G01 Z-0.125 F5 (Feed down to Z–0.125 at 5 ipm)
N35 X3 Y2 F10 (Feed diagonally to X3,Y2 at 10 ipm)
N40 G00 Z1.0 (Rapid up to Z1)
N45 X0.0 Y0.0 (Rapid over to X0,Y0)
N50 M05 (Spindle off)
N55 M30 (Program end)
In the sample program, several different examples of the G01 command are shown:
1. The first G01 command (in N30) instructs the machine to plunge feed the tool below the surface of the part by 0.125 in. at a feedrate of 5 in./min.
2. N35 is a two-axis (X and Y) diagonal feed move, and the linear feedrate is increased to 10 ipm.
Note: Because there is contact between the cutting tool and the workpiece, it is imperative that the proper spindle speeds and feedrates be used. It is the programmer’s responsibility to ensure acceptable cutter speeds and feeds.
- G02 and G03 - Arc at Feed Rate
Details:
A circular or helical arc is specified using either G02 (clockwise arc) or G03 (counterclockwise arc). The axis of the circle or helix must be parallel to the X-, Y- or Z-axis of the machine coordinate system. The axis (or, equivalently, the plane perpendicular to the axis) is selected with G17 (Z-axis, XY-plane), G18 (Y-axis, XZ-plane) or G19 (X-axis, YZ-plane). If the arc is circular, it lies in a plane parallel to the selected plane.
If a line of code makes an arc and includes rotational axis motion, the rotational axes turn at a constant rate so that the rotational motion starts and finishes when the XYZ motion starts and finishes. Lines of this sort are hardly ever programmed.
If cutter radius compensation is active, the motion will differ from the above; see Cutter Compensation. Two formats are allowed for specifying an arc. We will call these the center format and the radius format. In both formats the G02 or G03 is optional if it is the current motion mode.

Radius Format Arc:
In the radius format, the coordinates of the end point of the arc in the selected plane are specified along with the radius of the arc. Program: G02 X~ Y~ Z~ A~ R~ (or use G03 instead of G02). R is the radius. The axis words are all optional except that at least one of the two words for the axes in the selected plane must be used. The R number is the radius. A positive radius indicates that the arc turns through 180 degrees or less, while a negative radius indicates a turn of 180 degrees to 359.999 degrees. If the arc is helical, the value of the end point of the arc on the coordinate axis parallel to the axis of the helix is also specified.
It is an error if:
• Both of the axis words for the axes of the selected plane are omitted;
• No R word is given;
• The end point of the arc is the same as the current point.
It is not good practice to program radius format arcs that are nearly full circles or are semicircles (or nearly semicircles) because a small change in the location of the end point will produce a much larger change in the location of the center of the circle (and, hence, the middle of the arc). The magnification effect is large enough that rounding error in a number can produce out-of-tolerance cuts. Nearly full circles are outrageously bad, semicircles (and nearly so) are only very bad. Other size arcs (in the range tiny to 165 degrees or 195 to 345 degrees) are OK.
Here is an example of a radius format command to mill an arc:
G17 G02 X 1.0 Y 1.5 R 2.0 Z 0.5
That means to make a clockwise (as viewed from the positive Z-axis) circular or helical arc whose axis is parallel to the Z-axis, ending where X=1.0, Y=1.5 and Z=0.5, with a radius of 2.0. If the starting value of Z is 0.5, this is an arc of a circle parallel to the XY-plane; otherwise it is a helical arc.
Center Format Arc:
In the center format, the coordinates of the end point of the arc in the selected plane are specified along with the offsets of the center of the arc from the current location. In this format, it is OK if the end point of the arc is the same as the current point.
It is an error if 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 0.0002 inch (if inches are being used) or 0.002 millimeter (if millimeters are being used).
The center is specified using the I and J words. There are two ways of interpreting them. The usual way is that I and J are the center relative to the current point at the start of the arc. This is sometimes called Incremental IJ mode. The second way is that I and J specify the center as actual coordinates in the current system. This is rather misleadingly called Absolute IJ mode. The IJ mode is set using the button and LED on the Settings screen. The choice of modes is to provide compatibility with commercial controllers. You will probably find Incremental to be best. In Absolute it will, of course usually be necessary to use both I and J words unless by chance the arc’s center is at the origin.
When the XY-plane is selected, program: G2 X~ Y~ Z~ A~ I~ J~ (or use G3 instead of G2). The axis words are all optional except that at least one of X and Y must be used. I and J are the offsets from the current location or coordinates – depending on IJ mode (X and Y directions, respectively) of the center of the circle. I and J are optional except that at least one of the two must be used.
It is an error if:
• X and Y are both omitted;
• I and J are both omitted.
When the XZ-plane is selected, program: G02 X~ Y~ Z~ A~ I~ K~ (or use G03 instead of G02). The axis words are all optional except that at least one of X and Z must be used. I and K are the offsets from the current location or coordinates – depending on IJ mode (X and Z directions, respectively) of the center of the circle. I and K are optional except that at least one of the two must be used.
It is an error if:
• X and Z are both omitted;
• I and K are both omitted.
When the YZ-plane is selected, program: G02 X~ Y~ Z~ A~ J~ K~ (or use G03 instead of G02). The axis words are all optional except that at least one of Y and Z must be used. J and K are the offsets from the current location or coordinates – depending on IJ mode (Y and Z directions, respectively) of the center of the circle. J and K are optional except that at least one of the two must be used.
It is an error if:
• Y and Z are both omitted;
• J and K are both omitted.
Here is an example of a center format command to mill an arc in Incremental IJ mode:
G17 G02 X1.0 Y1.6 I0.3 J0.4 Z0.9
That means to make a clockwise (as viewed from the positive Z-axis) circular or helical arc whose axis is parallel to the Z-axis, ending where X=1.0, Y=1.6 and Z=0.9, with its center offset in the X direction by 0.3 units from the current X location and offset in the Y direction by 0.4 units from the current Y location. If the current location has X=0.7, Y=0.7 at the outset, the center will be at X=1.0, Y=1.1. If the starting value of Z is 0.9, this is a circular arc; otherwise it is a helical arc. The radius of this arc would be 0.5.
The above arc in Absolute IJ mode would be:
G17 G02 X1.0 Y1.6 I1.0 J1.1 Z0.9
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.
Example:
Download G02 Code Example
Download G03 Code Example
Download ALL of the Code Examples
(Sample Program G02EX3:)
(Workpiece Size: X4, Y3, Z1)
(Tool: Tool #2, 1/4" Slot Drill)
(Tool Start Position: X0, Y0, Z1)
N2 G90 G80 G40 G54 G20 G17 G50 G94 G64 (safety block)
N5 G90 G20
N10 M06 T2 G43 H2
N15 M03 S1200
N20 G00 X1 Y1
N25 Z0.1
N30 G01 Z-0.1 F5
N35 G02 X2 Y2 I1 J0 F20 (Arc feed CW, radius I1,J0 at 20 ipm)
N40 G01 X3.5
N45 G02 X3 Y0.5 R2 (Arc feed CW, radius 2)
N50 X1 Y1 R2 (Arc feed CW, radius 2)
N55 G00 Z0.1
N60 X2 Y1.5
N65 G01 Z-0.25
N70 G02 X2 Y1.5 I0.25 J-0.25 (Full circle arc feed move CW)
N75 G00 Z1
N80 X0 Y0
N85 M05
N90 M30
- G04 - Dwell
Details:
For a dwell, program: G04 P~. This will keep the axes unmoving for the period of time in seconds specified by the P number. It is an error if the P number is negative.

Example:
Download G04 Code Example
Download ALL of the Code Examples
(Sample Program G04EX5:)
(Workpiece Size: X3.5, Y2, Z0.5)
(Tool: Tool #1, 1/8" Slot Mill)
(Tool Start Position: X0, Y0, Z1)
N2 G90 G80 G40 G54 G20 G17 G50 G94 G64 (safety block)
N5 G90 G20 (Absolute programming in inch mode)
N10 M06 T1 G43 H1 (Tool change to Tool #1)
N15 M03 S1300 (Spindle on CW at 1300 rpm)
N20 G00 X3 Y1 Z0.1 (Rapid to X3,Y1,Z0.1)
N25 G01 Z-0.125 F5.0 (Feed down to Z–0.125 at 5 ipm)
N30 G04 P2 (Dwell for 2 seconds)
N35 G00 X2 Z0.1 (Rapid up to 0.1 and over to X2)
N40 G01 Z-0.125 F5.0 (Feed down to Z–0.125)
N45 G04 P1 (Dwell for 1 second)
N50 G00 Z1.0 (Rapid out to Z1)
N55 X0. Y0. (Rapid to X0, Y0)
N60 M05 (Spindle off )
N65 M30 (Program end)
- G10 - Coordinate System Data Tool and Work Offset Tables
Details:
To set the offset values of a tool, program:
G10 L1 P~ X~ Z~ A~, where the P number must evaluate to an integer in the range 0 to 255 – the tool number – and offsets of the tool specified by the P number are reset to the given. The A number will reset the tool tip radius. Only those values for which an axis word is included on the line will be reset. The Tool diameter cannot be set in this way.
To set the coordinate values for the origin of a fixture coordinate system, program:
G10 L2 P~ X~ Y~ Z~ A~, where the P number must evaluate to an integer in the range 1 to 255 – the fixture number (Values 1 to 6 corresponding to G54 to G59) – and all axis words are optional. The coordinates of the origin of the coordinate system specified by the P number are reset to the coordinate values given (in terms of the absolute coordinate system). Only those coordinates for which an axis word is included on the line will be reset.
It is an error if:
• The P number does not evaluate to an integer in the range 0 to 255.
If origin offsets (made by G92 or G92.3) were in effect before G10 is used, they 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. The values set will not be persistent unless the tool or fixture tables are saved using the buttons on Tables screen.
Example:
G10 L2 P1 x3.5 y17.2 sets the origin of the first coordinate system (the one selected by G54) to a point where X is 3.5 and Y is 17.2 (in absolute coordinates). The Z coordinate of the origin (and the coordinates for any rotational axes) are whatever those coordinates of the origin were before the line was executed.
- G12 and G13 - Clockwise/Counterclockwise Circular Pocket
Details:
These circular pocket commands are a sort of canned cycle which can be used to produce a circular hole larger than the tool in use or with a suitable tool (like a woodruff key cutter) to cut internal grooves for “O” rings etc.
Program: G12 I~ for a clockwise move and G13 I~ for a counterclockwise move.
The tool is moved in the X direction by the value of the I word and a circle cut in the direction specified with the original X and Y coordinates as the center. The tool is returned to the center. Its effect is undefined if the current plane is not XY.
- G15 and G16 - Exit and Enter Polar Mode
Details:
It is possible for G0 and G1 moves in the X/Y plane only to specify coordinates as a radius and angle relative to a temporary center point; program G16 to enter this mode. The current coordinates of the controlled point are the temporary center.
Example:
G15 to revert to normal Cartesian coordinates.
G0 X2.0 Y2.0 // normal G0 move to 2.0,2.0
G16 // start of polar mode.
G10 X1.0 Y45
( this will move to X = 2.7071, Y = 2.7071 which is a spot on a circle) (of radius 1.0 at 45 degrees from the initial coordinates of 2.0,2.0.)
This can be very useful, for example, for drilling a circle of holes. The code below moves to a circle of holes every 90 degrees on a circle of radius 2.5", center X = 0.5, Y = 0.6 and high- speed peck drills to Z = -0.6
G0 Z0.0
X0.5 Y0.6 (go to the center point)
G16 (enable Polar coordinates)
G81 X2.5 Y0.0 R0.0 Z-.6 F3
(in G16 mode the X becomes the offset from center and the Y becomes the degrees of rotation from the center)
X2.5 Y90
X2.5 Y180
X2.6 Y270
G15 (cancels the g16)
G80 (cancels the canned cycle)
G0 Z0.0
X0.0 Y0.0
M30
Note:
(1) You must not make X or Y moves other than by using G0 or G1 when G16 is active;
(2) This G16 is different to a Fanuc implementation in that it uses the current point as the polar center. The Fanuc version requires a lot of origin shifting to get the desired result for any circle not centered on 0, 0.
- G17, G18 and G19 - Plane Selection
Details:
Program G17 to select the XY-plane, G18 to select the XZ-plane or G19 to select the YZ-plane.


Download G17 Code Example
Download G18 Code Example
Download G19 Code Example
Download ALL of the Code Examples
- G20 and G21 - Length Units
Details:
Program G20 to use inches for length units and program G21 to use millimeters. It is usually a good idea to program either G20 or G21 near the beginning of a program before any motion occurs and not to use either one anywhere else in the program. It is the responsibility of the user to be sure all numbers are appropriate for use with the current length units.
Download G20 Code Example
Download G21 Code Example
Download ALL of the Code Examples
- G28 and G30 - Return to Home
Details:
A home position is defined (by parameters 5161-5166). The parameter values are in terms of the absolute coordinate system, but are in unspecified length units. To return to home position by way of the programmed position, program: G28 X~ Y~ Z~ A~ (or use G30). All axis words are optional. The path is made by a traverse move from the current position to the programmed position, followed by a traverse move to the home position. If no axis words are programmed, the intermediate point is the current point, only one move is made.
Example:
Download G28 Code Example
Download ALL of the Code Examples
(Sample Program G28EX111:)
(Workpiece Size: X4, Y4, Z1)
(Tools: Tool #7, 1" Slot Drill)
(Tool #10, 1/2" HSS Drill)
(Tool Start Position: X0, Y0, Z1)
(Reference Point: X0, Y0, Z5 )
N2 G90 G80 G40 G54 G20 G17 G50 G94 G64 (safety block)
N5 G90 G20
N10 M06 T7 G43 H7
N12 M03 S1000
N15 G00 X4.75 Y2
N17 Z0.1
N20 G01 Z-0.5 F5
N25 G01 X2 F10
N30 G00 Z0.25
N35 G28 X0 Y2.5 Z1 (Return to reference via X0,Y2.5,Z1)
N40 M06 T10 G43 H10
N45 M03 S2000
N50 G00 X2 Y2
N52 Z.5
N55 G01 Z-1.25 F5
N60 G00 Z1
N65 X0 Y0
N70 M05
N75 M30
- G28.1 - Reference Axes
Details:
Program: G28.1 X~ Y~ Z~ A~ to reference the given axes. The axes will move at the current feed rate towards the home switch(es), as defined by the Configuration. When the absolute machine coordinate reaches the value given by an axis word then the feed rate is set to that defined by Configure>Config Referencing. Provided the current absolute position is approximately correct, then this will give a soft stop onto the reference switch(es).
- G31 - Straight Probe
Details:
Program: G31 X~ Y~ Z~ A~ to perform a straight probe operation. The rotational axis words are allowed, but it is better to omit them. If rotational axis words are used, the numbers must be the same as the current position numbers so that the rotational axes do not move. The linear axis words are optional, except that at least one of them must be used. The tool in the spindle must be a probe.
It is an error if:
• The current point is less than 0.01 inch (0.254 millimeter) from the programmed point;
• G31 is used in inverse time feed rate mode;
• Any rotational axis is commanded to move;
• No X-, Y- or Z-axis word is used.
In response to this command, the machine moves the controlled point (which should be at the end of the probe tip) in a straight line at the current feed rate toward the programmed point; if the probe trips, then the probe decelerates.
After successful probing, parameters 2000 to 2005 will be set to the coordinates of the location of the controlled point at the time the probe tripped (not where it stopped) or if it does not trip to the coordinates at the end of the move and a triplet giving X, Y and Z at the trip will be written to the triplet file if it has been opened by the M40 macro/OpenDigFile() function (q.v.). Code in macros or screen buttons can determine if a point is a trip or just the end of the move by inspecting if the DIGITIZE input is active after the G31 command or comparing the axis DROs with the requested move.
Using the straight probe command, if the probe shank is kept nominally parallel to the Z-axis (i.e., any rotational axes are at zero) and the tool length offset for the probe is used, so that the controlled point is at the end of the tip of the probe:
• Without additional knowledge about the probe, the parallelism of a face of a part to the XY-plane may, for example, be found;
• If the probe tip radius is known approximately, the parallelism of a face of a part to the YZ or XZ-plane may, for example, be found;
• If the shank of the probe is known to be well-aligned with the Z-axis and the probe tip radius is known approximately, the center of a circular hole, may, for example, be found;
• If the shank of the probe is known to be well-aligned with the Z-axis and the probe tip radius is known precisely, more uses may be made of the straight probe command, such as finding the diameter of a circular hole.
If the straightness of the probe shank cannot be adjusted to high accuracy, it is desirable to know the effective radii of the probe tip in at least the +X, -X, +Y and -Y directions. These quantities can be stored in parameters either by being included in the parameter file or by being set in a part-program.
Using the probe with rotational axes not set to zero is also feasible. Doing so is more complex than when rotational axes are at zero and we do not deal with it here.
Example:
As a usable example, see the code for finding the center and diameter of a circular hole. For this code to yield accurate results, the probe shank must be well-aligned with the Z-axis, the cross section of the probe tip at its widest point must be very circular and the probe tip radius (i.e., the radius of the circular cross section) must be known precisely. If the probe tip radius is known only approximately (but the other conditions hold), the location of the hole center will still be accurate, but the hole diameter will not.
N010 (probe to find center and diameter of circular hole)
N020 (This program will not run as given here. You have to)
N030 (insert numbers in place of <description of number>.)
N040 (Delete lines N020, N030 and N040 when you do that.)
N050 G0 Z <Z-value of retracted position> F <feed rate>
N060 #1001=<nominal X-value of hole center>
N070 #1002=<nominal Y-value of hole center>
N080 #1003=<some Z-value inside the hole>
N090 #1004=<probe tip radius>
N100 #1005=[<nominal hole diameter>/2.0 - #1004]
N110 G0 X#1001 Y#1002 (move above nominal hole center)
N120 G0 Z#1003 (move into hole - to be cautious, substitute G1 for G0 here)
N130 G31 X[#1001 + #1005] (probe +X side of hole)
N140 #1011=#2000 (save results)
N150 G0 X#1001 Y#1002 (back to center of hole)
N160 G31 X[#1001 - #1005] (probe -X side of hole)
N170 #1021=[[#1011 + #2000] / 2.0] (find pretty good X-value of hole center)
N180 G0 X#1021 Y#1002 (back to center of hole)
N190 G31 Y[#1002 + #1005] (probe +Y side of hole)
N200 #1012=#2001 (save results)
N210 G0 X#1021 Y#1002 (back to center of hole)
N220 G31 Y[#1002 - #1005] (probe -Y side of hole)
N230 #1022=[[#1012 + #2001] / 2.0] (find very good Y-value of hole center)
N240 #1014=[#1012 - #2001 + [2 * #1004]] (find hole diameter in Y-direction)
N250 G0 X#1021 Y#1022 (back to center of hole)
N260 G31 X[#1021 + #1005] (probe +X side of hole)
N270 #1031=#2000 (save results)
N280 G0 X#1021 Y#1022 (back to center of hole)
N290 G31 X[#1021 - #1005] (probe -X side of hole)
N300 #1041=[[#1031 + #2000] / 2.0] (find very good X-value of hole center)
N310 #1024=[#1031 - #2000 + [2 * #1004]] (find hole diameter in X-direction)
N320 #1034=[[#1014 + #1024] / 2.0] (find average hole diameter)
N330 #1035=[#1024 - #1014] (find difference in hole diameters)
N340 G0 X#1041 Y#1022 (back to center of hole)
N350 M2 (that’s all, folks)
In the above code, an entry of the form <description of a number> is meant to be replaced by an actual number that matches the description of number. After this section of code has executed, the X-value of the center will be in parameter 1041, the Y-value of the center in parameter 1022 and the diameter in parameter 1034. In addition, the diameter parallel to the X-axis will be in parameter 1024, the diameter parallel to the Y-axis in parameter 1014 and the difference (an indicator of circularity) in parameter 1035. The probe tip will be in the hole at the XY center of the hole.
The example does not include a tool change to put a probe in the spindle. Add the tool change code at the beginning, if needed.
- G40, G41 and G42 - Cutter Radius Compensation
Details:
To turn cutter radius compensation off, program: G40. It is OK to turn compensation off when it is already off.
Cutter radius compensation may be performed only if the XY-plane is active.
To turn cutter radius compensation on left (i.e., the cutter stays to the left of the programmed path when the tool radius is positive), program: G41 D~. To turn cutter radius compensation on right (i.e., the cutter stays to the right of the programmed path when the tool radius is positive), program: G42 D~. The D word is optional; if there is no D word, the radius of the tool currently in the spindle will be used. If used, the D number should normally be the slot number of the tool in the spindle, although this is not required. It is OK for the D number to be zero; a radius value of zero will be used.
G41 and G42 can be qualified by a P-word. This will override the value of the diameter of the tool (if any) given in the current tool table entry. It is an error if:
• The D number is not an integer, is negative or is larger than the number of carousel slots;
• The XY-plane is not active;
• Cutter radius compensation is commanded to turn on when it is already on.
The behavior of the machining system when cutter radius compensation is ON is described in the chapter on Cutter Compensation. Notice the importance of programming valid entry and exit moves.
Note: The tool offsets must have been applied with a G43 H~ for compensation to work.
- G43, G44 and G49 - Tool Length Offsets
Details:
To use a tool length offset, program: G43 H~, where the H number is the desired index in the tool table. It is expected that all entries in this table will be positive. The H number should be, but does not have to be, the same as the slot number of the tool currently in the spindle. The H number may be zero; an offset value of zero will be used. Omitting H has the same effect as a zero value.
G44 is provided for compatibility and is used if entries in the table give negative offsets.
It is an error if the H number is not an integer, is negative or is larger than the number of carousel slots.
To use no tool length offset, program: G49.
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.
It is strongly advised to put the G43 command on the same line (block) as the T~ and the M06 which actually implements the change. If this is done then the control software anticipates the new offset during the time the operator has control for changing the tool. The operator can change the work Z offset safely if this condition is met.
- G50 and G51 - Scale Factors
Details:
To define a scale factor which will be applied to an X, Y, Z, A, I & J word before it is used program: G51 X~ Y~ Z~ A~ where the X, Y, Z etc. words are the scale factors for the given axes. These values are, of course, never themselves scaled.
It is not permitted to use unequal scale factors to produce elliptical arcs with G2 or G3.
To reset the scale factors of all axes to 1.0 program: G50.
- G52 - Temporary Coordinate System Offset
Details:
To offset the current point by a given positive or negative distance (without motion), program: G52 X~ Y~ Z~ A~, where the axis words contain the offsets you want to provide. 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 coordinate on that axis of the current point is not changed.
It is an error if all axis words are omitted.
G52 and G92 use common internal mechanisms in the CS and may not be used together.
When G52 is executed, the origin of the currently active coordinate system moves by the values given.
The effect of G52 is cancelled by programming: G52 X0 Y0 etc.
Here is an example. Suppose the current point is at X=4 in the currently specified coordinate system, then G52 X7 sets the X-axis offset to 7 and so causes the X-coordinate of the current point to be -3.
The axis offsets are always used when motion is specified in absolute distance mode using any of the fixture coordinate systems. Thus all fixture coordinate systems are affected by G52.
- G53 - Move in Absolute Coordinates
Details:
For linear motion to a point expressed in absolute coordinates, program: G1 G53 X~ Y~ Z~ A~ (or similarly with G0 instead of G1), where all the axis words are optional, except that at least one must be used. The G0 or G1 is optional if it is in the current motion mode. G53 is not modal and must be programmed on each line on which it is intended to be active. This will produce coordinated linear motion to the programmed point. If G1 is active, the speed of motion is the current feed rate (or slower if the machine will not go that fast). If G0 is active, the speed of motion is the current traverse rate (or slower if the machine will not go that fast).
It is an error if:
• G53 is used without G0 or G1 being active;
• G53 is used while cutter radius compensation is on.
- G54 to G59 and G59 P~ - Select Work Offset Coordinate System
Details:
To select work offset #1, program: G54 and similarly for the first six offsets. The system-number-G-code pairs are: (1-G54), (2-G55), (3-G56), (4-G57), (5-G58), (6-G59).
To access any of the 254 work offsets (1 - 254) program: G59 P~ where the P word gives the required offset number. Thus G59 P5 is identical in effect to G58.
It is an error if one of these G-codes is used while cutter radius compensation is on.
See relevant chapter for an overview of coordinate systems.
Example:
Download G54 Code Example
Download ALL of the Code Examples
(Sample Program G54EX19:)
(Workpiece Size: X8, Y5, Z2)
(Tool: Tool #6, 3/4" HSS Drill)
(Tool Start Position: X0, Y0, Z1)
(Workpiece Coordinate system 2: X1, Y1, Z0)
(Workpiece Coordinate system 3: X5, Y1, Z0)
N2 G90 G80 G40 G54 G20 G17 G50 G94 G64 (safety block)
N5 G90 G80 G20
N10 M06 T6 G43 H6
N15 M03 S1300
N20 G55 G00 X1.0 Y1.0 (Rapid to X1, Y1 of work coordinate system 2)
N25 Z0.5
N30 G82 Z-0.25 R0.125 P1 F5
N35 Y2
N40 X2
N45 Y1
N50 X1.5 Y1.5
N60 G80 G00 Z1
N65 G56 G00 X1.0 Y1.0 (Rapid to X1, Y1 of work coordinate system 3)
N70 Z0.5
N75 G82 Z-0.25 R0.125 P1 F5
N80 Y2
N85 X2
N90 Y1
N95 X1.5 Y1.5
N100 G80 G00 Z1
N105 X0 Y0
N110 M05
N115 M30
- G61 and G64 - Set Path Control Mode
Details:
Program: G61 to put the machining system into exact stop mode or G64 for constant velocity mode. It is OK to program for the mode that is already active. These modes are described in detail above.
- G68 and G69 - Coordinate System Rotation
Details:
A rotation transformation can be applied to the controlled point coordinates commanded by a part program or by the MDI line. To do this program G68 X~ Y~ R~ The X and Y words specify the center about which the rotation is to be applied in the current coordinate system. R is the angle of rotation in degrees with positive values being counter-clockwise.
If X or Y are omitted then zero is assumed. A and B can be used as synonyms for X and Y respectively.
To cancel rotation program G69. If a G68 is used while rotation is in operation a G69 is implied before it. In other words successive G68s are not cumulative and the X and Y points are always in an un-rotated system.
When a rotation is in use the X and Y axis DROs will be red to remind the operator that these values are program coordinate values which will be rotated.
This function can be used to compensate for work not exactly aligned on the table, to rotate the operation of a part program if it is coded with Y travel greater than X and so the work will not fit on the table or as software "vise soft-jaws".
Note:
• G68 may only be used in the XY plane (G17 mode)
• The effects of changing work offsets when a rotation transformation is in effect will be non-intuitive so it is wiser not to program this. Indeed care should be taken proving any program including transformations.
• There is very little standardization of the functions of this code across different CNC controls so careful checks should be made on code written for other machines.
• Jogging always takes place in the direction of the machine axes. The toolpath display frame is oriented to the physical axes and will show the part at the angle at which it will be cut.
- G73 - Canned Cycle - High Speed Peck Drill
Details:
The G73 cycle is intended for deep drilling or milling with chip breaking. See also G83. The retracts in this cycle break the chip but do not totally retract the drill from the hole. It is suitable for tools with long flutes which will clear the broken chips from the hole. This cycle takes a Q number which represents a “delta” increment along the Z-axis.
Program: G73 X~ Y~ Z~ A~ R~ L~ Q~
• Preliminary motion, as described in G81 to 89 canned cycles.
• Move the Z-axis only at the current feed rate downward by delta or to the Z position, whichever is less deep.
• Rapid back out by the distance defined in the G73 Pullback DRO on the Settings screen.
• Rapid back down to the bottom of the current hole, but backed off a bit.
• Repeat steps 1, 2 and 3 until the Z position is reached at step 1.
• Retract the Z-axis at traverse rate to clear Z.
It is an error if the Q number is negative or zero. The following sample program demonstrates the G73 command.

Example:
Download G73 Code Example
Download ALL of the Code Examples
((Sample Program G73EX20:)
(Workpiece Size: X4, Y3, Z1)
(Tool: Tool #3, 3/8" HSS Drill)
(Tool Start Position: X0, Y0, Z1)
N2 G90 G80 G40 G54 G20 G17 G50 G94 G64 (safety block)
N5 G90 G80 G20
N10 M06 T3 G43 H3
N15 M03 S1200
N20 G00 X1 Y1
N25 G73 Z-0.75 R0.125 Q0.0625 F5 (Invoke G73 cycle)
N30 X2.0
N35 X3.0
N40 Y2.0
N45 X2.0
N50 X1.0
N55 G80 G00 Z1 (Canned cycle cancel)
N60 X0 Y0
N65 M05
N70 M30
- G80 - Cancel Modal Motion
Details:
Program: G80 to ensure no axis motion will occur, to terminate canned cycles etc. Note that it cancels the current G0, G1, G2 or G3 mode so this must be re-established for the next move that is requited. This particularly affects people adapting a CAM postprocessors from another machine as this behavior varies between different CNC controls.
It is an error if:
• Axis words are programmed when G80 is active, unless a modal group 0 G-code is programmed which uses axis words.
Download G80 Code Example
Download ALL of the Code Examples
- G81 to G89 - Canned Cycles
- Background
Details:
The canned cycles G81 through G89 have been implemented as described in this section. Two examples are given with the description of G81 below.
All canned cycles are performed with respect to the currently selected plane. Any of the three planes (XY, YZ, and ZX) may be selected. Throughout this section, most of the descriptions assume the XY-plane has been selected. The behavior is always analogous if the YZ or XZ-plane is selected.
Rotational axis words are allowed in canned cycles, but it is better to omit them. If rotational axis words are used, the numbers must be the same as the current position numbers so that the rotational axes do not move.
All canned cycles use X, Y, R and Z numbers in the NC-code. These numbers are used to determine X, Y, R and Z positions. The R (usually meaning retract) position is along the axis perpendicular to the currently selected plane (Z-axis for XY-plane, X-axis for YZ-plane, Y-axis for XZ-plane). Some canned cycles use additional arguments.
For canned cycles, we will call a number “sticky” if, when the same cycle is used on several lines of code in a row, the number must be used the first time, but is optional on the rest of the lines. Sticky numbers keep their value on the rest of the lines if they are not explicitly programmed to be different. The R number is always sticky.
In incremental distance mode: when the XY-plane is selected, X, Y and R numbers are treated as increments to the current position and Z as an increment from the Z-axis position before the move involving Z takes place; when the YZ or XZ-plane is selected, treatment of the axis words is analogous. In absolute distance mode, the X, Y, R and Z numbers are absolute positions in the current coordinate system.
The L number is optional and represents the number of repeats. L=0 is not allowed. If the repeat feature is used, it is normally used in incremental distance mode, so that the same sequence of motions is repeated in several equally spaced places along a straight line. In absolute distance mode, L > 1 means “do the same cycle in the same place several times,” Omitting the L word is equivalent to specifying L=1. The L number is not sticky.
When L > 1 in incremental mode with the XY-plane selected, the X and Y positions are determined by adding the given X and Y numbers either to the current X and Y positions (on the first go-around) or to the X and Y positions at the end of the previous go-around (on the repetitions). The R and Z positions do not change during the repeats.
The height of the retract move at the end of each repeat (called “clear Z” in the descriptions below) is determined by the setting of the retract mode: either to the original Z position (if that is above the R position and the retract mode is G98) or otherwise to the R position.
It is an error if:
• X, Y and Z words are all missing during a canned cycle;
• A P number is required and a negative P number is used;
• An L number is used that does not evaluate to a positive integer;
• Rotational axis motion is used during a canned cycle;
• Inverse time feed rate is active during a canned cycle;
• Cutter radius compensation is active during a canned cycle.
When the XY plane is active, the Z number is sticky and it is an error if:
• The Z number is missing and the same canned cycle was not already active;
• The R number is less than the Z number.
When the XZ plane is active, the Y number is sticky and it is an error if:
• The Y number is missing and the same canned cycle was not already active;
• The R number is less than the Y number.
When the YZ plane is active, the X number is sticky and it is an error if:
• The X number is missing and the same canned cycle was not already active;
• The R number is less than the X number.
Preliminary and In-Between Motion
At the very beginning of the execution of any of the canned cycles, with the XY-plane selected, if the current Z position is below the R position, the Z-axis is traversed to the R position. This happens only once, regardless of the value of L.
In addition, at the beginning of the first cycle and each repeat, the following one or two moves are made:
• A straight traverse parallel to the XY-plane to the given XY-position;
• A straight traverse of the Z-axis only to the R position, if it is not already at the R position.
If the XZ or YZ plane is active, the preliminary and in-between motions are analogous. - G81 Cycle
Details:
The G81 cycle is intended for drilling.
Program:
G81 X~ Y~ Z~ A~ R~ L~
• Preliminary motion, as described above.
• Move the Z-axis only at the current feed rate to the Z position.
• Retract the Z-axis at traverse rate to clear Z.
Example 1:
Download G81 Code Example
Download ALL of the Code Examples
Suppose the current position is (1, 2, 3) and the XY-plane has been selected and the following line of NC-code is interpreted.
G90 G81 G98 X4 Y5 Z1.5 R2.8
This calls for absolute distance mode (G90), old “Z” retract mode (G98) and calls for the G81 drilling cycle to be performed once. The X number and X position are 4. The Y number and Y position are 5. The Z number and Z position are 1.5. The R number and clear Z are 2.8. The following moves take place.
• a traverse parallel to the XY-plane to (4,5,3);
• a traverse parallel to the Z-axis to (4,5,2.8);
• a feed parallel to the Z-axis to (4,5,1.5);
• a traverse parallel to the Z-axis to (4,5,3).
Example 2:
Suppose the current position is (1, 2, 3) and the XY-plane has been selected and the following line of NC-code is interpreted.
G91 G81 G98 X4 Y5 Z-0.6 R1.8 L3
This calls for incremental distance mode (G91), old “Z” retract mode and calls for the G81 drilling cycle to be repeated three times. The X number is 4, the Y number is 5, the Z number is -0.6 and the R number 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.0
The first move is a traverse along the Z-axis to (1,2,4.8), since old Z < clear Z.
The first repeat consists of 3 moves.
• a traverse parallel to the XY-plane to (5,7,4.8);
• a feed parallel to the Z-axis to (5,7, 4.2);
• a traverse parallel to the Z-axis to (5,7,4.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).
• a traverse parallel to the XY-plane to (9,12,4.8);
• a feed parallel to the Z-axis to (9,12, 4.2);
• a traverse parallel to the Z-axis to (9,12,4.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).
• a traverse parallel to the XY-plane to (13,17,4.8);
• a feed parallel to the Z-axis to (13,17, 4.2);
• a traverse parallel to the Z-axis to (13,17,4.8).
Execute the following to observe the G81 drill cycle. Remember, the G81 command follows a certain sequence.
(Sample Program G81EX18:)
(Workpiece Size: X4, Y3, Z1)
(Tool: Tool #6, 3/4" HSS Drill)
(Tool Start Position: X0, Y0, Z1)
N2 G90 G80 G40 G54 G20 G17 G50 G94 G64 (safety block)
N5 G90 G80 G20
N10 M06 T6 G43 H6
N15 M03 S1300
N20 G00 X1 Y1
N25 Z0.5
N30 G81 Z-0.25 R0.125 F5 (Drill cycle invoked)
N35 X2
N40 X3
N45 Y2
N50 X2
N55 X1
N60 G80 G00 Z1 (Cancel canned cycles)
N65 X0 Y0
N70 M05
N75 M30
- G82 Cycle
Details:
The G82 cycle is intended for drilling.
Program:
G82 X~ Y~ Z~ A~ R~ L~ P~
• Preliminary motion, as described above.
• Move the Z-axis only at the current feed rate to the Z position.
• Dwell for the P number of seconds.
• Retract the Z-axis at traverse rate to clear Z.
Download G82 Code Example
Download ALL of the Code Examples
- G83 Cycle
Details:
The G83 cycle (often called peck drilling) is intended for deep drilling or milling with chip breaking. See also G73. 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.
Program: G83 X~ Y~ Z~ A~ R~ L~ Q~
• Preliminary motion, as described above.
• Move the Z-axis only at the current feed rate downward by delta or to the Z position, whichever is less deep.
• Rapid back out to the clear Z.
• Rapid back down to the current hole bottom, backed off a bit.
• Repeat steps 1, 2 and 3 until the Z position is reached at step 1.
• Retract the Z-axis at traverse rate to clear Z.
It is an error if:
• The Q number is negative or zero.
Download G83 Code Example
Download ALL of the Code Examples
- G85 Cycle
Details:
The G85 cycle is intended for boring or reaming, but could be used for drilling or milling.
Program:
G85 X~ Y~ Z~ A~ R~ L~
• Preliminary motion, as described above.
• Move the Z-axis only at the current feed rate to the Z position.
• Retract the Z-axis at the current feed rate to clear Z.
- G86 Cycle
Details:
The G86 cycle is intended for boring. This cycle uses a P number for the number of seconds to dwell.
Program:
G86 X~ Y~ Z~ A~ R~ L~ P~
• Preliminary motion, as described above.
• Move the Z-axis only at the current feed rate to the Z position.
• Dwell for the P number of seconds.
• Stop the spindle turning.
• Retract the Z-axis at traverse rate to clear Z.
• Restart the spindle in the direction it was going.
The spindle must be turning before this cycle is used. It is an error if:
• The spindle is not turning before this cycle is executed.
- G88 Cycle
Details:
The G88 cycle is intended for boring. This cycle uses a P word, where P specifies the number of seconds to dwell.
Program:
G88 X~ Y~ Z~ A~ R~ L~ P~
• Preliminary motion, as described above.
• Move the Z-axis only at the current feed rate to the Z position.
• Dwell for the P number of seconds.
• Stop the spindle turning.
• Stop the program so the operator can retract the spindle manually.
• Restart the spindle in the direction it was going.
- G89 Cycle
Details:
The G89 cycle is intended for boring. This cycle uses a P number, where P specifies the number of seconds to dwell.
Program:
G89 X~ Y~ Z~ A~ R~ L~ P~
• Preliminary motion, as described above.
• Move the Z-axis only at the current feed rate to the Z position.
• Dwell for the P number of seconds.
• Retract the Z-axis at the current feed rate to clear Z.
- Background
- G90 and G91 - Distance Mode
Details:
Interpretation of the CS-code can be in one of two distance modes: absolute or incremental.
To go into absolute distance mode, program: G90. In absolute distance mode, axis numbers (X, Y, Z, A) usually represent positions in terms of the currently active coordinate system. Any exceptions to that rule are described explicitly in this section describing G-codes.
To go into incremental distance mode, program: G91. In incremental distance mode, axis numbers (X, Y, Z, A) usually represent increments from the current values of the numbers.
I and J numbers always represent increments, regardless of the distance mode setting. K numbers represent increments.
Download G90 Code Example
Download G91 Code Example
Download ALL of the Code Examples
- G92, G92.1, G92.2 and G92.3 - G92 Offsets
Details:
You are strongly advised not to use this legacy feature on any axis where there is another offset applied.
To make the current point have the coordinates you want (without motion), program:
G92 X~ Y~ Z~ A~, 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 coordinate on that axis of the current point is not changed.
It is an error if all axis words are omitted.
G52 and G92 use common internal mechanisms in the CS and may not be used together.
When G92 is executed, the origin of the currently active coordinate system moves. To do this, origin offsets are calculated so that the coordinates of the current point with respect to the moved origin are as specified on the line containing the G92. In addition, parameters 5211 to 5214 are set to the X-, Y-, Z-, A-axis offsets. The offset for an axis is the amount the origin must be moved so that the coordinate of the controlled point on the axis has the specified value.
Here is an example. Suppose the current point is at X=4 in the currently specified coordinate system and the current X-axis offset is zero, then G92 X7 sets the X-axis offset to -3, sets parameter 5211 to -3 and causes the X-coordinate of the current point to be 7.
The axis offsets are always used when motion is specified in absolute distance mode using any of the fixture coordinate systems. Thus, all fixture coordinate systems are affected by G92.
Being in incremental distance mode has no effect on the action of G92.
Non-zero offsets may already be in effect when the G92 is called. They are in effect discarded before the new value is applied. Mathematically the new value of each offset is A+B, where A is what the offset would be if the old offset were zero and B is the old offset. For example, after the previous example, the X-value of the current point is 7. If G92 X9 is then programmed, the new X-axis offset is -5, which is calculated by [[7-9] + -3]. Put another way the G92 X9 produces the same offset whatever G92 offset was already in place.
To reset axis offsets to zero, program: G92.1 or G92.2 G92.1 sets parameters 5211 to 5214 to zero, whereas G92.2 leaves their current values alone.
To set the axis offset values to the values given in parameters 5211 to 5214, program: G92.3
You can set axis offsets in one program and use the same offsets in another program by programming G92 in the first program. This will set parameters 5211 to 5214. 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.
Download G92 Code Example
Download ALL of the Code Examples
- G93, G94 and G95 - Set Path Control Mode
Details:
Three feed rate modes are recognized: inverse time, units per minute and units per revolution of spindle. Program: G93 to start the inverse time mode (this is very infrequently employed). Program: G94 to start the units per minute mode. Program: G95 to start the units per rev mode.
In inverse time feed rate mode, an F word means the move should be completed in [one divided by the F number] minutes. For example, if the F number is 2.0, the move should be completed in half a minute.
In units per minute feed rate mode, an F word on the line is interpreted to mean the controlled point should move at a certain number of inches per minute, millimeters per minute or degrees per minute, depending upon what length units are being used and which axis or axes are moving.
In units per rev feed rate mode, an F word on the line is interpreted to mean the controlled point should move at a certain number of inches per spindle revolution, millimeters per spindle revolution or degrees per spindle revolution, depending upon what length units are being used and which axis or axes are moving.
When the inverse time feed rate mode is active, an F word must appear on every line which has a G1, G2 or G3 motion and an F word on a line that does not have G1, G2 or G3 is ignored. Being in inverse time feed rate mode does not affect G0 (rapid traverse) motions.
It is an error if inverse time feed rate mode is active and a line with G1, G2 or G3 (explicitly or implicitly) does not have an F word.
- G98 and G99 - Canned Cycle Return Level
Details:
When the spindle retracts during canned cycles, there is a choice of how far it retracts:
1. Retract perpendicular to the selected plane to the position indicated by the R word;
2. Retract perpendicular to the selected plane to the position that axis was in just before the canned cycle started (unless that position is lower than the position indicated by the R word, in which case use the R word position).
To use option 1, program: G99. To use option 2, program: G98. Remember that the R word has different meanings in absolute distance mode and incremental distance mode.

Download G98 Code Example
Download G99 Code Example
Download ALL of the Code Examples
M-codes - M-code Table
- M0, M1, M2 and M30 - Program Stopping and Ending
Details:
To stop a running program temporarily (regardless of the setting of the optional stop switch), program: M0.
To stop a running program temporarily (but only if the optional stop switch is on), program: M1.
It is OK to program M0 and M1 in MDI mode, but the effect will probably not be noticeable, because normal behavior in MDI mode is to stop after each line of input, anyway.
If a program is stopped by an M0, M1, pressing the cycle start button will restart the program at the following line.
To end a program, program: M2 or M30. M2 leaves the next line to be executed as the M2 line. M30 “rewinds” the G-code file. These commands can have the following effects depending on the options chosen on the Configure>Logic dialog:
• Axis offsets are set to zero (like G92.2) and origin offsets are set to the default (like G54).
• Selected plane is set to XY (like G17).
• Distance mode is set to absolute (like G90).
• Feed rate mode is set to Units per minute mode (like G94).
• Feed and speed overrides are set to ON (like M48).
• Cutter compensation is turned off (like G40).
• The spindle is stopped (like M5).
• The current motion mode is set to G1 (like G1).
• Coolant is turned off (like M9).
No more lines of code in the file will be executed after the M2 or M30 command is executed. Pressing cycle start will resume the program (M2) or start the program back at the beginning of the file (M30).
Download M00 Code Example
Download M01 Code Example
Download M02 Code Example
Download M30 Code Example
Download ALL of the Code Examples
- M3, M4 and M5 - Spindle Control
Details:
To start the spindle turning clockwise at the currently programmed speed, program: M3.
To start the spindle turning counterclockwise at the currently programmed speed, program: M4.
For a PWM or Step/Dir spindle the speed is programmed by the S word. For an on/off spindle control it will be set by the gearing/pulleys on the machine.
To stop the spindle from turning, program: M5.
It is OK to use M3 or M4 if the spindle speed is set to zero; if this is done (or if the speed override switch is enabled and set to zero), the spindle will not start turning. If, later, the spindle speed is set above zero (or the override switch is turned up), the spindle will start turning. It is permitted to use M3 or M4 when the spindle is already turning or to use M5 when the spindle is already stopped but see the discussion on safety interlocks in configuration for the implications of a sequence that would reverse an already running spindle.
Download M03 Code Example
Download M04 Code Example
Download M05 Code Example
Download ALL of the Code Examples
- M6 - Tool Change
Details:
Provided tool change requests are not to be ignored (as defined in Configure>Logic), The CS will call a macro (q.v.) M6Start when the command is encountered. It will then wait for Cycle Start to be pressed, execute the macro M6End and continue running the part-program. You can provide Visual Basic code in the macros to operate your own mechanical tool changer and to move the axes to a convenient location for tool changing if you wish.
You are strongly advised to put the T~, the M06 and the G43 H~ on one line (block) of code. See G43 for more details.

Download M06 Code Example
Download ALL of the Code Examples
- M7, M8 and M9 - Coolant Control
Details:
To turn mist coolant on, program: M7.
To turn flood coolant on, program: M8.
To turn all coolant off, program: M9.
It is always OK to use any of these commands, regardless of what coolant is on or off.
Download M08 Code Example
Download M09 Code Example
Download ALL of the Code Examples
- M47 - Re-run from First Line
Details:
On encountering an M47 the part-program will continue running from its first line.
It is an error if M47 is executed in a subroutine.
The run can be stopped by the Pause or Stop buttons.
See also the use of M99 outside a subroutine to achieve the same effect.
- M48 and M49 - Override Control
Details:
To enable the speed and feed override, program: M48. To disable both overrides, program: M49. It is OK to enable or disable the switches when they are already enabled or disabled.
- M98 - Call Subroutine
Details:
To call a subroutine program: M98 P~ L~ or M98 ~P ~Q. The program must contain a letter O line with the number of the P word of the Call (for instance O1, O125, O777). This O line is a sort of “label” which indicates the start of the subroutine. The O line may not have a line number (e.g N123 O777) on it. The O line and the following code, will normally be written with other subroutines and follow an M2, M30 or M99 so it is not reached directly by the flow of the program.
The L word (or optionally the Q word) gives the number of times that the subroutine is to be called before continuing with the line following the M98. If the L (Q) word is omitted its value defaults to 1.
By using parameters values or incremental moves a repeated subroutine can make several roughing cuts around a complex path or cut several identical objects from one piece of material.
Subroutine calls may be nested. That is to say a subroutine may contain a M98 call to another subroutine. As no conditional branching is permitted it is not meaningful for subroutines to call themselves recursively.
Download M98 Code Example
Download ALL of the Code Examples
- M99 - Return from Subroutine
Details:
To return from a subroutine program: M99. Execution will continue after the M98 which called the subroutine.
If M99 is written in the main program (i.e., not in a subroutine), then the program will start execution from the first line again. See also M47 to achieve the same effect.
Download M99 Code Example
Download ALL of the Code Examples
- Self-reversing Tapping Cycles
Details:
To use the Tormach Auto-reverse tapping heads program M871 P~ (or M872, M873, M874)
The P word specifies the depth to be threaded relative to the current Z position which will typically be just clear of the workpiece surface. The P word can be negative or positive with the same meaning.
Before use of these codes the size of tapping head to be used and the pitch of the thread must be defined in the appropriated place on the Settings screen. If the part program is running in Inch (G20) mode then the pitch is taken as a number of threads per inch. If it is metric (G21) then the pitch will be in millimeters. If the spindle speed is too high for the chosen pitch then an error message will be displayed and the cycle will not be performed.
The cycle operates as follows:
The currently set spindle speed and thread pitch are used to calculate the feed rate required to move the tap at the correct speed. The corresponding feedrate for the high speed retraction of the tap is also calculated. If this exceeds the available rapid rate then an error is displayed.
The tap is then fed downwards for the commanded depth (P word).
At the end of the down-feed the spindle is rapidly retracted by the appropriate distance for the size of the head in use. This engages the reverse drive.
The spindle is then retracted, at the higher reverse rate previously calculated, for a distance sufficient to ensure the tap springs clear of the hole.
The Z axis is then positioned at the original height above the work ready to move to another hole or another tool and operation.
Note:
• The above explanation is slightly simplified from the actual code used to aid understanding.
• For best results, especially for deep holes and blind tapping, the spindle speed chosen should be checked with a tachometer to ensure it is as near the commanded (S word) speed as possible.
- M998 - Goto Toolchange Position
Details:
Execution of M998 will send the machine to the tool change position. The tool change position is defined on the Settings screen. The Z-axis will move first, then X and Y. An entry of 9999 will disable the axis. Execution of this function requires the machine to be referenced (Homed).
Download M998 Code Example
Download ALL of the Code Examples
- User Defined M-codes
Details:
If any M-code is used which is not in the above list of built-in codes then the Control Software will attempt to find a file named “Mxx.m1S” in the Macros folder corresponding to the current XML profile name. If it finds the file then it will execute the Visual Basic script program it finds within it.
New macros can be written using an external editor program like Notepad and saved in the Macros folder.
Other Codes - Other Codes Table
- Order of Execution Table
- Modal Groups Table
- F - Feed Rate
Details:
To set the feed rate, program: F~. Depending on the setting of the Feed Mode toggle the rate may be in units-per-minute or units-per-rev of the spindle. The units are those defined by the G20/G21 mode. Depending on the setting in Configure>Logic a revolution of the spindle may be defined as a pulse appearing on the Index input or be derived from the speed requested by the S word or Set Spindle speed DRO. The feed rate may sometimes be overridden as described in M48 and M49 above.
- S - Spindle Speed
Details:
To set the speed in revolutions per minute (rpm) of the spindle, program: S~. The spindle will turn at that speed when it has been programmed to start turning. It is OK to program an S word whether the spindle is turning or not. If the speed override switch is enabled and not set at 100%, the speed will be different from what is programmed. It is OK to program S0; the spindle will not turn if that is done. It is an error if: The S number is negative.
- T - Select Tool
-
To select a tool, program: T~, where the T number is slot number for the tool. The tool is not changed automatically. It is OK, but not normally useful, if T words appear on two or more lines with no tool change. It is OK to program T0; no tool will be selected. This is useful if you want the spindle to be empty after a tool change.
It is an error if:
• A negative T number is used or a T number larger than 255 is used.

