Posted tagged ‘programming basics’

Programming Systems | CNC programming Basics | G-Code | M-Code | Incremental and Absolute Programming System | Interpolation | Linear Interpolation | Circular Interpolation

September 16, 2011


The method by which contouring machine tools move from one programmed point to the next is called interpolation. This ability to merge individual axis points into a predefined tool path is built into most of today’s MCUs.

There are five methods of interpolation:

  • linear
  • circular
  • helical
  • parabolic
  • cubic

All contouring controls provide linear interpolation, and most controls are capable of both
linear and circular interpolation. Helical, parabolic, and cubic interpolation are used by industries that manufacture parts which have complex shapes, such as aerospace parts and dies for car bodies.

Linear Interpolation

Linear Interpolation consists of any programmed points linked together by straight lines, whether the points are close together or far apart

Curves can be produced with linear interpolation by breaking them into short, straight-line segments. This method has limitations, because a very large number of points would have to be programmed to describe the curve in order to produce a contour shape. A contour programmed in linear interpolation requires the coordinate positions (XY positions in two-axis work) for the start and finish of each line segment. Therefore, the end point of one line or segment becomes the start point for the next segment, and so on, throughout the entire program.

01-example of Linear Interpolation-straight line motion of a cutter-2 axis-2 position

Circular Interpolation

The development of MCUs capable of circular interpolation has greatly simplified the process of programming arcs and circles. To program an arc, the MCU requires only the coordinate positions (the XY axes) of the circle center, the radius of the circle, the start point and end point of the arc being cut, and the direction in which the arc is to be cut (clockwise or counterclockwise)01-circular Interpolation


The most common codes used when programming CNC machines tools are

  • G-codes (preparatory functions), and
  • M codes (miscellaneous functions).

Other codes such as F, S, D, and T are used for machine functions such as feed, speed, cutter diameter offset, tool number, etc.


G-codes are sometimes called cycle codes because they refer to some action occurring on the X, Y, and/or Z axis of a machine tool.

01-G-Codes example-rapid transverse-Linear Interpolation-Straight line path01-G-Codes-Circular Interpolation colockwise-Anticlockwise or Counterclockwise

Group Code Function
01 G00 Rapid Positioning
01 G01 Linear Interpolation
01 G02 Circular Interpolation  clockwise (CW)
01 G03 Circular Interpolation Counter clockwise (CCW)
06 G20* Inch input (in.)
06 G21* Metric Input (mm)
G24 Radius Programming (**)
00 G28 Return to Reference Point
00 G29 Return from Reference Point
G32 Thread Cutting (**)
07 G40 Cutter Compensation Cancel
07 G41 Cutter Compensation Left
07 G42 Cutter Compensation Right
08 G43 Tool length compensation positive
08 G44 Tool length compensation minus
08 G49 Tool Length Compensation Cancel
G84 Canned Turning Cycle (**)
03 G90 Absolute Programming
03 G91 Incremental Programming

(*) – on some machines and controls, these may be G70 (inch) and G71 (metric)
(**) – refers only to CNC lathes and turning centers.



M or miscellaneous codes are used to either turn ON or OFF different functions which control certain machine tool operations.

01-M-Codes-Direction of Rotation-Clockwise-Counter clockwise-Tool Change - End of program-return to beginning

Code     Function

M00     Program stop
M02     End of program
M03     Spindle start (forward CW)
M04     Spindle start (reverse CCW)
M05     Spindle stop
M06     Tool change
M08     Coolant on
M09     Coolant off
M10     Chuck – clamping (**)
M11     Chuck – unclamping (**)
M12     Tailstock spindle out (**)
M13     Tailstock spindle in (**)
M17     Tool post rotation normal (**)
M18     Tool post rotation reverse (**)
M30     End of tape and rewind
M98     Transfer to subprogram
M99     End of subprogram

(**) – refers only to CNC lathes and turning centers.

Programming Systems | CNCAbsolute Programming System programming Basics | G-Code | M-Code | Incremental and

September 16, 2011

Two types of programming modes, the incremental system and the absolute system, are used for CNC. Both systems have applications in CNC programming, and no system is either right or wrong all the time. Most controls on machine tools today are capable of handling either incremental or absolute programming.


01-CNC positioning of a lathe or Milling Machine-Incremental Programming-Absolute Programming system-CNC Programming Basics

Incremental program locations are always given as the distance and direction from the immediately preceding point

01-reference point systems-incremental mode-incremental program-immedaite proceeding point-G91 command

  • A “X plus” (X+) command will cause the cutting tool to be located to the right of the last point.
  • A “X minus” (X-) command will cause the cutting tool to be located to the left of the last point.
  • A “Y plus” (Y+) command will cause the cutting tool to be located toward the column.
  • A “Y minus” (Y-) will cause the cutting tool to be located away from the column.
  • A “Z plus” (Z+) command will cause the cutting tool or spindle to move up or away from the workpiece.
  • A “Z minus” (Z-) moves the cutting tool down or into the workpiece.

In incremental programming, the G91 command indicates to the computer and MCU (Machine Control Unit) that programming is in the incremental mode.

Absolute program locations are always given from a single fixed zero or origin point. The zero or origin point may be a position on the machine table, such as the corner of the worktable or at any specific point on the workpiece. In absolute dimensioning and programming, each point or location on the workpiece is given as a certain distance from the zero or reference point.

01-Absolute Program-G90 Code-Certain distance from zero

  • A “X plus” (X+) command will cause the cutting tool to be located to the right of the zero or origin point.
  • A “X minus” (X-) command will cause the cutting tool to be located to the left of the zero or origin point.
  • A “Y plus” (Y+) command will cause the cutting tool to be located toward the column.
  • A “Y minus” (Y-) command will cause the cutting tool to be located away from the column.

In absolute programming, the G90 command indicates to the computer and MCU that the programming is in the absolute mode.

The term numerical control is a widely accepted and commonly used term in the machine tool industry. Numerical control (NC) enables an operator to communicate with machine tools through a series of numbers and symbols.

NC which quickly became Computer Numerical Control (CNC) has brought tremendous changes to the metalworking industry. New machine tools in CNC have enabled industry to consistently produce parts to accuracies undreamed of only a few years ago. The same part can be reproduced to the same degree of accuracy any number of times if the CNC program has been properly prepared and the computer properly programmed. The operating commands which control the machine tool are executed automatically with amazing speed, accuracy, efficiency, and repeatability.

The ever-increasing use of CNC in industry has created a need for personnel who are knowledgeable about and capable of preparing the programs which guide the machine tools to produce parts to the required shape and accuracy. With this in mind, the authors have prepared this textbook to take the mystery out of CNC – to put it into a logical sequence and express it in simple language that everyone can understand.

01-CNC lathe - CNC Turning Center-Cartesian Coordinate System


 01-cost-effective-2-axis-cnc-lathes-computer numeric control

Milling Machine

The milling machine has always been one of the most versatile machine tools used in industry (Fig. 5). Operations such as milling, contouring, gear cutting, drilling, boring, and reaming are only a few of the many operations which can be performed on a milling machine. The milling machine can be programmed on three axes:
• The X axis controls the table movement left or right.
• The Y axis controls the table movement toward or away from the column.
• The Z axis controls the vertical (up or down) movement of the knee or spindle.

01-3 axis - vertical Machining center-CNC Machining CenterThe main axes of a vertical machining center.

01-Cnc-Milling-Machines-milling, contouring, gear cutting, drilling, boring, and reaming