Basics of G Code

Visit our CNC Shop

NC 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
Material.

G01 Z-0.25 F45 M08

Position the Z axis 0.25 inches below Z=0.0 or into the
Material at the feed rate of 45 inches/minute). The Auxiliary output for the selected tool is turned on.
(This output can be wired to operate a tool misting or cooling unit.)


G01 X10. F150

Position the X=10.0 inches at the feed rate of 150
inches/minute

G01 Y10.

Position the Y=10.0 inches (feed rate will continue at last
set speed)

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
Material. The Auxiliary output for the selected tool is turned off. (This
output can be wired to operate a tool misting or cooling unit.)

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
.250 2FLUTE” will displayed on the keypad.

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

G01 Z-0.25 F45 M08

Position the Z axis 0.25 inches below Z=0.0 or into the
Material at the feed rate of 45 inches/minute). The Auxiliary output for the selected tool is turned on.
(This output can be wired to operate a tool misting or cooling unit.)


G01 X10. F150

Position the X=10.0 inches at the feed rate of 150
inches/minute

G01 Y10.

Position the Y=10.0 inches (feed rate will continue at last
set speed)

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
Material. The Auxiliary output for the selected tool is turned off. (This
output can be wired to operate a tool misting or cooling unit.)

G00 T2 M06 (E-MILL .125 3FLUTE)

Tool 2 call. Following moves will use tool one.”E-MILL
.125 3FLUTE” will displayed on the keypad.

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

G01 Z-0.25 F45 M08

Position the Z axis 0.25 inches below Z=0.0 or into the
Material at the feed rate of 45 inches/minute). The Auxiliary output for the selected tool is turned on.
(This output can be wired to operate a tool misting or cooling unit.)


G01 X22. F150

Position the X=22.0 inches at the feed rate of 150
inches/minute

G01 Y10.

Position the Y=10.0 inches (feed rate will continue at last
set speed)

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
Material. The Auxiliary output for the selected tool is turned off. (This
output can be wired to operate a tool misting or cooling unit.)

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
peck, 30 ipm

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

MISCELLANEOUS

  • Line
    numbers are optional, they have no effect on program execution.

  • Decimal
    points for whole numbers are optional, they are only necessary for fractional
    numbers

  • Drilling
    with an electric/pneumatic feed drill is accomplished by calling Tool 31…40
    (T31 M06) with standard G00 rapid moves immediately after the tool call to
    position the drill. At the end of the rapid move the drill will be fed into the
    material. The next rapid will produce the same results. To stop drilling call
    another tool (T01 M06)

  • Peck
    drilling and standard drilling cycles (G80,81,83) are not supported on
    electric/pneumatic feed drills.

  • Depending on features purchased with any particular machine,
    all or a portion of the G&M codes are supported.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s