The NIST RS274/NGC Interpreter - Version 3

Thomas R. Kramer Frederick M. Proctor Elena Messina

Intelligent Systems Division National Institute of Standards and Technology Technology Administration U.S. Department of Commerce Gaithersburg, Maryland 20899

NISTIR 6556 August 17, 2000

Disclaimer

Commercial equipment and materials are identified in order to specify certain procedures adequately. In no case does such identification imply recommendation or endorsement by the National Institute of Standards and Technology, not does it imply that the materials or equipment identified are necessarily the best available for the purpose.

Acknowledgements

Partial funding for the work described in this paper was provided to Catholic University by the National Institute of Standards and Technology under cooperative agreement Number 70NANB7H0016.

Abstract

This report describes an interpreter which reads numerical control code and produces calls to a set of canonical machining functions. The interpreter is a software system written in the C++ programming language. The output of the interpreter may be used to drive 3-axis to 6-axis machining centers. Input to the interpreter is RS274 code in the dialect defined by the Next Generation Controller (NGC) project, with modifications. The interpreter may be compiled as a stand-alone computer program or may be integrated with the NIST Enhanced Machine Controller (EMC) control system. Input can come from a file or from a user typing on a computer keyboard. Output commands can either be printed for future use or be executed directly on a machining center. The report includes a full description of the RS274/NGC input language and the canonical machining functions called by the interpreter. It is a complete users manual.

Keywords

controller, interpreter, machining, NC code, numerical control, NIST, rs274

CONTENTS
Machining Center Overview .................................................................. 4
Mechanical Components ........................................................................4
Control and Data Components ...............................................................6
Interpreter Interaction with Switches .................................................................9
Feed and Speed Override Switches ........................................................9
Optional Program Stop Switch ..............................................................9
Input: the RS274/NGC Language ....................................................... 12
RS274/NGC Language View of a Machining Center ......................................12
Coordinate Systems .............................................................................14
Rapid Linear Motion — G0 .................................................................23
Linear Motion at Feed Rate — G1 ......................................................23
Arc at Feed Rate — G2 and G3 ...........................................................23
Set Coordinate System Data — G10 ...................................................25
Plane Selection — G17, G18, and G19 ...............................................25
Length Units — G20 and G21 .............................................................26
Return to Home — G28 and G30 ........................................................26
Straight Probe — G38.2 .......................................................................26
Tool Length Offsets — G43 and G49 ..................................................29
Move in Absolute Coordinates — G53 ...............................................29
Select Coordinate System — G54 to G59.3 ........................................29
Set Path Control Mode — G61, G61.1, and G64 ................................30
Cancel Modal Motion — G80 .............................................................30
Canned Cycles — G81 to G89 .............................................................30
Set Distance Mode — G90 and G91 ....................................................36
Set Feed Rate Mode — G93 and G94 .................................................37
Set Canned Cycle Return Level — G98 and G99 ...............................37
Spindle Control — M3, M4, M5 .........................................................39
Tool Change — M6 .............................................................................39
Coolant Control — M7, M8, M9 .........................................................39
Override Control — M48 and M49 .....................................................39
Output: the Canonical Machining Functions ..................................... 42
Mechanical Components ......................................................................45
Control Components ............................................................................45
The Canonical Machining Functions Defined .................................................46
Initialization and Termination ..............................................................47
Free Space Motion ...............................................................................48
Machining Attributes ...........................................................................48
Machining Functions ...........................................................................51
Spindle Functions ................................................................................55
Miscellaneous Functions ......................................................................58
Program Functions ...............................................................................61
Cutter Radius Compensation ...............................................................61
Stand-Alone Interpreter ....................................................................... 62
Building an SAI Executable .............................................................................65
Appendix A Error Handling ...................................................................... 70
Appendix B Cutter Radius Compensation ............................................... 73
Data for Cutter Radius Compensation .................................................74
Programming Instructions ............................................................................... 75
Material Edge Contour .................................................................................... 75
Programming Entry Moves ..................................................................76
Programming Errors and Limitations ............................................................. 80
Cutter Gouging (11) .............................................................................82
Tool Radius Index Too Big (15) ..........................................................82
Two G Codes Used from Same Modal Group (17) .............................82
First Move into Cutter Compensation ............................................................ 82
Appendix C Sample Programs ................................................................... 84
Sample Simple Program ................................................................................. 84
Sample Program to Test Expressions ............................................................. 85
Sample Program to Test Canned Cycles ......................................................... 86
Appendix D Interpreter Software .............................................................. 88
Interpreter Interfaces ....................................................................................... 88
Software Files and Organization ..................................................................... 89
Interpreter-do-it Functions .............................................................................. 91
Interpreter-give-information Functions .......................................................... 92
World-give-information Functions ................................................................. 93
Interpreter Function Call Hierarchies ............................................................. 95
Interpreter World Model ....................................................................101
Expression Evaluation .......................................................................103
Parameter Buffering ...........................................................................103
Production Language .................................................................................... 105
Production Tokens in Terms of Characters .................................................. 107

FIGURES

Figure 1. G87 Cycle .........................................................................................35 Figure 2. Two Cutter Radius Compensation Methods ................................74 Figure 3. Cutter Radius Compensation Entry Moves .................................76 Figure 4. Simpler Cutter Radius Compensation Entry Move ....................78 Figure 5. Cutter Radius Compensation Entry Moves .................................80 Figure 6. Two Cutter Radius Compensation Errors ...................................81 Figure 7. First Cutter Radius Compensation Move - Straight ...................82 Figure 8. First Cutter Radius Compensation Move - Arc ...........................83 Figure 9. Interpreter Interfaces .....................................................................88 Figure 10. Software .........................................................................................90 Figure 11. Interpreter-do-it Function Call Hierarchy .................................96 Figure 12. Interpreter Function Call Hierarchy

(from rs274_ngc read) ...............................................................................97 Figure 13. Interpreter Function Call Hierarchy

