Software

Mach3, Mach4, SigmaNest, etc.

Mach3

Mach3

Mach3 Gcode Manual

__Use__MachMotion_Logo_HiRes_TransBG-update-01-450.png


1 Definitions

1.1 Linear Axes

The X, Y, and Z axes form a standard right-handed coordinate system of orthogonal linear axes. Positions of the three linear motion mechanisms are expressed using coordinates on these axes.

1.2 Rotational Axes

The rotational axes are measured in degrees as wrapped linear axes in which the direction of positive rotation is counterclockwise when viewed from the positive end of the corresponding X, Y, or Z-axis. By "wrapped linear axis," we mean one on which the angular position increases without limit (goes towards plus infinity) as the axis turns counterclockwise and decreases without limit (goes towards minus infinity) as the axis turns clockwise. Wrapped linear axes are used regardless of whether or not there is a mechanical limit on rotation.

Clockwise or counterclockwise is from the point of view of the work piece. If the work piece is fastened to a turntable which turns on a rotational axis, a counterclockwise turn from the point of view of the work piece is accomplished by turning the turntable in a direction that (for most common machine configurations) looks clockwise from the point of view of someone standing next to the machine.

1.3 Scaling Input

It is possible to set up scaling factors for each axis. These will be applied to the values of X, Y, Z, A, B, C, I, J and R words whenever these are entered. This allows the size of features machined to be altered and mirror images to be created - by use of negative scale factors. The scaling is the first thing done with the values and things like feed rate are always based on the scaled values.

The offsets stored in tool and fixture tables are not scaled before use. Scaling may, of course, have been applied at the time the values were entered (say using G10).

1.4 Controlled Point

The controlled point is the point whose position and rate of motion are controlled. When the tool length offset is zero (the default value), this is a point on the spindle axis (often called the gauge point) that is some fixed distance beyond the end of the spindle, usually near the end of a tool holder that fits into the spindle. The location of the controlled point can be moved out along the spindle axis by specifying some positive amount for the tool length offset. This amount is normally the length of the cutting tool in use, so that the controlled point is at the end of the cutting tool. G and M-code reference

1.5 Co-ordinated Linear Motion

To drive a tool along a specified path, a machining system must often co-ordinate the motion of several axes. We use the term "coordinated linear motion" to describe the situation in which, nominally, each axis moves at constant speed and all axes move from their starting positions to their end positions at the same time. If only the X, Y, and Z axes (or any one or two of them) move, this produces motion in a straight line, hence the word "linear" in the term. In actual motions, it is often not possible to maintain constant speed because acceleration or deceleration is required at the beginning and/or end of the motion. It is feasible, however, to control the axes so that, at all times, each axis has completed the same fraction of its required motion as the other axes. This moves the tool along the same path, and we also call this kind of motion coordinated linear motion.

Co-ordinated linear motion can be performed either at the prevailing feed rate, or at rapid traverse rate. If physical limits on axis speed make the desired rate unobtainable, all axes are slowed to maintain the desired path.

1.6 Feed Rate

The rate at which the controlled point or the axes move is nominally a steady rate which may be set by the user. In the Interpreter, the interpretation of the feed rate is as follows unless inverse time feed rate (G93) mode is being used:

  • For motion involving one or more of the linear axes (X, Y, Z and optionally A, B, C), without simultaneous rotational axis motion, the feed rate means length units per minute along the programmed linear XYZ(ABC) path
  • For motion involving one or more of the linear axes (X, Y, Z and optionally A, B, C), with simultaneous rotational axis motion, the feed rate means length units per minute along the programmed linear XYZ(ABC) path combined with the angular velocity of the rotary axes multiplied by the appropriate axis Correction Diameter multiplied by pi (p = 3.14152...); i.e. the declared "circumference" of the part
  • For motion of one rotational axis with X, Y, and Z axes not moving, the feed rate means degrees per minute rotation of the rotational axis.
  • For motion of two or three rotational axes with X, Y, and Z axes not moving, the rate is applied as follows. Let dA, dB, and dC be the angles in degrees through which the A, B, and C axes, respectively, must move. Let D = sqrt (dA2+ dB2+ dC2). Conceptually, D is a measure of total angular motion, using the usual Euclidean metric. Let T be the amount of time required to move through D degrees at the current feed rate in degrees per minute. The rotational axes should be moved in coordinated linear motion so that the elapsed time from the start to the end of the motion is T plus any time required for acceleration or deceleration.

1.7 Arc Motion

Any pair of the linear axes (XY, YZ, and XZ) can be controlled to move in a circular arc in the plane of that pair of axes. While this is occurring, the third linear axis and the rotational axes can be controlled to move simultaneously at effectively a constant rate. As in coordinated linear motion, the motions can be coordinated so that acceleration and deceleration do not affect the path.

If the rotational axes do not move, but the third linear axis does move, the trajectory of the controlled point is a helix.

The feed rate during arc motion is as described in Feed Rate above. In the case of helical motion, the rate is applied along the helix. Beware as other interpretations are used on other systems.

1.8 Coolant

Flood coolant and mist coolant may each be turned on independently. They are turned off together.

1.9 Dwell

A machining system may be commanded to dwell (i.e., keep all axes unmoving) for a specific amount of time. The most common use of dwell is to break and clear chips or for a spindle to get up to speed. The units in which you specify Dwell are either seconds or Milliseconds depending on the setting on Configure>Logic.

1.10 Units

Units used for distances along the X, Y, and Z axes may be measured in millimeters or inches. Units for all other quantities involved in machine control cannot be changed.

Different quantities use different specific units. Spindle speed is measured in revolutions per minute. The positions of rotational axes are measured in degrees. Feed rates are expressed in current length units per minute or in degrees per minute, as described above.

Carefully check the system's response to changing units while tool and fixture offsets are loaded into the tables, while these offsets are active and/or while a part program is executing

 

 

WARNING
Changing units during a file can cause the machine to move unexpectedly causing INJURY, PROPERTY DAMAGE, or DEATH

 

1.11 Current Position

The controlled point is always at some location called the "current position" and Mach3 always knows where that is. The numbers representing the current position are adjusted in the absence of any axis motion if any of several events take place:

  • Length units are changed (but see Warning above)
  • Tool length offset is changed
  • Coordinate system offsets are changed.

1.12 Selected Plane

There is always a "selected plane", which must be the XY-plane, the YZ-plane, or the XZ-plane of the machining system. The Z-axis is, of course, perpendicular to the XY-plane, the X-axis to the YZ-plane, and the Y-axis to the XZ-plane.

1.13 Tool Table

Zero or one tool is assigned to each slot in the tool table.

1.14 Tool Change

Mach3 allows you to implement a procedure for implementing automatic tool changes using macros or to change the tools by hand when required.

1.15 Pallet Shuttle

Mach3 allows you to implement a procedure for implementing pallet shuttle using macros.

1.16 Path Control Modes

The machining system may be put into any one of two path control modes:

(1) Exact stop mode, (2) constant velocity mode. In exact stop mode, the machine stops briefly at the end of each programmed move. In constant velocity mode, sharp corners of the path may be rounded slightly so that the feed rate may be kept up. These modes are to allow the user to control the compromise involved in turning corners because a real machine has a finite acceleration due to the inertia of its mechanism.

Exact Stop does what it says. The machine will come to rest at each change of direction and the tool will therefore precisely follow the commanded path.

Constant Velocity will overlap acceleration in the new direction with deceleration in the current one in order to keep the commanded feedrate. This implies a rounding of any corner but faster and smoother cutting. This is particularly important in routing and plasma cutting. G and M-code reference

The lower the acceleration of the machine axes, the greater will be the radius of the rounded corner.

In Plasma mode (set on Configure Logic dialog) the system uses a proprietary algorithm to optimize motion around corners for plasma cutting.

It is also possible to define a limiting angle so that changes in direction of more than this angle will always be treated as Exact Stop even though Constant Velocity is selected. This allows gentle corners to be smoother but avoids excessive rounding of sharp corners even on machines with low acceleration on one or more axes. This feature is enabled in the Configure Logic dialog and the limiting angle is set by a DRO. This setting will probably need to be chosen experimentally depending on the characteristics of the machine tool and, perhaps, the tool path of an individual job.

2 Interpreter Interaction with Controls

2.1 Feed and Speed Override Controls

Mach3 commands which enable (M48) or disable (M49) the feed and speed override switches. It is useful to be able to override these switches for some machining operations. The idea is that optimal settings have been included in the program, and the operator should not change them.

2.2 Block Delete control

If the block delete control is ON, lines of code which start with a slash (the block delete character) are not executed. If the switch is off, such lines are executed.

2.3 Optional Program Stop Control

The optional program stop control (see Configure>Logic) works as follows. If this control is ON and an input line contains an M1 code, program execution is stopped at the end on the commands on that line until the Cycle Start button is pushed.

3 Tool File

Mach3 maintains a tool file for each of the 254 tools which can be used.

Each data line of the file contains the data for one tool. This allows the definition of the tool length (Z axis), tool diameter (for milling) and tool tip radius (for turning).

4 The Language of Part Programs

4.1 Overview

The language is based on lines of code. Each line (also called a "block") may include commands to the machining system to do several different things. Lines of code may be collected in a file to make a program.

A typical line of code consists of an optional line number at the beginning followed by one or more "words." A word consists of a letter followed by a number (or something that evaluates to a number). A word may either give a command or provide an argument to a command. For example, G1 X3 is a valid line of code with two words. "G1" is a command meaning "move in a straight line at the programmed feed rate," and "X3" provides an argument value (the value of X should be 3 at the end of the move). Most commands start with either G or M (for General and Miscellaneous). The words for these commands are called "G codes" and "M codes."

The language has two commands (M2 or M30), either of which ends a program. A program may end before the end of a file. Lines of a file that occur after the end of a program are not to be executed in the normal flow so will generally be parts of subroutines.

Parameter
Number

Meaning

Parameter
Number

Meaning

5161

G28 home X

5264

Work offset 3 A

5162

G28 home Y

5265

Work offset 3 B

5163

G28 home Z

5266

Work offset 3 C

5164

G28 home A

5281

Work offset 4 X

5165

G28 home B

5282

Work offset 4 Y

5166

G28 home C

5283

Work offset 4 Z

5181

G30 home X

5284

Work offset 4 A

5182

G30 home Y

5285

Work offset 4 B

5183

G30 home Z

5286

Work offset 4 C

5184

G30 home A

5301

Work offset 5 X

5185

G30 home B

5302

Work offset 5 Y

5186

G30 home C

5303

Work offset 5 Z

5211

G92 offset X

5304

Work offset 5 A

5212

G92 offset Y

5305

Work offset 5 B

5213

G92 offset Z

5306

Work offset 5 C

5214

G92 offset A

5321

Work offset 6 X

5215

G92 offset B

5322

Work offset 6 Y

5216

G92 offset C

5323

Work offset 6 Z

5220

Current Work Offset Number

5324

Work offset 6 A

5221

Work offset 1 X

5325

Work offset 6 B

5222

Work offset 1 Y

5326

Work offset 6 C

5223

Work offset 1 Z

And so on every 20 values until

5224

Work offset 1 A

10281

Work offset 254 X

5225

Work offset 1 B

10282

Work offset 254 Y

5226

Work offset 1 C

10283

Work offset 254 Z

5241

Work offset 2 X

10284

Work offset 254 A

5242

Work offset 2 Y

10285

Work offset 254 B

5243

Work offset 2 Z

10286

Work offset 254 C

5244

Work offset 2 A

10301

Work offset 255 X

5245

Work offset 2 B

10302

Work offset 255 Y

5246

Work offset 2 C

10303

Work offset 255 Z

5261

Work offset 3 X

10304

Work offset 255 A

5262

Work offset 3 Y

10305

Work offset 255 B

5263

Work offset 3 Z

10306

Work offset 255 C

 

4.2 Parameters

A Mach3 machining system maintains an array of 10,320 numerical parameters. Many of them have specific uses. The parameters which are associated with fixtures are persistent over time. Other parameters will be undefined when Mach3 is loaded. The parameters are preserved when the interpreter is reset. The parameters with meanings defined by Mach3 are given in figure 10.1

Figure 10.1 - System defined parameters G and M-code reference

4.3 Coordinate Systems

The machining system has an absolute coordinate system and 254 work offset (fixture) systems.

You can set the offsets of tools by G10 L1 P~ X~ Z~. The P word defines the tool offset number to be set.

You can set the offsets of the fixture systems using G10 L2 P~ X~ Y~ Z~ A~ B~ C~.

The P word defines the fixture to be set. The X, Y, Z etc. words are the coordinates for the origin of for the axes in terms of the absolute coordinate system.

You can select one of the first seven work offsets by using G54, G55, G56, G57, G58, and G59.

Any of the 255 work offsets can be selected by G59 P~ (e.g. G59 P23 would select fixture 23). The absolute coordinate system can be selected by G59 P0.

You can offset the current coordinate system using G92 or G92.3. This offset will then be applied on top of work offset coordinate systems. This offset may be cancelled with G92.1 or G92.2.

 You can make straight moves in the absolute machine coordinate system by using G53 with either G0 or G1.

Letter

Meaning

A

A-axis of machine

B

B-axis of machine

C

C-axis of machine

D

Tool Radius Compensation Number

F

Feedrate

G

General Function

H

Tool Length Offset Index

I

X-Axis Offset for Arcs

X Offset in G87 Canned Cycle

J

Y-Axis Offset for Arcs

Y Offset in G87 Canned Cycle

K

Z-Axis Offset for Arcs

Z Offset in G87 Canned Cycle

L

Number of Repetitions in Canned Cycles/Sub-Routines Key Used with G10

M

Miscellaneous Function

N

Line Number

O

Subroutine Label Number

