CNC Programming FAQ for students, computer programmers, prospective CNC programmers, liberal arts majors, systems administrators working with CNC applications, and managers.
“I am in much dismay at having got into so amazing a quagmire & botheration with these Numbers” – Augusta Ada Byron, later Countess of Lovelace, arguably the world’s first technical writer.
1. What is CNC, anyway?
2. What is a G-code?
3. Can I get a bit more on G-codes?
4. What is DNC?
5. What is/are “Serial Communications”? Don’t bore me.
6. What is/are “Serial Communications”? I need details.
7. What is XModem?
8. How are CNC machines programmed?
9. What is APT?
10. What is a CL file?
11. What is a postprocessor?
12. What is “Dumb APT”?
13. Why am I confused by the letters I, J, and K?
14. What is an inverse-time feedrate?
CNC stands for Computer Numerical Control and refers to the operation of a machine tool via motors, switches, and so on, with a computer controlling the whole shebang. The tool itself may be as small as a benchtop lathe or as large as the gantry mills used to machine airplane wing spars. If you really needed an answer to this question, then you probably won’t be very interested in the rest of this.
CNC programs are usually made up of word addresses. These start with a letter and are usually followed by a numeric value. A word is usually referred to by its letter, hence the word X3.5 (specifying an X axis position) would be called an “X-word” and the word F15.0 (specifying a feedrate) would be called an “F-word” (really!). “G-words” specify things called Preparatory Function Codes and have come to be called “G-codes”. (Do not refer to “G-words” in earshot of a CNC programmer. “F-words” are generally ok to use.) G-codes often trigger machine movement – actually to be technically proper, they often trigger slide or axis movement. However, improperly used they sometimes cause machine movement.)
Think of these as 26 counters labeled A through Z inside the CNC controller.
G0 is generally used to denote a rapid traverse. For example, the command G0 X5.0 Z3.5 would cause the tool to move to an X position on 5.0 and a Z position of 3.5 as quickly as possible.
G1 is used to move the tool in a straight line at a feedrate you specify. This is a bit more complicated than it might first appear since moving from point A to point B at a specific rate often involves moving 3 machine axes at three different rates. G1 is usually called linear interpolation. The command G1 X4.5 Y3.0 Z-2.5 F20.0 would cause the tool to move to the specified XYZ position at a rate of 20 inches or millimeters per minute.
G2 is where things can start to get more complicated. It’s always used to make an arc, moving clockwise at a rate you specify. The G2 format you’ll see most creates an arc in the XY plane and specifies the arc center incrementally – for example G2 X-0.26 Y1.14 I0.5 J0.0 means “Starting from where the tool is now, move clockwise in an arc. The center of the arc has an X value 0.5 greater than the current position (from I0.5) and the same Y value as the current position (J0.0). Stop when you get to X-0.26 and Y1.14. Travel at whatever feedrate I last specified.”
Things get more complex if you need an arc that’s not parallel to the XY plane. Some machines allow G2 commands in the YZ and ZX planes, in which case Z axis center references are handled by the K-word. Some machines will create a helix with a G2. Some will create a circle with one G2, others may be limited to less than 90 degrees.
You can usually assume that a controller’s G2 command makes a clockwise arc, but not that it will be specified as described above. Some controllers require absolute center coordinates rather than relative, and some require an arc radius rather than a center, and some use all of these methods in various combinations. The EIA standards specify incremental centers but early lobbying by some folks (the Postprocessor Writer’s Guild?) appears to have created a situation whereby there are actually several ways to define a circle center.
G3 is like a G2, just think counterclockwise.
G4 is like some folks we’ve all worked with. It does nothing for a specified time. It just dwells – you’ll have to check your controller manual to see what follows the G4. Some use X, F, or P words in milliseconds, some allow an S word to specify spindle revolutions, and some allow nothing at all and default to about a half second.
G5 thru G89 will be dealt with as time permits. For now, the important ones to look up somewhere else are G17, G18, and G19. These have a dramatic effect on G2 and G3. Also, G53 thru G59 can transform your whole program (pun intended) and those in the G80 range can make a “hole” lot of difference.
G90 indicates that programmed values are to be treated as absolute, or actual coordinate values. If the programs issues a G1 X5.0 Z 2.0 , then the tool moves to that position. A venerable German tool maker once told us how he remembers that G90 means absolute – he said that the German word for absolute is obsolute and that the “o” looks like the “0″ in G90. Actually, the German word for absolute starts with an “a”, so either he couldn’t spell (possible) or we misunderstood (likely). Either way, it’s a good way to remember.
G91 indicates that programmed values are to be treated as incremental, or relative coordinate values. If the programs issues a G1 X5.0 Z 2.0 , then the tool moves five units in the positive X direction and two in the positive Z direction. The same tool maker (see G90) said that the “i” in the German inkrement looked like the “1″ in G91.
As usual, there’s more than one answer – even for the abbreviation. Some say it’s Direct Numerical Control (the original wording) and some say Distributed Numerical Control. All definitions include computer to machine tool communication, or what could be termed “tape elimination”. Then they differ based on including or excluding some or all of the following capabilities:
* Drip feeding a controller
* Accepting data from a controller
* Storing and organizing libraries of CNC programs
* Operating as a network
Originally, “DNC” defined an ambitious approach that involved controlling multiple machine tools directly from a central computer. This was during the “NC” days prior to CNC and was really a kind of hybrid CNC/DNC approach. The central computer was connected directly to machine servos. Eventually, as more and more tape elimination systems were developed, “DNC” was adopted to describe them instead, especially since the central computer approach was not very successful.
The short answer, which you probably don’t really care to know, is that serial communications is a bit by bit data transfer method. In a computer, each character is made up of a group of “bits”, an abbreviation for binary digits. In most computers, each character contains 8 bits. When communicating via a serial link, a couple of additional bits are tacked on for various reasons. If a computer is transferring data to a CNC controller at a speed of 9600bps (bits per second) and each character requires 10 bits to transfer, then 960 characters per second can be sent down the wire. Seven bit character codes are also widely used, so the “divide by 10″ method is slightly pessimistic for these. This is different from parallel communications, where each bit in a character has its own data path and the whole character gets sent in one shot. On PC’s, printer ports use parallel methods and comm ports use serial methods.
The long answer, which you may well need to know, is complicated enough that we gave it it’s own page – see the table of contents.
Back to Top
XModems are used to transfer “X Files”. (See serial communications)
CNC Controller – Note the high-tech operator instructionsSeveral methods are used. The most basic method is to simply do the necessary geometric calculations with a calculator and write the program directly using G-codes, M-codes, and so on. The program is then keyed directly into the controller (usually called MDI, for Manual Data Input) or keyed into a computer and transferred to the controller via punched tape or some other medium.
Some controllers can be programmed using a “conversational” method offered by the controller vendor. This may involve a more advanced language or hitting buttons with symbols on them. (Screaming at the control is not “conversational programming”).
APT ProgramSpecialized languages such as APT and COMPACT II have been available since the sixties and continue to be used. These create a controller-neutral tool path, usually called a CL File (Cutter Location or Center Line – take your choice), which is then converted to a CNC program acceptable to a given CNC control. A separate postprocessor is generally used for each CNC control or control family. Actually, COMPACT II uses different terminology but the concept is similar. APT will perform complex geometric calculations and has provided “modern” features like tool path associativity since its inception.
CAD/CAM system showing 2 views of a partGraphically oriented CAD/CAM systems for design and NC programming became generally available in the late seventies. Like APT, they usually create a neutral file usually called a CL File although their CL File format is generally far different from traditional APT CL File formats.
Parametric programs are used for family of parts programming and these can be written in any programming language. APT, Fortran, BASIC, C, whatever…
< Unbounded Enthusiasm Mode >
It stands for Automatically Programmed Tool, it’s a programming language, and to some extent it’s an architecture. An Association of Computing Machinery document states that it is the oldest programming language of any kind still in use. (It resulted from a study done at the MIT Servomechanism Laboratory in 1952 under the sponsorship of the Air Materiel Command. A prototype ran on the Whirlwind computer in 1955. We believe that the first commercially available version was released by IBM in 1958 for the IBM 704 computer.) It has been listed in most dictionaries for decades. It offered tool path associativity, macros, transformations, pocketing, five axis tool control, complex surface definition and machining, complex tool shapes, and many other modern features before any CAD/CAM system (as defined today) even existed. The shelf life of an APT program far exceeds that of any other archival storage method. It defined an API back in the sixties. It’s still hard to beat for point to point programming and production machining. A knowledge of APT capabilities and architecture helps you evaluate other CNC programming methods and some basics can be found under APT Language and APT Architecture.
< / Unbounded Enthusiasm Mode >
APT methods did not adapt well to a graphics world and most people consider it obsolete, but APT remains a very powerful, and in some cases the best, tool for repetitive programming tasks.
A CL file is a CNC program in a neutral format that is created by a CAD/CAM system, APT, or some other type of NC programming system. It is considered neutral because it is not formatted for any particular machine tool. There is no single standard CL file format, and there is no single standard even for CL file contents. Two common formats of “ASCII” CL files are shown here – each describes the same tool path. A traditional APT CL file is discussed after the table.
PARTNO ABIRD
CUTTER/.0$$S14
GOTO/.0,.0,5.0$$S15
RAPID
GOTO/-1.50,1.250,5.0$$S17
FEDRAT/15.0$$S18
GOTO/-1.50,1.250,-.20$$S19
GOTO/-1.251350,1.250,.0$$S20
MOVARC/CENTER,-.750,1.250,.0,AXIS,.0,.0,1.0,RADIUS,.50090$$S21
GOTO/-.256223,1.163192,.0
GOTO/-.488339,.107357,.0$$S22
MOVARC/CENTER,.0,.0,.0,AXIS,.0,.0,-1.0,RADIUS,.50$$S23
GOTO/.446479,-.225070,.0
GOTO/1.303521,1.475070,.0$$S24
MOVARC/CENTER,1.750,1.250,.0,AXIS,.0,.0,1.0,RADIUS,.50$$S25
GOTO/2.171831,.981562,.0
GOTO/.421831,-1.768438,.0$$S26
MOVARC/CENTER,.0,-1.50,.0,AXIS,.0,.0,-1.0,RADIUS,.50$$S27
GOTO/-.482340,-1.631711,.0
GOTO/-1.233209,1.118052,.0$$S28
GOTO/-1.50,1.250,-.20$$S29
RAPID
GOTO/-1.50,1.250,.30$$S31
RAPID
GOTO/.0,.0,5.0$$S33
END
FINI PARTNO ABIRD
CUTTER/ .0
LOADTL/ 1.0
SPINDL/ 2000.0,CLW
COOLNT/ ON
FROM/ .0,.0,5.0
RAPID
GOTO/ -1.50,1.250,5.0
FEDRAT/ 15.0
GOTO/ -1.50,1.250,-.20
GOTO/ -1.25180,1.250,-.20
INDIRV/ .027273,.999628,.0
TLON,GOFWD/ (CIRCLE/ -.750,1.250,.0,.50090),ON,(LINE/ -.750,$
1.250,.0,-.254332,1.171790,-.20)
GOTO/ -.488339,.107357,-.20
INDIRV/ -.183921,-.982941,.0
TLON,GOFWD/ (CIRCLE/ .0,.0,.0,.50),ON,(LINE/ .0,.0,.0,.446479,$
-.225070,-.20)
GOTO/ 1.303521,1.475070,-.20
INDIRV/ .477749,.878497,.0
TLON,GOFWD/ (CIRCLE/ 1.750,1.250,.0,.50),ON,(LINE/ 1.750,1.250,$
.0,2.171831,.981562,-.20)
GOTO/ .421831,-1.768438,-.20
INDIRV/ -.562248,-.826969,.0
TLON,GOFWD/ (CIRCLE/ .0,-1.50,.0,.50),ON,(LINE/ .0,-1.50,.0,$
-.482340,-1.631711,-.20)
GOTO/ -1.233209,1.118052,-.20
GOTO/ -1.50,1.250,-.20
COOLNT/ OFF
RAPID
GOTO/ -1.50,1.250,.30
SPINDL/ OFF
RAPID
GOTO/ .0,.0,5.0
END
FINI
CL File viewer showing contentsA traditional APT CL file is not human readable without translating from an internal integer and floating point format into numbers and letters. The data itself is similar, but an APT CL file contains more information, especially regarding circles. If the files above are used with a machine tool that does not support circular interpolation (that is, has no G2 or G3 command) then the postprocessor must generate the short linear moves made to form the arcs. With an APT CL file, this would not be necessary. For each arc, the APT CL file would contain a type 3000 record containing the coordinates of the center and the tool axis vector (angle), the radius, as well as the linear moves needed to make the arc if they are needed. For each actual move generated by a motion statement, a type 5000 record would be present containing all points necessary to complete the motion.
For the statement reading GOTO/ -1.50, 1.250, 5.0 in the CL files above (which would probably result in G0X-1.5Y1.25) the type 5000 record would contain the following:
5 5000 5 bb 0 -1.5 1.25 5.0
broken down as:
5 = Record number
5000 = Record type
5 = Code for ‘First or only record in this move’
bb = Geometry name used to create motion – blank in this case
0 = Subscript applied to name, if any
-1.5 = X
1.25 = Y
5.0 = Z
A postprocessor is a program that reads a CL file and produces a CNC program for a specific machine tool. Some “posts” are custom written for a specific tool/controller combination and others are generated via systems provided by postprocessor vendors. There are also generic posts that support, for example, 3 axis machining centers with many specific features customized using tables.
A postprocessor should be able to produce correct output for automatic tool changers, cycles, tool offsets, origins, circular and other interpolation, and other features specific to a tool/controller combination. The output from a postprocessor should be usable in the controller without further modification.
Creating a postprocessor using specialized packages is a fairly simple task. Writing custom posts has always been somewhat of a black art practiced by folks with a bizarre love of terms like “tool axis vector”, “linearization”, “zero-suppression”, and “modality”.
Back to Top
This is a term often used to describe a CL file that actually consists of APT statements. Typically, they contain no geometry definitions, but consist mainly of postprocessor commands, linear moves ( GOTO/ X,Y,Z ) and possibly some arcs. Since they’re in APT format, they can be processed by APT (creating yet another CL file) or in may cases, directly by a postprocessor.
Dumb APT programs are created by CAD/CAM systems (and even some APT processors), not by dumb APT programmers. They are called “dumb” simply because they describe the tool path directly and contain no part geometry. An APT program written by a human would almost always describe at least some of the part geometry.
Back to Top
Possibly because they commonly apply to two different aspects of CNC programming.
In a CNC program (the one with the G and M codes) I, J, and K are used to specify the center of an arc or circle and refer to positions on the X, Y, and Z axes – as in G2 X3.0 Y4.5I0.5 J0.3125.
In a CL file or in APT, they are used to position the tool axis vector – as in GOTO/X,Y,Z,I,J,K .You can think of the tool axis vector as a tool centerline (think mill here, not lathe or punch press) that is exactly one unit long – say, one inch. That makes it a “unit vector”. I, J, and K are used here to describe how the tool is tilted with respect to the Z axis. I, J, and K simply define the other end of the unit vector along X, Y, and Z. On a three axis machine, the tool doesn’t tip, so the tool centerline stays parallel with Z – therefore I, J, and K will always be 0, 0, 1 because (using the tool tip as a reference) you can find the other end of the vector by moving 0 in X, 0 in Y, and 1 in Z.
If you are programming a five axis machine in a CAD/CAM system, position the tool at X=2, Y=3, and Z=4 and tip the tool five degrees around the Y axis you’ll probably see the CL file output as GOTO/ 2.0, 3.0, 4.0, 0.0872, 0.0, 0.9962 . Here, we moved the top of the unit vector a bit in X and, of course the Z component got a bit smaller as a result. A postprocessor would read this and probably output G1 X2.0 Y3.0 Z4.0 A90.0 B5.0 – not an I, J, or K in the whole block!.
Enough already. The short answer is that you see I, J, and K in CNC programs as circle centers and in CL files and APT programs (and math texts) as unit vector components.
Feedrate refers to the various was of specifying the rate at which the tool moves through the material. It’s usually specified in a CNC program via an “F-word”, as in F30.0. For simple milling, the rate is usually expressed in millimeters or inches per minute. Although this is conceptually simple, it gets complicated if you think about it. For a machine tool to drive the cutter from one point in space to another at the rate you specify, each axis probably needs to move at a different speed. In a curve, the edge of the cutter will be feeding at a different rate than the center.
A CNC program listing with inverse time feedrates. Click to view.Part of an old postprocessor source listing showing part of the inverse time routine. Great fun to write these! Click to see it.If you have a rotary axis on your machine, you may get to enjoy using the exciting inverse time feedrate method. Here, you need to know what “units per minute” feedrate you need and the distance the cutter will traverse in the move you’re working on. (This can get complicated for rotary moves and programmers often ignore that detail – usually ok to do). Once you have the distance, multiply it by 60 and divide it into the desired UPM feedrate. Put that number in the F-word. Do this for each move involving linear and rotary motion. Now you know why almost all multi-axis (more than 3) programs are written using APT or a CAD/CAM system, and you have an interesting question to ask your postprocessor vendor – “How does it handle inverse time feedrates?”
APT and many CAD/CAM systems create a FEDRAT/ statement in the CL file (e.g. FEDRAT/30.0,IPM ) which is usually translated by the postprocessor to an F-word.
Supported G and M Codes
This
command summary serves as a guide for both new and experienced EIA-274D (G
Codes) users. The following table lists the supported G and M codes for VisualCNC
controller interface. Parameters within brackets ([ ]) are optional, the fields represented by
“d.d” may be any decimal number and fields represented by
“d” may be any positive integer number.
| G00 [Xd.d] [Yd.d] [Zd.d] |
High speed move (slew or rapid), modal |
|
G01 [Xd.d] [Yd.d] [Zd.d] [Fd.d] |
Linear move (feed or machine), modal |
|
G02 [Xd.d] [Yd.d] [Zd.d] [Id.d] [Jd.d] [Kd.d] [Fd.d] |
CW 2D circular move, modal |
|
G03 [Xd.d] [Yd.d] [Zd.d] [Id.d] [Jd.d] [Kd.d] [Fd.d] |
CCW 2D circular move, modal |
|
G04 Pd.d |
Dwell (seconds) |
|
G17 |
Specify XY plane for helical & circular |
|
G18 |
Specify XZ plane for helical & circular |
|
G19 |
Specify YZ plane for helical & circular |
|
G30
|
Cancel Mirror Image |
|
G31 |
X Mirror |
|
G32
|
Y Mirror |
|
G37 |
Find home |
|
G40
|
Cancel cutter compensation |
|
G41 |
Cutter compensation left |
|
G42
|
Cutter compensation right |
|
G43 Hd |
Sets tool length offset |
|
G49
|
Cancel tool length offset |
|
G54 |
Work Coordinate (Home or Fixture Offset) #1 |
|
G55
|
Work Coordinate (Home or Fixture Offset) #2 |
|
G56 |
Work Coordinate (Home or Fixture Offset) #3 |
|
G57
|
Work Coordinate (Home or Fixture Offset) #4 |
|
G58 |
Work Coordinate (Home or Fixture Offset) #5 |
|
G59
|
Work Coordinate (Home or Fixture Offset) #6 |
|
G62 |
Clear soft home |
|
G70
|
Enter Inch Mode |
|
G71 |
Enter Metric Mode |
|
G80
|
Cancel Drilling Cycle |
|
G81 Rd.d Zd.d [Fd.d] |
Drill Cycle |
|
G82 Rd.d Zd.d Pd [Fd.d]
|
Counter Bore Cycle |
|
G83 Rd.d Zd.d Qd.d [Fd.d] |
Peck drill |
|
G85 Rd.d Zd.d [Fd.d]
|
Boring Cycle |
|
G89 Rd.d Zd.d Pd [Fd.d] |
Boring with pause |
|
G90 |
Absolute coordinate mode |
|
G91 |
Incremental coordinate mode |
|
G92 [Xd.d] [Yd.d] [Zd.d] |
Set soft home |
|
Sd |
Set spindle speed (rpm) |
|
M00 |
Program pause |
|
M01 |
Optional pause |
|
M02 or M30 |
Program end |
|
M03 |
Spindle on |
|
M05
|
Spindle off |
|
M06 |
Tool Change (example: T02 M06) |
|
M08 |
Mist Coolant Device On |
|
M09 |
Mist Coolant Device Off |
The
following table lists the letters used to denote various arguments.
(
) – Comments or Tool change operator message ex: (Text to
be displayed)
Q – Peck drill delta (used in G83)
F – Feed rate (used in G00, G01, G02, G03, G81, G82, G83, G85, G89) Units
per Minute
P – Dwell (used in G04)
I – Circular interpolation value in X dimension (used in G02, G03)
J - Circular interpolation value in Y dimension (used in G02, G03)
K – Circular interpolation value in Z dimension (used in G02, G03)
M – Miscellaneous function (control function)
N – Sequence number
R – Beginning Z motion dimension (used in G81, G82, G83, G85, G89)
S – Spindle rpm
T – Tool change (used in G00)
X – X motion dimension
Y – Y motion dimension
Z – Z motion dimension
Sample
File 1 (Standard)
The
following is a 10″ square. Rapid level .5 inches above material, feed down
45 ipm, cut feed 150 ipm, rapid down to .1 above material, depth .25 inches.
Surface or Z=0 is set at the surface of the material to be cut. This is for a
single head system with no tool change.
|
G90 |
Absolute Coordinate Mode |
|
G00 S18000 M03 |
Spindle Speed Set to 18,000 RPM’s |
|
G00 X0. Y0. |
Position X=0.0 and Y=0.0 |
|
G00 Z0.1 |
Position the Z axis 0.1 inches above Z=0.0 or above the |
|
G01 Z-0.25 F45 M08 |
Position the Z axis 0.25 inches below Z=0.0 or into the
|
|
G01 X10. F150 |
Position the X=10.0 inches at the feed rate of 150 |
|
G01 Y10. |
Position the Y=10.0 inches (feed rate will continue at last |
|
G01 X0. |
Position the X=0.0 inches |
|
G01 Y0. |
Position the Y=0.0 inches |
|
G00 Z0.5 M09 |
Position the Z axis 0.5 inches above Z=0.0 or above the |
|
G00 X0. Y0. |
Position X=0.0 and Y=0.0 |
|
M02 |
End of Program Spindle is turned off. |
Sample
File 2 (Automatic Tool Change)
The
following is a 10″ square. Rapid level .5 inches above material, feed down
45 ipm, cut feed 150 ipm, rapid down to .1 above material, depth .25 inches.
Surface or Z=0 is set at the surface of the material to be cut. Additionally it
calls a second tool to perform another cut of the same size elsewhere on the raw
material. This is for a single head system with auto tool change.
|
G90 |
Absolute Coordinate Mode |
|
G00 S18000 M03 |
Spindle Speed Set to 18,000 RPM’s |
|
G00 T1 M06 (E-MILL .250 2FLUTE) |
Tool 1 call. Following moves will use tool one.”E-MILL |
|
G00 X0. Y0. |
Position X=0.0 and Y=0.0 |
|
G00 Z0.1 |
Position the Z axis 0.1 inches above Z=0.0 or above the |
|
G01 Z-0.25 F45 M08 |
Position the Z axis 0.25 inches below Z=0.0 or into the
|
|
G01 X10. F150 |
Position the X=10.0 inches at the feed rate of 150 |
|
G01 Y10. |
Position the Y=10.0 inches (feed rate will continue at last |
|
G01 X0. |
Position the X=0.0 inches |
|
G01 Y0. |
Position the Y=0.0 inches |
|
G00 Z0.5 M09 |
Position the Z axis 0.5 inches above Z=0.0 or above the |
|
G00 T2 M06 (E-MILL .125 3FLUTE) |
Tool 2 call. Following moves will use tool one.”E-MILL |
|
G00 X12. Y0. |
Position X=12.0 and Y=0.0 |
|
G00 Z0.1 |
Position the Z axis 0.1 inches above Z=0.0 or above the |
|
G01 Z-0.25 F45 M08 |
Position the Z axis 0.25 inches below Z=0.0 or into the
|
|
G01 X22. F150 |
Position the X=22.0 inches at the feed rate of 150 |
|
G01 Y10. |
Position the Y=10.0 inches (feed rate will continue at last |
|
G01 X12. |
Position the X=12.0 inches |
|
G01 Y0. |
Position the Y=0.0 inches |
|
G00 Z0.5 M09 |
Position the Z axis 0.5 inches above Z=0.0 or above the |
|
G00 T0 M06 |
Optional command to put current away tool |
|
G00 X0. Y0. |
Position X=0.0 and Y=0.0 |
|
M02 |
End of Program Spindle is turned off. |
Cutter Compensation G40\G41\G42
Note
that all G41\G42 contours MUST start with a lead in and end with a lead out.
|
G90 G70 |
Absolute coordinate system, Inch Mode |
|
S18000 |
Set spindle speed to 18000 RPM |
|
G00 T1 M06 (.250 End Mill) |
Select Tool #1 and display “.250 End Mill” |
|
G00 Z-0.5 |
Rapid move to safe rapid level |
|
G00 X0. Y-0.25 |
Rapid move |
|
Z.1 |
Compensation entry move |
|
G41 D01 |
Turn on left tool compensation for table entry #1 |
|
Y0 |
|
|
G01 Z-.250 F30 M08 |
Feed Z to -.25 at 30ipm and turn on tool mist |
|
Y10 F200 |
Feed to Y=10 at 200 ipm |
|
X10 |
Feed move |
|
Y0 |
Feed move |
|
X0 |
Feed move |
|
G40 |
Turn tool compensation off |
|
G0 Z.5 M09 |
Rapid Z=.5 and turn mist off |
|
X -.2 |
Exit tool compensation move |
|
M02 |
End of file |
G81
/ G83 Drilling, Peck Drilling
|
G90 G70 |
absolute coordinate system, inch mode |
|
S12000 |
set spindle speed to 12000 RPM |
|
G00 X0Y0 |
Rapid move |
|
G00 Z.1 M08 |
rapid Z move (note Z positive is UP), turn misting unit on |
|
G81 Z-.2 F50 |
Drill cycle next coordinates to Z=-.2 at 50 ipm |
|
X1Y1 |
Drill |
|
X2 |
Drill |
|
X3 |
Drill |
|
G80 |
Drill cycle off |
|
G00 Z1. |
Rapid Move |
|
X0Y2 |
Rapid Move |
|
G83 R.1 Z-.5 Q.1 F30 |
Peck drill cycle next coordinates to Z=-.5 at .1 lift, .1 |
|
X1 |
Peck drill |
|
X2 |
Peck Drill |
| X3 |
Peck Drill |
|
M09 |
Mist Unit Off |
|
G80 |
Cancel Drill Cycle |
|
G00 Z-0.5 |
Rapid Z move |
|
G00 X0. Y0. |
rapid XY move |
|
M02 |
End of Job |
RS-274D is the recommended standard for numerically controlled machines
developed by the Electronic Industry Association in the early 1960’s. The
RS-274D revision was approved in February, 1980. These standards provide
a basis for the writing of numeric
control programs.
There are a number of historical sidelights to this standard, many having
to do with the original use of punched paper tape as the only data interchange
medium. The 64-character EIA-244 paper tape standard is now (thankfully)
obsolete, and ASCII character bit patterns are now the standard representation.
This old tape standard had specific characters used for ’searching’ for
specific lines (program blocks) on the tape, ‘rewinding’ the tape, etc.
Ocasionally this obsolete language is still used when referring to some
cnc control tasks.
The full NIST Enhanced Machine Controller is nc programmed using a variant
of the RS274D language to control motion and I/O. This variant is called
RS276NGC because it was developed for the Next Generation Controller, a
project of the National Center for Manufacturing Science. The version of
RS274 used by EMC adheres closely to the publications of the NCMS wherever
those publications produce an unambiguous set. In some cases reference
to other implementations of RS274 had to be made by NIST.
Blocks
The basic unit of the nc program is the ‘block’, which is seen in printed
form as a ‘line’ of text. Each block can contain one or more ‘words’, which
consist of a letter, describing a setting to be made, or a function to
be performed, followed by a numeric field, supplying a value to that function.
A permissible block of input is currently restricted to a maximum of 256
characters.
The following order is required for the construction of a block.
1. an optional block delete character, which is a slash / .
2. an optional line number.
3. any number of segments, where a segment is a word or a comment.
4. an end of line character.
The interpreter allows words starting with any letter except N (which denotes
a line number and must be first) to occur in any order. Execution of the
block will be the same regardless of the order.
An example of a program block would be
/N0001 G0 X123.05
This block is constructed using three words, N0001, G0, and X123.05. The
meanings of each of these words is described in detail below. In essence,
the n word numbers the line, the g0 word tells the machine to get to its
destination as quickly as it can, and the final position of the x axis
is to be 123.05. Since it is constructed with a preceeding slash, this
block could be deleted during a run if optional block delete were activated.
There are some general considerations when writing nc code for the EMC:
- The interpreter allows spaces and tabs anywhere within a block of code.
The result of the interpretation of a block will be the same as it would
if any white spaces were not there. 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 by the interpreter. They are ignored.
- The interpreter also assumes input is case insensitive. Any letter may
be in upper or lower case without changing the meaning of a line.
Whenever you write nc programs, you would do well to be considerate of
others who may have to read that code, even though the interpreter itself
does not care about white space and case. Unless your are really up against
the 256 digit block size limit, white space between words and the absense
of it within words makes a block much easier to understand.
There are a number of limitations about the number or types of words
that can be strung together into a block. The interpreter uses the following
rules:
- A line may have zero to four G words.
- Two G words from the same modal group may not appear on the same line.
- A line may have zero to four M words.
- Two M words from the same modal group may not appear on the same line.
- For all other legal letters, a line may have only one word beginning with
that letter.
Don’t worry to much about modal codes or the order of execution of the
words within a block of nc program just yet. These will become clear as
you work your way through the definitions of the permissible words listed
in the next unit.
For now it is enough to remember that a program block is more than the
words that are written in it. Various words can be combined to specify
multi-axis moves, or perform special functions. While a block of code has
a specific order of execution, it must be considered to be a single command.
All of the words within a block combine to produce a single set of actions
which may be very different from the actions assigned to the same words
were they placed in separate blocks. A simple example using axis words
should illustrate this point.
n1 x6 – moves from the current x location to x6
n2 y3 – moves from current y location to y3 at x6
n3 z2 – moves from current z location to z2 at x6 and y3
n10 x6 y3 z2 – moves on a single line from current x, y, z to x6 y3
z2
The final position of the first three blocks (n1-n3) and the (n10) block
are the same. The first set of blocks might be executed in sequence to
move the tool around an obstacle while the path of the tool for the combined
block (n10) might run it into the part or the fixture.
To make the specification of an allowable line of code precise, NIST
defined it in a production language (Wirth Syntax Notation). These definitions
appear as Table *** at the end of this chapter. In order that the definition
in the appendix not be unwieldy, many constraints imposed by the interpreter
are omitted from that appendix. The list of error messages elsewhere in
the Handbook indicates all of the additional constraints.
Numbers
Since every nc word is composed of a letter and a value. Before we begin
a serious discussion of the meaning of nc programming words we need to
consider the meaning of value within the interpreter. 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. In this chapter all examples
will use explicit numbers. Expressions and unary operations are treated
in the computation chapter. The use of parameter values or variables are
a described in detail in the Using Variables chapter.
EMC uses the following rules regarding numbers. In these rules a digit
is a single character between 0 and 9.
A number consists of :
- an optional plus or minus sign, followed by
- zero to many digits, followed, possibly, by
- one decimal point, followed by
- 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.
Some additional rules about the meaning of numbers are that:
- Numbers may have any number of digits, subject to the limitation on line
length. - A non-zero number with no sign as the first character is assumed to be
positive. - Initial and trailing zeros are allowed but not required.
- A number with initial or trailing zeros will have the same value 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 to some range of values. In many uses, decimal
numbers must be close to integers; this includes the values of indexes
(for parameters and changer slot numbers, for example). In the interpreter,
a decimal number which is supposed be close to an integer is considered
close enough if it is within 0.0001 of an integer.
Words
An nc program word is an acceptable letter followed by a real_value.
Table 2 shows the current list of words that the EMC interpreter recognizes.
The meanings of many of these words are listed in detail below. Some are
included in and in the chapter on tool radius compensation and the chapter
on canned cycles.
| DF
G H I J K L |
tool radius compensation numberfeedrate
general function (see below) tool length offset X-axis offset for arcs X offset in G87 canned cycle Y-axis offset for arcs and Y offset in G87 canned cycle and Z offset in G87 canned cycle L number of repetitions in canned cycles and key used with G10 |
MN
P Q R S T X Y Z |
miscellaneous function (see below)line number
dwell time with G4 and canned cycles Q feed increment in G83 canned cycle R arc radius canned cycle plane S spindle speed T tool selection X-axis of machine Y-axis of machine Z-axis of machine |
Line Number Words
A line number is the letter N followed by an integer (with no sign)
between 0 and 99999. Line numbers are not checked except for to many digits.
It is not necessary to number lines because they are not used by the interpreter.
But they can be convenient when looking over a program. N word line numbers
are reported in error messages when errors are caused by program problems.
Line numbers can be confusing because they are not the number that is
displayed as being executed. Nor are they the number used to restart an
nc program at a line other than the start. That number is the number of
the current block in the program file with 0 being the first block.
Axis Words
We have already seen examples of axis words. An X word would be X10.001,
which by itself indicates the X axis should move to a position of 10.001
user units, which would normally be inches or mm. Table one lists the common
names for axis. Not all of these names can be used by all of the EMC interpreters.
X, Y, and Z words will be accepted by the current (Jan, 2000) interpreter.
NIST will soon release an expanded interpreter that will allow for three
rotary axis A, B, C, as well.
| X – Primary Linear AxisY – Primary Linear Axis
Z – Primary Linear Axis |
U – Secondary axis parallel to XV – Secondary axis parallel to Y
W- Secondary axis parallel to Z |
A – Angular axis around X axisB – Angular axis around Y axis C – Angular axis around Z axis |
Preparatory Words
Some G words alter the state of the machine so that it changes from
cutting straight lines to cutting arcs. Other G words cause the interpretation
of numbers as millimeters rather than inches. While still others set or
remove tool length or diameter offsets. Most of the G words tend to be
related to motion or sets of motions. Table 4 lists the currently available
g words.
| G0 rapid positioningG1 linear interpolation
G2 circular/helical interpolation (clockwise) G3 circular/helical interpolation (c-clockwise) G4 dwell G17 xy plane selection G18 xz plane selection G19 yz plane selection G20 inch system selection G21 millimeter system selection G40 cancel cutter diameter compensation G41 start cutter diameter compensation left G42 start cutter diameter compensation right 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 6G59.1 use preset work coordinate system 7 G59.2 use preset work coordinate system 8 G59.3 use preset work coordinate system 9 G80 cancel motion mode (includes canned) G81 drilling canned cycle G82 drilling with dwell canned cycle G83 chip-breaking drilling canned cycle G84 right hand tapping canned cycle G86 boring, spindle stop, rapid out canned G87 back boring canned cycle G88 boring, spindle stop, manual out canned G89 boring, dwell, feed out canned cycle G90 absolute distance mode G91 incremental distance mode G92 offset coordinate systems G92.2 cancel offset coordinate systems G94 feed per minute mode G98 initial level return in canned cycles |
Tool diameter compensation (g40, g41, g42) and tool length compensation
(g43, g49) are covered in a separate page. Canned milling cycles (g80 -
g89, g98) are covered in their own page. Coordinate systems and how to
use them is also covered in a separate page. (g10, G53 – G59.3, G92, G92.2)
Basic Motion and Feedrate
G0 Rapid Positioning
Using a G0 in your code is equivilant to saying “go rapidly to
point xxx yyyy”. This code causes motion to occur at the maximum traverse
rate.
Example:
N100 G0 X10.00 Y5.00
This line of code causes the spindle to rapid travel from wherever it
is currently to coordinates X= 10″, Y=5″
When more than one axis is programmed on the same line, they move simultaneously
until each axis arrives at the programmed location. Note that the axes
will arrive at the same time, since the ones that would arrive before the
last axis gets to the end are slowed down. The overall time for the move
is exactly the same as if they all went at their max speeds and the last
axis to arrive stops the clock.
To set values for rapid travel in EMC, one would look for this line
in the appropriate emc.ini file:
[AXIS_#] MAX_VELOCITY = (units/second)
The previous value for the rapid rate, [TRAJ] MAX_VELOCITY, is still
used as the upper bound for the tool center point velocity. You can make
this much larger than each of the individual axis values to ensure that
the axes will move as fast as they can.
One thing to remember when doing rapid positioning, is to make sure
that there are no obstacles in the way of the tool or spindle while making
a move. G0 code can make spectacular crashes, if Z is not clear
of clamps, vises, uncut parts, etc…..Try to raise the tool out of the
way to a “safe” level before making a rapid.
I like to put a G0 Z2.0 (Z value depending on clamp height) towards
the beginning of my code, before making any X or Y moves.
Example:
N100 G0 Z1.5 —-move spindle above obstacles
N110 G0 X2.0 Y1.5 —-rapid travel to first location
G1 Linear Interpolation
G1 causes the machine to travel in a straight line with the benefit
of a programmed feed rate (using “F” and the desired feedrate). This is
used for actual machining and contouring.
Example:
N120 Z0.1 F6.0 —-move the tool down to Z=0.1 at a rate of 6 inches/minute
N130 Z-.125 F3.0 —-move tool into the workpiece at 3 inches/minute
N140 X2.5 F8.0 —-move the table, so that the spindle travels to X=2.5
at a rate of 8 inches/minute
G2 Circular/Helical Interpolation (Clockwise)
G2 causes clockwise circular motion to be generated at a specified feed
rate (F). The generated motion can be 2-dimensional, or 3-dimensional (helical).
On a common 3-axis mill, one would normally encounter lots of arcs generated
for the X,Y plane, with Z axis motion happening independently (2 axis moves
in G17 plane). But, the machine is capable of making helical motion, just
by mixing Z axis moves in with the circular interpolation.
When coding circular moves, you must specify where the machine must
go and where the center of the arc is in either of two ways: By specifying
the center of the arc with I and J words, or giving the radius
as an R word.
I is the incremental distance from the X starting point
to the X coordinate of the center of the arc. J is the incremental
distance from the Y starting point to the Y coordinate of the center
of the arc.
Examples:
G1 X0.0 Y1.0 F20.0 —-go to X1.0, Y0.0 at a feed rate of 20 inches/minute
G2 X1.0 Y0.0 I0.0 J-1.0 —-go in an arc from X0.0, Y1.0 to X1.0 Y0.0,
with the center of the arc at X0.0, Y0.0
G1 X0.0 Y1.0 F20.0 —-go to X1.0, Y0.0 at a feed rate of 20 inches/minute
G2 X1.0 Y0.0 R1.0 —-go in an arc from X0.0, Y1.0 to X1.0 Y0.0, with
a radius of R=1.0
G3 Circular/Helical Interpolation (Counterclockwise)
G3 is the counterclockwise sibling to G2.
G4 Dwell
Plane selection for coordinated motion
G17 xy plane selection
G18 xz plane selection
G19 yz plane selection
Short term change in programming units
G20 inch system selection
G21 millimeter system selection
Fixture Offsets (G54-G59.3)
Fixture offset are used to make a part home that is different from the
absolute, machine coordinate system. This
allows the part programmer to set up home positions for multiple parts.
A typical operation that uses fixture offsets
would be to mill multiple copies of parts on “islands” in a piece,
similar to the figure below:

To use fixture offsets, the values of the desired home positions must
be stored in the control, prior to running a program that uses them.
Once there are values assigned, a call to G54, for instance, would add
2 to all X values in a program. A call to G58 would add 2 to X values and
-2 to Y values in this example.
G53 is used to cancel out fixture offsets. So, calling G53 and then
G0 X0 Y0 would send the machine back to the actual coordinates of X=0,
Y=0.
| 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 |
Canned Cycles/Drill Subroutines (G80-G89)
Distance Modes
G90 absolute distance mode
G91 incremental distance mode
Feedrate and feed modes
G93 inverse time feed mode
G94 feed per minute mode
Miscellaneous words
M words are used to control many of the I/O functions of a machine.
M words can start the spindle and turn on mist or flood coolant. M words
also signal the end of a program or a stop withing a program. The complete
list of M words available to the RS274NGC programmer is included in table
| M0 program stopM1 optional program stop
M2 program end M3 turn spindle clockwise M4 turn spindle counterclockwise M6 tool change M7 mist coolant on |
M8 flood coolant onM9 mist and flood coolant off
M26 enable automatic b-axis clamping M27 disable automatic b-axis clamping M30 program end, pallet shuttle, and reset M49 disable speed and feed overrides M60 pallet shuttle and program stop |
Modal Codes
Many G codes and M codes cause the machine 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”.
Modal codes are like a light switch. Flip it on and the lamp stays lit
until someone turns it off. For example, the coolant commands are modal.
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, it will be executed again on the next line unless
a command is given specifying a different motion (or some other command
which implicitly cancels G1 is given).
“Non-modal” codes effect only the lines on which they occur. For example,
G4 (dwell) is non-modal.
Modal commands are arranged in sets called “modal groups”. 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. Measurement in inches vs.
measure in millimeters are modal. A machine tool may be in many modes at
the same time, with one mode from each group being in effect. The modal
groups used in the interpreter are shown in Table 1.
| group 1 = {G0, G1, G2, G3, G80, G81, G82, G83, G84, G85, G86, G87, G88, G89} – motiongroup 2 = {G17, G18, G19} – plane selection group 3 = {G90, G91} – distance mode group 5 = {G93, G94} – spindle speed mode group 6 = {G20, G21} – units group 7 = {G40, G41, G42} – cutter diameter compensation group 8 = {G43, G49} – tool length offset group 10 = {G98, G99} – return mode in canned cycles group12 = {G54, G55, G56, G57, G58, G59, G59.1, G59.2, G59.3} coordinate |
| group 2 = {M26, M27} – axis clampinggroup 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 group 9 = {M48, M49} – feed and speed override bypass |
Ivan Irons | CNC Information | G-Code Quick Guide
Ivan Irons | CNC Information | G-Code Quick Guide
Page 2
What is this guide?
A number of people ask me about G-Code on a consistent basis. It is one of those “unknown” things for people when they learn CNC. It is a computer language and that makes some people nervous. I wrote this guide to help people ease into g-code and to alleviate their anxiety about it.
What is G-Code?
G-Code programming is a very robust and simple language. G-codes are what CNC Machines run on. A CNC control program process the g-code line by line and send this information to the machine. The machine then takes this information and makes precise movements. Yes, it is as simple as that.
Where does G-Code come from?
That is simple enough, it come from your CAM program. When you process your design in your CAM program you pick out various machining parameters and inputs. You match it up with the CNC Machine the part will be run on and then Post-Process. You CAM program then spits out very precise G-Code for your machine and your part. If you make changes to your design, you will need to go through the CAM process again.
Post Processors
A post processor is a specific way you CAM Program will process your design. There are standard ones and custom ones. If a standard one doesn’t work for you, most good CAM Software gives you the option to customize the post processor to fit your needs.
Canned Cycles
We won’t be covering Canned Cycles here. There are G-Codes that do pertain to Canned Cycles. This guide is targeted toward beginner to intermediate CNC Learners.
The Big G-Code List
What comes next is a listing of what each g-code means. You can use this list if you are having a problem and are trying to decipher what is going on in your program. A note of caution…this is a generic list. Many manufacturers don’t exactly adhere to this list and change the codes on a whim. You will need to be familiar with your own CAM Program, CNC Control Software and CNC Machine to determine if they have changed something. It is not something I can do for you.
Ivan Irons | CNC Information | G-Code Quick Guide
Page 3
G0 or G00 – Rapid Movement
The most rapid movement the CNC Machine can make to the next position. If moving in multiple axis, each axis will move as fast as they can independently of one another.
G1 or G01 – Linear Movement
A straight move with a speed defined by an “F.” [F=Feedrate] If moving in multiple axis, the machine will move in each axis until it reaches its defined position.
G2 or G02 – Interpolation Clockwise
A circular movement in 2-axis in a clockwise motion. Will create an arc to a specified radius defined by an R or I/J combination.
G2 or G03 – Interpolation Counter Clockwise
A circular movement in 2-axis in a counter-clockwise motion. Will create an arc to a specified radius defined by an R or I/J combination.
G4 or G04 – Dwell
Machine will dwell once reached position to a user defined time, noted by a “P”
G9 or G09 – Exact Stop/Exact Position
Machine will not traverse to next line of code until it locates exactly to specified position.
G17 – XY plane selection
G18 – ZX plane selection
G19 – YZ plane selection
G20 – Machine in inch
G21 – Machine in MM
G28 – Return to Reference Position
Normally machine home.
G30 – Return to 2nd reference position
G40 – Cutter Compensation Cancel
G41 – Cutter Compensation Left
G42 – Cutter Compensation Right
G43 – Tool Length Compensation +
G44 – Tool Length Compensation -
Ivan Irons | CNC Information | G-Code Quick Guide
Page 4
G54-G59 – Work Coordinate Systems
User defined, XYZ
G68 – Coordinate Rotation
G69 – Coordinate Rotation Cancel
G73 – Peck Drilling Cycle
G76 – Boring Cycle
G80 – Cancel Canned Cycle
G81 – Drilling Cycle
G82 – Drilling Cycle
G83 – Pecking Cycle
G84 – Tapping Cycle
G85 – Boring Cycle
G86 – Boring Cycle
G87 – Back Boring Cycle
G90 – Absolute Command
G91 – Incremental Command
G92 – Programming of Absolute Zero
G94 – Feed Per Minute
G95 – Feed Per Revolution
G98 – Return to initial point in canned cycle
G99 – Return to R point in canned cycle
Ivan Irons | CNC Information | G-Code Quick Guide
Page 5
The Future of G-Code
The future of g-code is in jeopardy. Kind of…but don’t hold your breath. There are changes going on to try to create a new standard. A new standard where you can go straight from CAD or CAM right to the CNC machine.
This is basically an attempt to try to eliminate a step in the CNC Process. Others have tried to update or eliminate g-code before. So far, its simplicity has won out. It has survived. Is it worth learning a little about it today? Yes.
2” Square G-Code Example
The numbers on the left of the G-Code are the sequence numbers of the code and the order it will be executed in. I have added notes after different actions to let you know what that line of code means. My note starts with a “-“ then continues. A “-“ means nothing in G-Code.
N0000 (Filename: 2INSquare.txt) – Name of File
N0010 (Post processor: Plasma.post) – Name of Post Processor Used
N0020 (Date: 8/1/2007) – Date G-Code was generated
N0030 G20 (Units: Inches) – Measurement Units Used
N0040 G53 – Machine co-ordinate system
N0050 G90 – Absolute Programming
N0060 G40 – Tool radius compensation off
N0070 F1 – Feedrate of 1” per min
N0090 (Part: Square) – name of the part
N0100 (Process: Plasma, DEFAULT, Plasma, 0.01 in kerf) – Tool to be used
N0110 G00 – Go to Home
N0120 X0.1113 Y-0.0904 – Move to this exact X, Y position
N0130 G04 P2000 – Pause for 2 seconds, this is in milliseconds
N0140 M03 – Fire the plasma torch
N0150 G04 P500 – Pause for .5 seconds, this is in milliseconds
N0160 G03 X0.0000 Y-0.0050 I-0.1113 J-0.0298 F40.0 – move to this X, Y position in an arcing movement at a feedrate of 40 inches per min
N0180 G01 Y2.0000 – Travel in the Y+ direction for 2 inches to X0, Y2
N0200 G01 X2.0000 – Travel in the X+ direction for 2 inches to X2, Y2
N0220 G01 Y0.0000 – Travel in the Y- direction for 2 inches to X2, Y0
N0240 G01 X0.0000 – Travel in the X- direction for 2 inches to X0, Y0
N0250 G03 X-0.1113 Y-0.0904 I0.0000 J-0.1152 – move to this X, Y position in an arcing movement
N0260 M05 – Turn off the plasma torch
N0270 G04 P2000 – Pause for 2 seconds, this is in milliseconds
N0280 G00 – Move to Home
N0300 M30 – End Program
Do I need to be a G-Code Expert?
In a word, no. You will probably need to know how to quickly scan your G-Code if you are having problems during your machining simulation. Other then that G-Code and a CNC program are throwaway programs for the most part.
Ivan Irons | CNC Information | G-Code Quick Guide
Page 6
What are M-Codes?
M-Codes are other codes that are throughout your CNC Program. Think of them like the lesser cousin to G-Codes. M-Codes are usually very specific to the machine. For example, “M03” might stand for “Torch Off” on a CNC Plasma Cutter. It also might stand for “Spindle Turn Clockwise” on a CNC Mill or CNC Router.
M-Codes
M0 – program stop M1 – optional program stop M2 – program end M3 – turn spindle clockwise M4 – turn spindle counterclockwise M5 – stop spindle turning M6 – tool change M7 – mist coolant on
M8 – flood coolant on M9 – mist and flood coolant off M26 – enable automatic b-axis clamping M27 – disable automatic b-axis clamping M30 – program end, pallet shuttle, and reset M48 – enable speed and feed overrides M49 – disable speed and feed overrides M60 – pallet shuttle and program stop
Ivan Irons | CNC Information | G-Code Quick Guide
http://www.CNCInformation.com
Page 7
Disclaimer
This is not a class on learning g-code. It is a quick guide of the different g-codes. In other words, this guide is for reference only. You should always prove out your process, program and cnc machine before you ever begin machining.
In order to learn the entire CNC Process, you will need to spend time. Time learning about the whole process, not just one part. G-Code is just one part of a whole process. If you are focused on only one part you are destined to have trouble.
This guide is assumed to be correct, but is subject to change at any time. This guide is for reference only. Your safety is your responsibility. Use you head.











price=$1,799