(from read_real_value) .............................................................................98 Figure 14. Interpreter Function Call Hierarchy

(from rs274ngc_execute) ...........................................................................99 Figure 15. Interpreter Function Call Hierarchy

(from convert_motion) ............................................................................100 Figure 16. SAI Driver Function Call Hierarchy.........................................101

TABLES

Table 1. Sample Tool File ............................................................................... 11 Table 2. Default Parameter File..................................................................... 13 Table 3. Word-starting Letters ...................................................................... 16 Table 4. Modal Groups ................................................................................... 20 Table 5. G Codes.............................................................................................. 22 Table 6. Code to Probe Hole.......................................................................... 28 Table 7. M Codes ............................................................................................. 38 Table 8. Order of Execution ........................................................................... 41 Table 9. Canonical Machining Functions Called By Interpreter ............... 44 Table 10. Transcript of an SAI Session Using Keyboard Input.................. 64 Table 11. Makefile for Interpreter................................................................. 67 Table 12. NC Program for Figure 3............................................................... 77 Table 13. NC Program for Figure 5............................................................... 79 Table 14. Block Attributes............................................................................ 103

1 Introduction

The RS274/NGC Interpreter (the Interpreter) is a software system that reads numerical control code in the “NGC” dialect of the RS274 numerical control language and produces calls to a set of canonical machining functions. The output of the Interpreter can be used to drive machining centers with three to six axes. Two earlier versions of the RS274/NGC Interpreter were built. This report describes a new version, version 3.

The Interpreter may be used either (1) in a stand-alone system, the “Stand-Alone Interpreter” (SAI) that reads RS274/NGC control code and writes canonical machining function calls but does not control physical equipment, or (2) integrated with an Enhanced Machine Controller (EMC) system, as described below, to control a machining center.

This report is self-contained in regard to the RS274/NGC language, the canonical machining functions, and the operation of the SAI; no other documents should be required to understand them fully. The report is not self-contained with regard to EMC systems. The reader operating an EMC system will need additional documentation.

The report does not deal with unimplemented alternatives or research issues.

1.1 Audience

This report is intended to be useful to:

  • programmers writing RS274/NGC programs that will be run on an EMC controller or tested on the SAI,

  • machine operators running machining centers with EMC controllers,

  • people installing the SAI software,

  • software developers building controllers for machining centers,

  • manufacturing researchers.

The beginning of each major section and appendix of the report describes the audience for the section.

1.2 Background

1.2.1 Enhanced Machine Controller Project

The Intelligent Systems Division of the National Institute of Standards and Technology (NIST) is carrying out an Enhanced Machine Controller project. The primary objective of the project is to build a testbed for evaluating application programming interface standards for open-architecture machine controllers. A secondary objective is to demonstrate implementations of the Next Generation Controller (NGC) architecture.

1.2.2 Numerical Control Programming Language RS274

RS274 is a programming language for numerically controlled (NC) machine tools, which has been used for many years. The most recent standard version of RS274 is RS274-D, which was completed in 1979. It is described in the document “EIA Standard EIA-274-D” by the Electronic Industries Association [EIA]. Most NC machine tools can be run using programs written in RS274. Implementations of the language differ from machine to machine, however, and a program that runs on one machine probably will not run on one from a different maker.

1.2.3 The RS274/NGC Language

The NGC architecture has many independent parts, one of which is a specification for the RS274/ NGC language, a numerical control code language for machining and turning centers. The specification was originally given in an August 24, 1992 report “RS274/NGC for the LOW END CONTROLLER -First Draft” [Allen-Bradley] prepared by the Allen-Bradley company. A second draft of that document was released in August 1994 by the National Center for Manufacturing Sciences under the name “The Next Generation Controller Part Programming Functional Specification (RS-274/NGC)” [NCMS]. All references in this report are to the second draft. The RS274/NGC language has many capabilities beyond those of RS274-D.

In the remainder of this report, “the RS274/NGC language” means that portion of the specification implemented in the EMC project (with modifications and additions). The report does not provide specific references to parts of [NCMS] or discuss how the implementation differs from it. The in-line documentation of the source code for the Interpreter, however, has many references and discusses differences.

1.2.4 Previous Work at NIST

As part of its assistance to the program that developed the NGC architecture, the Intelligent Systems Division prepared a report “NIST Support to the Next Generation Controller Program: 1991 Final Technical Report,” [Albus] containing a variety of suggestions. Appendix C to that report proposed three sets of commands for 3-axis machining, one set for each of three proposed hierarchical control levels. The suite proposed for the lowest (primitive) control level was implemented in 1993 by the EMC project as a set of functions in the C programming language. This suite, known in the EMC project and in this report as the “canonical machining functions,” was upgraded in 1994 for 4-axis machining, and in 1995 for 5-axis machining. For the Interpreter, the suite has been revised to be suitable for 3-axis to 6-axis machining.

Also in 1993, the authors developed a software system in the C language for reading machining commands in the RS274/NGC language and outputting canonical machining functions. This was called “the RS274/NGC Interpreter.” A report, “The NIST RS274/NGC Interpreter, Version 1” [Kramer1] was published in April 1994 describing that interpreter.

In 1994, the EMC project, in collaboration with the General Motors Company (GM), undertook to retrofit a 4-axis Kearney and Trecker 800 machining center with an EMC controller. The retrofit was successfully completed in 1995. For this project, NIST built both Version 2 of the RS274/ NGC Interpreter and an RS274KT Interpreter, which interprets programs written in the K&T dialect of RS274 [K&T]. These two interpreters were written in the C++ programming language. Reports were written describing the RS274KT Interpreter [Kramer2] and version 2 of the RS274/ NGC Interpreter [Kramer3]. In addition, a report about the canonical machining functions was written [Proctor] which extended them to six axes.

