Shared Flashcard Set


CNC study
Mechanical Engineering

Additional Mechanical Engineering Flashcards






Programming NC/CNC/Machines is a serious business. One mistake in programming such as a misplaced decimal point or a transposition of numbers can result in damage to the work piece or serious injury to the operator. Check your work carefully!


 It is not enough to simply program all the correct points around the part. Proper speeds and feeds combined with appropriate tool selection are essential to the manufacture of quality parts and the safety of the operator.


It is generally a good idea to program consistently. As operators become familiar with your programming style it will be easier for them to spot errors.


CNC machine relies on numerical input. This input may be in the form of manual data input (MDI) by the operator or a CNC program.


The operator/programmer must therefore "communicate" with the machine control using a numerical based language. NC (Numerical Control) and CNC (Computer Numerical Control) are the languages used for this communication.


Job of the CNC programmer

  • Translate the information provided on a blueprint into the CNC commands necessary for the machine to make the part.
  • The programmer must also know how to apply the necessary math and machining principles in order to effectively create CNC programs.

Program Documentation


Proper Documentation:

  • Easier to bid jobs more accurately

  • Improve processes

  • Track and Solve problems

  • Shorten setup times

  • Track tool life

  • Predict tool life

  • Train new operators

  • Find root causes of failures and successes  


All programming points on a part will be one of the following:

  • Intersecting Points

  • Tangency Points

  • Specific points such as hole locations etc.


The 7 Steps to Successful CNC Programming

Step 1

Determine how you are going to machine the part. You will also need to know:

Appropriate speeds and feeds

  • Fixturing
  • The order and sequence of operations
  • The number of programs and setups required
  • The machine limitations
  • Safety considerations

You must know how you are going to make the part before you can program the machine to make it.


Step 2

Make up a tool list of the tools you intend to use. Will make a difference in how the part should be programmed.


Step 3

Make up a setup sheet and define the tool/cutter paths as they relate to the program origin. This step organizes your thinking and provides the operator with description of how you intend to set up and run the part. Making a drawing that details the cutter paths around the part will keep you on track and help with calculations.


Step 4

Write the program by using the setup sheet. This will keep the process organized and gives you a reference to go back to in the event you get interrupted.

Program documentation is very important. Save time and money you will be making similar parts.


Step 5

Proofread your manuscript for errors. You will catch mistakes that could be costly.


Step 6

Type/load program into the machine control


Step 7

Use the CRT of the machine to proofread the program listing for errors. 


Helpful Hint

Keep a note book that documents:


Uncommon setups

Problems, and their solutions

Track any pertinent information that makes the job easier

Special tool numbers

Locations or offsets


Unique inspection methods that may be required from time to time

Phone numbers of reliable repairmen

Maintenance tips

How to reset machines after power failures or interrupted cycles

Any information that is needed infrequently but is vitally important to have





Rectangular Coordinates


Is a system that enables people to describe the location of any point in space. This system uses 3 axis that are intersecting and mutually perpendicular.

This system uses 1 axis for each of the following:

Height, Width, Length








A point is defined as a location only.

 It defines a place not an object, so it has no length, width, height, dimension or extent.








The shortest distance between two points. In geometry a line is conceived as being straight and having infinite length but no other dimension such as width or breadth. The direction of the line can be defined by as little as 2 points. Line is one dimensional.





A plane is two dimensional concept.

It has both infinite length and width but no thickness.

Any three points in space will define a plane as will any two intersecting lines creating a plane.

Every day examples of planes would include desk tops, floors, window panes, ceilings, etc.


In order to define a three dimensional space you need a minimum of one of the following:

Three mutually perpendicular axis or lines

A point of origin at the intersection of three three lines

The Z line is used to describe height, the X and Y lines define the length and width.


Point of Origin: Is the point from which we begin to measure height, width and length.

Remember that the lines are considered to extend infinitely in both positive and a minus direction from the origin point.

Point to the left of or below the origin point will have a negative or minus value.

Point to the right or above the origin will have a plus or a positive value.




Define distance by dividing a line into equal increments. For simplicity assume that each line segment equals one inch.


CNC Programming Consists of the following:



CAM- assign a cycle

Control-feeding CAD/CAM to control



Machine Coordinate System is built into the machine by the manufacturer.

It is defined by the limit switches on the machine.

