0% found this document useful (0 votes)
111 views24 pages

Preparatory Functions (G-Codes)

The document summarizes preparatory functions (G-codes) supported by TurboCNC, including: G00 for rapid positioning, G01 for linear interpolation at a specified feed rate, and G02/G03 for clockwise/counter-clockwise circular interpolation by specifying offsets from the start point or radius. It provides syntax examples and notes for each code.

Uploaded by

hasan alsarraf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views24 pages

Preparatory Functions (G-Codes)

The document summarizes preparatory functions (G-codes) supported by TurboCNC, including: G00 for rapid positioning, G01 for linear interpolation at a specified feed rate, and G02/G03 for clockwise/counter-clockwise circular interpolation by specifying offsets from the start point or radius. It provides syntax examples and notes for each code.

Uploaded by

hasan alsarraf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 24

Preparatory Functions (G-Codes)

Supported Preparatory Functions


Code Function   Code Function
G00 Rapid positioning   G70 Inch units
G01 Linear interpolation   G71 Metric units
G02 CW circular interpolation (3D)   G72 CW helical interpolation (obsolete)
G03 CCW circular interpolation (3D)   G73 CCW helical interpolation (obsolete)
G04 Dwell   G76 Multi-pass threading cycle
G16 Set implicit planes (obsolete)   G77 Turning/Boring cycle
G17 Set XY plane   G78 Peck motion (general)
G18 Set XZ plane   G80 Cancel canned cycle
G19 Set YZ plane   G81 Drill cycle
G20 Inch units   G82 Drill cycle with dwell
G21 Metric units   G83 Drill cycle with peck
G28 Home all axes   G90 Absolute coordinates
G31 Probe move   G91 Incremental coordinates
G32 Probe cycle   G92 Preload of registers
G33 Single pass threading   G93 Inverse time feed rate
G50 Probe hole ID   G94 Inches/mm per minute
G53 Master coordinates (fixture 0)   G95 Inches/mm per rev
G54 Fixture offset 1   G97 Set spindle rpm
G55 Fixture offset 2   G178 Speed peck motion
G56 Fixture offset 3   G183 Speed peck drill cycle
G57 Fixture offset 4      
G58 Fixture offset 5      
G59 Fixture offset 6      
Table –1 Preparatory Functions, which are or have been supported by TurboCNC.
G00 Rapid Positioning 
Function: Moves to a new position as fast as possible. 

Syntax: G00 [axis words]

Example:

G00 X1.2 Y0.3 ; Moves to (1.2, 0.3)

Notes:

 Only the axes called out on the line will be moved.


 In a minor departure from the Standard, G00 is interpolated by default so that axes start
and stop in unison and that a straight line is tracked between both positions. See the
configuration section on how to change this.
 In Absolute Mode the coordinates given are absolute axis positions.
 In Incremental Mode the coordinates given are signed distances from the current
positions.
 The absolute maximum speed is software limited to 2000 inches per minute (50 800
mm/min in metric) regardless of the physical limitations of the machine.
 The actual speed and ramping action of motion is chosen so as not to exceed the least
capable moving axis.

G01 Linear Interpolation


Function: Moves to a new position linearly at some feed rate.

Syntax: G01 [axis words] [optional feed word]

Example:

G01 X1.2 Y0.3 F3.0  ; Moves to (1.2,0.3) at 3 units/minute

Notes:

The feed rate is calculated as follows by the program:

 A single linear axis feeds in units/minute or units/revolution depending on active modes.


In G93 mode (inverse time feed rate) each move takes a constant amount of time to
complete.
 A single angular axis feeds in degrees/second.
 Multiple linear axes feed according to the "true distance" of the move in units/rev or
units/minute.
 Multiple angular axes feed in deg/sec for the first axis on the line, all others follow such
that they start and stop in unison.
 Mixed angular and linear axes follow the rules for linear axes only, the angular axes will
follow such that they start and stop in unison.
 No axis will ever go faster than the max speed established in setup.
 The Feed Rate Override modifies the feed rate, if enabled.
 Feed words are modal. If there is no feed word in the current block, the last feed word
read will be used.

G02 CW circular interpolation (3D)


Function: Moves to a new position in a clockwise circular arc. The arc center is specified with
signed offsets from the start position or implicitly by the magnitude of the radius. 

Syntax 1: G02 [two axis words (optional third)] [interpolation parameters] [optional feed word]

Syntax 2: G02 [two axis words (optional third)] [radius word] [optional feed word]

Example 1:
G17 (plane XY specified for clarity)
G00 X0 Y0 (get into start position)
G02 X2 Y0 I1 J0 F4
 

Moves from the current point to (0,0) in an


arc with its center at the current point + 1
unit in the X direction at 4 units/minute.
Absolute mode assumed. The "I" parameter
is associated with the "X" axis, and the "J"
parameter is associated with the "Y" axis.

G17 (plane XY specified for clarity)


G00 X0 Y0 Z0 (get into start position)
G02 X2 Y0 Z1 I1 J0 F4
 
This generates the same arc as above, but adds linear movement along the Z-axis thus
producing a helical cut.

Example 2:

G17 (plane XY specified for clarity)


G00 X0 Y1 (get into start position)
G02 X1 Y0 R1 F4
 

 
Moves from the current point to (2,0) in a
clockwise arc of 1 unit radius less than 180
degrees at 4 units per minute. Again, absolute
mode is assumed.