In 1995 the EMC project collaborated with several industrial partners in an open-architecture machine tool controller project known as VGER (a name, not an acronym). This project retrofitted an SNK 5-axis machining center with an open architecture controller. NIST provided the RS274 interpreter for this project [Kramer4]. It was intended to be able to interpret some existing programs for the SNK machine which were written for its former Fanuc controller [Fanuc]. Thus, the RS274/VGER Interpreter took Fanuc flavored RS274/NGC code as input.

1.2.5 Current Work at NIST

The EMC project has provided the EMC controller to several small machine shops. Version 2 of the RS274/NGC Interpreter, with numerous upgrades, has been used as the interpreter. In order to be able to provide EMC controllers for 3-axis to 6-axis machining centers without having many sets of source code to maintain, it was decided to build a single set of interpreter source code that would serve for all. The Interpreter reported here is that one.

1.3 Major Characteristics of the Interpreter

1.3.1 How it Runs

When the Interpreter starts up, before accepting any input, it sets up a world model that includes data about itself, parameter data, and data about the machining center being controlled (including data about the tools in the tool carousel of the machine).

Once initialized, the Interpreter runs using a two-step process:

  1. Get a line of RS274/NGC code and read it into memory, building an internal representation of the meaning of the entire line. We will call this stage “reading.”

  2. Change internal state and/or call one or more canonical machining functions (see Section 4 ) in order to do what the line says to do. We will call this “executing” the line.

The Interpreter runs integrated with the EMC system or in the SAI system. The Interpreter software is the same in both cases. We will refer to the software that tells the Interpreter what to do and asks it for data as the “driver,” regardless of whether it runs in the EMC system or in the SAI.

If an error occurs, the Interpreter returns an error code to the driver. It is always possible to recover from an error that occurs during reading. If an error occurs while executing the line, recoverability is situation dependent.

1.3.2 Modes of Use

1.3.2.1 Integrated with EMC System

In the EMC system, the Interpreter is used both to interpret NC programs from files and to interpret individual commands entered using the manual data input (MDI) capability of the control system. When running an NC program from a file, the driver tells the Interpreter when to read another line of code from the program file. When using MDI input, the driver sends the Interpreter a line of code to read that the controller has received from its user interface. Either way, the Interpreter reads the line and tells the driver if the line was readable. If so, the driver tells the Interpreter to execute the line.

The Interpreter does not control machine action directly. Rather, the Interpreter calls canonical machining functions that generate messages, which are passed back to the control system. The control system queues up and executes the messages.

1.3.2.2 Stand-Alone Interpreter (SAI)

The SAI runs in a command window on any computer for which it is compiled. It also reads either from a file or by MDI (from the keyboard of the computer). The SAI is intended to allow the pretesting of NC programs. It can also be used in MDI mode to experiment with the RS274/NGC language and the Interpreter.

2 Machining Center Overview

This section gives a brief description of how a machining center is viewed from the input and output ends of the Interpreter. It is assumed the reader is already familiar with machining centers. This section is intended to be useful to NC programmers, machine operators, developers, and researchers. SAI installers will probably not find it useful.

The section describes the format of tool files, which are required for using the Interpreter but are not known to either the RS274/NGC language or the canonical machining functions. Parameter files, also required by the Interpreter, are described in Section 3.2.1 .

2.1 Machining Centers

Both the RS274/NGC input language and the output canonical machining functions have a view of (1) mechanical components of a machining center being controlled and (2) what activities of the machining center may be controlled, and what data is used in control. The two views of the mechanical components are very similar, the canonical machining function view including a few more components. The two views of control and data differ significantly, with the canonical machining function view being much simpler in most cases; the Interpreter deals with many complexities of the RS274/NGC language so that lower levels of control do not have to. For example, the RS274/NGC language includes a single command to perform a peck drilling cycle. The Interpreter decomposes this complex single command into many simple straight_feed and straight_traverse canonical function calls.

This section, Section 2, presents the elements that are shared between the two views. Unshared elements of the two views are described in Section 3.2 (RS274/NGC language) and Section 4.2 (canonical machining functions).

The view here includes some items that a given machining center may not have, such as a pallet shuttle. The RS274/NGC language and canonical machining functions may be used with such a machine provided that no NC program used with the controller includes commands intended to activate physical capabilities the machine does not have. For such a machine, it would be useful to modify the Interpreter so it will reject input commands and will not produce output canonical function calls addressed to non-existent equipment. For each of the A, B, and C axes, the Interpreter source code already handles the case of the missing axis, as described in Section 5.2.

2.1.1 Mechanical Components

A machining center has many mechanical components that may be controlled or may affect the way in which control is exercised. This section describes the subset of those components that interact with the Interpreter. Mechanical components that do not interact directly with the Interpreter, such as the jog buttons, are not described here, even if they affect control.

2.1.1.1 Linear Axes

A machining center has independent mechanisms1 for producing relative linear motion of the tool

1. If the motion of mechanical components is not independent, as with hexapod machines, the RS274/NGC language and the canonical machining functions will still be usable, as long as the lower levels of control know how to control the actual mechanisms to produce the same relative motion of tool and workpiece as would be produced by independent axes.

and workpiece in three mutually orthogonal directions. These are the X, Y and Z axes.

2.1.1.2 Rotational axes

Three additional independent mechanisms produce relative rotation of the workpiece and the tool around an axis. These mechanisms (often a rotary table on which the workpiece is mounted or a drum on which the spindle is mounted) are called rotational axes and labelled A, B, and C. The A-axis is parallel to the X-axis. B is parallel to the Y-axis, and C parallel to the Z-axis1. Each rotational mechanism may or may not have a mechanical limit on how far it can rotate.

2.1.1.3 Spindle

A machining center has a spindle which holds one cutting tool, probe, or other item. The spindle can rotate in either direction, and it can be made to rotate at a constant rate, which may be changed. Except on machines where the spindle may be moved by moving a rotational axis, the axis of the spindle is kept parallel to the Z-axis and is coincident with the Z-axis when X and Y are zero. The spindle can be stopped in a fixed orientation or stopped without specifying orientation.