Once the machine has been turned on and the various axis have been to the home or zero reference return point, the machine automatically knows where each axis is at any given time.

While it is true that most up to date machines have a zero reference return for establishing a home position and a work coordinate system, it is important to note that not all machines use the same location on the machine tool for the home position.


In the machine coordinate system of a lathe the X0 is at the centerline of the chuck with the positive direction pointing towards the rear of the machine. The Z axis runs parallel to the centerline of the chuck and has its origin for the machine coordinates system at the point farthest from the chuck.

Machine Coordinate System is handy to have a machine coordinate system for setting up the machine and tool changes, but that it is an awkward system to use for programming.

It is unlikely that you will need or want to program a part using the machine coordinate system.

The programming manuals that came with your machine should describe if and where a home point exists for the machine.


Incremental Programming: Also known as point-to-point programming is a style of programming that allows the programmer to program the part without any coordinate system.

By simply describing the next destination point as the actual distance and direction from the existing location of the cutting tool, the programmer is able to move the tool around the part from point to point.

If you want to program incrementally, you will need to provide the machine with an appropriate code.

G91 is the most common code for establishing point to point or incremental programming.

When using incremental programming, each new point becomes a new start/origin point from which to calculate the next point.


Incremental Programming Tip:

When programming incrementally, it is important that you start and end from the same point. If not, your program will accumulate an error every time you run them.

One way to proofread an incremental program for this type of error is to add all of X points together, the Y points together and the Z points together.

All of the totals for the X, Y and Z columns of numbers should equal to 0. If they do not add up to 0 you have an error.


The Coordinate Axis and The Machine

The Z-axis runs parallel to the center line of the spindle.

The X and Y axis form a plane that is normal [perpendicular] to the Z-axis.


While any point in space can be described by 3 mutually perpendicular axis, often machines have more than 3 axis usually, these additional axis describes an auxiliary moving axis.


4th axis usually describes a rotary table.

5th axis might be a tilting table or tilting head.

The point of origin for each machine will vary, depending on the manufacture of the machine and the style of the machine.

For the most part you will be programming the machines using absolute and/or incremental programming methods.

The A, B, C and U, V, W axis are some additional programmable axis you may encounter.

A, B, C, designate rotational axis.



On a mill with a rotary table that tilts the axis commands for the rotation or tilting could be A, B or C depending on weather or not the tilting or rotating is about the X, Y or Z primary axis.

Mill turn centers where the drive spindle can be indexed will typically assign C as the programmable axis for indexing the chuck.

The A axis is an auxiliary axis that rotates around the X axis.

The B axis is an auxiliary axis that rotates around the Y axis.

The C axis is an auxiliary axis that rotates around the Z axis.

Many lathes use U and W in addition to X and Z for programming parts in the X, Z plane.

Some mills that have tables/columns that move parallel to the Z axis will use W to designate the table/column movement and Z to program the quill movement.

The U axis is an auxiliary axis that moves parallel to the X axis.

The V axis is an auxiliary axis that moves parallel to the Y axis.

The W axis is an auxiliary axis that moves parallel to the Z axis.


Absolute Programming is a system of programming that enables the programmer to establish a specific origin point from which all other points can be calculated.

The point chosen for the origin of the work coordinate system does not need to be within the limits of the machine.

The origin point doesn't even need to be within the limits of the machine.

Any point that is convenient to use for the origin point can be used regardless of where that point might exist in space.

The point for the program origin will often be determined by the blue print datums, critical features of the part or locating surfaces used to secure the part for machining.

G90 is the command that puts the machine in absolute programming mode.

Once you know what point you want to use for your origin, program the appropriate code into the machine; most often this code will be a G92 or G50, this code should be followed by an X, Y, Z or other axis name with the corresponding distance and direction from the origin point to the currently programmed tool location.


Program Break Down:

appropriate code, axis name, corresponding distance and direction

To determine the current value for the axis command, follow these steps:

1. Start at the point you have chosen to be the origin.

2. From that point, describe the distance and direction to the currently programmed tool location.

A G92 or G50 command defines the cutter location by both distance and direction from the program origin to the current location of the cutter.

Many machines no longer rely on G50/G92 for establishing the program zero. Instead they use a local work coordinate system.

The work coordinate system allows the programming of up to 6 local work coordinate systems in the same program.