G17 (plane XY specified for clarity)


G00 X0 Y1 Z0 (get into start position)
G02 X1 Y0 Z1 R1 F4
 
This generates the same arc as above, but adds linear movement along the Z-axis thus
producing a helical cut.

Notes:

I and J are incremental by default. (NOTE: In rev 3.00g and prior, the I and J word were
absolute in absolute mode, incremental in incremental mode. This is no longer the case. See
the dialect customizations section above for information on how to change this)

Using a negative radius chooses the arc greater than 180 degrees that crosses both points, a
positive radius takes the arc that is 180 degrees or less. The program will stop with a warning if
you have a radius that is impossible. The R form is notoriously inaccurate for arcs very close to
180 degrees.

The sense and 2D plane of the arc is set by the current plane mode. Axis words appropriate to
the plane must be included i.e.:
 G17 – XY plane, X and Y [offsets I, J] [linear Z axis]
 G18 – ZX plane, X and Z [offsets I, K] [linear Y axis]
 G19 – ZY plane, Y and Z [offsets J, K] [linear X axis]

The order of parameters on the program line is not important. Use the I word for offset in the X
direction, J for offset in Y, and K for offset in Z to describe the relationship of center position
from the starting point. See the plane selector information section for more detail.

Start, destination and offset information for arcs can be specified using expressions, For
example:

G02 X[3.5 + COS(135)] Y[4.0 + SIN(135)]


I[3.5-(2.5 * COS(135))] J[4.0-(2.5 * SIN(135))]
 
This block assumes absolute mode for IJK, and has been split over two lines on this page. The
arc lies on a circle with its center located at (3.5, 4.0), has a radius of 2.5 units, and the block
will cause movement describing an arc clockwise from the current position to 135 degrees.

Full Circles:

If the destination letters are omitted, or, the distance between the start and end points of the arc
is less than one full step for each axis on the plane, a full circle will be described by the tool
motion. You must specify the move using the IJK form when omitting the axis end points for a
full circle move, as the R form is indeterminate for these cases.

Feed rates in an arc:

Feed rates are applied along the helix (i.e.: cutter path) during a three dimensional move.

If the specified feed rate is higher than either the computer, or the CNC machine, is capable of
achieving the feed rate will then be clamped at the system's maximum capability. The feed rate
is clamped at the lower of that specified by Mav Vel, or that sustainable by the acceleration
available at the axes. The formula used to determine the maximum feed rate based on
acceleration is dependent upon the radius of the arc and is computed as follows:

f = sqrt((Accel * Radius) / sqrt(2))


Accel is the product of Accel and Scale on the axis menu

The following chart shows the effect of radius on the maximum feed rate for various
accelerations.
G03 CCW circular interpolation (3D)
Function: Moves to a new position in a counter-clockwise circular arc. The arc center is
specified with signed offsets from the start position or implicitly by the magnitude of the radius. 

See the section on G02 for general information on this code.

G04 Dwell
Function: Pauses execution for an integer number of seconds

Syntax: G04 [P word]

Example:

G04 P6 ; Six-second pause

Notes:

The P symbol and units of integer seconds are used. See the customization section for
instructions on how to change the unit of time to milliseconds.

Any delay of more than 2 seconds will show a countdown.

Press a key to exit a delay prematurely.

WARNING
Never use G04 dwells and your hands as a tool-changer. It

!
takes longer than you think... Use M00 or M06 instead.

G16 Set implicit planes 


Obsolete Function: Set circular and helical interpolation plane to be defined implicitly by block

Background:
The original TurboCNC through rev 3.1a allowed an implicit plane specification in which the first
two axes called out on a G02/03 line became the plane of action for the interpolation. In this
mode, only the I and J parameters were used. The "I" offset was applied to the first axis on the
line, the "J" axis to the second. This affected G02, G03, G72, and G73. For the helical moves,
the third axis was always the direction of linear travel.

The idea here was to allow unusual interpolation schemes to be used on machines with many
axes or non-conventional axis names.

 This code is no longer supported! Use the conventional plane selectors (G17 through 19) for
defining arc planes in new programs.

G17-19 Set current 2D plane


G17 Function: Sets plane for circular and helical interpolation to X-Y.

G18 Function: Sets plane for circular and helical interpolation to Z-X.

G19 Function: Sets plane for circular and helical interpolation to Z-Y.

Syntax: none

Notes:

The rule for planes and how to determine the


sense of CW vs. CCW is (from the Standard):

"Arcs shall be CW or CCW as viewed in the


negative direction of the out-of- plane axis in a
standard right hand axis system."

Translation: For mill users, if +X is rightward


and +Y is toward the back of the machine (tool
motion relative to the work!) and +Z is up, then
as you look down (-Z) at the table in G17 mode,
arcs will look CW or CCW as you'd expect.

For lathe users, if +Z is away from the headstock, and +X is increasing diameter, then in G18
mode CW/CCW will look reversed if you look down at the slide. This is because in this right
hand system, -Y is looking up.

G20 Inch units


Function: Sets distance unit to inches.

Syntax: none

Notes:

All coordinates and feed rates will be in inches after this command is executed.

G20 and G21 are identical to G70 and G71.

Saving the .ini file while in either mode makes it modal on startup.

G21 Metric units


