Computer Numerical Control 
Programming Basics 
You can Join at Our Group 
Facebook : CNC INDONESIA or 
Email :soekarno.gempar@gmail 
Definitions 
CAD – COMPUTER-AIDED-DESIGN 
■ Designing the part to be machined by CNC machine 
CAM – COMPUTER-AIDED-MANUFACTURING 
■ Developing the toolpaths, feeds and speeds for the CNC Machines 
CNC – COMPUTER-NUMERICAL-CONTROLLED 
■ Computer controlled machine controlled by a Machine Control Unit 
(MCU) 
Programming Process 
CAD - DRAW PART IN AUTOCAD OR AUTODESK INVENTOR 
Program Transfer – Load drawing file into MasterCAM 
CAM – PROGRAM CUTTERS, TOOLPATHS, SPEEDS, FEEDS, ETC. IN 
MASTERCAM 
Post Processor - A software link in the CAD/CAM chain that communicates 
instructions from CAM to a CNC machine. 
. 
Program data transfer - PC to Machine Control Unit which runs the CNC machine 
CNC – MACHINE PART ON A CNC MACHINE USING INSTRUCTIONS FORM 
CAD/CAM PROGRAMMING
CNC Machine Types 
CNC Milling Center 
CNC Turning Center 
CNC Gantry Router
What is a CNC Machine? 
CNC : Computer and Numeric Control: 
Conventionally, an operator decides and adjusts various machines parameters like feed , 
depth of cut etc depending on type of job , and controls the slide movements by hand. In 
a CNC Machine functions and slide movements are controlled by motors using computer 
programs. 
● Programmed instructions are converted into output signals which in turn control 
machine operations such as spindle speeds, tool selection, tool movement, and 
cutting fluid flow. 
● A numerical control, or “NC”, system controls many machine functions and 
movements which were traditionally performed by skilled machinists. 
● Numerical control developed out of the need to meet the requirements of high 
production rates, uniformity and consistent part quality. 
Advantages: 
● High Repeatability and Precision e.g. Aircraft parts 
● Volume of production is very high 
● Complex contours/surfaces need to be machined. E.g. Turbines 
● Flexibility in job change, automatic tool settings, less scrap 
● More safe, higher productivity, better quality 
● Less paper work, faster prototype production, reduction in lead times 
Disadvantages: 
● Costly setup, skilled operators 
● Computers, programming knowledge required 
● Maintenance is difficult 
How CNC works: 
● Controlled by G and M codes. 
● These are number values and co-ordinates. 
● Each number or code is assigned to a particular operation. 
○ Typed in manually to CAD by machine operators. 
○ G&M codes are automatically generated by the computer software. 
● The tool or material moves. 
● Tools can operate in 1-5 axes. 
● Larger machines have a machine control unit (MCU) which manages operations. 
● Movement is controlled by a motor (actuators). 
● Feedback is provided by sensors (transducers) Closed loop? 
● Tool magazines are used to change tools automatically.
Tool Paths, and Cutting Motions: 
● Tool paths describe the route the cutting tool takes. 
● Motion can be described as point to point, or contouring. 
● Speeds are the rate at which the tool operates e.g. rpm. 
● Feeds are the rate at which the cutting tool and work piece move in relation to 
each other. Expressed in IPM (inches per minute) 
● Feeds and speeds are determined by cutting depth, material and quality of finish 
needed. e.g. harder materials need slower feeds and speeds. 
● Rouging cuts remove larger amounts of material than finishing cuts. 
● Rapid traversing allows the tool or work piece to move rapidly when no 
machining is taking place 
Point to Point and Contour Tool Paths: 
Point to Point Toolpath Contour ToolPath 
Point to Point toolpaths cut following lines Contour toolpaths cut follow surfaces 
Linear Interpolation :( Point to Point) 
Linear interpolation consist of a programmed point linked together by straight lines 
Circular Interpolation: (Contour) Circular interpolation is the process of programming 
arcs and circles. 
. 
Circular interpolation requires endpoints, a feed rate, a 
center, a radius, and a direction of movement.
CNC Programming Basics 
Block of Information: 
When running, a part program is interpreted one command line at a time until all lines are 
completed. 
N001 G01 X1.2345 Y.06789 MO3 
N001 Represents the sequence number of the operation 
G01 Represents linear operation (tool movement) 
X12345 Will move the tool or table 1.2345 in. a positive direction along the X axis 
Y6789 Will move the tool or table 0.6789 in. along the Y axis 
M03 Turns spindle on clockwise 
Commands, which are also referred to as blocks, are made up of words which each begin 
with a letter address and end with a numerical value. 
Each letter address relates to a specific machine function. “G” and “M” letter addresses 
O - Program number (Used for program identification) 
N - Sequence number (Used for line identification) 
G - Preparatory function 
X - X axis designation 
Y - Y axis designation 
Z - Z axis designation 
R - Radius designation 
F – Feed rate designation 
S - Spindle speed designation 
H - Tool length offset designation 
D - Tool radius offset designation 
T - Tool Designation 
M - Miscellaneous function
G- CODES (Preparatory Functions) which cause some movement of the machine table 
or head. 
G00 – Rapid Movement 
G01 Linear Interpolation (movement) 
G02 Circular Interpolation, CW 
G03 Circular Interpolation, CCW 
G17 XY Plane,G18 XZ Plane,G19 YZ Plane 
G20/G70 Inch units 
G21/G71 Metric Units 
G40 Cutter compensation cancel 
G41 Cutter compensation left 
G42 Cutter compensation right 
G43 Tool length compensation (plus) 
G43 Tool length compensation (plus) 
G44 Tool length compensation (minus) 
G49 Tool length compensation cancel 
G80 Cancel canned cycles 
G81 Drilling cycle 
G82 Counter boring cycle 
G83 Deep hole drilling cycle 
G90 Absolute positioning
G91 Incremental positioning 
M-CODES (Miscellaneous) which turn ON or OFF different functions 
M00 Program stop 
M01 Optional program stop 
M02 Program end 
M03 Spindle on clockwise 
M04 Spindle on counterclockwise 
M05 Spindle stop 
M06 Tool change 
M08 Coolant on 
M09 Coolant off 
M10 Clamps on 
M11 Clamps off 
M30 Program stop, reset to start 
Important things to know: 
Feed rate and spindle speed 
● Feed and Speed Codes: F and S- Specify feed and spindle speed 
Coolant Control: On/Off, Flood, Mist 
Tool Control: Tool and tool parameters 
● Tool codes: T – specify tool number 
Programming consists of a series of instructions in form of letter codes 
Preparatory Codes: 
● G codes- Initial machining setup and establishing operating conditions
● N codes- specify program line number to executed by the MCU 
Axis Codes: X,Y,Z - Used to specify motion of the slide along X, Y, Z direction 
Program Example 
O1234 (Program Number) 
N5 G90 G20 (ABSOLUTE COORDINATE. IN INCHES) 
N10 M06 T3 (TOOLCHANGE TO TOOL #3) 
N15 M03 S1250 (SPINDLE ON CW AT 1250RPM) 
N20 G00 X1 Y1 (RAPID OVER TO X1 Y1) 
N25 Z0.1 (RAPID DOWN TO Z0.1) 
N30 G01 Z-0.125 F5 (FEED DOWN TO Z-0.125 AT 5IPM) 
N35 X3 Y2 F10 (FEED DIAGONALLY TO X3 Y2 AT 10IPM) 
N40 G00 Z1 (RAPID UP TO Z1) 
N45 X0 Y0 (RAPID OVER TO X0 Y0) 
N50 M05 (SPINDLE OFF) 
N55 M30 (PROGRAM END

Cnc programming basics.doc

  • 1.
    Computer Numerical Control Programming Basics You can Join at Our Group Facebook : CNC INDONESIA or Email :soekarno.gempar@gmail Definitions CAD – COMPUTER-AIDED-DESIGN ■ Designing the part to be machined by CNC machine CAM – COMPUTER-AIDED-MANUFACTURING ■ Developing the toolpaths, feeds and speeds for the CNC Machines CNC – COMPUTER-NUMERICAL-CONTROLLED ■ Computer controlled machine controlled by a Machine Control Unit (MCU) Programming Process CAD - DRAW PART IN AUTOCAD OR AUTODESK INVENTOR Program Transfer – Load drawing file into MasterCAM CAM – PROGRAM CUTTERS, TOOLPATHS, SPEEDS, FEEDS, ETC. IN MASTERCAM Post Processor - A software link in the CAD/CAM chain that communicates instructions from CAM to a CNC machine. . Program data transfer - PC to Machine Control Unit which runs the CNC machine CNC – MACHINE PART ON A CNC MACHINE USING INSTRUCTIONS FORM CAD/CAM PROGRAMMING
  • 2.
    CNC Machine Types CNC Milling Center CNC Turning Center CNC Gantry Router
  • 3.
    What is aCNC Machine? CNC : Computer and Numeric Control: Conventionally, an operator decides and adjusts various machines parameters like feed , depth of cut etc depending on type of job , and controls the slide movements by hand. In a CNC Machine functions and slide movements are controlled by motors using computer programs. ● Programmed instructions are converted into output signals which in turn control machine operations such as spindle speeds, tool selection, tool movement, and cutting fluid flow. ● A numerical control, or “NC”, system controls many machine functions and movements which were traditionally performed by skilled machinists. ● Numerical control developed out of the need to meet the requirements of high production rates, uniformity and consistent part quality. Advantages: ● High Repeatability and Precision e.g. Aircraft parts ● Volume of production is very high ● Complex contours/surfaces need to be machined. E.g. Turbines ● Flexibility in job change, automatic tool settings, less scrap ● More safe, higher productivity, better quality ● Less paper work, faster prototype production, reduction in lead times Disadvantages: ● Costly setup, skilled operators ● Computers, programming knowledge required ● Maintenance is difficult How CNC works: ● Controlled by G and M codes. ● These are number values and co-ordinates. ● Each number or code is assigned to a particular operation. ○ Typed in manually to CAD by machine operators. ○ G&M codes are automatically generated by the computer software. ● The tool or material moves. ● Tools can operate in 1-5 axes. ● Larger machines have a machine control unit (MCU) which manages operations. ● Movement is controlled by a motor (actuators). ● Feedback is provided by sensors (transducers) Closed loop? ● Tool magazines are used to change tools automatically.
  • 4.
    Tool Paths, andCutting Motions: ● Tool paths describe the route the cutting tool takes. ● Motion can be described as point to point, or contouring. ● Speeds are the rate at which the tool operates e.g. rpm. ● Feeds are the rate at which the cutting tool and work piece move in relation to each other. Expressed in IPM (inches per minute) ● Feeds and speeds are determined by cutting depth, material and quality of finish needed. e.g. harder materials need slower feeds and speeds. ● Rouging cuts remove larger amounts of material than finishing cuts. ● Rapid traversing allows the tool or work piece to move rapidly when no machining is taking place Point to Point and Contour Tool Paths: Point to Point Toolpath Contour ToolPath Point to Point toolpaths cut following lines Contour toolpaths cut follow surfaces Linear Interpolation :( Point to Point) Linear interpolation consist of a programmed point linked together by straight lines Circular Interpolation: (Contour) Circular interpolation is the process of programming arcs and circles. . Circular interpolation requires endpoints, a feed rate, a center, a radius, and a direction of movement.
  • 5.
    CNC Programming Basics Block of Information: When running, a part program is interpreted one command line at a time until all lines are completed. N001 G01 X1.2345 Y.06789 MO3 N001 Represents the sequence number of the operation G01 Represents linear operation (tool movement) X12345 Will move the tool or table 1.2345 in. a positive direction along the X axis Y6789 Will move the tool or table 0.6789 in. along the Y axis M03 Turns spindle on clockwise Commands, which are also referred to as blocks, are made up of words which each begin with a letter address and end with a numerical value. Each letter address relates to a specific machine function. “G” and “M” letter addresses O - Program number (Used for program identification) N - Sequence number (Used for line identification) G - Preparatory function X - X axis designation Y - Y axis designation Z - Z axis designation R - Radius designation F – Feed rate designation S - Spindle speed designation H - Tool length offset designation D - Tool radius offset designation T - Tool Designation M - Miscellaneous function
  • 6.
    G- CODES (PreparatoryFunctions) which cause some movement of the machine table or head. G00 – Rapid Movement G01 Linear Interpolation (movement) G02 Circular Interpolation, CW G03 Circular Interpolation, CCW G17 XY Plane,G18 XZ Plane,G19 YZ Plane G20/G70 Inch units G21/G71 Metric Units G40 Cutter compensation cancel G41 Cutter compensation left G42 Cutter compensation right G43 Tool length compensation (plus) G43 Tool length compensation (plus) G44 Tool length compensation (minus) G49 Tool length compensation cancel G80 Cancel canned cycles G81 Drilling cycle G82 Counter boring cycle G83 Deep hole drilling cycle G90 Absolute positioning
  • 7.
    G91 Incremental positioning M-CODES (Miscellaneous) which turn ON or OFF different functions M00 Program stop M01 Optional program stop M02 Program end M03 Spindle on clockwise M04 Spindle on counterclockwise M05 Spindle stop M06 Tool change M08 Coolant on M09 Coolant off M10 Clamps on M11 Clamps off M30 Program stop, reset to start Important things to know: Feed rate and spindle speed ● Feed and Speed Codes: F and S- Specify feed and spindle speed Coolant Control: On/Off, Flood, Mist Tool Control: Tool and tool parameters ● Tool codes: T – specify tool number Programming consists of a series of instructions in form of letter codes Preparatory Codes: ● G codes- Initial machining setup and establishing operating conditions
  • 8.
    ● N codes-specify program line number to executed by the MCU Axis Codes: X,Y,Z - Used to specify motion of the slide along X, Y, Z direction Program Example O1234 (Program Number) N5 G90 G20 (ABSOLUTE COORDINATE. IN INCHES) N10 M06 T3 (TOOLCHANGE TO TOOL #3) N15 M03 S1250 (SPINDLE ON CW AT 1250RPM) N20 G00 X1 Y1 (RAPID OVER TO X1 Y1) N25 Z0.1 (RAPID DOWN TO Z0.1) N30 G01 Z-0.125 F5 (FEED DOWN TO Z-0.125 AT 5IPM) N35 X3 Y2 F10 (FEED DIAGONALLY TO X3 Y2 AT 10IPM) N40 G00 Z1 (RAPID UP TO Z1) N45 X0 Y0 (RAPID OVER TO X0 Y0) N50 M05 (SPINDLE OFF) N55 M30 (PROGRAM END