2.1.1.4 Coolant

A machining center has components to provide mist coolant and/or flood coolant. The canonical machining functions view also has through-tool coolant; see Section 4.2.2.1.

2.1.1.5 Pallet Shuttle

A machining center has a pallet shuttle system. The system has two movable pallets on which workpieces can be fixtured. Only one pallet at a time is in position for machining.

2.1.1.6 Tool Carousel

A machining center has a tool carousel with slots for tools fixed in tool holders.

2.1.1.7 Tool Changer

A machining center has a mechanism for changing tools (fixed in tool holders) between the spindle and the tool carousel.

2.1.1.8 Message Display

A machining center has a device that can display messages.

2.1.1.9 Feed and Speed Override Switches

A machining center has separate feed and speed override switches, which let the operator specify that the actual feed rate or spindle speed used in machining should be some percentage of the programmed rate. See Section 2.1.2.15 and Section 2.2.1 .

  1. Block Delete Switch

  2. Optional Program Stop Switch

A machining center has a block delete switch. See Section 2.2.2 .

A machining center has an optional program stop switch. See Section 2.2.3.

1. The requirement of parallelism is not used by either language, so both languages are usable if any rotational axis is not parallel to any linear axis. Rotational axis commands flow through both languages to lower levels of control without significant change in nature.

2.1.2 Control and Data Components

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

2.1.2.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 deceases 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 workpiece. If the workpiece is fastened to a turntable which turns on a rotational axis, a counterclockwise turn from the point of view of the workpiece 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

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

2.1.2.4 Coordinated Linear Motion

To drive a tool along a specified path, a machining center must often coordinate 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 same path, and we also call this kind of motion coordinated linear motion.

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

1. If the parallelism requirement is violated, the system builder will have to say how to distinguish clockwise from counterclockwise.

2.1.2.5 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 mode is being used in the RS274/NGC view (see Section 3.5.19). The canonical machining functions view of feed rate, as described in Section 4.3.5.1, has conditions under which the set feed rate is applied differently, but none of these is used in the Interpreter.

A. For motion involving one or more of the X, Y, and Z axes (with or without simultaneous rotational axis motion), the feed rate means length units per minute along the programmed XYZ path, as if the rotational axes were not moving.

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

C. 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 = (dA)2+ (dB)2+ (dC )2 . 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.

2.1.2.6 Arc Motion