Function: Sets distance unit to mm.

Syntax: none

Notes:

 All coordinates and feed rates will be in millimeters after this command is executed.
 G20 and G21 are identical to G70 and G71.

Saving the .ini file while in either mode makes it modal on startup.

TurboCNC stores and uses all values in Imperial measure internally. This will cause very small
conversion errors (> 0.00001 inch or 0.000004 mm) to show up on the display in Metric mode.

G28 Home all axes


Function: Drive each axis with a home switch to re-establish position.

Syntax: G28 [optional feed word]

Notes:

Each axis with a home switch will be driven to the home position where its coordinates will be
reset. G28 is often used to recalibrate your machine during long cycle times where temperature
creep or other position loss sources are a factor.

An axis must have a physical home switch to be "homed" in this context.

The mechanism is as follows:

 Each axis with a home switch moves simultaneously in the home direction.
 As each home switch goes active, each axis will stop
 When they are all on their switches, each axis will simultaneously move in the opposite
direction
 As each home switch goes inactive, each axis will stop again
 Each axis position is re-established as configured in machine coordinates

The speed of the homing action is set by the modal F word and current feed mode.

It is not necessary to be in machine coordinates to initiate homing.

If no axis has a home switch, an error warning will be issued.

G31 Probe move


Function: Move to a position until the probe input goes active

Syntax: G31 [axis words] [optional feed word]

Example:

G31 Z-4.0 F10


 
Move to Z -4.0 at 10 IPM, until the probe input goes active.

Notes:

The move works in a similar fashion to G01. If the probe hits something, the machines stops
and write the position to the file POINTS.DAT in the same directory as the executable.

If nothing is hit, the move ends at the position specified and no data is written.

Use G31 to get off of the part again if you need to, the program only accepts the inactive to
active transition as valid input.

WARNING Note that if you move twice in the same direction with G31 or any other
codes, you can smash your probe! Good practice is to design your probe

! with built in over travel that activates the panic stop input if exceeded.
G32 Probe cycle
Function: Repetitive probing to digitally scan a 2D or 3D surface

Syntax: G32 [axis bound 1] [bound 2] [optional bound 3] [discretization] [optional feed word]

Example:

G00 X0 Y0 Z0 ; get into position


G32 X1 Y1 Z-1 I0.250 F10

Moves X from 0 to 1 by .250 increments, each time moving Y from 0 to 1 by 0.250 increments.


Z will plunge from 0 to -1 and back to 0 again, stopping and writing the position to disk for each
probe strike on the downward stroke. Absolute mode assumed.

Notes:

 This is 2 or 3-axis general, so the last axis cycles the most and the first axis only once
through a number of points determined by the discretization distance. You need at least
two axes moving to scan. Using a single axis will move in the same way as G31.

 The digitizing scheme is of the "bed of nails" variety, e.g.: straight up and down in the
last axis on the line.

 The output is written to a scan file in the same directory as the executable, with a
filename of SURFSCAN.DAT.

WARNING Rounding error may prevent the last row or column from being
scanned. Add a small amount to the bounding distance to avoid

!
this:
 
G32 X1 Y1 Z-1 I0.250 F10 ;X1,Y1 ;may or may not be reached
G32 X1.001 Y1.001 Z-1 I0.250 F10 ;This is better

G33 Single pass threading


Function: Makes a single threading motion in sync with the spindle.

Syntax: G33 [axis coord] [lead parameter]

Example:

G33 Z-1.25 K0.050


 
Assuming inches and absolute mode, this threads 20 TPI to a shoulder at Z = -1.25

Notes:

A spindle index pulse must be enabled and present for this to work. See the section on hooking
up a spindle encoder for details on how to do this.

The program will time-out after 5 seconds of spindle pulse inactivity. Similarly, the operation will
be halted if the speed detected at the spindle is greater than 5000 rpm. This offers a measure of
protection against the failure modes of signal noise, signal loss, or stalls.

K is the lead parameter for the Z-axis, I is for X, and J is for Y. See the dialect customization
section if you want to specify pitches instead or change K for some other letter.

Multiaxis Operations: You can thread up to three axes simultaneously for tapered threading or
unusual machining situations like gear hobbing. The lead and distance should work out to an
equal number of revolutions for each. An axis with no lead specified will move at the regular
feed rate.
Allow a few revs of "lead in" for the axis to synchronize. You need a lot of acceleration to keep
up with the changes in velocity. If the axis falls behind and can't keep up, the program will stop
and warn you.

The synchronization is always from the start point for each pass, so for multi-start threads,
offset the start position by some fraction of the thread lead. For 30 degree infeed, change the
start position on each pass along a 30 deg vector.

See also G76, multi-pass threading.

G50 Probe hole ID


Function: Finds the center of a hole using a touch probe

Syntax: G50 [optional feed word]

Notes:

Put the probe inside the hole approximately in the center, and call G50 from within a program or
the MDI window. 

This is an orthogonal six hit probing algorithm - clock positions struck are 12,6,9,3,12,6 in the
XY plane as you normally view the part on a mill. You must have a touch probe installed and the
probe input configured for this to work. Hole probing is always in the XY plane.

The speed of G50 probing is given by the modal feed word and mode.

Watch out for keyways and similar things that can throw you off. Use this command for auto-
setting boring operations or fixture locating where some part-to-part variation is expected and
you need to locate to a hole center exactly.