The G54-G59 commands tell the machine control to use specific local work coordinate system.

These local coordinate systems are established by the operator during the set up of the part.

Programming using G54-G59 makes it easy to program multiple parts on different vises, each one can have its own local coordinate system unique to its set up.


Incremental Program


Absolute Program









Start from point 1




From Origin




Start from point 2




From Origin




Start from point 3




From Origin




Start from point 4




From Origin




Start from point 5




From Origin




Start from point 5




From Origin











Two Very Important Rules:

Rule 1

Always relate the machine moves to the tool tip not to the actual table movement. Machine controls are designed to be programmed as if you were driving the tool tip. On a lathe this is not a problem, but on milling type machining centers, it is usually a combination of the machine table and the tool tip that moves.

Rule 2

Program the desired tool path relative to the center of the cutter. This is true for lathes as well as mills. When programming a lathe, use the center of the tool nose radius. This is particularly important when manually programming machines. If you are generating G-code using a Computer Aided Manufacturing (CAM) system this is less critical.

Programming to the center of the cutter is essential for correctly applying the math to generate accurate machine control data.


When side cutting on a mill or cutting on a lathe, the cutter path must be offset by an amount equal to the radius of the cutter unless cutter radius compensation has been programmed.



Positioning type machine motion: Used to get to and around the part as quickly as possible.

Some machines do not have a specific code for positioning so you are limited to using the maximum feed rate that is programmable for that particular machine.

There may also be times when you do not want to use rapid moves for operator safety and convenience.

At that point, you would use a feed rate that is best for the circumstance.

Machines that have a specific rapid positioning code most often use G0 or G00 command.

A G0 command in most cases is a rapid non-linear move, a dog leg.

Occasionally, a machine will have the parameters set so that the rapid moves are linear.


Interpolation- A function of a control whereby data points are generated between given coordinate positions.

More specifically to machines interpolation is used to insure that all axis moves arrive at a specific point at the same time.

The machine accomplishes this by continuously calculating its distance/time for each moving axis to ensure that the tool axis arrive exactly on time.


G1/G01: Linear Interpolation- Move to the specified point via a straight line at the programmed feed rate.

G2/G02: Clockwise Interpolation- Move to specified point via a clockwise arc at the programmed feed rate.

G3/G03: Counter Clockwise Interpolation- Move to specified point via a counter clockwise arc at the programmed feed rate.

When you think about arcs on a CNC machine imagine that you are looking down the length of the Z axis at the work piece. That orientation will show you if you need the G02 or G03 command.


Programming Tip

The "0" in the G01, G02, and G03 commands is a "zero" not the letter "O".

This is a very common programming error.

Often when typing it is easy to hit the wrong key.

The program will not run and depending on the computer or printer you use the error may be hard to find.

If you are using a computer text editor to type your program you can use the search feature of the editor to search for any occurrence of the letter 'O".

Most controls that use a letter "O" use it to signify the program number at the beginning of the program, so, beyond that you should only have "zeros".


The Dwell

When it is necessary to program the machine to do nothing for a specific amount of time use the G4 or G04 command. G4 or G04 commands the machinr to dwell for a specific time in seconds as specified by a P or X command.

P = Seconds/1000. (P500 = 1/2 second) Decimal points are not used with P codes.

X = Seconds (X1.5 = 1.5 seconds) Decimal points can be used with X codes.


Plane Selection

To program arcs and radii, the programmer must define the geometric plane which will accommodate the curve.

The 3 most common choices for planes are:

G17: The X, Y plane of Interpolation

G18: The X, Z plane of Interpolation

G19: The Y, Z plane of Interpolation


Arc Center Locations

When programming arcs and radii, the programmer needs to describe:

The plane of the arc (G17, G18, or G19).

The destination point (X,Y, Z axis cooridinates).

The direction of the arc (G02 or G03).

The location of the center of the arc (I, J, or K)


The most common method of the more modern machines is to progrm the Is, Js, and Ks using the following method:

I = An incremental distance and direction from the start point of the arc to the arc center along the X axis.

K = An incremental distance and direction from the start point of the arc to the arc center along the Z axis.

J = An incremental distance and direction from the start point of the arc to the arc center along the Y axis.


Lathe use a combination of Is and Ks because arc on lathe are typically on the X, Z (G18) plane.