Any pair of the linear axes (XY, YZ, 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 item A of Section 2.1.2.5, immediately above. In the case of helical motion, the rate is applied along the helix. In some other versions of RS274, the rate is applied to the circular arc which is the projection of the helix on the selected plane.

2.1.2.7 Coolant

Flood coolant and mist coolant may each be turned on independently. The RS274/NGC language turns them off together (see Section 3.6.4) while the canonical machining functions turn them off independently (see Section 4.3.9 ).

2.1.2.8 Dwell

A machining center 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, so the spindle is usually turning during a dwell.

2.1.2.9 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 in Section 2.1.2.5 .

2.1.2.10 Current Position

The controlled point is always at some location called the “current position,” and the controller always knows where that is. The numbers representing the current position must be adjusted in the absence of any axis motion if any of several events take place:

  1. Length units are changed.

  2. Tool length offset is changed.

  3. Coordinate system offsets are changed.

2.1.2.11 Selected Plane

There is always a “selected plane”, which must be the XY-plane, the YZ-plane, or the XZ-plane of the machining center. 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.

2.1.2.12 Tool Carousel

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

2.1.2.13 Tool Change

A machining center may be commanded to change tools.

2.1.2.14 Pallet Shuttle

The two pallets may be exchanged by command.

2.1.2.15 Feed and Speed Override Switches

The feed and speed override switches may be enabled (so they work as expected) or disabled (so they have no effect on the feed rate or spindle speed). The RS274/NGC language has one command that enables both switches and one command that disables both (see Section 3.6.5). The canonical machining functions have separate commands for the two switches (see Section 4.3.9). See Section 2.2.1 for further details.

2.1.2.16 Path Control Mode

The machining center may be put into any one of three path control modes: (1) exact stop mode,

(2) exact path mode, or (3) continuous mode. In exact stop mode, the machine stops briefly at the end of each programmed move. In exact path mode, the machine follows the programmed path as exactly as possible, slowing or stopping if necessary at sharp corners of the path. In continuous mode, sharp corners of the path may be rounded slightly so that the feed rate may be kept up. See Section 3.5.14 and Section 4.3.5.3

The canonical machining functions share with the RS274 language the simplifying assumption that machine dynamics can be almost ignored. That is, in this model, acceleration and deceleration do not occur. Components of the machining center can be told to move at a specific rate, and that rate is imagined as being achieved instantaneously. Stopping is also imagined as instantaneous. This model obviously does not correspond with reality. The control modes provided here provide some compensation for this lack of consideration of dynamics.

2.2 Interpreter Interaction with Switches

As noted in Section 2.1.2, the Interpreter interacts with three switches. This section describes the interactions in more detail. In no case does the Interpreter know what the setting of any of these switches is.

2.2.1 Feed and Speed Override Switches

The Interpreter will interpret RS274/NGC commands which enable (M48) or disable (M49) the feed and speed override switches and will make canonical machining function calls to enable or disable them (Section 4.3.9). 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.

The EMC control system reacts to the setting of the speed or feed override switches on the control panel, when these switches are enabled.

The SAI does not emulate these switches.

2.2.2 Block Delete Switch

If the block delete switch is on, lines of RS274/NGC code which start with a slash (the block delete character) are not interpreted. If the switch is off, such lines are interpreted.

As outlined in Section 1.3.1, the Interpreter runs in two stages (read and execute). The driver tells the Interpreter when to perform each stage. When the Interpreter reads a line starting with a slash, it informs the driver, “I just read a line starting with a slash.” The driver checks the setting of the block delete switch. If the switch is off, it tells the Interpreter, “Execute that line.” If the switch is on, the driver does not tell the Interpreter to execute the line. Instead, it tells the Interpreter to read another line, with the result that the line starting with the slash is not executed.

In the SAI, the block delete switch may be set, and its default setting is off.

2.2.3 Optional Program Stop Switch

The optional program stop switch works as follows. If this switch is on and an input RS274/NGC code line contains an M1 code, program execution is supposed to stop until the cycle start button is pushed. The Interpreter interprets an M1 on an input line into an OPTIONAL_PROGRAM_STOP canonical function call in the output (see Section 4.3.10).

When the Interpreter is integrated with the EMC system, the controller checks the optional stop switch when the OPTIONAL_PROGRAM_STOP canonical function call is executed and either stops (if the switch is on) or not (if the switch is off).

The SAI does not emulate the optional program stop switch.

2.3 Tool File

A tool file is required to use the Interpreter. The file tells which tools are in which carousel slots and what the length and diameter of each tool are.

The Interpreter does not deal directly with tool files. A tool file is read either by the EMC system or the SAI, as the case may be, and the Interpreter gets the tool information by making calls to canonical functions that obtain it from the EMC system or SAI.

The format of a tool file is exemplified in Table 1 .

The file consists of any number of header lines, followed by one blank line, followed by any number of lines of data. The header lines are ignored. It is important that there be exactly one blank line (with no spaces or tabs, even) before the data. The header line shown in Table 1 describes the data columns, so it is suggested (but not required) that such a line always be included in the header.

Each data line of the file contains the data for one tool. Each line has five entries. The first four entries are required. The last entry (a comment) is optional. It makes reading easier if the entries are arranged in columns, as shown in the table, but the only format requirement is that there be at least one space or tab after each of the first three entries on a line and a space, tab, or newline at the end of the fourth entry. The meanings of the columns and the type of data to be put in each are as follows.

The “POCKET” column contains an unsigned integer which represents the pocket number (slot number) of the tool carousel slot in which the tool is placed. The entries in this column must all be different.

The “FMS” column contains an unsigned integer which represents a code number for the tool. The user may use any code for any tool, as long as the codes are unsigned integers.

The “TLO” column contains a real number which represents the tool length offset. This number will be used if tool length offsets are being used and this pocket is selected. This is normally a positive real number, but it may be zero or any other number if it is never to be used.

The “DIAM” column contains a real number. This number is used only if tool radius compensation is turned on using this pocket. If the programmed path during compensation is the edge of the material being cut, this should be a positive real number representing the measured diameter of the tool. If the programmed path during compensation is the path of a tool whose diameter is nominal, this should be a small number (positive, negative, or zero) representing the difference between the measured diameter of the tool and the nominal diameter. If cutter radius compensation is not used with a tool, it does not matter what number is in this column.

The “Comment” column may optionally be used to describe the tool. Any type of description is OK. This column is for the benefit of human readers only.

The SAI only reads data from the first four columns of each line. The rest of the line is read but ignored.

The units used for the length and diameter of the tool may be in either millimeters or inches, but if the data is used by an NC program, the user must be sure the units used for a tool in the file are the same as the units in effect when NC code that uses the tool data is interpreted. The table shows a mixture of types of units.

The lines do not have to be in any particular order. Switching the order of lines has no effect on the SAI (unless the same slot number is used on two or more lines, which should not normally be done, in which case the data for only the last such line will persist).

POCKET FMS TLO DIAMETER COMMENT
1 1 2.0 1.0
2 2 1.0 0.2
5 5 1.5 0.25 endmill
10 10 2.4 -0.3 for testing
21 21 173.740 0 1/2” spot drill
32 32 247.615 0 8.5 mm drill
41 41 228.360 0 10 mm tap
60 60 0 0 large chuck
Table 1. Sample Tool File

3 Input: the RS274/NGC Language

This section describes the input language, RS274/NGC. This section is intended for NC programmers, machine operators, developers and researchers. SAI installers can skip it.

3.1 Overview

The RS274/NGC language is based on lines of code. Each line (also called a “block”) may include commands to a machining center 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 RS274/NGC commands start with either G or M (for miscellaneous). The words for these commands are called “G codes” and “M codes.”

The RS274/NGC language has no indicator for the start of a program. The Interpreter, however, deals with files. A single program may be in a single file, or a program may be spread across several files. A file may demarcated with percents in the following way. The first non-blank line of a file may contain nothing but a percent sign, “%”, possibly surrounded by white space, and later in the file (normally at the end of the file) there may be a similar line. Demarcating a file with percents is optional if the file has an M2 or M30 in it, but is required if not. An error will be signalled if a file has a percent line at the beginning but not at the end. The useful contents of a file demarcated by percents stop after the second percent line. Anything after that is ignored.

The RS274/NGC 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. The SAI does not even read them.

3.2 RS274/NGC Language View of a Machining Center

The RS274/NGC language is based on a particular view of what a machining center to be controlled is like. The view is as described in Section 2.1, with the changes described below. The RS274/NGC language view includes one mechanical component not known to the canonical machining functions: a cycle start button. The use of the button is described in Section 3.6.1 .

The RS274/NGC language contains commands that change the way subsequent commands are to be interpreted, but do not tell the machining center to do anything. These are not covered in this section, but are dealt with as they arise in Section 3.5.17, Section 3.5.19, and Section 3.5.20 .

3.2.1 Parameters

In the RS274/NGC language view, a machining center maintains an array of 5400 numerical parameters. Many of them have specific uses. The parameter array should persist over time, even if the machining center is powered down. The RS274/NGC language makes no provision regarding how to ensure persistence. The EMC project uses a parameter file to ensure persistence and gives the Interpreter the responsibility for maintaining the file. The Interpreter reads the file when it starts up, and writes the file when it exits.

Parameter number Parameter value Comment Parameter number Parameter value Comment
5161 5162 5163 5164 5165 5166 5181 5182 5183 5184 5185 5186 5211 5212 5213 5214 5215 5216 5220 5221 5222 5223 5224 5225 5226 5241 5242 5243 5244 5245 5246 5261 5262 5263 5264 5265 5266 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 G28 home X G28 home Y G28 home Z G28 home A G28 home B G28 home C G30 home X G30 home Y G30 home Z G30 home A G30 home B G30 home C G92 offset X G92 offset Y G92 offset Z G92 offset A G92 offset B G92 offset C coord. system number coord. system 1 X coord. system 1 Y coord. system 1 Z coord. system 1 A coord. system 1 B coord. system 1 C coord. system 2 X coord. system 2 Y coord. system 2 Z coord. system 2 A coord. system 2 B coord. system 2 C coord. system 3 X coord. system 3 Y coord. system 3 Z coord. system 3 A coord. system 3 B coord. system 3 C 5281 5282 5283 5284 5285 5286 5301 5302 5303 5304 5305 5306 5321 5322 5323 5324 5325 5326 5341 5342 5343 5344 5345 5346 5361 5362 5363 5364 5365 5366 5381 5382 5383 5384 5385 5386 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 coord. system 4 X coord. system 4 Y coord. system 4 Z coord. system 4 A coord. system 4 B coord. system 4 C coord. system 5 X coord. system 5 Y coord. system 5 Z coord. system 5 A coord. system 5 B coord. system 5 C coord. system 6 X coord. system 6 Y coord. system 6 Z coord. system 6 A coord. system 6 B coord. system 6 C coord. system 7 X coord. system 7 Y coord. system 7 Z coord. system 7 A coord. system 7 B coord. system 7 C coord. system 8 X coord. system 8 Y coord. system 8 Z coord. system 8 A coord. system 8 B coord. system 8 C coord. system 9 X coord. system 9 Y coord. system 9 Z coord. system 9 A coord. system 9 B coord. system 9 C
Table 2. Default Parameter File Actual file is in 3 columns, not 6. A, B, and C values are conditional. Comments are optional. All the parameters in this file are required. All values are set to 0.0, except 5220 is 1.0.

The format of a parameter file is shown in Table 2. The file consists of any number of header lines, followed by one blank line, followed by any number of lines of data. The Interpreter skips over the header lines. It is important that there be exactly one blank line (with no spaces or tabs, even) before the data. The header line shown in Table 2 describes the data columns, so it is suggested (but not required) that that line always be included in the header.

The Interpreter reads only the first two columns of the table. The third column, “Comment,” is not read by the Interpreter.

Each line of the file contains the index number of a parameter in the first column and the value to which that parameter should be set in the second column. The value is represented as a double-precision floating point number inside the Interpreter, but a decimal point is not required in the file. All of the parameters shown in Table 2 are required parameters and must be included in any parameter file, except that any parameter representing a rotational axis value for an unused axis may be omitted. An error will be signalled if any required parameter is missing. A parameter file may include any other parameter, as long as its number is in the range 1 to 5400. The parameter numbers must be arranged in ascending order. An error will be signalled if not. Any parameter included in the file read by the Interpreter will be included in the file it writes as it exits. The original file is saved as a backup file when the new file is written.

3.2.2 Coordinate Systems

In the RS274/NGC language view, a machining center has an absolute coordinate system and nine program coordinate systems.

You can set the offsets of the nine program coordinate systems using G10 L2 Pn (n is the number of the coordinate system) with values for the axes in terms of the absolute coordinate system. See Section 3.5.5 .

You can select one of the nine systems by using G54, G55, G56, G57, G58, G59, G59.1, G59.2, or G59.3 (see Section 3.5.13 ). It is not possible to select the absolute coordinate system directly.

You can offset the current coordinate system using G92 or G92.3. This offset will then apply to all nine program coordinate systems. This offset may be cancelled with G92.1 or G92.2. See Section

3.5.18 .

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

Data for coordinate systems is stored in parameters.

During initialization, the coordinate system is selected that is specified by parameter 5220. A value of 1 means the first coordinate system (the one G54 activates), a value of 2 means the second coordinate system (the one G55 activates), and so on. It is an error for the value of parameter 5220 to be anything but a whole number between one and nine.

3.3 Format of a Line

A permissible line of input RS274/NGC 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.

  1. an optional block delete character, which is a slash “/” .

  2. an optional line number.

  3. any number of words, parameter settings, and comments.

4. 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. To make the specification of an allowable line of code precise, we have defined it in a production

language (Wirth Syntax Notation) in Appendix E .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. The line “g0x +0. 12 34y 7” is equivalent to “g0 x+0.1234 y7”, for example. Blank lines are allowed in the input. They are to 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.

3.3.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. Line numbers may also be skipped, and that is normal practice. A line number is not required to be used, but must be in the proper place if used.

3.3.2 Word

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

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

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 (see Table 5)
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
key used with G10
M miscellaneous function (see Table 7)
N line number
P dwell time in canned cycles
dwell time with G4
key used with G10
Q feed increment in G83 canned cycle
R arc radius
canned cycle plane
S spindle speed
T tool selection
X X-axis of machine
Y Y-axis of machine
Z Z-axis of machine
Table 3. Word-starting Letters

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.

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

  • 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 in RS274/NGC 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.

3.3.2.2 Parameter Value

A parameter value is the pound character # followed by a real value. The real value must evaluate to an integer between 1 and 5399. 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.

3.3.2.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 nonexclusive 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.

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

3.3.3 Parameter Setting

A parameter setting is the following four items one after the other: (1) a pound character # , (2) a real value which evaluates to an integer between 1 and 5399, (3) an equal sign = , and (4) 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.

3.3.4 Comments and Messages

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)”. Comments do not cause a machining center to do anything.