G53 Change to master coordinates


Function: Change to master coordinates, also known as fixture 0.

Syntax: none

Notes:

In master coordinate mode, no fixture offset is active. If tool 0 is set as well, you are in Machine
Coordinates. These are the coordinates that are active while homing, and in setting up feed
screw error compensation.

At startup, you are in machine coordinates by default. No offsets are active in machine
coordinate mode.

G54-G59 Change fixture offset


Function: Change to a new fixture offset, from 1 (G54) to 6 (G59)

Syntax: none

Notes:

When the fixture offset is changed, all the tool offsets follow. Machining in a new offset mode is
like having "zero" in a new place on your machine.

The coordinates you see on the screen are the master coordinates + the fixture offset in use +
the tool offset in use. Tool 0 is no tool offset, G53 is no fixture offset.

The most common use for these is multiple fixtures on the same table. For example, home the
machine in G53. Your usual 6" vise can be "zeroed" in G54 mode, and the center of a 5C collet
vise, say, can be zero in G55. Changing modes puts you in a new coordinate system painlessly
and allows different classes of parts to be machined on a large table.

G53-59 are modal. A fixture offset stays in effect until a new one is commanded.
G70 Inch mode
Function: Sets distance unit to inches.

Syntax: none

Notes:

Same as G20.

G71 Metric mode


Function: Sets distance unit to mm.

Syntax: none

Notes:

Same as G21.

G72 CW helical interpolation


Obsolete Function: Was similar to G02, but allowed a third axis to travel linearly as well.

Background:

Originally (through version 3.1a), TurboCNC used G02 and G03 as strictly 2D arc functions, and
a separate G word for helical interpolation. This was unnecessary, and violated the Standard.

This function is no longer supported. Use G02 with a third axis callout instead.

G73 CCW helical interpolation


Obsolete Function: Was similar to G03, but allowed a third axis to travel linearly as well.

This function is no longer supported. Use G03 with a third axis callout instead.

G76 Multi-pass threading
Function: Machines an OD or ID thread completely on a lathe.

Syntax: G76 [X coord] [Z coord] [K height] [D first pass] [F lead] [A tool nose angle]

Example:

G76 X-0.210 Z-1.25 K.040 D0.003 F0.050 A60


 
Assuming inches and absolute radius mode, this threads 1/2-20 TPI UNF to Z = -1.25
completely.

Notes:

The starting point is returned to after each pass. The X location of the starting point determines
the back out distance after each cut it complete.

The A word specifies the included tool nose angle, which is customarily 60 degrees for common
threads. The tool will automatically feed on an angle of 1/2 A. If A is not specified, it defaults to
0, which produces a radial infeed.

K, D and F are always positive, regardless of the actual orientation or "hand" of the thread.

Each successive pass will remove the same area of material as the first pass did, in order to
equalize the torque load. This is standard, and helps to improve the finish.

G77 Turning/Boring/Milling Cycle


Function: Turning with multiple passes, infeeding by an amount set by the I word.
Syntax: G77 [repetitive axis] [infeed axis] [feed per pass] [optional feed rate]

Example:

G77 Z-1.250 X0.250 I0.050 F5.0


 
On a radius programmed lathe that cuts to an X coordinate of 0.250, back and forth in Z from
current position to -1.250, feeding in 0.050 each pass and cutting at 5 units/min. Here's the
actual motion sequence for on the above, assuming the tool started at 0,0:

X0.050 slowly 
Z-1.250 slowly 
X-0.025 slowly 
Z0 rapidly 
X0.100 slowly 
Z-1.250 slowly 
etc...
Notes:

The order of the operands defines the motion. The back-and-forth action will occur from the
current position of the first axis on the line to the position specified. The second axis called out
will eventually reach the position specified by feeding in increments of I each pass.

The sign of I is unimportant. Always use I for the infeed, no matter what other axes are being
used.

Infeed is applied to the second axis on the line. Creative use of this command can be made for
fly cutting / slab-milling or cutting deep blind slots on mills or trimming the edges of stock.

After each pass, the control "backs off" by 1 1/2 times the infeed. So if you're boring, make sure
you have enough clearance for the bar.

If the infeed doesn't divide into an even number of passes, a small finishing pass will be taken.

G78 Peck Motion Cycle


Function: Feeds to a position on an axis, incrementally in "pecks" with a full rapid retract.

Syntax: G78 [axis of action] [peck distance] [optional feed word] [optional dwell]

Example:

G78 Z-2.000 I0.100 F2.0


 
Moves from the current position to Z=-2.000 at 2 units/min 0.100 units at a time (retracts to
original Z each time).

Notes:

The sign of I is unimportant, but this code is always used with I, regardless of the actual letter
for the moving axis.

If you put in a dwell parameter with the P operator, a dwell in milliseconds will be taken at the
end of each pass.

G78 Z-2.000 I-0.100 F2.0 P100


 
does the same as the previous example, but with a tenth of a second dwell at the bottom of the
hole. This helps the tool life considerably in some cases. After each peck and retract, the tool
will rapid to 10% of the peck increment before the last stop, and then feed in again. The letter
and units used for the dwell are the same as for the G8x cycles if user configured.

This command is single axis only.

A good use of this code is "peck turning" plastic on a lathe to keep the chips short.
G80 Cancel drill cycle
Function: Cancel canned drill cycle