The most common arc on a mill are on the X, Y plane (G17) and uses Is and Js.

Most mills are capable of generating arcs on any of the plane: (G19) would use Js and Ks.




The method used to calculate the arc vectors I, J, or K is the distance and direction from the start point of the arc to the center of the arc.

Arriving to the correct I, J, K values will involve some simple right angle trigonometry.


More On Arcs

Some controls use an optional "R" code to describe the arc center.

When this option is avaible the programmer is only required to program

arc plane

arc direction

end point

R code which equals the radius value of the arc

(G03 G17 X5.0 Y13.378 R25).

The machine does its own calculations of the arc center.

I,J, and K codes cannot be mixed with R codes.

In the event these codes are mixed th R code will take precedence over the other codes.

R codes are good for arcus up to 180 degrees.

On some controls, placing a (-) sign in frint of the R code will allow programming of arcs up to 359+ degrees, not quite 360 degress.

When programming arcs, end points and arc centers must calculated correctly. Errors in calculations will result in errors in the arcs generated.


Putting It All Together


There are many different codes but only two major types of codes.


      Modal Codes: Defined as codes that once programmed do not change until they are re-programmed or the machine is reset.


      One-Shot codes: Defined as codes that are effective only for the immediate block programmed. Once the machine has met the conditions of a one-shot code, it continues with the rest of the program without referring back to this code.

  • Program: A series of commands strung together instructing the machine to do specific things at at specific times.

One command is called a block.

A block is composed of one or more codes.

A code is a letter address followed by numbers which have a specific meaning.


Letter Addresses and Their Meaning


CNC Code



Program Number


Sequence number (optional on some controls)


Preparatory functions, motions, canned cycles


Coordinate axis used to define motion and point location


Designates additional axis motion


Arc radius of modifier for canned cycles


Arc center values


Feedrates (can be in IPM/IPR or MPM/MPR)


Spindle Speed


Tool number/offset number


Tool length offset for mills with FANUC controls


Tool radius offset for mills with cutter radius compensation (CRC)


X Specifies the dwell time in seconds for G04 commands and some canned cycles. P designates dwell time in seconds/1000


P is also used to designate the program number when calling a sub-program. It is also the letter used to designate the sequence number in the main program to return to when returning from a sub-program (optional)


Specifies the number of repetitions for a canned cycle or sub-program (optional)


Modifiers used in various canned cycles


Miscellaneous functions, usually toggles on/off coolant, spindle, calls sub-programs, etc.


The syntax used when programming these codes is faily simple.

A good format for prioritizing the codes might be as follows:

O on the first line for the program number (required)

Then N, G, X, Y, Z, (A, B, C), R, I, J, K, H, D, P, Q, L, F, S, T and M.

Notes about the codes

N: Sequence numbers are not required on some machines. However wnem they are used creatively, they can simplify operating and editing. One example would be to only sequence numbers at tool changes. The operator can then search by N number to find o tool to to be re-run.

G: Many G codes can be mixed on the same line providing they are not of the same grouping. For example G00 and G01 are from the same group. If both codes were programmed on the same line the latter of the two codes will be used and the earlier one ignored. On the other hand, programming a G00, G17 and a G80 on the same line is acceptable since they are from different and non-conflicting groups.Cunsult the programming manuals that came with your particular machines to determine which G codes can be combined.


S: Some machines use direct spindle programming, while others use a table to program spindle speeds. An example of direct spindle programming would be prgramming S1000 to get 1000 RPM. A machine using a spindle speed table might be programmed with an S48 to get the desired 1000 RPM. Consult the programming manuals for specific machines to determine proper spindle speed programming. Many machines have two or more spindle ranges. To get a specific spindlespeed you would have to program not only the spindle speed but also the appropriate M code that puts the machine in the correct speed range. On lathes it is very common to program using Constant Surface Feet Per Minute (CSFM). This allows the spindle to increase its speed as the tool moves towards the center of the work piece and then slow down as it moves away from the center. This is particularly important for maintaining a good surface finish on the work piece and reducing production times. The most common command for CSFM is G96. Direct spindle programming is usually command with a G97 command.