A comment 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. The rest of the characters before the right parenthesis are considered to be a message. Messages should be displayed on the message display device. Comments not containing messages need not be displayed there.

3.3.5 Item Repeats

A line may have any number of G words, but two G words from the same modal group (see Section 3.4 ) 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.

For all other legal letters, a line may have only one word beginning with that letter.

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.

3.3.6 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, the line “g40 g1 #3=15 (foo) #4=-7.0” 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 (foo)”) for the five items.

3.3.7 Commands and Machine Modes

In RS274/NGC, many commands cause a machining center 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.

3.4 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 center may be in many modes at the same time, with one mode from each modal group being in effect. The modal groups are shown in Table 4 .

The modal groups for G codes are:

group 1 = {G0, G1, G2, G3, G38.2, G80, G81, G82, G83, 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.1, G59.2, G59.3} coordinate system selection group 13 = {G61, G61.1, G64} path control mode

The modal groups for M codes are:

group 4 = {M0, M1, M2, M30, M60} stopping group 6 = {M6} tool change group 7 = {M3, M4, M5} spindle turning group 8 = {M7, M8, M9} coolant (special case: M7 and M8 may be active at the same time) group 9 = {M48, M49} enable/disable feed and speed override switches

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}

Table 4. Modal Groups

For several modal groups, when a machining center 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 center 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.