Syntax: none

Notes:

It's good practice, but not strictly necessary, to put this code after a series of the G81, G82, or
G83 drill cycles. It clears the canned cycle variables from memory.

Some CAM programs automatically generate this code after every series of drilled holes.

G81 Drill cycle


Function: Drill a hole on a 3-axis mill

Syntax: G81 [axis words] [release plane] [optional feed word]

Example:

G81 X1 Y1 Z-0.75 F2.0 R0.25


 
The following will occur. Absolute mode and inch units are assumed.

Rapid to R plane if Z is less than 0.25 absolute

Move the table to the XY position (1,1) specified; holding Z at the point it was before.

Feed the Z-axis to -0.75 at 10ipm.

Rapid the Z-axis to 0.25 (the release plane)

Notes:

This is the canonical RS-274D drill cycle. Drills a hole at a specific XY position, to a depth Z at
the current feed rate, and retracts to a release plane "R". 

To drill another hole just like the first, just input the XY position on the next line:

G81 X1.5 Y1.25


 
This second hole will be done the exact same way was the first, but at the new position of X=1.5
and Y=1.25.

Release plane: If the R plane is between the current Z position and the bottom of the hole, the
control will rapid to the R plane after moving XY and before drilling. If the R plane is "above"
where the drill is in Z at the start of G81, the control will rapid to the R plane first before moving
XY. This affords maximum safety without overly compromising speed.

Note that R is absolute in absolute mode, incremental in incremental mode! All the other
parameters behave similarly.

All of the coordinates (XYZR) need to be called out on the first G81. These will "stay in effect"
thereafter until G80 is called (modality). So, if you have a series of holes that are all to the same
depth, you can use this:

G81 X1 Y1 Z-0.75 F2.0 R0.25 ;First hole 


G81 X2 Y2 
G81 X3 Y2 
X2.5 
G80 ;Four holes were drilled at (1,1) (2,2) (3,2) and (2.5,2)
 
These cycles ignore the plane selector as per the Standard. The drilling always occurs in Z, the
positioning in XY.
G82 Drill + Dwell cycle
Function: Drill cycle with dwell at the bottom of the hole

Syntax: Similar to G81, but requires a # parameter for the dwell at the bottom of the hole in
milliseconds.

Example:

G82 X0 Y0.5 Z-1 F10 R0.25 P250

Drills at coord (0,0.5) to a depth of Z=-1 at 10 IPM. Dwells for a quarter second, and then
retracts to Z=0.25.

Notes:

Dwell is in milliseconds for this code by default. This can be customized to seconds, or some
other letter chosen besides P for CAM compatibility.

G83 Peck drill cycle


Function: Drill with a pecking action and an optional dwell

Syntax: Similar to G81/82, but requires an I parameter for the peck increment when drilling.

Example:

G83 X0 Y0.5 Z-1 F10 R0.25 Q0.100 P250


 
This is the same as the G82 example above, but the drill will descend at the 10 IPM feed rate in
0.100 inch pecks with a rapid retract to the original Z. The drill rapids down to 10% of the peck
distance above the bottom of the hole before feeding again to minimize "air time".

Notes:

The dwell parameter (P) is optional with G83 as a convenient departure from the Standard. The
above example will dwell a quarter second at the end of each peck. The dwell is in integer
milliseconds by default.

The sign of Q is unimportant. The letters P and Q, and the dwell units are customizable.

G90 Absolute coordinates


Function: Set coordinates to absolute mode (default).

Syntax: none

Notes:

In absolute mode, all axis words and many parameters refer to an absolute coordinate position.

G90/91 are modal. Either mode will stay in effect until the other is called.

G90 is the default mode at startup.

G91 Incremental coordinates


Function: Set coordinates to incremental mode (offsets from current position)

Syntax: none

Notes:

In incremental mode, all axis words and many parameters are a signed offset from the current
position.

G90/91 are modal. Either mode will stay in effect until the other is called.
G92 Preload of registers/Set machine coordinates
Function: Set position without motion

Syntax: G92 [axis words]

Example:

G92 X0 ;Zeroes X axis


G92 X0 Y0 Z0 ;Zeroes the principle axes on a mill
G92 Z1.234 ;Z is now set to 1.234
 
Notes:

This code sets the position of any or all axes to a specific value. Use this to reset the position
inside a program. No motion will occur.

In machine coordinate (G53 T0) mode, the machine coordinates themselves are updated.

In any fixture offset mode (G54-G59) and T0, the fixture offset is updated.

In any tool-offset mode (T1-T20), the tool offset is updated.

This code is not modal.

G93 Inverse time feed rate


Function: Set feed rate unit to inverse time ratio

Syntax: none

Example:

G93 F60 ;All G01 blocks will take one second


G93 F120 ;All G01 blocks will take 1/2 second
G93 F0.5 ;All G01 blocks will take 2 minutes
 
Notes:

In this mode, the length of time that each block will take to execute is controlled. The unit is the
reciprocal of length of time in minutes. (e.g.: 60 is 1/60th of a minute or one second).

G93/94/95 are modal to one another. Each mode will stay in effect until another is called.

This mode is useful for unusual situations where the feed rate is difficult to calculate directly, but
the overall time to move is known - such as when several axis types are moving simultaneously.