F: Feedrates can be in Inches Per Revolution (IPR) or Inches Per Minute (IPM) as set by the corresponding G code. Check the machine programming manual to determine the correct feed code for your machine. Many machines use a G94 to program inches per minutes and a G95 to program inches per revolution. Some machines may not use G codes to differentiate between IPR and IPM programming. In this case usually a different letter such as an E would be used for the feed command. F10.0 would program a 10.0 per minute feed rate. An E.01 would program a .01" per revolution feed rate.


Program Using Incremental Programming Method

Program Comments

01234.............................01234 Program Number

N5G0G91S500M3.................N5 Optional sequence number

.....................................G0 Set for rapid non-linear move

...............................G91 Set for incremental programming

.........................................S500 Spindle speed 500 rpm

.............................................M3 Spindle normal rotation

X3.5Y3.5M8.........X,Y Incremental values of destination point

...........................................M8 Coolant on

G1X5.F5. ............................G1 Set for linear interpolation

............................................F5. Sets feed rate at 5. IPM

Y-3. .................................... Incremental move to Y position

X.5...................................... Incremental move to X position

G2X1.5Y-1.5J-1.5................G2 Clockwise circular interolation

...................................................X,Y Destination Point

................................J Arc center location from the start

.........................................................point of the arc

.................................(figured to the center of the cutter)

G1Y-1.5..........................G1 Resets to linear

.......................................interpolation and

........................................incremental Y move

X-9. ...................................Incremental move to X position

Y1.5 ..................................Incremental move to Y position

G2X1.5Y1.5|1.5 .................G2 CW circular interpolation

..........................................X,Y Destination Point

..........................................| Arc center location from the

..........................................start point of the

..........................................(figured to the center

.......................................... of the cutter)

G1X.5 ............................... G1 Resets to linear interpolation

.........................................and incremental X move

Y3. .................................... Incremental move to Y position

G0X-3.5Y-3.5M5 ................G0 Set rapid non-linear


.........................................X,Y Returns to original start point

..........................................M5 Spindle off

M9 .....................................M9 Coolant off

M30 ...................................M30 Program reset/tape rewind




Rule #1 states , always relate machine moves to the ___,not ____.



Tool Tip


Table Movement




Rule #2 states, always program the desired path relative to the _____ of the cutter.









In order for the machine tool to make parts, the programmer must first define the part boundaries by Intersecting points, and Tangency.



Over 300 years ago, Rene Descartes developed a system whereby any point in space can be described in mathematical terms from any other point via 3 mutually Perpendicular axis. This system is known as the Rectangular coordinate system.


The Machine Coordinate System is:


- Built into machine

- Defined by machine Limit Switches

- Referred to as Zero Reference return




Incremental programming is also known as Point to Point programming and called up by the G code G91




Absolute programming is a system where every point is calculated from a previously defined work zero/origin. This type of programming is called up by a G90




A G92 code defines the existing location of the cutting tool numerically by both Distance and Direction from the program zero.




Essentially every program point becomes o new ___ point from which to describe the next program point when using incremental programming.








I, J, and K, define arc center by __and___from the ___to the____.




Start Point

Arc Center





Some codes are one shot codes while others are___.




CRC (cutter radius compensation)

(can be either left G41 or right G42)


A. To climb cut the outside of a part using CW spindle rotation, you should program a G__ for the correct CRC.


B. To conventional cut the inside of a pocket using CW spindle rotation, you should program a G____ for the correct CRC.







G codes can be combined numerous ways on the same line providing you don't have more than one G code from the same____.






When initiating CRC, the G41/G42 code must be accompanied by an___ or___ move.





Linear Interpolation G00 and G01.




Circular Interpolation G02 and G03




G04 Dwell: Modal [NO]

G04 will stop all movement for a specified amount of time.

G4 X1000 will pause all motion for 1 second.



Plane selection G17 G18 G19: MODAL [YES]

The G-Codes G17, G18 and G19 control the 3 planes of operation on most C N C Machines. Cutter radius compensation and tool compensation are affected by the plane selection. The default plane is XY.


Cutter Radius Compensation G40 G41 G42: MODAL [YES]

G40: Cutter compensation cancels.

G41: Cutter compensation left.

G42: Cutter compensation right..

The radius used for compensation is stored in the Tool Table and the correct tool must be active when the compensation is applied. The cutter radius compensation depends on the active plane.




Canned Cycle G81 -> G85.

Supporting users have an ad free experience!