3.5 G Codes

G codes of the RS274/NGC language are shown in Table 5 and described following that.

The descriptions contain command prototypes, set in helvetica type.

In the command prototypes, three dots (…) stand for a real value. As described earlier, a real value may be (1) an explicit number, 4, for example, (2) an expression, [2+2], for example, (3) a parameter value, #88, for example, or (4) a unary function value, acos[0], for example.

In most cases, if axis words (any or all of X…, Y…, Z…, A…, B…, C…) are given, they specify a destination point. Axis numbers are in the currently active coordinate system, unless explicitly described as being in the absolute coordinate system. Where axis words are optional, any omitted axes will have their current value. Any items in the command prototypes not explicitly described as optional are required. It is an error if a required item is omitted.

In the prototypes, the values following letters are often given as explicit numbers. Unless stated otherwise, the explicit numbers can be real values. For example, G10 L2 could equally well be written G[2*5] L[1+1]. If the value of parameter 100 were 2, G10 L#100 would also mean the same. Using real values which are not explicit numbers as just shown in the examples is rarely useful.

If L… is written in a prototype the “…” will often be referred to as the “L number”. Similarly the “…” in H… may be called the “H number”, and so on for any other letter.

G Code Meaning

G0 rapid positioning G1 linear interpolation G2 circular/helical interpolation (clockwise) G3 circular/helical interpolation (counterclockwise) G4 dwell G10 coordinate system origin setting G17 XY-plane selection G18 XZ-plane selection G19 YZ-plane selection G20 inch system selection G21 millimeter system selection G28 return to home G30 return to secondary home G38.2 straight probe G40 cancel cutter radius compensation G41 start cutter radius compensation left G42 start cutter radius compensation right G43 tool length offset (plus) G49 cancel tool length offset G53 motion in machine coordinate system G54 use preset work coordinate system 1 G55 use preset work coordinate system 2 G56 use preset work coordinate system 3 G57 use preset work coordinate system 4 G58 use preset work coordinate system 5 G59 use preset work coordinate system 6 G59.1 use preset work coordinate system 7 G59.2 use preset work coordinate system 8 G59.3 use preset work coordinate system 9 G61 set path control mode: exact path G61.1 set path control mode: exact stop G64 set path control mode: continuous G80 cancel motion mode (including any canned cycle) G81 canned cycle: drilling G82 canned cycle: drilling with dwell G83 canned cycle: peck drilling G84 canned cycle: right hand tapping G85 canned cycle: boring, no dwell, feed out G86 canned cycle: boring, spindle stop, rapid out G87 canned cycle: back boring G88 canned cycle: boring, spindle stop, manual out G89 canned cycle: boring, dwell, feed out G90 absolute distance mode G91 incremental distance mode G92 offset coordinate systems and set parameters G92.1 cancel offset coordinate systems and set parameters to zero G92.2 cancel offset coordinate systems but do not reset parameters G92.3 apply parameters to offset coordinate systems G93 inverse time feed rate mode G94 units per minute feed rate mode G98 initial level return in canned cycles G99 R-point level return in canned cycles

Table 5. G Codes

3.5.1 Rapid Linear Motion — G0

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.

It is an error if:

• all axis words are omitted.

If cutter radius compensation is active, the motion will differ from the above; see Appendix B. If G53 is programmed on the same line, the motion will also differ; see Section 3.5.12 .

3.5.2 Linear Motion at Feed Rate — G1

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 coordinated linear motion to the destination point at the current feed rate (or slower if the machine will not go that fast).

It is an error if:

• all axis words are omitted.

If cutter radius compensation is active, the motion will differ from the above; see Appendix B. If G53 is programmed on the same line, the motion will also differ; see Section 3.5.12 .