As with the other feed modes, if the commanded feed rate is too fast for the machine, the
motion will be performed at the fastest available speed.

With arcs, each arc segment is treated as an individual block in this mode.

G94 IPM feed rate


Function: Set feed rate unit to units/min

Syntax: none

Notes:

G93/94/95 are modal to one another. Each mode will stay in effect until another is called.

G94 is the default mode at startup.

G95 IPR feed rate


Function: Set feed rate unit to units/rev.
Syntax: G95 [optional S word]

Example:

G95 S1000 F0.002 ; Feed is now 0.002/rev at 1000 rpm

Notes:

Be sure to have set the "S" word for spindle speed when calling this function for the first time
before any motion takes place. You can also read the spindle speed after engaging G95 mode
by using the M50 code if you have a spindle encoder on your machine.

G93/94/95 are modal to one another. Each mode will stay in effect until another is called.

G97 Program spindle RPM


Function: Set spindle RPM

Syntax: G97 [S word]

Example:

G97 S1000 ;1000 rpm


Notes:

This function is a "placeholder" in the source code. Registered users can use it as a starting
point to program their own spindle control routines into TurboCNC. 

If you use units/rev feed rates by calling G95, you must use this code or otherwise set the S
parameter with the spindle speed before trying to move.

G178 Speed peck motion


Function: Speedy generalized single axis pecking motion

Syntax: G178 [axis of action] [peck distance] [optional feed word] [optional dwell]

Example:

G178 Z-2.000 I0.100 F2.0


Moves from the current position to Z=-2.000 at 2 units/min 0.100 units at a time with dwells.

Notes:

This command is single axis only, and is identical to G78, except that no retracts are made
while machining. Only the dwells are taken.

In some cutting situations you can use this to avoid dangerous continuous chips while
machining, and saving a significant amount of time in the process by not retracting fully.

G183 Speed peck drill cycle


Function: Speedy peck drilling in pecks with dwells

Syntax: Same as G83

Notes:

This code operates in exactly the same manner as G83, except that it does not retract at all
between each peck. The dwells are taken.

In some cutting situations you can use this to avoid dangerous continuous chips while
conserving machining time if many holes are to be drilled.
Miscellaneous Functions (M-Codes)
Supported Miscellaneous Functions
Miscellaneous Functions are generally simpler than Preparatory Functions and seldom have
parameters.

Code Function Code Function


M00 Automatic halt M40 Select Gear Ratio 1
M01 Optional halt M41 Select Gear Ratio 2
M02 End of program M42 Select Gear Ratio 3
M03 Spindle on CW M43 Select Gear Ratio 4
M04 Spindle on CCW M44 Select Gear Ratio 5
M05 Spindle off M45 Select Gear Ratio 6
M06 Tool change M46 Select Gear Ratio 7
M07 Coolant A on M48 Restore feed override
M08 Coolant B on M49 Cancel feed override
M09 Coolants off M50 Read spindle speed
M10 Clamp M60 Jump to Subroutine (obsolete – use M98)
M11 Unclamp M62 Return from Subroutine (obsolete – use M99)
M13 Spindle CW and coolant A on M70 Set PLC handshake output to inactive
M14 Spindle CCW and coolant A on M71 Set PLC handshake output to active
M17 Enable drives M72 Wait for PLC handshake input to go inactive 
M18 Disable drives M73 Wait for PLC handshake input to go active
M21 Open collet M97 Jump
M22 Close collet M98 Jump to subroutine
M30 End of tape M99 Return from subroutine
   
 Table –2 Miscellaneous Functions that are or have been supported by TurboCNC.

M00 Automatic halt


Function: Halts program until operator presses a key.

Notes:

Comments included in the block containing M00 are displayed within the prompt that is raised.
A vertical bar, '|' can be used to force a new line. This feature is a convenient method of
presenting instructions to the machinist at runtime.

M01 Optional halt


Function: Halts the program only if optional halts are enabled.

Notes:

Similar to M00. Use Optional Halts under the machining options menu to toggle whether these
are enabled.

This is commonly used for "first article" type checks while the part is on machine.

Comments included in the block containing M01 are displayed within the prompt that is raised.
A vertical bar, '|' can be used to force a new line. This feature is a convenient method of
presenting instructions to the machinist at runtime.

M02 End of program


Function: Stops program execution. 

Notes:

This (or M30) must be the last line of a program.

Comments included in the block containing M02 are displayed within the prompt that is raised.
A vertical bar, '|' can be used to force a new line. This feature is a convenient method of
presenting instructions to the machinist at runtime.
M03 Spindle on CW
Function: Turns on spindle in the clockwise direction.

Notes:

Clockwise is the usual direction for a lathe or mill. If the spindle is commanded to run forward
while it is already on, it will be shut off for 7 seconds and then re-activated in the new direction.

M04 Spindle on CCW


Function: Turns on spindle in the counter-clockwise direction.

Notes:

Similar to M03.

Turn the spindle off with M05 before changing directions or calling M03/04. If the spindle is
commanded to reverse while it is already on, it will be shut off for 7 seconds and then re-
activated in the new direction.

M05 Spindle off


Function: Turns off spindle

Notes:

Turns off the spindle output line. No braking is assumed. The spindle direction line state is not
affected.

M06 Tool change


Function: Halt for tool change

Example:

M06 T1 ; Stops with a prompts for change to tool 1