P

Dwell Time in Canned Cycles

Dwell Time with G4
Key Used with G10

Q

Feed Increment in G83 Canned Cycle

Repetitions of Sub-Routine Call

R

Arc Radius
Canned Cycle Retract Level

S

Spindle Speed

T

Tool Selection

U

Synonymous with A

V

Synonymous with B

W

Synonymous with C

X

X-Axis of Machine

Y

Y-Axis of Machine

Z

Z-Axis of Machine

Figure 1 - Word Initial Letters for G-Codes

5 Format of a Line

A permissible line of input code consists of the following, in order, with the restriction that there is a maximum (currently 256) to the number of characters allowed on a line.

  • An optional block delete character ("/”).
  • An optional line number.
  • Any number of words, parameter settings, and comments.
  • An end of line marker (carriage return or line feed or both).

Any input not explicitly allowed is illegal and will cause the Interpreter to signal an error or to ignore the line.

Spaces and tabs are allowed anywhere on a line of code and do not change the meaning of the line, except inside comments. This makes some strange-looking input legal. For example, the line “G0 X+0.1234 Y7” is equivalent to “G0 X+0.1234 Y7”.

Blank lines are allowed in the input. They will be ignored.

Input is case insensitive, except in comments, i.e., any letter outside a comment may be in upper or lower case without changing the meaning of a line.

5.1 Line Number

A line number is the letter N followed by an integer (with no sign) between 0 and 99999 written with no more than five digits (000009 is not OK, for example). Line numbers may be repeated or used out of order, although normal practice is to avoid such usage. A line number is not required to be used (and this omission is common) but it must be in the proper place if it is used.

5.2 Subroutine Labels

A subroutine label is the letter O followed by an integer (with no sign) between 0 and 99999 written with no more than five digits (000009 is not permitted, for example).

Subroutine labels may be used in any order but must be unique in a program although violation of this rule may not be flagged as an error. Nothing else except a comment should appear on the same line after a subroutine label.

5.3 Word

A word is a letter other than N or O followed by a real value.

Words may begin with any of the letters shown in figure 11.2. The table includes N and O for completeness, even though, as defined above, line numbers are not words. Several letters (I, J, K, L, P, and R) may have different meanings in different contexts.

A real value is some collection of characters that can be processed to come up with a number. A real value may be an explicit number (such as 341 or -0.8807), a parameter value, an expression, or a unary operation value. Definitions of these follow immediately.

Processing characters to come up with a number is called "evaluating". An explicit number evaluates to itself.

5.3.1 Number

The following rules are used for (explicit) numbers. In these rules a digit is a single character between 0 and 9.

  • A number consists of (1) an optional plus or minus sign, followed by (2) zero to many digits, followed, possibly, by (3) one decimal point, followed by (4) zero to many digits - provided that there is at least one digit somewhere in the number. G and M-code reference
  • There are two kinds of numbers: integers and decimals. An integer does not have a decimal point in it; a decimal does.
  • Numbers may have any number of digits, subject to the limitation on line length. Only about seventeen significant figures will be retained, however (enough for all known applications).
  • A non-zero number with no sign as the first character is assumed to be positive.

Notice that initial (before the decimal point and the first non-zero digit) and trailing (after the decimal point and the last non-zero digit) zeros are allowed but not required. A number written with initial or trailing zeros will have the same value when it is read as if the extra zeros were not there.

Numbers used for specific purposes by Mach3 are often restricted to some finite set of values or some to some range of values. In many uses, decimal numbers must be close to integers; this includes the values of indexes (for parameters and carousel slot numbers, for example), M codes, and G codes multiplied by ten. A decimal number which is supposed be close to an integer is considered close enough if it is within 0.0001 of an integer.

5.3.2 Parameter Value

A parameter value is the hash character # followed by a real value. The real value must evaluate to an integer between 1 and 10320. The integer is a parameter number, and the value of the parameter value is whatever number is stored in the numbered parameter.

The # character takes precedence over other operations, so that, for example, #1+2 means the number found by adding 2 to the value of parameter 1, not the value found in parameter 3. Of course, #[1+2] does mean the value found in parameter 3. The # character may be repeated; for example ##2 means the value of the parameter whose index is the (integer) value of parameter 2.

5.3.3 Expressions and Binary Operations

An expression is a set of characters starting with a left bracket “[“ and ending with a balancing right bracket "]". In between the brackets are numbers, parameter values, mathematical operations, and other expressions. An expression may be evaluated to produce a number. The expressions on a line are evaluated when the line is read, before anything on the line is executed. An example of an expression is:

[1+acos[0]-[#3**[4.0/2]]]

Binary operations appear only inside expressions. Nine binary operations are defined. There are four basic mathematical operations: addition (+), subtraction (-), multiplication (*), and division (/). There are three logical operations: non-exclusive or (OR), exclusive or (XOR), and logical and (AND). The eighth operation is the modulus operation (MOD). The ninth operation is the "power" operation (**) of raising the number on the left of the operation to the power on the right.

The binary operations are divided into three groups. The first group is: power. The second group is: multiplication, division, and modulus. The third group is: addition, subtraction, logical non-exclusive or, logical exclusive or, and logical and. If operations are strung together (for example in the expression [2.0/3*1.5-5.5/11.0]), operations in the first group are to be performed before operations in the second group and operations in the second group before operations in the third group. If an expression contains more than one operation from the same group (such as the first / and * in the example), the operation on the left is performed first. Thus, the example is equivalent to: [((2.0/3)*1.5)-(5.5/11.0)] which simplifies to [1.0-0.5] which is 0.5.

The logical operations and modulus are to be performed on any real numbers, not just on integers. The number zero is equivalent to logical false, and any non-zero number is equivalent to logical true.

5.3.4 Unary Operation Value

A unary operation value is either "ATAN" followed by one expression divided by another expression (for example ATAN[2]/[1+3]) or any other unary operation name followed by an expression (for example SIN[90]). The unary operations are: ABS (absolute value), ACOS (arc cosine), ASIN (arc sine), ATAN (arc tangent), COS (cosine), EXP (e raised to the given power), FIX (round down), FUP (round up), LN (natural logarithm), ROUND (round to the nearest whole number), SIN (sine), SQRT (square root), and TAN (tangent). Arguments to unary operations which take angle measures (COS, SIN, and TAN) are in degrees. Values returned by unary operations which return angle measures (ACOS, ASIN, and ATAN) are also in degrees.

The FIX operation rounds towards the left (less positive or more negative) on a number line, so that FIX[2.8]=2 and FIX[-2.8]=-3, for example. The FUP operation rounds towards the right (more positive or less negative) on a number line; FUP[2.8]=3 and FUP[-2.8]=-2, for example.

5.4 Parameter Setting

A parameter setting is the following four items one after the other:

  • A pound character #
  • A real value which evaluates to an integer between 1 and 10320,
  • An equal sign = , and
  • A real value. For example "#3 = 15" is a parameter setting meaning "set parameter 3 to 15."

A parameter setting does not take effect until after all parameter values on the same line have been found. For example, if parameter 3 has been previously set to 15 and the line #3=6 G1 x#3 is interpreted, a straight move to a point where x equals 15 will occur and the value of parameter 3 will be 6.

5.5 Comments and Messages

A line that starts with the percent character, %, is treated as a comment and not interpreted in any way.

Printable characters and white space inside parentheses is a comment. A left parenthesis always starts a comment. The comment ends at the first right parenthesis found thereafter. Once a left parenthesis is placed on a line, a matching right parenthesis must appear before the end of the line. Comments may not be nested; it is an error if a left parenthesis is found after the start of a comment and before the end of the comment. Here is an example of a line containing a comment: G80 M5 (stop motion)

An alternative form of comment is to use the two characters.

// This is treated as a comment

Comments do not cause the machining system to do anything.

A comment that is included in parentheses, contains a message if MSG, appears after the left parenthesis and before any other printing characters. Variants of MSG, which include white space and lower case characters, are allowed. Note that the comma which is required. The rest of the characters before the right parenthesis are considered to be a message to the operator. Messages are displayed on screen in the "Error" intelligent label.

5.6 Item Repeats

A line may have any number of G words, but two G words from the same modal group may not appear on the same line.

A line may have zero to four M words. Two M words from the same modal group may not appear on the same line.

If a parameter setting of the same parameter is repeated on a line, #3=15 #3=6, for example, only the last setting will take effect. It is silly, but not illegal, to set the same parameter twice on the same line.

If more than one comment appears on a line, only the last one will be used; each of the other comments will be read and its format will be checked, but it will be ignored thereafter. It is expected that putting more than one comment on a line will be very rare.

5.7 Item Order

The three types of item whose order may vary on a line (as given at the beginning of this section) are word, parameter setting, and comment. Imagine that these three types of item are divided into three groups by type.

The first group (the words) may be reordered in any way without changing the meaning of the line.

If the second group (the parameter settings) is reordered, there will be no change in the meaning of the line unless the same parameter is set more than once. In this case, only the last setting of the parameter will take effect. For example, after the line #3=15 #3=6 has been interpreted, the value of parameter 3 will be 6. If the order is reversed to #3=6 #3=15 and the line is interpreted, the value of parameter 3 will be 15.

If the third group (the comments) contains more than one comment and is reordered, only the last comment will be used.

If each group is kept in order or reordered without changing the meaning of the line, then the three groups may be interleaved in any way without changing the meaning of the line. For example:

g40 g1 #3=15 (so there!) #4=-7.0

This line has five items and means exactly the same thing in any of the 120 possible orders - such as:

#4=-7.0 g1 #3=15 g40 (so there!)

5.8 Commands and Machine Modes

Mach3 has many commands which cause a machining system to change from one mode to another, and the mode stays active until some other command changes it implicitly or explicitly. Such commands are called "modal". For example, if coolant is turned on, it stays on until it is explicitly turned off. The G codes for motion are also modal. If a G1 (straight move) command is given on one line, for example, it will be executed again on the next line if one or more axis words is available on the line, unless an explicit command is given on that next line using the axis words or cancelling motion.

"Non-modal" codes have effect only on the lines on which they occur. For example, G4 (dwell) is non-modal.

6 Modal Groups

Modal commands are arranged in sets called "modal groups", and only one member of a modal group may be in force at any given time. In general, a modal group contains commands for which it is logically impossible for two members to be in effect at the same time - like measure in inches vs. measure in millimeters. A machining system may be in many modes at the same time, with one mode from each modal group being in effect. The modal groups are shown below.

The modal Groups for G codes are:

·         Group 1 = {G00, G01, G02, G03, G38.2, G80, G81, G82, G84, G85, G86, G87, G88, G89} motion

·         Group 2 = {G17, G18, G19} plane selection

·         Group 3 = {G90, G91} distance mode

·         Group 5 = {G93, G94} feed rate mode

·         Group 6 = {G20, G21} units

·         Group 7 = {G40, G41, G42} cutter radius compensation

·         Group 8 = {G43, G49} tool length offset

·         Group 10 = {G98, G99} return mode in canned cycles

·         Group 12 = {G54, G55, G56, G57, G58, G59, G59.xxx} coordinate system selection

·         Group 13 = {G61, G61.1, G64} path control mode

In addition to the above modal groups, there is a group for non-modal

G codes:

·         Group 0 = {G4, G10, G28, G30, G53, G92, G92.1, G92.2, G92.3}

Figure 2 - Modal Groups

For several modal groups, when a machining system is ready to accept commands, one member of the group must be in effect. There are default settings for these modal groups. When the machining system is turned on or otherwise re-initialized, the default values are automatically in effect.

Group 1, the first group on the table, is a group of G codes for motion. One of these is always in effect. That one is called the current motion mode.

It is an error to put a G-code from group 1 and a G-code from group 0 on the same line if both of them use axis words. If an axis word-using G-code from group 1 is implicitly in effect on a line (by having been activated on an earlier line), and a group 0 G-code that uses axis words appears on the line, the activity of the group 1 G-code is suspended for that line. The axis word-using G-codes from group 0 are G10, G28, G30, and G92. Mach3 displays the current mode at the top of each screen.

8 Macro M-Codes

8.1 Macro Overview

If any M-code is used which is not in the above list of built-in codes then Mach3 will attempt to find a file named "Mxx.M1S" in the Macros folder. If it finds the file then it will execute the VB script program it finds within it.

The Operator>Macros menu item displays a dialog which allows you to see the currently installed macros, to Load, Edit and Save or Save As the text. The dialog also has a Help button which will display the VB functions which can be called to control Mach3. For example you can interrogate the position of axes, move axes, interrogate input signals and control output signals.

New macros can be written using an external editor program like Notepad and saved in the Macros folder or you can load an existing macro within Mach3, totally rewrite it and save it with a different file name.

8.2 List of M-Codes

Mach3 supports the following M-Codes.

M-Code

Functions

M0

Program stop

M1

Optional program stop

M3/M4

Rotate spindle clockwise/counterclockwise

M5

Stop spindle rotation

M6

Tool change (by two macros)

M7

Mist on

M8

Flood on

M9

Mist & flood off

M30

Program end and rewind

M47

Repeat program from first line

M48

Enable speed and feed override

M98

Call subroutine

M99

Return from subroutine/repeat

 

MachMotion has created the following custom M-Codes for controlling outputs.

Custom M-Code

Functions

M200

Output 5 on

M201

Output 5 off

M202

Output 6 on

M203

Output 6 off

M204

Output 7 on

M205

Output 7 off

M206

Output 8 on

M207

Output 8 off

M208

Output 9 on

M209

Output 9 off

M210

Output 10 on

M211

Output 10 off

M212

Output 11 on

M213

Output 11 off

M214

Output 12 on

M215

Output 12 off

 

9 Other Input Codes

9.1 Set Feed Rate – F

To set the feed rate, program F~.

Depending on the setting of the Feed Mode toggle the rate may be in units/minute or units/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.

9.2 Set Spindle Speed – S

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.

9.3 Select Tool – T

To select a tool, program T~ where the T number is the slot number in the tool changer (of course a rack for manual changing) for the tool.

Even if you have an automatic tool changer, the tool is not changed automatically by the T word (to do this use M06). The T word just allows the changer to get the tool ready.

M06 (depending on the settings in Config>Logic) will operate the tool changer or stop execution of the part-program so you can change the tool by hand. The detailed execution of these changes is set in the M6Start and M6End macros. If you require anything special you will have to customize these.

The T word, itself, does not actually apply any offsets. Use G43 or G44, q.v., to do this. The H word in G43/G44 specifies which tool table entry to use to get the tool offset. Notice that this is different to the action when you type a tool slot number into the T DRO. In this case an implied G43 is performed so the length offset for the tool will be applied assuming that the slot number and the tool table entry number are the same.

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.

10 Error Handling

This section describes error handling in Mach3.

If a command does not work as expected or does not do anything check that you have typed it correctly. Common mistakes are GO, instead of G0 i.e. letter O instead of zero) and too many decimal points in numbers. Mach3 does not check for axis over travel (unless software limits are in use) or excessively high feeds or speeds. Nor does it does not detect situations where a legal command does something unfortunate, such as machining a fixture.

11 Order of Execution

The order of execution of items on a line is critical to safe and effective machine operation. Items are executed in the order shown in Figure 3 if they occur on the same line.

Order

Item

1

Comment (including message)

2

Set feed rate mode (G93, G94, G95)

3

Set feed rate (F)

4

Set spindle speed (S)

5

Select tool

6

Tool change (M6) and Execute M-code macros

7

Spindle On/Off (M3, M4, M5)

8

Coolant On/Off (M7, M8, M9)

9

Enable/disable overrides (M48, M49)

10

Dwell (G4)

11

Set active plane (G17, G18, G18)

12

Set length units (G20, G21)

13

Cutter radius compensation On/Off (G40, G41, G42)

14

Tool table offset On/Off (G43, G49)

15

Fixture table select (G54 - G58 & G59 P~)

16

Set path control mode (G61, G61.1, G64)

17

Set distance mode (G90, G91)

18

Set canned cycle return level mode (G98, G99)

19

Home, or change coordinate system data (G10), or set offsets (G92,G94)

20

Perform motion (G0 to G3, G12, G13, G80 to G89 as modified by G53

21

Stop or repeat (M0, M1, M2, M30, M47, M99)

Figure 3 - Order of Execution on a Line

 

12 G-Codes

G00 Rapid Move

  • For rapid linear motion, program G0 X~ Y~ Z~ A~ B~ C~, where all the axis words are optional, except that at least one must be used. The G0 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 G0 command is executing.
  • 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.

 

It is an error if: 

  • All axis words are omitted

 

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.

G01 Linear Move

  • For linear motion at feed rate (for cutting or not), program G1 X~ Y~ Z~ A~ B~ C~, where all the axis words are optional, except that at least one must be used. The G1 is optional if the current motion mode is G1. This will produce co-ordinated linear motion to the destination point at the current feed rate (or slower if the machine will not go that fast).
  • 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 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.

 

It is an error if:

  • All axis words are omitted

 

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.

G02 & G03 Arc Move

A circular or helical arc is specified using either G2 (clockwise arc) or G3 (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.

 

Two formats are allowed for specifying an arc. We will call these the center format and the radius format. In both formats the G2 or G3 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 G2 X~ Y~ Z~ A~ B~ C~ R~ (or use G3 instead of G2). 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
  • 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 G2 X10 Y15 R20 Z5

 

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=10, Y=15, and Z=5, with a radius of 20. If the starting value of Z is 5, this is an arc of a circle parallel to the XY-plane; otherwise it is a helical arc.

 

Arc Center Format

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 mm (if mm 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 Configure>State… menu when Mach3 is set up. The choice of modes are 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~ B~ C~ 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 G2 X~ Y~ Z~ A~ B~ C~ I~ K~ (or use G3 instead of G2). 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 G2 X~ Y~ Z~ A~ B~ C~ J~ K~ (or use G3 instead of G2). 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 G2 X10 Y16 I3 J4 Z9

 

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=10, Y=16, and Z=9, with its center offset in the X direction by 3 units from the current X location and offset in the Y direction by 4 units from the current Y location. If the current location has X=7, Y=7 at the outset, the center will be at X=10, Y=11. If the starting value of Z is 9, this is a circular arc; otherwise it is a helical arc. The radius of this arc would be 5.

 

The above arc in Absolute IJ mode would be:

 

G17 G2 X10 Y16 I10 J11 Z9

 

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.

G4 Dwell

For a dwell, program G4 P~. This will keep the axes unmoving for the period of time in seconds or milliseconds specified by the P number. The time unit to be used is set up on the Config>Logic dialog. For example, with units set to Seconds, G4 P0.5 will dwell for half a second.

 

It is an error if:

  • The P number is negative

G10 Tool Offset and Work Offset Tables

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 - 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~ B~ C~, 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 & G13 CW/CCW Circular Pocket

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 if 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 & G16 Exit and Enter Polar Mode

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. Use G16 to enter this mode. The current coordinates of the controlled point are the temporary center.

 

Use G15 to revert to normal Cartesian coordinates:

 

G0 X10 Y10 // Normal G0 move to 10, 10

G16        // Start of polar mode

G10 X10 Y45

(This will move to X 17.xxx, Y 17.xxx which is a spot on a circle)

(of radius 10 at 45 degrees from the initial coordinates of 10,10.)

 

This can be very useful, for example, for drilling a circle of holes. The code below moves to a circle of holes every 10 degrees on a circle of radius 50 mm center X = 10, Y = 5.5 and peck drills to Z = -0.6.

 

G21        // Metric

G00 X10 Y5.5

G16

G01 X50 Y0 // Polar move to a radius of 50 angle 0deg

G83 Z-0.6  // Peck drill

G01 Y10    // Ten degrees from original center...

G83 Z-0.6

G01 Y20    // 20 degrees....etc...

G01 Y30

G01 Y40

> ...etc....

G15        // Back to normal Cartesian

 

Notes:

  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 & G19 Plane Selection

Use G17 to select the XY-plane, G18 to select the XZ-plane, or G19 to select the YZ-plane. The effects of having a plane selected are discussed in under G02/03 and canned cycles

G20 & G21 Unit Selection

Command G20 or G21 to use inches or millimeters respectively for length units. It is usually a good idea to command 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. See also G70/G71 which are synonymous.

G28 & G30 Return to Home

A home position is defined by parameters 5161-5166 for G28 and 5181-5186 for G30. 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 commanded position, program G28 X~ Y~ Z~ A~ B~ C~ (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 commanded, the intermediate point is the current point, so only one move is made. Note: G28 / G30 should not be on the same line as a G90 or G91.

G28.1 Reference Axis

Program G28.1 X~ Y~ Z~ A~ B~ C~ to reference the given axes. The axes will move at the current feed rate towards the home switches, 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 switches. Note: G28.1 should not be on the same line as a G90 or G91.

G31 Straight Probe

The Straight Probe Command

Program G31 X~ Y~ Z~ A~ B~ C~ 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.254 mm or 0.01 inches 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, it is retracted slightly from the trip point at the end of command execution. If the probe does not trip even after overshooting the programmed point slightly, an error is signaled.

 

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 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.)

 

Using the Straight Probe Command

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 Mach3 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 Code

As a usable example, the code for finding the center and diameter of a circular hole is shown below. 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)

 

Figure 4 - Code to Probe Hole

In the above figure an entry of the form <description of 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 & G42 Cutter Comp

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 of Cutter Compensation. Notice the importance of programming valid entry and exit moves.

G43, G44 & G49 Tool Length Offsets

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. It is OK for the H number to 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.

G50 & G51 Scale Factor

To define a scale factor which will be applied to an X, Y, Z, A, B, C, I & J word before it is used program G51 X~ Y~ Z~ A~ B~ C~ 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 Coordinate System Offset

To offset the current point by a given positive or negative distance (without motion), program G52 X~ Y~ Z~ A~ B~ C~, 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 Mach3 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,  hen 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 ABS Coordinates

Absolute machine coordinates: G53 - move in” For linear motion to a point expressed in absolute coordinates, program G1 G53 X~ Y~ Z~ A~ B~ C~ (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 co-ordinated 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-G59 and G59 P1-254 Work Offsets

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

G61 & G64 Path Control Mode

Command G61 or G64 to put the machining system into exact stop mode or constant velocity mode respectively. It is OK to program for the mode that is already active. These modes are described in detail above.

G68 & G69 Rotate Coordinate System

Program G68 A~ B~ I~ R~ to rotate the program coordinate system.

 

A~ is the X coordinate and B~ the Y coordinate of the center of rotation in the current coordinate system (i.e. including all work and tool offsets and G52/G92 offsets.)

 

R~ is the rotation angle in degrees (positive is CCW viewed from the positive Z direction).

 

I~ is optional and the value is not used. If I~ is present it causes the given R value to be added to any existing rotation set by G68.

 

E.g. G68 A12 B25 R45 causes the coordinate system to be rotated by 45 degrees about the point Z=12, Y=25.

 

Subsequently: G68 A12 B35 I1 R40 leaves the coordinate system rotated by 85 degrees about X = 12, Y=25.

 

Command G69 to cancel rotation.

Notes:

  1. This code only allows rotation when the current plane is X-Y
  2. The I word can be used even if the center point is different from that used before although, in this case, the results need careful planning. It could be useful when simulating engine turning.

G70 & G71 Units

Command G70 or G71 to use inches or millimeters respectively.

 

It is usually a good idea to program either G70 or G71 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. See also G20/G21 which are synonymous and preferred.

G73 High Speed Peck Drill

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. Command:

 

G73 X~ Y~ Z~ A~ B~ C~ R~ L~ Q~

 

  1. Preliminary motion, as described in G81 to 89 canned cycles
  2. Move the Z-axis only at the current feed rate downward by delta or to the Z position, whichever is less deep
  3. Rapid back out by the distance defined in the G73 Pullback DRO on the Settings screen
  4. Rapid back down to the current hole bottom, backed off a bit
  5. Repeat steps 1, 2, and 3 until the Z position is reached at step 1
  6. Retract the Z-axis at traverse rate to clear Z

 

It is an error if:

  • The Q number is negative or zero.

G80 Cancel Canned Cycles

Program G80 to ensure no axis motion will occur. 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.

G81 - G89 Canned Cycles

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, or 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 Drill Cycle

The G81 cycle is intended for drilling. Command G81 X~ Y~ Z~ A~ B~ C~ 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: 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

  1. 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)

G82 Drill Cycle with Dwell

The G82 cycle is intended for drilling. Command G82 X~ Y~ Z~ A~ B~ C~ 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

G83 Peck Drill Cycle

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. Command G83 X~ Y~ Z~ A~ B~ C~ 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
  • Retract the Z-axis at traverse rate to clear Z

 

It is an error if:

  • The Q number is negative or zero

G85 Boring or Reaming Cycle

The G85 cycle is intended for boring or reaming, but could be used for drilling or milling. Program

G85 X~ Y~ Z~ A~ B~ C~ 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 Boring Cycle

The G86 cycle is intended for boring. This cycle uses a P number for the number of seconds to dwell. Command G86 X~ Y~ Z~ A~ B~ C~ 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 Boring Cycle

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- B~ C~ 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 Boring Cycle

The G89 cycle is intended for boring. This cycle uses a P number, where P specifies the number of seconds to dwell. Command G89 X~ Y~ Z~ A~ B~ C~ 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

G90 & G91 Distance Mode

Interpretation of Mach3 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, B, and C) 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, B, and C) 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 in all but one usage (the G87 boring cycle), where the meaning changes with distance mode.

G90.1 & G91.1 Set IJ Arc Mode

Interpretation of the IJK values in G02 and G03 codes can be in one of two distance modes: absolute or incremental.

 

To go into absolute IJ mode, program G90.1. In absolute distance mode, IJK numbers represent absolute positions in terms of the currently active coordinate system.

 

To go into incremental IJ mode, program G91.1. In incremental distance mode, IJK numbers usually represent increments from the current controlled point.

 

Incorrect settings of this mode will generally result in large incorrectly oriented arcs in the tool path display.

G92, G92.1, G92.2 & G92.3 Offsets

 

ATTENTION

It is strongly advised not to use this legacy feature on any axis where there is another offset applied including cutter comp.

 

To make the current point have the coordinates you want (without motion), program G92 X~ Y~ Z~ A~ B~ C~, 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 Mach3 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 5216 are set to the X, Y, Z, A, B, and C-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 be 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 5216 to zero, whereas G92.2 leaves their current values alone.

 

To set the axis offset values to the values given in parameters 5211 to 5216, program G92.3

 

You can set axis offsets in one program and use the same offsets in another program. Command G92 in the first program. This will set parameters 5211 to 5216. 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.

G93 Inverse Time

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.

G94 Units per 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.

G98 & G99 Canned Cycle Return

When the spindle retracts during canned cycles, there is a choice of how far it retracts:

  • Retract perpendicular to the selected plane to the position indicated by the R word, or
  • 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 the first option, program G99 To use the second option, program G98 Remember that the R word has different meanings in absolute distance mode and incremental distance mode.

 

 

Mach3

Ultimate Screen Reference Guide

The ultimate screen was developed by and for MachMotion to be used with the Mach3 software from Artsoft. As of 2017 MachMotion only includes the Ultimate Screen on its waterjet controls.

Learn more about the Ultimate Screen from our Reference Guide:

File Type Document Name View / Download / Print
pdf-icon.png Ultimate Screen Reference Guide

 

 

Purchasing the Ultimate Screen Software:

In general we do not sell the ultimate screen for use with controls not purchased from MachMotion. However, on a case by case basis we can evaluate your situation and determine if it would be suitable and functional for your application. Contact MachMotion Support to inquire. There is a minimum cost of $250 and additional support and customization is charged at $125/hour.

Mach4

Mach4

Mach4 G-Code and M-Code Reference

__Use__MachMotion_Logo_HiRes_TransBG-update-01-450.png


1. Introduction

G-Code is a special programming language that is interpreted by Computer Numerical Control (CNC) machines to create motion and other tasks. It is a language that can be quite complex at times and can vary from machine to machine. The basics, however, are much simpler than it first appears and for the most part follows an industry adopted standard. Mach4 has made a large leap closer to this standard.

An important point to remember when reading this manual: In describing motion of a machine it will always be described as tool movement relative to the work piece. In many machines the work piece will move in more axes than the tool; however the program will always define tool movement around the work piece. Axis directions follow the right hand rule, see figure A.

 

Right-hand-rule.JPG

 

Glossary

Block

A single line of G-Code

Canned Cycle

Complex cycle defined by a single block of code, used to simplify programming

Dwell

Program pause with a duration defined by “P” in seconds. If “P” contains a decimal

point, the time is in seconds.

EOB

End of block. Required at the end of every block of G-Code. In Mach4 this is a

carriage return

Feedrate

Velocity, set by F, at which an axis will move

Group

Collection of G-Codes that control the same function or mode, i.e. G90 and G91

positioning modes

Modal

Active until a code from the same group is called

Normal

A line perpendicular to a plane, pointing in the positive direction.

Origin

Point in a coordinate system where X, Y and Z are zero

RPM

Revolutions per minute

UPM

Units per minute (inches, millimeters, degrees, etc)

Word

A single word of G-Code is a letter followed by a number. G01, X1.0, etc. are words

 

G

Preparatory function, G followed by a numerical code, specifies machining modes

and functions

M

Miscellaneous function, M followed by a numerical code, defines program flow and can control auxiliary functions such as coolant. Can also perform machine specific

functions and macros user or builder.

X, Y, Z, A, B, C

Movement commands followed by a numerical value, define the end point of a

motion command

S

Spindle speed, followed by numerical value of desired rpm or surface speed

T

Tool call, followed by next tool number to be used

H

Tool height offset to be used, generally matches the tool number

D

Tool diameter offset to be used, generally matches the tool number

F

Followed by a numerical value to define the feedrate. The magnitude and value of

which will be determined by the feed mode setting

P

Followed by a numerical value, specifies dwell time in milliseconds. (also used in

other functions) If the value contains a decimal point, the dwell time is in seconds.

N

Sequence numbers. Used for program organization and go to commands

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Format

In writing G-Code programs there are some rules to be aware of as well as some general formatting guidelines that should be followed or at least considered.

The first part of any program should be a safe start up block. This line of code is used to make sure that some modes are disabled and others are set to their most common setting. An example safe start block would look like this:

G00 G90 G17 G54 G40 G49 G80

This block of code tells the machine that we want to be in rapid mode and using absolute position in the XY plane of fixture offset 1. At the same time we want to cancel any tool diameter and length offsets and make sure any active canned cycles are cancelled.

G00 – Rapid mode

G90 – Absolute position mode G17 – XY plane select

G54 – Fixture offset 1

G40 – Cutter compensation (tool diameter) cancel G49 – Length offset cancel

G80 – Canned cycle cancel

Jumping to the end of the program there is not a lot required. Typically there will be a couple blocks of code to return the Z axis to the home position and maybe move the work piece closer to the operator for easier loading and unloading of parts. Shutting off the spindle and coolant or any other accessories is also a good idea here. The final block in a program is a program end code, most commonly M30 but there are other options. Make sure this final block is followed by an end of block. It is easy to forget this last EOB in a program for Mach because it is just a carriage return and not always readily apparent. One way to make sure that there is always an EOB on your program end block is to follow it with %. Like this:

.

.

. M30

%

This percent sign is a familiar symbol to CNC programmers in industry; however any symbol or character can be used as it will not be read by the control because of the program end before it. If there is no EOB following the percent sign it will not show up in the program when loaded into Mach.

In between the start and end is the body of the program. There are a few rules here. Each block of code will contain a combination of words. Multiple G-Codes can be specified in a single block, however if more than one from the same modal group is specified the last one in the block will be valid, with the exception of group 00. Modal G-Codes stay active until another from the same group is called. For example; G01 is modal so it is not necessary to put it in consecutive blocks. Once active every successive positioning block will be in the G1 mode unless another code from group one is called (G00, G02, G03, etc.). All G-Codes not in group 0 behave this way.

Only one M-Code can be specified in a single block. Same holds true for all other words.

Generally leading zeroes are not required in G-Code. For example G01 and G1 are the same. The same holds true for M-Codes, position commands, feedrates, etc. When specifying values for position, feedrate, variables, etc., it is good practice to always use a decimal point and trailing zero, instead of X1 use X1.0. Although the decimal point is not required (in Mach X1 = X1.0) it is HIGHLY recommended.

 2. G-Code List

Code

Group

Description

Modal

G00

1

Rapid Move

Y

G01

1

Linear Feed Move

Y

G02

1

Clockwise Arc Feed Move

Y

G03

1

Counter Clockwise Arc Feed Move

Y

G04

0

Dwell

N

G09

0

Exact stop

N

G10

0

Fixture and Tool Offset Setting

N

G12

1

Clockwise Circle

Y

G13

1

Counter Clockwise Circle

Y

G15

17

Polar Coordinate Cancel

Y

G16

17

Polar Coordinate

Y

G17

2

XY Plane Select

Y

G18

2

ZX Plane Select

Y

G19

2

YZ Plane Select

Y

G20

6

Inch

Y

G21

6

Millimeter

Y

G28

0

Zero Return

N

G30

0

2nd, 3rd, 4th Zero Return

N

G31

1

Probe function

N

G32

1

Threading*

N

G40

7

Cutter Compensation Cancel

Y

G40.1

18

Arc Type Cutter Compensation

Y

G40.2

18

Line Offset Type Cutter Compensation

Y

G41

7

Cutter Compensation Left

Y

G42

7

Cutter Compensation Right

Y

G43

8

Tool Length Offset + Enable

Y

G44

8

Tool Length Offset - Enable

Y

G49

8

Tool Length Offset Cancel

Y

G50

11

Cancel Scaling

Y

G51

11

Scale Axes

Y

G52

0

Local Coordinate System Shift

Y

G53

0

Machine Coordinate System

N

G54

14

Fixture Offset 1

Y

G54.1

14

Additional Fixture Offsets

Y

G55

14

Fixture Offset 2

Y

G56

14

Fixture Offset 3

Y

G57

14

Fixture Offset 4

Y

G58

14

Fixture Offset 5

Y

G59

14

Fixture Offset 6

Y

G60

0

Unidirectional Approach

N

G61

15

Exact Stop Mode

Y

G64

15

Cutting Mode (Constant Velocity)

Y

G65

0

Macro Call

N

G66

12

Macro Modal Call

Y

G67

12

Macro Modal Call Cancel

Y

G68

16

Coordinate System Rotation

Y

G69

16

Coordinate System Rotation Cancel

Y

G73

9

High Speed Peck Drilling

Y

G74

9

LH Tapping*

Y

G76

9

Fine Boring*

Y

G80

9

Canned Cycle Cancel

Y

G81

9

Hole Drilling

Y

G82

9

Spot Face

Y

G83

9

Deep Hole Peck Drilling

Y

G84

9

RH Tapping

Y

G84.2

9

RH Rigid Tapping*

Y

G84.3

9

LH Rigid Tapping*

Y

G85

9

Boring, Retract at Feed, Spindle On

Y

G86

9

Boring, Retract at Rapid, Spindle Off

Y

G87

9

Back Boring*

Y

G88

9

Boring, Manual Retract

Y

G89

9

Boring, Dwell, Retract at Feed, Spindle On

Y

G90

3

Absolute Position Mode

Y

G90.1

4

Arc Center Absolute Mode

Y

G91

3

Incremental Position Mode

Y

G91.1

4

Arc Center Incremental Mode

Y

G92

0

Local Coordinate System Setting

Y

G92.1

0

Local Coordinate System Cancel

Y

G93

5

Inverse Time Feed

Y

G94

5

Feed per Minute

Y

G95

5

Feed per Revolution*

Y

G96

13

Constant Surface Speed*

Y

G97

13

Constant Speed

Y

G98

10

Initial Point Return

Y

G99

10

R Point Return

Y

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

* Implementation based on machine and control configuration

G-Code Descriptions and Examples

Note: For clarity rotational moves have been omitted from this manual. All motion commands can also contain A, B, and/or C axis motion.

G00 –Rapid move:

Rapid moves are used to move from point to point in free space, not cutting material. These moves do not require a feed rate input as they take place at max velocity of the machine. In absolute position mode (G90) X, Y and Z define the end point of the move in the user coordinate system. In incremental position mode (G91) X, Y and Z define the distance and direction to move from the current position.

Format: G00 X Y Z

Example: Program a rapid move to X1.0, Y3.0

G0 G90 G54 G17 G40 G49 G80

Safe start line

T1 M6

Tool change

S2500 M3

Start spindle

G0 X1.0 Y3.0

Rapid to XY position

M30

Program end and rewind

 

G01 – Linear Feed Move:

Linear feed moves are point to point moves in a straight line at a federate specified by F. The moves are interpolated so all axes in motion reach the end point at the same time. In absolute position mode (G90) X, Y and Z define the end point of the move in the user coordinate system. In incremental position mode (G91) X, Y and Z define the distance and direction to move from the current position.

Format: G01 X Y Z F .

Example: Program a feed move from X1, Y3, to X10, Y-1 at a feedrate of 15 UPM.

G0 G90 G54 G17 G40 G49 G80

Safe start line

T1 M6

Tool change

S2500 M3

Start spindle

G94

Feed per minute mode

G0 X1.0 Y3.0

Rapid to XY position

G1 X10.0 Y-1.0 F15.0

Move to XY position at feedrate

M30

Program end and rewind

G02/G03 – Arc Feed Move:

Used to cut an arc at a federate specified by F. An arc is defined by its start and end points, its radius or center point, a direction, and a plane. Direction is determined by G02, clockwise, and G03, counterclockwise, when viewed from the plane’s positive direction (If XY plane is selected look down so that the X axis positive direction is pointing to the right, and the Y axis positive direction is pointing forward). See figure 2-1 for a graphic representation of the motion of a G02. The start point is the current position of the machine. Specify the end point with X, Y, and Z. The values input for the end point will depend on the current G90/G91 (abs/inc) setting of the machine. Only the two points in the current plane are required for an arc. Adding in the third point will create a helical interpolation.

Next is to specify the radius or the center point of the arc, only one or the other, not both.

  • To specify the radius, use R and input the actual radius of the desired arc, see Format 2. When an arc is created knowing only start and end points and a radius there are two possible solutions, an arc with a sweep less than 180° and one with sweep greater than 180°. The sign of the radius value, positive or negative, determines which arc will be cut, see figure 2-2. A positive value for R cuts an arc with sweep less than 180°. A negative value for R cuts an arc with sweep greater than 180°.

  • A more accurate and reliable way to define an arc is by specifying the center point, this is done with arguments I, J, and K, see Format 1. The center point must be defined in the current plane. I, J, and K correspond to X, Y, Z respectively; the current plane selection will determine which two are used. XY plane (G17) would use I and J for example. Mach has two settings for how I, J, and K should be specified, absolute and incremental. This setting can be changed by G-Code, G90.1 and G91.1, or in the general tab in the Mach configuration. This setting is independent of the G90/G91 setting. If arc center mode is set to incremental then I, J, K are the distance and direction from the start point to the center point of the arc. If arc center mode is set to absolute then I, J, K are the absolute position of the arc center point in the current user coordinate system.

Format 1: (G17) G02/03 X Y I J F (G18) G02/03 X Z I K F (G19) G02/03 Y Z J K F

Format 2: (G17) G02/03 X Y R F (G18) G02/03 X Z R F (G19) G02/03 Y Z R F

Example: Program an arc centered at 1.0, 0.0 in the XY plane with radius 2. Start point at 3.0,0.0 and sweep 90 degrees counter clockwise. Feedrate 10 UPM. (Arc center mode set to incremental)

Format 1:

G0 G90 G54 G17 G40 G49 G80

Safe start line

T1 M6

Tool change

S2500 M3

Start spindle

G0 X3.0 Y0.0

Position to X and Y start point

G43 H1 Z.5

Activate tool offset 1 and move to Z rapid plane

G94

Feed per minute mode

G1 Z0.0 F10.0

Z plunge at feedrate

G3 X1.0 Y2.0 I-2.0 J0.0 F10.0

Arc move

G0 Z.5

Retract Z to rapid plane

G0 G53 Z0.0

Return Z to home

M30

Program end and rewind

 

 

 

 

 

 

 

 

Format 2:

G0 G90 G54 G17 G40 G49 G80

Safe start line

T1 M6

Tool change

S2500 M3

Start spindle

G0 X3.0 Y0.0

Position to X and Y start point

G43 H1 Z.5

Activate tool offset 1 and move to Z rapid plane

G94

Feed per minute mode

G1 Z0.0 F10.0

Z plunge at feedrate

G3 X1.0 Y2.0 R2.0 F10.0

Arc move

G0 Z.5

Retract Z to rapid plane

G0 G53 Z0.0

Return Z to home

M30

Program end and rewind

 

 

 

 

 

 

 

 

 

 

A helical interpolation is defined very similar to an arc. The only difference is the addition of the third coordinate of the end point. This third coordinate will define the height of the helix. See the following format for what this looks like in the XY plane:

Format 1: (G17) G02/03 X Y Z I J F Format 2: (G17) G02/03 X Y Z R F

Example: Program a helix with radius 1.0 and center point 0.0, 0.0 in the X,Y plane, start point 0.0, .5, height 1.0 with initial Z at 0.0. Feedrate 10 UPM. Arc sweep should be 270° clockwise. See figure 2-2 for the tool path.

G0 G90 G54 G17 G40 G49 G80

Safe start line

T1 M6

Tool change

S2500 M3

Start spindle

G0 X0.0 Y.5

Position to X and Y start point

G43 H1 Z.5

Activate tool offset 1 and move to Z rapid plane

G94

Feed per minute mode

G1 Z0.0 F10.0

Z plunge at feedrate

G2 X-.5 Y0.0 Z-1.0 I0.0 J-.5 F10.0

Helical interpolation

G0 Z.5

Retract Z to rapid plane

G0 G53 Z0.0

Return Z to home

M30

Program end and rewind

G04 – Dwell:

A dwell is simply a pause in the program. The duration of the dwell is specified by P in milliseconds with no decimal point. If a decimal point is used, then P specifies seconds. No machine movement will take place during a dwell. No auxiliary codes will be turned off, i.e. if the spindle is on it will stay on, coolant will stay on, etc.

G04 P5 will wait 5 milliseconds. You MUST wait more than 1ms. For example, G04 P1 will not work.

G04 P5. will wait 5 seconds.

G04 P#VAR will always wait in milliseconds

Format: G04 P

Example: Program a 5 second dwell after positioning to X1.0, Z1.0 (using no decimal point to specify milliseconds).

G0 G54 G18 G40 G80

Safe start line

T0101

Tool change

S2500 M3

Start spindle

G0 X1.0 Z1.0

Rapid to XZ position

G4 P5000

Dwell for 5 seconds

M30

Program end and rewind

 

 

 

 

 

Example: Program a 5 second dwell after positioning to X1.0, Z1.0 (using decimal point to specify seconds).

G0 G54 G18 G40 G80

Safe start line

T0101

Tool change

S2500 M3

Start spindle

G0 X1.0 Z1.0

Rapid to XZ position

G4 P5.

Dwell for 5 seconds

M30

Program end and rewind

 

G09 – Exact Stop:

G09 is a non-modal exact stop. Machine accelerations cause corners to be slightly rounded; when a true sharp corner is required G09 should be used. Although similar to G61 in function, G09 is not modal while G61 is. When G09 is included in a movement block, axis motion is decelerated to the end point of motion and the position is checked to be exactly as specified. This position check at the end of the move ensures that the machine actually reaches the desired position before moving onto the next block.

Format: G01 G09 X Y F

Example: Program a 2.0 inch square centered at X0.0, Y0.0 with true sharp corners at X1.0, Y1.0 and X- 1.0, Y-1.0, feedrate 15.0 UPM

G0 G90 G54 G17 G40 G49 G80

Safe start line

T1 M6

Tool change

S2500 M3

Start spindle

G94

Feed per minute mode

G0 X-1.0 Y1.0

Rapid to XY position

G1 G9 X1.0 F15.0

Move to position at feedrate, exact stop active

Y-1.0

Move to position at feedrate

G9 X-1.0

Move to position at feedrate, exact stop active

Y1.0

Move to position at feedrate

M30

Program end and rewind

 

 

 

 

 

 

 

 

Figure 9-1 shows what this square would look like, slightly exaggerated.

Square-with-exact-stop-on-two-corners.JPG

G10 – Fixture and Tool Offset Setting:

It is possible to set fixture and tool offsets in the program. This can be very useful for programming multiple fixtures that have known zero points, multi pallet machines, applying automatic compensation of tool wear, and many other situations that require changing offset values. G10 is also one of the least understood G-Codes and is therefore underutilized. Changing offset values in a program requires a bit of cautiousness, a mistake can easily result in ruined parts and damaged tools. When used properly however, G10 can add flexibility and safety to a program and machine, especially with automation and lights out capacity or inexperienced operators.

Starting with fixture offset setting the G10 block will look like the following: Format: G10 L2 P X Y Z A B C

L selects the function of the G10 block, different values will have different functions. L2 is the designation for fixture offset setting. The value of P specifies which offset is being set. For the basic 6 fixture offsets P values are as follows:

Fixture offset (G )

P

54

1

55

2

56

3

57

4

58

5

                  59

6

 

 

 

 

 

The data for the fixture offset is set by X, Y, Z, A, B, C.

X

X axis offset

Y

Y axis offset

Z

Z axis offset

A

A axis offset

B

B axis offset

C

C axis offset

 

 

 

 

 

 

 

 

All values do not need to be specified, only the ones to be set. If, for example, a Z is not programmed it simply will not be changed in the fixture offset.

In G90, absolute, mode the values in the G10 line will be directly input into the fixture offset. When in G91, incremental, mode the values will be added to the desired fixture offset. This is a major difference in functionality and care should be taken to make sure the right mode is active for the desired effect.

Example: Set G56 fixture offset to X-8.0, Y-3.0, Z-5.0, A45.0 in a program.

G0 G90 G54 G17 G40 G49 G80

Safe start line

G10 L2 P3 X-8.0 Y-3.0 Z-5.0 A45.0

Set G56 fixture offset values

M30

Program end and rewind

 

 

 

Additional fixture offsets, G54.1 Pxx, can also be set using G10. Setting of these offsets is the same, except it is done using L20. The legacy additional fixture offsets (see fixture offset section of this manual for more details) can still be set with G10. The following table shows the additional fixture offset P number and its corresponding G10 P number as well as the legacy offsets. Note that G54.1 P1 is the same offset as G59 P7, so G10 L20 P1 and G10 L2 P7 both set the same offset values.

G54.1 P

G10 L20 P

Legacy G59 P

Legacy G10 L2 P

1

1

7

7

2

2

8

8

3

3

9

9

-

-

-

-

-

-

-

-

-

-

-

-

248

248

254

254

 

 

 

 

 

 

Example: Set G54.1 P5 fixture offset to X3.0, Y3.4, Z-10.0 in a program.

G0 G90 G54 G17 G40 G49 G80

Safe start line

G10 L20 P5 X3.0 Y3.4 Z-10.0

Set G54.1 P5 fixture offset values

M30

Program end and rewind

 

 

 

Work shift and head shift can also be set with G10. Work shift is set using G10 L2 P0. Head shift is set using G10 L20 P0. Notice the L20 for head shift. All other values are set in the same format as the other fixture offsets.

Tool offset setting requires just as much care as setting of fixture offsets. G90 and G91 affect the setting of offset values in the same way. G90 causes the current value to be over written with the value in the G10 block, while G91 adds the value from the G10 block to the current value.

Format: G10 L1 P Z W D R X U Y V Q

Again, not all values are required, if omitted that value simply will not be set. L1 specifies tool offset setting, P is again the offset number to be set (offset #1 = P1, offset #2 = P2, etc.). The remaining arguments specify the type and value of offset to be set.

Z

Height offset

W

Height wear offset

D

Diameter offset

R

Diameter wear offset

X*

X offset

U*

X wear offset

Y*

Y offset

V*

Y wear offset

Q

Tool pocket

 

 

 

 

 

 


*Future feature not yet implemented Example: Set height of tool offset #5 to 1.5. Add .05 to offset #2 diameter wear.

G0 G90 G54 G17 G40 G49 G80

Safe start line

G10 L1 P5 Z1.5

Set tool offset 5 height to 1.5

G91

Set incremental to add to offset

G10 L1 P2 R.05

Add .05 to tool offset #2 diameter wear

M30

Program end and rewind

 

G12/G13 – Circle Interpolation:

These codes are used to cut a circle using the current position as the center point. Words, I and J, define the radius of the circle and the lead-in direction. G12 will cut a circle in the clockwise direction and G13 will cut in the counterclockwise direction. It is also possible to cut a larger circular pocket by specifying Q for the start radius and P for the step over amount. This can be useful for cutting a circular pocket or an ID groove.

Format 1: G12/13 I J F Format 2: G12/13 I J P Q

See figure 12-1 for a graphic of the motion. The current position will be the center of the circle.

G12---G13-Circle-Interpolation.JPG

Figure 12-1: Tool motion during circle interpolation

Example: Cut a 1.0 inch radius circle centered at X1.5 Y0.25. Lead-in along the X axis.

G0 G90 G54 G17 G40 G49 G80

Safe start line, absolute mode, XY plane

G0 X1.5 Y.25

Move to initial position

G13 I1.0 F30.0

Cut circle

G0 G53 Z0.0

Z axis to machine zero

M30

Program end and rewind

 

 

 

 

Example: Cut the same circle but lead-in at 45°. (X=1*Cos(45°)=.7071, Y=1*Sin(45°)=.7071)

G0 G90 G54 G17 G40 G49 G80

Safe start line, absolute mode, XY plane

G0 X1.5 Y.25

Move to initial position

G13 I0.7071 J0.7071 F30.0

Cut circle

G0 G53 Z0.0

Z axis to machine zero

M30

Program end and rewind

 

G15/G16 – Polar Coordinates:

To enable polar coordinate positioning command G16 in a program. The setting is modal and will remain active until G15, polar coordinate cancel, is commanded or the system is reset. In the polar coordinate mode movement end points are specified as a radius and angle, the origin of which is determined by the absolute/incremental position mode setting (see G90/G91). In absolute position mode the origin for positioning is the zero point of the user coordinate system. In incremental position mode the origin is the current position.

Format: G16 X Y Z

The current plane setting determines which word is radius and which is angle.

G17 – XY Plane – X is radius, Y is angle G18 – ZX Plane – Z is radius, X is angle G19 – YZ Plane – Y is radius, Z is angle

Linear and arc moves can be programmed in the polar coordinate mode. When programming arc moves with G02 and G03 use R to specify the arc radius.

Example: See figure 15-1 for the tool path display of the following program.

G0 G90 G54 G17 G40 G49 G80

Safe start line, absolute mode, XY plane

G16

Enable polar coordinate mode

G0 X1.0 Y45.0

Move to radius 1 and 45° from origin

G3 X1.0 Y135.0 R0.75 F60.0

Arc move of radius .75, endpoint at radius 1.0

and angle 135°

G1 X2.25 Y180.0

Linear move to radius 2.25 angle 180°

G3 X2.25 Y0 R5.0

Arc move of radius 5., endpoint at radius 2.25,

angle 0

G1 X1.0 Y45.0

Linear move to radius 1.0, angle 45°

G15

Disable polar coordinate mode

G0 G53 Z0.0

Z axis to machine zero

M30

Program end and rewind

 

Tool-Path-of-Polar-Coordinate-Mode-Example.JPG

Figure 15-1: Tool path of polar coordinate mode example

G17/G18/G19 – Plane Selection:

Arcs, circles and drill cycles require the selection of a plane. The three axes X, Y and Z define three available planes XY, ZX, and YZ, see figure 17-1. The third axis defines the top of the plane, this axis is also known as the normal see figure 17-2. Selection of a plane is done by

specifying one of three G-Codes: G17 for XY, G18 for ZX and G19 for YZ. These are modal G-Codes and will stay active until another plane is selected or the system is reset. The default plane selection is G17.

All arc and circular motion will take place on a single plane. Direction of motion, clockwise or counterclockwise, is as viewed from the normal direction, see figure 17-2.

Canned drill cycles also require the selection of a plane. In this case all hole positions will be located in the selected plane and the normal axis will be the drilling axis. For example in the XY plane the Z axis is the drilling axis.

 

Planes.JPG

 

Figure 17-1: Planes

Plane-Orientation.JPG

Figure 17-2: Plane orientation

G20/G21 – Unit selection:

Programming units are selected using G20 for inch and G21 for millimeter. Use these G-Codes to specify the units in the program only; the setting will not affect Mach DRO’s, configuration settings, or offsets.

G28 – Zero Return:

This function is used to send one or more axes to the home position via an intermediate point. Exercise caution when using this function. If not fully understood the resulting

motion may differ greatly from what is expected. When used correctly the intermediate point can be useful for avoiding obstacles in the way of a direct path to the home position, see figure 28-1.

Zero-Return-Via-Intermediate-Point.JPG

Figure 28-1: Zero return via intermediate point

Format: G28 X Y Z A B C

This is not a modal code and will only be active in the block in which it is specified. Following the G28 are the axes to be sent home. For example, to send the Z axis back to the home position program: G28 Z0. The value specified with the axis letter specifies the intermediate point.

Look at an example program:

G0 G90 G54 G17 G40 G49 G80

Safe start line

G0 X1.0 Y.5 Z1.0

Rapid position to point

G28 Z0.0

Send Z axis home via point Z0

M30

Program end and rewind

 

 

 

 

Reading through the program there is a safe start up block that sets the machine to absolute position mode. The next line causes the machine to move to the point X1, Y.5, Z1. in the coordinate system set by the G54 fixture offset. Now for the G28 block. This line of code, G28 Z0, gives instructions to send the Z axis to the home position via the point Z0. The motion will be as follows: First the Z axis will plunge to the point Z0 then return to home. If not intended this motion could result in a broken tool or scrapped part. To avoid this unintended motion the common programming format is as follows:

G91 G28 Z0

In this case the intermediate point is an incremental move of 0 inches resulting in no motion before the Z axis returns home.

G30 – 2nd, 3rd, 4th Zero Return:

G30 functions the same way as G28, moving the machine to a zero return point via an intermediate point. However, instead of sending the machine to the home position, G30 movement ends at a user definable 2nd, 3rd, or 4th zero return point, specified by P2, P3, or P4 respectively. If P is omitted the 2nd zero return point is selected. This is handy for tool changers that are not located at the home position or any number of other applications.

Format: G30 P X Y Z A B C

The 2nd zero return point is defined by # variables as follows:

Axis

P2 # Variables

P3 # Variables

P4 # Variables

X

5301

5311

5321

Y

5302

5312

5322

Z

5303

5313

5323

A

5304

5314

5324

B

5305

5315

5325

C

5306

5316

5326

 

 

 

 

 

 

The position values in the # variables can be set in a program or in MDI mode.

G31/G31.X – Probe function: Also known as skip function, G31 allows the use of part and tool probes. Multiple probes can be used, G31 for probe 1, G31.1 probe 2, G31.2 probe 3 and G31.3 probe 4. Motion is defined along linear axes, in a similar format to G01, with a feedrate.

Format: G31 X Y Z F

The machine will move toward the specified end point, at the same time it is looking for the probe input to be activated. When the probe input is activated the current position is recorded to # variables according to the table below and motion is stopped. The recorded position can then be used to calculate tool offsets, work offsets, measure parts, etc.

Axis

G31 User Position

#Variables

G31 Machine

Position #Variables

X

5061

5071

Y

5062

5072

Z

5063

5073

A

5064

5074

B

5065

5075

C

5066

5076

 

G32 – Threading:

It is possible to cut threads using a spindle to rotate the work piece and a non rotating threading tool. Equal lead straight, tapered and scroll threads can be cutting using this command.

Spindle speed feedback from an encoder, index pulse, tachometer or other device is required for this

operation. The syncing of the feed axis to the spindle speed creates an accurate thread; however, axis acceleration can cause variations in the thread lead especially at the start and end of the thread. The compensate program a slightly longer thread to give the axis time to accelerate. The amount of extra thread length will vary based on machine specifications. Changes in spindle speed and feedrate will impact thread quality and accuracy. Using constant surface speed mode can also result in variations in thread lead when cutting tapered or scroll threads, use G97 constant RPM mode instead. During the threading move the spindle speed and feedrate overrides will be disabled and the machine will run at 100%. Feed hold will be delayed, if pressed the machine will stop at the end of the threading move.

Format: G32 X Y Z F

The G32 threading cycle is a single linear move synced to the spindle speed. F specifies the lead or pitch of the thread. For example a 20 TPI thread would have a pitch of .05 inches, so program F.05. By default the movement is basic linear move with synced feedrate. Machine builders and advanced users have the added option to create custom M-Codes to specify the feed vector to create custom threads.

Example: Thread a ¼-20 rod held in the spindle, 1” length of thread.

G0 G90 G54 G18 G40 G49 G80

Safe start line

G0 X0.3 Y0.0 Z0.1

Rapid position

G97 S1000 M3

Start spindle at 1000 RPM

G0 X0.22

Move to start position for rough

G32 X0.22 Z-1.0 F.05

Cut straight thread

G0 X0.3

Retract X axis

Z0.1

Retract Z axis

X0.21

Move to start position for finish

G32 X0.21 Z-1.0 F.05

Cut straight thread

G0 X0.3

Retract X axis

Z0.1

Retract Z axis

G53 Z0.0 M5

Z home and stop spindle

M30

Program end and rewind

 

 

 

 

 

 

 

 

 

Threads can also be cut with a taper by adding the proper end point. Example: Cut same thread as previous example with 0.03 taper.

G0 G90 G54 G18 G40 G49 G80

Safe start line

G0 X0.3 Y0.0 Z0.1

Rapid position

G97 S1000 M3

Start spindle at 1000 RPM

G0 X0.22

Move to start position for rough

G32 X0.25 Z-1.0 F.05

Cut tapered thread

G0 X0.3

Retract X axis

Z0.1

Retract Z axis

X0.21

Move to start position for finish

G32 X0.24 Z-1.0 F.05

Cut tapered thread

G0 X0.3

Retract X axis

Z0.1

Retract Z axis

G53 Z0.0 M5

Z home and stop spindle

M30

Program end and rewind

 

Basic-Thread-Types.JPG

Figure 32-1: Basic thread types

G40 – Cutter Compensation Cancel:

Cancels the cutter compensation mode.

G40.1 – Arc Type Cutter Compensation:

Selects the arc type cutter compensation mode. In this mode, external corners will generate a rounded path, this provides smoother motion at high feedrates, see figure 401-1, G40.1. Cutter comp modes can be changed on the fly, figure 401-2. See the cutter compensation section of this manual for more details and limitations.

G40.1 – Arc type G40.2 – Line offset type

Cutter-Compensation-Types.JPG

Figure 401-1: Cutter compensation types.

G42-Cutter-Compensation-Path.JPG

Figure 401-2: G42 cutter compensation path.

G40.2 – Line Offset Type Cutter Compensation:

Selects the line offset type cutter compensation mode. In this mode, external corners will generate a square path, see figure 401-1, G40.2. Cutter comp modes can be changed on the fly, figure 401-2. See the cutter compensation section of this manual for more details and limitations.

G41/G42 – Cutter Compensation Left/Right:

Enables cutter compensation to the left (G41) or right (G42) of the cutter path by an amount specified in an offset selected by D.

Format: G1 G42 D X Y Z F

For detailed information see the cutter compensation section of this manual.

G43/G44 – Tool Length Offset:

Activates a tool length offset selected with H. When activated the position DROs will be updated to display the position of the program point of the tool, generally the tip. The tool offset can be applied in the positive direction with G43 or in the negative direction with G44. Generally G43 will be used to apply the tool offset. There are a number of ways of touching off a tool and determining the offset value, see tool offsets in the operation manual for more details, but they are all called and applied the same way.

Format: G43 H X Y Z

If axis positions are specified in the same block as G43 the machine will move to the commanded point. If the axes are omitted there will be no motion.

G49 – Tool Length Offset Cancel:

Cancels the tool length offset. If no motion is commanded in the G49 block there will be no motion of the machine.

G50 – Scaling Cancel:

Cancels scaling.

G51 – Scaling/Mirroring Function:

When activated the scaling function multiplies all commanded positions by the specified scale factor. The DROs and offsets are not affected, but motion commanded from a program or the MDI screen is affected.

Format: G51 X Y Z A B C

Specify the axis to be scaled and the desired scale factor. For example:

G0 G90 G54 G17 G40 G49 G80

Safe start line

G0 X4.0 Y0.0 Z1.0

Rapid position to point (X position is 4.)

G51 X2.0

Activate scaling on X axis (scale factor = 2)

G0 X5.0

Rapid position to point (X position is 10.)

G50

Cancel Scaling

G0 X5.0

Rapid position to point (X position is 5.)

M30

Program end and rewind

 

 

 

 

 

 

When scaling is active position moves will be calculated by multiplying the commanded position by the scale factor. In the example above the scale factor on the X axis is set to 2, then a move to X5. is commanded. The actual end position of this move will be 5 * 2 = 10. So the X axis moves to 10.

Exercise caution when using scaling, the results can be unpredictable depending on program complexity. For example if G52 X2 Y4 is programmed followed by an arc move in the XY plane, the arc will NOT be scaled 2x in the X axis and 4x in the Y axis to obtain an ellipse. The start and end positions will be as

expected, but the motion from one to the other may not be. Check and double check the tool path display before running the program.

To mirror a program, enter a negative scale value. For example:

G0 G90 G54 G17 G40 G49 G80

Safe start line

G0 X4.0 Y0.0 Z1.0

Rapid position to point (X position is 4.)

G51 X-1.0

Mirror X axis (scale factor = 1)

G0 X5.0

Rapid position to point (X position is -5.)

G50

Cancel Scaling

G0 X5.0

Rapid position to point (X position is 5.)

M30

Program end and rewind

 

G52 – Local Coordinate System Shift:

The local coordinate system setting is a programmable work shift. The setting is global; the entire system is shifted by the specified values. Every fixture offset will be affected, although the actual fixture offset values will not be changed.

Format: G52 X Y Z A B C

To activate a local coordinate system with G52 use the above format. Setting of a local coordinate system is just like setting a fixture offset. In the G52 block specify the desired axes to set, and the value of the shift. For example (see figure 52-1 for the tool path):

G0 G90 G54 G17 G40 G49 G80

Safe start line

G0 X-4.0 Y0.0 Z1.0

Rapid position to point

G12 I2.0 F30.0

Cut circle with radius 2.0

G52 X7.0

Local Coordinate system active, X offset = 7

G0 X-4.0 Y0.0 Z1.0

Rapid to same start point

G12 I2.0 F30.0

Cut same circle with radius 2.0

G52 X0.0

Local coordinate system cancelled

M30

Program end and rewind

 

Example-Program-Tool-Path.JPG

Figure 52-1: Example program tool path.

Once set, the setting will remain until cancelled by another G52 or the system is reset. As in the example above, a local coordinate system can be cancelled by specifying the axis with a value of zero. This effectively sets the local coordinate system shift to zero, giving it no effect.

G53 – Machine Coordinate System:

Although the majority of machine positioning will take place in a user created coordinate system it is sometimes beneficial to program positions in the machine coordinate system. G53 is a non modal, only active for the block in which it is specified, G-Code that allows the user to make positioning moves in the machine coordinate system. This can be useful for moving to a load/unload position at the end of a program or moving to a tool change location in a tool change macro. This is also a much safer way to move back to the machine home position, G53 X0 Y0 Z0, than using G28 as there is no intermediate position to be concerned with.

Format: G53 X Y Z A B C

G0 G90 G54 G17 G40 G49 G80

Safe start line

G0 X4.0 Y0.0 Z1.0

Rapid position in G54

Body of program

G53 Z0.0

Return directly to Z home position

G53 X10.0 Y0.0

Move to load/unload position

M30

Program end and rewind

 

 

 

 

 

 

In the example above, the last two positioning moves are made in the machine coordinate system. These two blocks could be the same for every program in this machine.

G54-G59 – Fixture Offset:

Used to select the active fixture offset in a program. The fixture offset will stay active until another is called or the system is reset. It is possible to use multiple fixture offsets in a single program.

G54.1 – Additional Fixture Offsets:

Additional fixture offsets are provided for users with many fixtures/parts/ setups. There are 248 additional offsets available.

Format: G54.1 P

P specifies the number of the additional offset, 1 thru 248.

Previous version of Mach use G59 P7, P8 and so on. These legacy offsets can still be used in place of the G54.1. G59 P7 = G54.1 P1, G59 P8 = G54.1 P2, and so on. G54.1 is more consistent with industry machines.

Please see the fixture offset section of the Mach4 Mill Operations Guide for more detail on setting up fixture offsets.

G60 – Unidirectional Approach:

In cases where mechanical backlash causes positioning errors unidirectional approach can be used to increase accuracy. G60 is a non-modal code, when specified in a movement block motion will move to the end point from a parameter defined distance and direction, see figure 60-1. The distance and direction of the approach movement is specified by setting values in # variables as shown in the following table:

Axis

# Variable

X

5440

Y

5441

Z

5442

A

5443

B

5444

C

5445

 

 

 

 

 

 

Format: G60 G0/G1 X Y Z

When unidirectional approach is used in a drill cycle the Z axis motion is not affected. G76 and G87 boring cycles have a tool shift that is also not affected by the G60 unidirectional approach.

 

Unidirectional-Approach.JPG

Figure 60-1: Unidirectional approach.

G61 – Exact Stop Mode:

In exact stop mode the machine will decelerate to a complete stop at the end of each commanded move, see figure 9-1. This is a modal code, once activated it will remain on until canceled. For sharp corners and simple positioning this mode works well. However, when the code gets more complex, or in side milling with arcs, the exact stop mode will produce jerky motion and witness marks on the work piece. For most milling jobs use G64.

G64 – Constant Velocity Mode:

In constant velocity mode Mach will try to maintain feedrate even around sharp corners. As a result sharp corners will be slightly rounded and the machine may never reach the programmed point before a direction change. The magnitude of these position errors will be determined by the acceleration capability of the machine and the programmed feedrate. In most cases the error will be too small to notice or affect part function. Cutting will be faster and smoother with better finishes and no witness marks from stopping. This will be the active mode for the majority of machining time. It is modal and will be active until exact stop mode is activated.

G65 – Macro Call:

Macros work like subprograms (see M98 on page 60) but allow values to be passed from the main program in the form of local variables. Macro programs can use these local variables passed to it to change part dimensions, select features, adjust feedrates, or anything else the user could need to change.

Format: G65 P A B C

The desired program number to be called is specified by P. The remaining arguments are determined by the macro program being called. The values of these arguments will be passed to local variables for use in the macro program. The available arguments and corresponding variables are shown in the table below.

Address

Variable

Address

Variable

Address

Variable

A

#1

I

#4

T

#20

B

#2

J

#5

U

#21

C

#3

K

#6

V

#22

D

#7

M

#13

W

#23

E

#8

Q

#17

X

#24

F

#9

R

#18

Y

#25

H

#11

S

#19

Z

#26

 

 

 

 

 

 

 

The G65 macro call is non modal and has no option for repeating, the macro subprogram will be run only once per G65 call. For more information on macro programming and the availability and use of # variables see the Mach4 Macro Programming Guide.

G66 – Macro Modal Call:

Sometimes it is useful to run the same macro in different positions (similar to drilling canned cycles) or with different parameters. G66 is a modal macro call, the macro is called and values passed in the same way as G65, but G66 remains active until cancelled. The block(s) following the G66 can contain new positions and variables to run the macro again.

Format: G66 P A B C … A B C …

G67

More information on macro programming is available in the Mach4 Macro Programming Guide.

G67 – Macro Modal Call Cancel:

Cancels the macro modal call.

G68 – Coordinate System Rotation:

It is possible to rotate a program around a specified point using the coordinate system rotation command. It is specified as follows:

Format: G68 X Y R

The command is only available in the XY (G17) plane and is modal. X and Y specify the point around which the program will be rotated, and R specifies the angle. A positive value for R will rotate the program counter clockwise when looking at the plane from the positive direction.

Once the rotation command is given, all command moves will take place in this rotated system. In effect, the X and Y axes of the machine will rotate the amount specified by R.

G0 G90 G54 G17 G40 G49 G80

Safe start line

G0 X0.0 Y0.0 Z1.0

Rapid position to point

G68 X0.0 Y0.0 R45.0

Rotate 45° counter clockwise about X0, Y0

G0 X1.0

Rapid position to X1.

G69

Cancel rotation

M30

Program end and rewind

 

 

 

 

 

In the example above, the machine will move to X0, Y0 then initiate the coordinate rotation of 45°. The next move is a purely X axis move to X1. However, because the coordinate system has been rotated the current X axis is actually 45° from the machine actual X axis. When the move takes place both X and Y axes will move to the programmed point. In this case the DROs will read X.7071 and Y.7071. See figure 68-1.

Coordinate-System-Rotation.JPG

Figure 68-1: Coordinate system rotation (G68 X0 Y0 R45)

The coordinates X.7071 and Y.7071 can be proven using simple geometry or trigonometry functions.

Coordinate system rotation is useful in many applications. Combined with a part probe the function can provide a lot of power and accuracy. When probing a part to find its location, it is also possible to determine if the part is clamped square to the axes or if it is oriented at some angle. If the part is skewed at an angle it can be automatically compensated for, resulting in higher quality parts.

G69 – Coordinate System Rotation Cancel:

Cancels a coordinate system rotation command. The machine returns back to normal function.

G73-G89 – Canned Cycles:

Canned cycles are special G-Codes used to simplify programming. See the Canned Cycles section of this manual for detailed information.

G-Code

Description

Format

G73

High Speed Peck

G73 X_ Y_ Z_ R_ Q_ F_

G74

Reverse Tapping

G74 X_ Y_ Z_ R_ F_

G76

Fine Boring

G76 X_ Y_ Z_ R_ I_ J_ P_ F_

G76 X_ Y_ Z_ R_ Q_ P_ F_

G80

Canned Cycle Cancel

G80

G81

Drilling

G81 X_ Y_ Z_ R_ F_

G82

Spot Face

G82 X_ Y_ Z_ R_ P_ F_

G83

Deep Hole Peck Drilling

G83 X_ Y_ Z_ R_ Q_ F_

G84

Tapping

G84 X_ Y_ Z_ R_ F_

G85

Boring, Retract at Feed, Spindle On

G85 X_ Y_ Z_ R_ F_

G86

Boring, Retract at Rapid, Spindle Off

G86 X_ Y_ Z_ R_ F_

G87

Back Boring

G87 X_ Y_ Z_ R_ I_ J_ F_

G87 X_ Y_ Z_ R_ Q_ F_

G88

Boring, Manual Retract

G88 X_ Y_ Z_ R_ P_ F_

G89

Boring, Dwell, Retract at Feed,

Spindle On

G89 X_ Y_ Z_ R_ P_ F_

 

G90/G91 – Absolute/Incremental Position Mode:

In absolute position mode, the machine will move to the commanded position in the active user coordinate system.

Example: Write a program to move to the hole positions in figure 90-1 in absolute position mode. Assume the machine starts at position X0, Y0, end the program at X0, Y0.

Hole-Pattern-Example.JPG

Figure 90-1: Hole pattern example

G0 G90 G54 G17 G40 G49 G80

Safe start line

G90

Absolute position mode

G0 X1.0 Y-1.0

Rapid to 1st hole

X2.0

Rapid to 2nd hole

X3.0

Rapid to 3rd hole

X0.0 Y0.0

Rapid back to 0, 0

M30

Program end and rewind

 

 

 

 

 

 

In incremental position mode, commanded moves are interpreted as distance and direction from the current position. A command of X1 will move 1 in the positive direction, NOT necessarily to the point X1 in the user coordinate system.

Example: Write a program to move to the hole positions in figure 90-1 in incremental position mode. Assume the machine starts at position X0, Y0, end the program at X0, Y0.

G0 G90 G54 G17 G40 G49 G80

Safe start line

G91

Incremental position mode

G0 X1.0 Y-1.0

Rapid to 1st hole

X1.0

Rapid to 2nd hole

X1.0

Rapid to 3rd hole

X-3.0 Y1.0

Rapid back to 0, 0

M30

Program end and rewind

 

 

 

 

 

 

Compare this to the program from G90. Because the starting point is X0, Y0 in both examples the move to the 1st hole is the same. However, if the machine started at X1, Y1 the absolute position program would still be correct, the incremental program would be shifted by the start location. For this reason it is important to ensure the proper mode is enabled for the program in use. A good safe start line will always contain a G90 or G91. These G-Codes are modal and will stay active until the other is specified.

G90.1/G91.1 – Absolute/Incremental Arc Center Mode:

This setting affects arcs when programmed in the I, J, K format. In absolute arc center mode the I, J, K values designate the position of the arc center in the user coordinate system. In incremental arc center mode the I, J, K values designate the distance and direction to the arc center from the start point. See figure 2-1 for a graphical description.

Path-of-Tool-Point-in-Circular-and-Helical-Interpolation-(G02).JPG

Figure 2-1: Path of tool point in circular and helical interpolation (G02).

Example: Program an arc centered at 1.0, 0.0 in the XY plane with radius 2. Start point at 3.0,0.0 and sweep 90 degrees counter clockwise. Program two times, once in incremental arc center mode and once in absolute arc center mode.

G0 G90 G54 G17 G40 G49 G80

Safe start line

G91.1

Incremental arc center mode

T1 M6

Tool change

S2500 M3

Start spindle

G0 X3.0 Y0.0

Position to X and Y start point

G43 H1 Z.5

Activate tool offset 1 and move to Z rapid plane

G1 Z0.0 F10.0

Z plunge at feedrate

G3 X1.0 Y2.0 I-2.0 J0.0 F10.0

Arc move

G0 Z.5

Retract Z to rapid plane

G0 G53 Z0.0

Return Z to home

M30

Program end and rewind

 

G0 G90 G54 G17 G40 G49 G80

Safe start line

G90.1

Absolute arc center mode

T1 M6

Tool change

S2500 M3

Start spindle

G0 X3.0 Y0.0

Position to X and Y start point

G43 H1 Z.5

Activate tool offset 1 and move to Z rapid plane

G1 Z0.0 F10.0

Z plunge at feedrate

G3 X1.0 Y2.0 I1.0 J0.0 F10.0

Arc move

G0 Z.5

Retract Z to rapid plane

G0 G53 Z0.0

Return Z to home

M30

Program end and rewind

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Notice the difference in the I values of the example programs. Both programs will produce the same arc.

G92 – Local Coordinate System Setting:

The coordinate system can be set by issuing G92 in the program. This function differs from G52 (Local Coordinate System Shift) in the way that it is specified. While G52 is specified with shift values, G92 is specified with the desired axis position. The affect is global and should be used with caution.

Format: G92 X Y Z A B C

Using the above format specify a value for the desired axis. When G92 is specified the position DRO’s are updated to the values specified. The local coordinate system setting will be cancelled when a G92.1 is specified or the system is reset.

G0 G90 G54 G17 G40 G49 G80

Safe start line

G0 X4.0 Y0.0 Z1.0

Rapid move, current position X4, Y0, Z1

G92 X1.0 Y2.0 Z3.0

Set local coordinate system, current position X1,

Y2, Z3

G92.1

Cancel local coordinate system, current position

X4, Y0, Z1

M30

Program end and rewind

 

 

 

 

 

 

G92 was used for fixture offset setting before fixture offsets were available. It is recommended that the fixture offsets be used instead of using G92. The offset amount of the G92 setting is not immediately known by the user, because of this the results can be unpredictable when fixture offsets and G92 are combined.

G93 – Inverse Time Feed:

Inverse time feed is most commonly used for machine movement containing at least one rotary axis, however that is not the only application. Instead of specifying a velocity a time to complete the movement is specified. The following formula is used to determine F:

Inverse-Time-Feed.JPG

When inverse time feed is active an F word is required in every block of code containing a feed move.

G94 – Feed Per Minute:

Most common feedrate setting. Specify the desired feedrate in units/minute. In this mode the feedrate is modal and not required in all feed move blocks.

G95 – Feed Per Revolution:

In mills the feed per revolution setting is most commonly used for tapping cycles. In this mode the feed rate is specified in units/revolution of the spindle. In the case of tapping the feedrate can be set as the pitch of the tap. For every revolution of the spindle the machine will move the specified units. Feed per rev mode requires RPM feedback from the spindle.

G96 – Constant Surface Speed:

Spindle speed can be specified two ways. One is constant surface speed. In this mode Mach will try to keep the surface speed constant based on cutting diameter. Surface speed is specified in surface units per minute. In the inch mode this is surface feet per minute, in millimeter mode it is surface meters per minute.

G97 – Constant RPM:

In this mode the spindle speed is specified in revolutions per minute. This is the most common setting for milling machines.

G98 – Initial Point Return:

Specifies that a canned cycle end at the initial Z level. The machine will also return to the initial point before a rapid move to the next position. Initial point return is useful for avoiding steps in parts or fixture clamps without adding a significant amount of cycle time. See figure 98-1.

Initial-and-R-Point-Return-Setting.JPG

Figure 98-1: Initial and R point return setting.

G99 – R Point Return:

Specifies that a canned cycle end at the programmed R level, see figure 98-1. When drilling holes in a flat plate, G99 can be used to reduce excessive machine movement decreasing cycle time.

Chapter 3: Canned Cycles

G73

High Speed Peck

G73 X_ Y_ Z_ R_ Q_ F_

G74

Reverse Tapping

G74 X_ Y_ Z_ R_ F_

G76

Fine Boring

G76 X_ Y_ Z_ R_ I_ J_ P_ F_

G76 X_ Y_ Z_ R_ Q_ P_ F_

G80

Canned Cycle Cancel

G80

G81

Drilling

G81 X_ Y_ Z_ R_ F_

G82

Spot Face

G82 X_ Y_ Z_ R_ P_ F_

G83

Deep Hole Peck Drilling

G83 X_ Y_ Z_ R_ Q_ F_

G84

Tapping

G84 X_ Y_ Z_ R_ F_

G85

Boring, Retract at Feed, Spindle On

G85 X_ Y_ Z_ R_ F_

G86

Boring, Retract at Rapid, Spindle Off

G86 X_ Y_ Z_ R_ F_

G87

Back Boring

G87 X_ Y_ Z_ R_ I_ J_ F_

G87 X_ Y_ Z_ R_ Q_ F_

G88

Boring, Manual Retract

G88 X_ Y_ Z_ R_ P_ F_

G89

Boring, Dwell, Retract at Feed, Spindle On

G89 X_ Y_ Z_ R_ P_ F_

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Canned cycles are used to reduce program complexity. For example peck drilling a 1 inch hole with .1 inch peck depth would use 30 lines of regular code, but with a canned cycle this same hole can be competed in just 2 lines of code. More importantly if multiple holes are required only 1 extra line of code per hole is needed. There are a variety of canned cycles for different hole types including drilling, boring, and tapping.

Hole machining cycles all behave similarly and mostly contain the same parameters. The meaning of each parameter can change depending on two settings. The first is the absolute or incremental mode setting (G90/G91) as defined earlier in this manual. The second is the return point selection G98 initial point return or G99 R point return.

Plane selection (G17/G18/G19) can also have an effect on hole machining cycles. Positioning will take place in the active plane, and the drilling operation will be on the normal axis. For example in G17 (XY Plane) hole position will be on the XY plane and the drilling axis will be Z. In G18 (ZX Plane) positioning will be on the ZX plane and the drilling axis will be Y. For the purposes of this manual all examples and definitions will be in the XY plane (G17).

The basic format of a canned cycle is as follows:

Gcc G98/99 Xxx Yyy Zzz Qqq Rrr Ppp Lll Fff Xxn Yyn

G80

cc

Number of the desired canned cycle (i.e. 81, 83, 74, etc)

xx

In G90: X position of the center point of the first hole with respect to the current work zero point

In G91: Distance and direction along X axis to center point of first hole from the current position

yy

In G90: Y position of the center point of the first hole with respect to the current work zero point

In G91: Distance and direction along Y axis to center point of first hole from the current position

zz

In G90: Z position of bottom of hole with respect to the current work zero point

In G91: Distance and direction along Z axis, from point R, to bottom of hole

qq

Peck increment if deep hole drilling, always positive

rr

Retract plane, retract position between pecks, in G99 mode this is the rapid plane

pp

Dwell, in milliseconds, at bottom of hole

ll

Number of repetitions

ff

Feedrate

xn

Position of nth hole X axis, same rules as applied to xx

yn

Position of nth hole Y axis, same rules as applied to yy

 

 

 

 

 

 

 

 

 

 

 

Please note that not all arguments will appear in all cycles, and there are a couple special cases that will be discussed.

Figure 2: Example hole pattern

Example-Hole-Pattern.JPG

G80 – Canned Cycle Cancel: To end a canned cycle a G80 must be called. G80 should be specified on its own line to avoid any unintended movements. For example:

G0 G90 G54 G17 G40 G49 G80

Safe start line

T1 M6

Tool change

S2500 M3

Start spindle

G0 X1.0 Y-1.0

Position to X and Y start point

G43 H1 Z.5

Activate tool offset 1 and move to Z initial point

G81 G99 X1.0 Y-1.0 Z-1.0 R.25 F10

Drill cycle start

X2.0 Y-1.0

Drill second hole

X3.0 Y-1.0

Drill third hole

G80

Canned cycle cancel

G0 G53 Z0

Return Z to home

M30

Program end and rewind

 

 

 

 

 

 

 

 

Drilling

G81 – Drilling: This is a straight drilling cycle. The tool simply moves to position, feeds to the bottom of the hole then rapid retracts to either the R point or the initial point. See figure 81-1 for a graphic of the tool motion. The format is as follows:

G81 X Y Z R L F

X, Y – Position of hole in XY plane Z – End point of hole

R – Retract plane

L – Number of repetitions

F – Feedrate

Motion-of-Tool-Point-for-G81-Cycle-End-Z-position-will-be-determined-by-G98-99-setting.JPG

Figure 81-1: Motion of tool point for G81 cycle. End Z position will be determined by G98/99 setting.

Example:

Create the program for the holes shown in Figure 2.

G0 G90 G54 G17 G40 G49 G80

Safe start line

T1 M6

Tool change

S2500 M3

Start spindle

G0 X1.0 Y-1.0

Position to X and Y start point

G43 H1 Z.5

Activate tool offset 1 and move to Z initial point

G81 G99 X1.0 Y-1.0 Z-1.0 R.25 F10

Drill cycle start

X2.0 Y-1.0

Drill second hole

X3.0 Y-1.0

Drill third hole

G80

Canned cycle cancel

G0 G53 Z0

Return Z to home

M30

Program end and rewind

 

 

 

 

 

 

 

 

 

 

G82 – Spot Face: Spot face adds the ability to dwell at the bottom of the hole for a specified amount of time. The actual tool motion is the same as a G81 cycle, however with the dwell it is possible to attain better accuracy and finish at the bottom of the hole. This is useful for chamfering, counter boring, and spot facing. The format is as follows:

G82 X Y Z R P L F X, Y – Position of hole in XY plane

Z – End point of hole R – Retract plane

P – Dwell

L – Number of repetitions F – Feedrate

Example:

Create a chamfering program for the holes shown in figure 2, dwell for .2 seconds.

G0 G90 G54 G17 G40 G49 G80

Safe start line

T1 M6

Tool change

S2500 M3

Start spindle

G0 X1.0 Y-1.0

Position to X and Y start point

G43 H1 Z.5

Activate tool offset 1 and move to Z initial point

G82 G99 X1.0 Y-1.0 Z-.200 P.2 R.25 F10

Spot drill cycle start

X2.0 Y-1.0

Drill second hole

X3.0 Y-1.0

Drill third hole

G80

Canned cycle cancel

G0 G53 Z0

Return Z to home

M30

Program end and rewind

 

 

 

 

 

 

 

 

 

G83 – Peck Drilling: Peck drilling is a cycle used for drilling deep holes. The cycle allows for breaking and clearing of chips and better application of coolant by fully retracting the tool from the hole between pecks. This retract move and plunge to previous depth are rapid moves, each peck is a feed move at the specified feed rate. See figure 83-1 for a graphic of the tool motion. The format is as follows:

G83 X Y Z Q R L F

X, Y – Position of hole in XY plane Z – End point of hole

Q – Peck amount R – Retract plane

L – Number of repetitions F – Feedrate

Motion-of-Tool-Point-for-G83-Cycle-End-Z-Position-will-be-Determined-by-G98-99-Settings.JPG

Figure 83-1: Motion of tool point for G83 cycle. End Z position will be determined by G98/99 setting.

Example:

Create the program for the holes shown in figure 2 using a .1 peck depth.

G0 G90 G54 G17 G40 G49 G80

Safe start line

T1 M6

Tool change

S2500 M3

Start spindle

G0 X1.0 Y-1.0

Position to X and Y start point

G43 H1 Z.5

Activate tool offset 1 and move to Z initial point

G83 G99 X1.0 Y-1.0 Z-1.0 Q.1 R.25 F10

Peck drill cycle start

X2.0 Y-1.0

Drill second hole

X3.0 Y-1.0

Drill third hole

G80

Canned cycle cancel

G0 G53 Z0

Return Z to home

M30

Program end and rewind

 

 

 

 

 

 

 

 

 

G73 – High Speed Peck: In materials that produce long stringy chips a high speed peck cycle can be used to break them up. Unlike the G83 cycle that retracts completely out of the hole after each peck, the G73 cycle only retracts .100 inch. See figure 73-1. This short retract helps to reduce cycle times when a complete retract is unnecessary. The format:

G73 X Y Z Q R L F

X, Y – Position of hole in XY plane Z – End point of hole

Q – Peck amount R – Retract plane

L – Number of repetitions F – Feedrate

Motion-of-Tool-Point-for-G73-Cycle-End-Z-Position-will-be-Determined-By-G98-99-Setting.JPG

Figure 73-1: Motion of tool point for G73 cycle. End Z position will be determined by G98/99 setting.

Example:

Create the program for the holes shown in figure 2 using a .025 peck depth.

G0 G90 G54 G17 G40 G49 G80

Safe start line

T1 M6

Tool change

S2500 M3

Start spindle

G0 X1.0 Y-1.0

Position to X and Y start point

G43 H1 Z.5

Activate tool offset 1 and move to Z initial point

G73 G99 X1.0 Y-1.0 Z-1.0 Q.1 R.25 F10

Peck drill cycle start

X2.0 Y-1.0

Drill second hole

X3.0 Y-1.0

Drill third hole

G80

Canned cycle cancel

G0 G53 Z0

Return Z to home

M30

Program end and rewind

 

 

 

 

 

 

 

 

Tapping

G84 – Right Hand Tapping: The tapping cycle is used to create threaded holes using a tap. Tapping requires that the spindle rpm and Z axis feedrate be matched, related by the pitch of the thread being cut. There are two ways to achieve this synchronization of spindle speed and Z axis feedrate. From the programming side it is easier to program the feedrate in units per revolution (G95). In the feed per rev mode the commanded feedrate will be simply the pitch of the thread. Metric threads are classified with the thread pitch, i.e. M8x1.25mm thread has a 1.25mm pitch. Unified threads are classified by threads per inch which requires a bit of calculation to get the pitch, don’t worry it’s easy. Simply divide 1 inch by the TPI. For a ¼-20 fastener we would calculate 1/20 = .05, this is the pitch. The catch is, to use feed per rev requires some form of rpm feedback from the machine, not every machine will have this. For the machines without feedback the tapping cycle can be programmed in feed per min mode (G94). This method requires a little more math to obtain the correct feedrate based on spindle rpm and pitch of the thread. The equation looks like this: RPM*Pitch=IPM. To tap that ¼-20 hole at 1500 RPM we first need to calculate the pitch, remember 1/TPI = Pitch, so 1/20=.05. Now we calculate the feed per min as 1500

* .05=75 IPM. It is important to note that if the spindle speed is changed, the feed per minute must also be changed to match. Now that the math is done, check out the format of the code:

G84 X Y Z R L F

X, Y – Position of hole in XY plane Z – End point of hole

R – Retract plane

L – Number of repetitions F – Feedrate

The motion of the tapping cycle is straight forward, but does require some additional description. See Figure 84-1 for a graphic of the tool motion. The movement is very similar to a straight drill cycle, action of the spindle being the major difference. The spindle must be started in the forward direction prior to calling the G84 cycle. The machine will then move to the hole position then the Z axis will move down to the R plane. The Z will feed down to the specified depth then the spindle and Z axis will stop then reverse direction to retract out of the hole. Due to slight variations of spindle speed, feedrate and accelerations in some machines it is recommended that a special tapping head be used. A tapping head allows the tap to float a little bit, compensating for those variations, especially at the bottom of the hole.

Changes to feedrate or spindle speed mid cycle can be damaging to the tool and work piece, for this reason the feedrate and spindle speed overrides are disabled. The machine will run at 100% override for the duration of the cycle. Feed hold is also disabled during the cycle. If feed hold is pressed motion will stop at the end of the tapping cycle.

Motion-of-Tool-Point-for-G84-Cycle-End-Z-position-will-be-determined-by-G98-99-Setting.JPG

Figure 84-1: Motion of tool point for G84 cycle. End Z position will be determined by G98/99 setting.

Example:

Create the program to tap the holes shown in figure 2 to a depth of .500 with a 3/8-16 tap using feed/min.

1/16=.0625

1000*.0625=62.5

G0 G90 G54 G17 G40 G49 G80

Safe start line

T1 M6

Tool change

S1000 M3

Start spindle

G0 X1.0 Y-1.0

Position to X and Y start point

G43 H1 Z.5

Activate tool offset 1 and move to Z initial point

G84 G99 X1.0 Y-1.0 Z-.500 R.25 F62.5

Tapping cycle start

X2.0 Y-1.0

Tap second hole

X3.0 Y-1.0

Tap third hole

G80

Canned cycle cancel

G0 G53 Z0

Return Z to home

M30

Program end and rewind

 

 

 

 

 

 

 

 

 

 

G74 – Left Hand Tapping: Left hand tapping is the same as right hand tapping (G84) except that it will cut left hand threads. The spindle must be started in the reverse direction before calling the G74 cycle.

G84.2/G84.3 – Right and Left Hand Rigid Tapping: Rigid tapping can be performed on capable machines. As the name implies the tap is held rigidly in the spindle, no tension/compression style tapping holder is required. Holding the tap in this manner requires the machine to have precise control of spindle speed, axis feed, and precise feedback of spindle RPM. The tapping axis will be electronically geared to the spindle RPM. Use G84.2 for right hand tapping and G84.3 for left hand tapping. See figure 84-1 for a graphic of the motion.

Format: G84.2/84.3 X Y Z R P L F J

X, Y – Position of hole in XY plane Z – End point of hole

R – Retract plane

P – Dwell in milliseconds L – Number of repetitions F – Feedrate

J – Spindle speed for retract

As will other tapping cycles the feedrate and spindle speed overrides are disabled and set to 100% for the duration of the cycle. Feed hold is also no effective until the end of the tapping cycle.

Example:

Create the program to tap the holes shown in figure 2 to a depth of .500 with a 3/8-16 tap using feed/min. Tap at 1000 RPM, retract at 2000 RPM

1/16=.0625

1000*.0625=62.5

G0 G90 G54 G17 G40 G49 G80

Safe start line

T1 M6

Tool change

S1000 M3

Start spindle

G0 X1.0 Y-1.0

Position to X and Y start point

G43 H1 Z.5

Activate tool offset 1 and move to Z initial point

G84.2 G99 X1.0 Y-1.0 Z-.500 R.25 F62.5 J2000

Rigid tapping cycle start

X2.0 Y-1.0

Tap second hole

X3.0 Y-1.0

Tap third hole

G80

Canned cycle cancel

G0 G53 Z0

Return Z to home

M30

Program end and rewind

 

 

 

 

 

 

 

Boring

G76 – Fine Boring: The fine boring cycle allows the user to stop the spindle and move the tool away from the wall before retracting. This allows for a rapid retract without leaving a scratch on the wall.

G76 X Y Z R I J P L F

or

G76 X Y Z R Q P L F

X, Y – Position of hole in XY plane Z – End point of hole

R – Retract plane

I – X shift distance and direction J – Y shift distance and direction

Q – Shift distance (Always positive. Direction and axis are defined by bits 5 and 4 in parameter 5101) P – Dwell in milliseconds

L – Number of repetitions F – Feedrate

Motion-of-Tool-Point-for-G76-Cycle-End-Z-Position-will-be-determined-by-G98-99-Setting.JPG

Figure 76-1: Motion of tool point for G76 cycle. End Z position will be determined by G98/99 setting.

After feeding to the bottom of the hole, the machine with pause for the specified dwell time, then the spindle will stop in the orient position before making the shift move defined by I and J. In machines with a spindle orient function called by M19 this will all be automatic. However, many machines are not capable of orienting the spindle so the orientation must be done manually. Because of the vast variety of machines that handle spindle orientation differently, the spindleorient.mcs script controls how the spindle is oriented, automatically or manually. If the machine is not capable of automatic spindle orientation, the spindle orient script should command a spindle stop and a mandatory program stop.

This will allow the operator to manually orient the spindle before the shift move is made. Here is an example of the spindleorient.mcs macro for the manual orient:

function spindleorient(orientation, direction)

local inst = mc.mcGetInstance() -- Get the current instance

local rc = mc.mcCntlWaitOnCycleStart(inst, "Press Cycle Start when the spindle is oriented.", 0)

if rc ~= mc.MERROR_NOERROR then

mc.mcCntlSetLastError(inst, "Spindle Orient Error")

return

end

end

 

if (mc.mcInEditor() == 1) then

spindleorient(0.0, 1)

end

 

 

 

 

 

 

 

 

 

Example:

Create the program to fine bore the holes shown in figure 2.

G0 G90 G54 G17 G40 G49 G80

Safe start line

T1 M6

Tool change

S2500 M3

Start spindle

G0 X1.0 Y-1.0

Position to X and Y start point

G43 H1 Z.5

Activate tool offset 1 and move to Z initial point

G76 G99 X1.0 Y-1.0 Z-1.0 R.25 I-.025 J0 F10.0

Fine bore cycle, shift X-.025 at bottom

X2.0 Y-1.0

Bore second hole

X3.0 Y-1.0

Bore third hole

G80

Canned cycle cancel

G0 G53 Z0

Return Z to home

M30

Program end and rewind

 

 

 

 

 

 

 

 

 

 

G85 – Boring, Feedrate Retract: G85 is a straight boring cycle, most commonly used for boring or reaming. The retract is at the programmed feedrate with the spindle on.

G85 X Y Z R L F

X, Y – Position of hole in XY plane Z – End point of hole

R – Retract plane

L – Number of repetitions F – Feedrate