3.5.3 Arc at Feed Rate — G2 and G3

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 (Zaxis, 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 RS274/NGC 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 what is described here. See Appendix B .

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.

3.5.3.1 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 x 10 y 15 r 20 z 5.

That means to make a clockwise (as viewed from the positive Z-axis) circular or helical arc whose axis is parallel to the Z-axis, ending where X=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.

3.5.3.2 Center Format Arc

In the center format, the coordinates of the end point of the arc in the selected plane are specified along with the offsets of the center of the arc from the current location. In this format, it is OK if the end point of the arc is the same as the current point. It is an error if:

• when the arc is projected on the selected plane, the distance from the current point to the center differs from the distance from the end point to the center by more than 0.0002 inch (if inches are being used) or 0.002 millimeter (if millimeters are being used).

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 (in the 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 (in the 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 (in the 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: G17 G2 x 10 y 16 i 3 j 4 z 9.

That means to make a clockwise (as viewed from the positive z-axis) circular or helical arc whose axis is parallel to the Z-axis, ending where X=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.

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.

3.5.4 Dwell — G4

For a dwell, program G4 P… . This will keep the axes unmoving for the period of time in seconds specified by the P number. It is an error if:

• the P number is negative.

3.5.5 Set Coordinate System Data — G10

The RS274/NGC language view of coordinate systems is described in Section 3.2.2 .

To set the coordinate values for the origin of a 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 9 (corresponding to G54 to G59.3) 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 1 to 9.

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.

Example: G10 L2 P1 x 3.5 y 17.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.

3.5.6 Plane Selection — G17, G18, and G19

Program 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 Section 3.5.3 and Section 3.5.16.

3.5.7 Length Units — G20 and G21

Program G20 to use inches for length units. Program G21 to use millimeters.

It is usually a good idea to program either G20 or G21 near the beginning of a program before any motion occurs, and not to use either one anywhere else in the program. It is the responsibility of the user to be sure all numbers are appropriate for use with the current length units.

3.5.8 Return to Home — G28 and G30

Two home positions are defined (by parameters 5161-5166 for G28 and parameters 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 programmed 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 programmed, the intermediate point is the current point, so only one move is made.

3.5.9 Straight Probe — G38.2

3.5.9.1 The Straight Probe Command

Program G38.2 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 millimeter or 0.01 inch from the programmed point.

  • G38.2 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, the probe 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 signalled.

After successful probing, parameters 5061 to 5066 will be set to the coordinates of the location of the controlled point at the time the probe tripped.

3.5.9.2 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 an RS274/NGC 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.

3.5.9.3 Example Code

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

In Table 6, 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.

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 .) N040 (Delete lines N020, N030, and N040 when you do that.) N050 G0 Z F N060 #1001= N070 #1002= N080 #1003= N090 #1004= N100 #1005=[/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 G38.2 X[#1001 + #1005] (probe +X side of hole) N140 #1011=#5061 (save results) N150 G0 X#1001 Y#1002 (back to center of hole) N160 G38.2 X[#1001 - #1005] (probe -X side of hole) N170 #1021=[[#1011 + #5061] / 2.0] (find pretty good X-value of hole center) N180 G0 X#1021 Y#1002 (back to center of hole) N190 G38.2 Y[#1002 + #1005] (probe +Y side of hole) N200 #1012=#5062 (save results) N210 G0 X#1021 Y#1002 (back to center of hole) N220 G38.2 Y[#1002 - #1005] (probe -Y side of hole) N230 #1022=[[#1012 + #5062] / 2.0] (find very good Y-value of hole center) N240 #1014=[#1012 - #5062 + [2 * #1004]] (find hole diameter in Y-direction) N250 G0 X#1021 Y#1022 (back to center of hole) N260 G38.2 X[#1021 + #1005] (probe +X side of hole) N270 #1031=#5061 (save results) N280 G0 X#1021 Y#1022 (back to center of hole) N290 G38.2 X[#1021 - #1005] (probe -X side of hole) N300 #1041=[[#1031 + #5061] / 2.0] (find very good X-value of hole center) N310 #1024=[#1031 - #5061 + [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)

Table 6. Code to Probe Hole

3.5.10 Cutter Radius Compensation — G40, G41, and G42

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.

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 center when cutter radius compensation is on is described in Appendix B .

3.5.11 Tool Length Offsets — G43 and G49

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.

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.

3.5.12 Move in Absolute Coordinates — G53

For linear motion to a point expressed in absolute coordinates, program G1 G53 X… Y… Z… A… B… C… (or use 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 the current motion mode. G53 is not modal and must be programmed on each line on which it is intended to be active. This will produce coordinated linear motion to the programmed point. If G1 is active, the speed of motion is the current feed rate (or slower if the machine will not go that fast). If G0 is active, the speed of motion is the current traverse rate (or slower if the machine will not go that fast).

It is an error if:

• G53 is used without G0 or G1 being active,

• G53 is used while cutter radius compensation is on.See Section 3.2.2 for an overview of coordinate systems.

3.5.13 Select Coordinate System — G54 to G59.3

To select coordinate system 1, program G54, and similarly for other coordinate systems. The system-number—G-code pairs are: (1—G54), (2—G55), (3—G56), (4—G57), (5—G58), (6—

G59), (7—G59.1), (8—G59.2), and (9—G59.3). It is an error if:

• one of these G-codes is used while cutter radius compensation is on. See Section 3.2.2 for an overview of coordinate systems.

3.5.14 Set Path Control Mode — G61, G61.1, and G64

Program G61 to put the machining center into exact path mode, G61.1 for exact stop mode, or G64 for continuous mode. It is OK to program for the mode that is already active. See Section

  1. for a discussion of these modes.

  2. Cancel Modal Motion — G80

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.

3.5.16 Canned Cycles — G81 to G89

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, 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, OLD_Z), or otherwise to the R position. See Section 3.5.20

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.

3.5.16.1 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:

1. a straight traverse parallel to the XY-plane to the given XY-position,

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

3.5.16.2 G81 Cycle

The G81 cycle is intended for drilling. Program G81 X… Y… Z… A… B… C… R… L…

  1. Preliminary motion, as described above.

  2. Move the Z-axis only at the current feed rate to the Z position.

  3. 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) and OLD_Z retract mode (G98) and calls for the G81 drilling cycle to be performed once. The X number and X position are 4. The Y number and Y position are 5. The Z number and Z position are 1.5. The R number and clear Z are 2.8. Old Z is 3. The following moves take place.

  1. a traverse parallel to the XY-plane to (4,5,3)

  2. a traverse parallel to the Z-axis to (4,5,2.8)

  3. a feed parallel to the Z-axis to (4,5,1.5)

  4. 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) and OLD_Z retract mode (G98) 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.

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.

  1. a traverse parallel to the XY-plane to (5,7,4.8)

  2. a feed parallel to the Z-axis to (5,7, 4.2)

  3. a traverse parallel to the Z-axis to (5,7,4.8)