; and changes to the tool 1 coordinate offset

Notes:

This is essentially the same as M00, but with a prompt to tell the user which tool is being
requested. Registered users may program their own, more sophisticated routines for automated
tool changes here.

The T word is required with M06. It may also be placed on any program line to change the tool
offset without pausing the program.

If the tool turret index line is enabled, M06 will not prompt the user, but activate the turret index
line briefly instead. The default time period is two seconds, the maximum period is 120 seconds.

The delay period for the turret index line is set in the ini file or the configuration menu under the
General heading.

Comments included in the block containing M06 are displayed within the prompt that is raised.
A vertical bar, '|' can be used to force a new line. This feature is a convenient method of
presenting instructions to the machinist at runtime.

M07 Coolant A on (flood)


Function: Turns on relay A

Notes:

This code is traditionally associated with flood coolant. It can be used as a generic output to
control anything.
M08 Coolant B on (mist)
Function: Turns on relay B.

Notes:

This code is traditionally associated with mist coolant. It can be used as a generic output to
control anything.

M09 Coolants off


Function: Switches off both relay A & B.

Notes:

Both coolant outputs (A and B, see M07 and M08) will be set to inactive.

M10 Clamp
Function: Closes a machine clamp

Example:

M10 Q12; Closes clamp twelve


Notes:

Use numbers 0-15 for the clamps. If Q is not specified, it defaults to clamp 0.

At a minimum, the clamp drive, direction, and closure sense lines need to be configured on the
machine to use this command.

The clamp address appears on the four clamp select output lines in binary, if they are
configured on the machine. Clamp 0 is all lines inactive; clamp 15 sets all lines active.

You do not need to configure all 4 clamp select lines. For example, if you only have four clamps
to control then it is permissible to use the first two clamp select lines only.

The clamp will be driven until the closure line goes active, or when 15 seconds has elapsed,
whichever comes first.

M11 Unclamp
Function: Identical to M10, except that it opens a machine clamp.

Notes:

At a minimum, the clamp drive, direction, and open sense lines need to be configured on the
machine to use this command.

The clamp will be driven until the open line goes active, or when 15 seconds has elapsed,
whichever comes first.

M13 Spindle CW and coolant A on


Function: Turns the spindle on in the clockwise direction and activates the "A" coolant.

M14 Spindle CCW and coolant A on


Function: Similar to M13, but the spindle will be started counterclockwise.

M17 Enable drives


Function: Set drive enable lines active

Notes:
The Stepper World SP3 and some versions of the MAXNC drives require an enable signal in
order to operate. After the drive enable output lines have been configured in TurboCNC, use
this code to turn them on. 

The drives will be disabled automatically when:

 a panic abort occurs during motion


 you exit TurboCNC normally

They will be enabled when:

 a program is started or resumed


 you enter jog mode
 TurboCNC is started
 you input an MDI command
 
You can also control these manually by using the options under the setup menu.

M18 Disable drives


Function: Set drive enable lines inactive

Notes:

Similar to M17, this turns the drive enable lines off.

M21 Open collet


Function: Opens a collet

Notes:

When this code is executed, the Collet Open line goes active for a short time, and then returns
to the inactive state. The default length of time is two seconds and the maximum is 120.
Change the length of time allowed by editing the ColletOpenTime(ms) entry in the ini file.

No feedback is required from the actual machine. This is designed to work with a pneumatic
collet closer on a lathe.

The delay periods for M21 and M22 are set in the ini file or the configuration menu under the
General heading.

M22 Close collet


Function: Closes a collet

Notes:

Similar to M21, this code activates the Collet Close output line for some length of time. Two
seconds is the default, 120 seconds is the maximum. Change the length of time allowed by
editing the ColletCloseTime(ms) entry in the ini file.

M30 End of program & rewind


Function: Stops program execution

Notes:

Functionally identical to M02. Hard disks don't need to be "rewound" of course, but paper tapes
used to be! Some CAM programs generate this code instead of M02 at the end of a program, so
it's here for compatibility.

Comments included in the block containing M30 are displayed within the prompt that is raised.
A vertical bar, '|' can be used to force a new line. This feature is a convenient method of
presenting instructions to the machinist at runtime.
M40 – M46: Gear Changes
Function:  Selects the speed map associated with the specified gear.

Notes:

Spindle speed control is oriented to the Sherline spindle. As such the default compilation only
implements M40 through M43. Increase MaxRatios in the spdmap unit to 7 to take advantage
of the full range of codes.

The following mappings are defined:

 M40 – Standard Pulleys, Low Range (45 – 1400 RPM)


 M41 – Standard Pulleys, High Range (70 – 2800 RPM)
 M42 – 10K RPM Pulleys, Low Range (150 – 2200 RPM)
 M43 – 10K RPM Pulleys, High Range (1500 – 10200 RPM)

M48 Restore feed override


Function: Restore feed override

Notes:

This brings the feed override back to whatever it was just before the most recent M49 call.

M49 Cancel feed override


Function: Cancel feed override

Notes:

This resets the feed override to 100% "from the inside". Use it before entering a critical section
of your program that requires an exact feed rate. The feed override can be restored with the
M48 code.

M50 Read spindle speed 


Function: Set S word with actual spindle speed

Notes:

This reads the spindle speed into the program for use with per revolution feed rates (see G95)
by reading the spindle index pulse.

You must have an index pulse enabled to use this code. See the hardware section for details on
how to set this up.

The operation will time out if five seconds goes by without a signal from the spindle.

An error will be triggered if the spindle appears to be going faster than 5000 rpm.

M60 Jump to subroutine (obsolete function)


Function: Jump to a new block saving return

Syntax: [N word] M60 [jump target]

Example:

N0010 M60 O0100 ; Jump to subroutine 0100


M05 ; Subroutine returns here – spindle off
M02 ; End Program
 
N0100 M03 ; Subroutine to turn spindle on
M62 ; Return from subroutine
 
Notes:
This function is considered obsolete. Use of M98 is strongly suggested. It is included as a
partial bridge to previous versions of TurboCNC.

The jump target word is set to 'O' by default. This can be reconfigured using the
'Configure/Dialect' menu.

Jumps to the line with the N word identical to the jump target word (N0100 in the example).

The N word of the line with the M98 is saved for the return (10 in the example). Naturally, this
means you should have a different N word on both the calling line and the target line.

Subroutines can be nested 20 levels deep.

M62 Return from subroutine (obsolete function)


Function: Return to block immediately after the most recent M60 call

Syntax: M62

Example:

See M60

Notes:

This function is considered obsolete. Use of M99 is strongly suggested. It is included as a


partial bridge to previous versions of TurboCNC.

The next block to be executed will be found on the line following the most recent M60 call.

See SAMPLE.CNC for a simple nested subroutine example. Please note that when using
subroutines, you'll need a unique N code on each calling line so that the program knows where
to go back to.

To visualize program execution with subroutines, imagine all the code in the subroutine invisibly
pasted in beneath the calling line. None of the modal codes are affected.

M70 Set PLC handshake output to inactive


Function: Set PLC handshake output to inactive

Notes:

Two PLC handshaking lines can be configured in TurboCNC. These are for telling external
logic, such as an automatic tool changer or what-have-you to do some work. M70 sets the
output handshake line to the inactive state. This can also be used to control extra solenoids or
relays.

M71 Set PLC handshake output to active


Function: Set PLC handshake output to active

Notes:

Similar to M70, M71 sets the output handshake line to the active state.

M72 Wait for PLC handshake input to go inactive


Function: Wait for PLC handshake input to go inactive

Notes:

When this code is called, the program stops running and waits for the PLC input line (separate
from the output line) to go to the inactive state. This is intended to be used to synchronize the
program with external logic that might be loading more stock, or performing some other
function.
M73 Wait for PLC handshake input to go active
Function: Wait for PLC handshake input to go active

Notes:

Similar to M72, this pauses until the PLC line goes to the active state. With either of these two
codes, the user can press a key to bypass the wait condition.

M97 Jump
Function: Jump to a new block

Syntax: M97 [jump target]

Example:

M97 O0200 ; Jump to block 0200


G00 X1 ; This line is skipped
N0200 M02 ; Jump target – Program End
 
Notes:

The jump target word is set to 'O' by default. This can be reconfigured using the
'Configure/Dialect' menu.

Jumps to the line with the N word identical to the jump target word (N0200 in the example).

Code following an M97 in a block is not executed. M-Codes within a block are executed first, in
the order that they are encountered. Only the parameters that follow the M97 for M-Codes
encountered earlier in the block will be used. Every other code or parameter is ignored.

The jump function is very useful when combined with 'Conditional Programming'

If there is a parsing error in the line containing the jump target, the message 'Jump Target not
Found' will be displayed.

M98 Jump to subroutine


Function: Jump to a new block saving return

Syntax: [N word] M98 [jump target]

Example:

N0010 M98 O0100 ; Jump to subroutine 0100


M05 ; Subroutine returns here – spindle off
M02 ; End Program
 
N0100 M03 ; Subroutine to turn spindle on
M99 ; Return from subroutine
 
Notes:

The jump target word is set to 'O' by default. This can be reconfigured using the
'Configure/Dialect' menu.

Jumps to the line with the N word identical to the jump target word (N0100 in the example).

The N word of the line with the M98 is saved for the return (10 in the example). Naturally, this
means you should have a different N word on both the calling line and the target line.

Subroutines can be nested 20 levels deep.


Code following an M98 in a block is not executed. M-Codes within a block are executed first, in
the order that they are encountered. Only the parameters that follow the M98 for M-Codes
encountered earlier in the block will be used. Every other code or parameter is ignored.

If there is a parsing error in the line containing the jump target, the message 'Jump Target not
Found' will be displayed.

M99 Return from subroutine


Function: Return to block immediately after the most recent M98 call

Syntax: M99

Example:

See M98

Notes:

The next block to be executed will be found on the line following the most recent M98 call.

Code following an M99 in a block is not executed. M-Codes within a block are executed first, in
the order that they are encountered. Only the parameters that follow the M99 for M-Codes
encountered earlier in the block will be used. Every other code or parameter is ignored.

See SAMPLE.CNC for a simple nested subroutine example. Please note that when using
subroutines, you'll need a unique N code on each calling line so that the program knows where
to go back to.

To visualize program execution with subroutines, imagine all the code in the subroutine invisibly
pasted in beneath the calling line. None of the modal codes are affected.

If there is a parsing error in the line containing the jump target, the message 'Jump Target not
Found' will be displayed.

You might also like