0% found this document useful (0 votes)
232 views

Experiment 6 - CNC Programing-Milling

The document provides information on CNC programming for turning operations, including: 1. G-codes and M-codes used for basic motions, cutting parameters, and machine functions. Common codes like G00, G01, G02, G03, M03 and M05 are explained. 2. Program format and structure, including the use of blocks, block numbers, comments, and modal commands. 3. A sample program is given as an example to demonstrate the code structure and use of G-codes and M-codes for operations like tool changes, drilling, grooving and returning to a tool change position.

Uploaded by

G. Dancer Gh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
232 views

Experiment 6 - CNC Programing-Milling

The document provides information on CNC programming for turning operations, including: 1. G-codes and M-codes used for basic motions, cutting parameters, and machine functions. Common codes like G00, G01, G02, G03, M03 and M05 are explained. 2. Program format and structure, including the use of blocks, block numbers, comments, and modal commands. 3. A sample program is given as an example to demonstrate the code structure and use of G-codes and M-codes for operations like tool changes, drilling, grooving and returning to a tool change position.

Uploaded by

G. Dancer Gh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Tafila Technical University

Department of Mechanical Engineering


CAD/CAM Laboratory
Dr. Ahmad Mostafa
1st semester 2020/2021

CNC PROGRAMMING TURNING


1. Introduction
CNC Machining is a process used in the manufacturing sector that involves the use of computers
to control machine tools. Tools that can be controlled in this manner include lathes, mills, routers
and grinders. The CNC Stands for Computer Numerical Control. Programming for turning and
milling using ISO standard G/M codes for basic motions, cutting parameters, canned cycles and
subprograms.

2. G-code
G-code stands for “geometric code”. G-codes, also called preparatory codes, are any word in a
CNC program that begins with the letter G. Generally it is a code telling the machine tool what
type of action to perform, such as:
 Rapid movement (transport the tool as quickly as possible in between cuts)
 Controlled feed in a straight line or arc
 Series of controlled feed movements that would result in a hole being bored, a workpiece
cut (routed) to a specific dimension, or a profile (contour) shape added to the edge of a
workpiece
 Set tool information such as offset
 Switch coordinate systems

Table 1: List of G-codes and their description


G-Code Description
G00 Rapid Linear Interpolation
G01 Linear Interpolation
G02 Clockwise Circular Interpolation
G03 Counter Clockwise Circular Interpolation
G04 Dwell
G05 High Speed Machining Mode
G10 Offset Input By Program
G12 Clockwise Circle With Entrance And Exit Arcs
G13 Counter Clockwise Circle With Entrance And Exit Arcs
G17 X-Y Plane Selection
G18 Z-X Plane Selection
G19 Y-Z Plane Selection
G28 Return To Reference Point
G34 Special Fixed Cycle (Bolt Hole Circle)

DR. AHMAD MOSTAFA CAD/CAM Lab. 1|EXPERIMENT 6


G35 Special Fixed Cycle (Line At Angle)
G36 Special Fixed Cycle (Arc)
G37 Special Fixed Cycle (Grid)
G40 Tool Radius Compensation Cancel
G41 Tool Radius Compensation Left
G42 Tool Radius Compensation Right
G43 Tool Length Compensation
G44 Tool Length Compensation Cancel
G45 Tool Offset Increase
G46 Tool Offset Decrease
G50.1 Programmed Mirror Image Cancel
G51.1 Programmed Mirror Image On
G52 Local Coordinate Setting
G54 - G59 Work Coordinate Registers 1 Thru 6
G60 Unidirectional Positioning
G61 Exact Stop Check Mode
G65 Macro Call (Non Modal)
G66 Macro Call (Modal)
G68 Programmed Coordinate Rotation
G69 Coordinate Rotation Cancel
G71 Rough Turning Cycle Overview
G73 Fixed Cycle (Step)
G74 Fixed Cycle (Reverse Tapping)
G76 Fixed Cycle (Fine Boring)
G80 Fixed Cycle Cancel
G81 Fixed Cycle (Drilling / Spot Drilling)
G82 Fixed Cycle (Drilling / Counter Boring)
G83 Fixed Cycle (Deep Hole Drilling)
G84 Fixed Cycle (Tapping)
G85 Fixed Cycle (Boring)
G86 Fixed Cycle (Boring)
G87 Fixed Cycle (Back Boring)
G88 Fixed Cycle (Boring)
G89 Fixed Cycle (Boring)
G90 Absolute Value Command
G91 Incremental Value Command
G96 Constant surface speed

3. M-codes
Most M codes activate machine functions like the coolant, spindle, etc. These are decided by the
machine manufacturer, and depend on the features that are available on the machine. E.g., a
machine with a tailstock will have M codes for tailstock in/out. A few (like M00, M01, M02, M98,
etc.in the list below) are fixed and based on the controller.

DR. AHMAD MOSTAFA CAD/CAM Lab. 2|EXPERIMENT 6


Table 2: List of some M-codes and their description
Code Description
M02 End of program
M03 Spindle on (clockwise rotation)
M04 Spindle on (counterclockwise rotation)
M05 Spindle stop
M06 Tool change
M08 Coolant on (flood)
M09 Coolant off
M30 End of program with return to program top

4. Program format
Program formats and commands explained in this chapter relate to the Fanuc 0iT controller. A
CNC program consists of a number of lines, called blocks. Each block contains a number of
commands.

Block format

For example: G01 X30.0 Z50.0 F0.2 block


The block tells the tool to move along a straight line to X30.0 Z50.0 at a feed rate of 0.2
mm/revolution.

A block consists of a set of words. Each word is a command. E.g., X30.0 is a word. A word
consists of an alphabet called the address, followed by a number.
In the previous example, X30.0, X is an address.

Common addresses
N- Block number - specifies the start of the block
G- Preparatory functions
M- Miscellaneous functions X X-axis coordinate
Z- Z-axis coordinate
I- X-axis location of arc center
K- Z-axis location of arc center
R- Radius of arc
S- Spindle speed or Cutting speed F Feed rate
T- Tool number

DR. AHMAD MOSTAFA CAD/CAM Lab. 3|EXPERIMENT 6


5. Program structure
A line of g-code is commonly called a “Block”. So the first thing to know is how to create blocks
since they’re the basic unit of a g-code part program.

Start
- The first line is the percent “%” character. The percent “%” is used to denote the beginning
and end of a program. Put one as the first line (block) and one as the last line (block) of
any g-code program. Not all controllers require this. Most will ignore anything after the
“%”, so you can put comments there.
- The second line is the program number, written as Onnnn
Example: O2345 means program number 2345
End
- The last is the program end command (M02 or M30). The last line is the % character.
Block numbers
- Block numbers add clarity to the program. They are written as Nxxxx
Example:
- -- -
N0123 G00 G90 X100.0 Y150.0
N0124 G01 Z-10.0 F250.0
N0125 X120.0
- -- -
- Block numbers are optional. They can be omitted from all blocks or included in some
blocks only. Quite often block numbers are used only in tool change blocks.
- The leading zero is optional. E.g., N0005 and N5 mean the same.
Comments
- Comments can be inserted to add clarity to the program. They can be operation names, tool
names, instructions to the operator, etc.
- Comments are inserted within brackets. Without comments a program is just a mass of
alphabets and numbers and you cannot figure out what each section of the program is doing.
- A comment can be in a separate block by itself, or after a set of commands.
Example
(RAPID TO TOOL CHANGE POSITION)
G00 X200.0 Z150.0 M05
T0202 (GROOVING TOOL)

DR. AHMAD MOSTAFA CAD/CAM Lab. 4|EXPERIMENT 6


Modal commands
- A Modal command is a command that remains active till it is canceled or changed by
another command of the same family.
Example
G01 X50.0 F0.2
G01 Z-5.0 F0.2
G01 X60.0 F0.2
G00 X100.0
G01 Z-80.0 F0.2
G01 X120.0 F0.2
- Here G01 and F are modal, and need not be repeated in every block. G01 remains active
till it is changed by G00. The block after G00 has it, but here F need not be repeated. The
blocks can be written as:
G01 X50.0 F0.2 Z-5.0 X60.0
G00 X100.0
G01 Z-80.0 X120.0

5.1. Sample program


Program block Explanation
% Program start character
O0998 Program number 998
G00 X200.0 Z150.0 Move to position away from part for tool change
T0101 Tool change to tool number 1 (Drill)
G97 S1200 M03 Constant spindle speed of 1200 RPM, spindle CW
M08 Coolant ON
G00 X0.0 Z2.0 Move at rapid to position for drilling
G01 Z-30.0 F0.15 Drill the hole feed rate 0.15 mm/rev.
G00 Z2.0 M09 Rapid out of hole and coolant OFF
G00 X200.0 Z150.0 M05 Rapid to tool change position and spindle OFF
T0202 Tool change to tool number 2 (Grooving tool)
G96 S180 M03 Constant spindle speed 180 m/min, spindle CW
G50 S3500 Limiting spindle speed 3500 RPM
G00 X54.0 Z-20.0 M08 Rapid to position above groove, coolant ON
G01 X30.0 F0.1 Feed to bottom of groove
G04 X1.0 Dwell 1 second
G00 X 54.0 Rapid out of groove
G00 X200.0 Z150.0 M05 Rapid to tool change position and spindle OFF
M09 Coolant OFF
M02 Program end
% End character

DR. AHMAD MOSTAFA CAD/CAM Lab. 5|EXPERIMENT 6


6. Milling
6.1. Axes convention
The axes and their directions are defined by the Right hand rule. The Z axis is along the spindle.
+Z is from the part looking towards the spindle. The program zero is the intersection of the axes.
All coordinates in a program are referenced from this point.
Rotary axes about X, Y and Z are called A, B and C, respectively. The sign of a rotary axis is
determined by the thumb and curled fingers of the right hand. If the thumb points in the + direction
of the linear axis, the other fingers point in the + direction of the corresponding rotary axis.

Figure 2: Axes on a vertical milling machine where X within the long side of the table and Y is
normal to it. Z is along the spindle
6.2. Coordinate system
In Absolute programming the end point of a motion is programmed with reference to the program
zero point. In Incremental programming the end point is specified with reference to the current
tool position.
Absolute traverse to P1, then to P2
G90 X50.0 Y20.0
X30.0 Y50.0
Absolute traverse to P1, incremental to P2
G90 X50.0 Y20.0
G91 X-20.0 Y30.0

7. Basic motion commands


G00 - Rapid traverse
Is executed at the rapid traverse rate that the machine is capable of. Typical rapid traverse rates on
machines are 20 to 40 m /min., but can be as high as 100 m/min.

DR. AHMAD MOSTAFA CAD/CAM Lab. 6|EXPERIMENT 6


Format
G00 X_ Y_ Z_
X, Y, Z = coordinates of destination point
The block consists of the rapid traverse command G00 followed by the destination coordinates.

G01 – Linear interpolation


The tool moves along a straight line in one or two axis simultaneously at a programmed linear
speed, the feed rate.

Format
G01 X_ Y_ Z_ F_
X, Y, Z = coordinates of destination point F = Feed rate
The block consists of the linear interpolation command G01 followed by the destination
coordinates and the feed rate.

G02 / G03 - Circular interpolation


The tool moves along a circular arc at a programmed linear speed, the feed rate.

G02- Clockwise direction G03- Counterclockwise

DR. AHMAD MOSTAFA CAD/CAM Lab. 7|EXPERIMENT 6


Example:

Arc radius programming


G02 X-120.0 Y60.0 R35.0 F300.0
G03 X-50.0 R35.0
Arc center programming
G02 X-120.0 Y60.0 I35.0 J0 F300.0
G03 X-50.0 I35.0 J0
8. Tool length compensation
Tools used in machining a part are of different lengths. It would be extremely tedious to write the
program with these lengths taken into consideration.

In this picture, to move to the position Z0, the programed coordinate would be Z80, Z160, Z100
and Z200 for tools T1 to T4, respectively. Each time that a tool got worn out and you had to
change it, you would have to change the Z coordinates in the whole program.
To eliminate this problem, machines have a length compensation feature. The program is written
for the drawing coordinates, without considering tool lengths. The lengths are entered in the

DR. AHMAD MOSTAFA CAD/CAM Lab. 8|EXPERIMENT 6


controller's memory. The controller does the job of adjusting for the tool length. A rapid motion
to the coordinate Z0, for example, would be programmed as G00 Z0 irrespective of which tool is
used.
Examples:

(0,0)

N10 G90
N20 F100 S1200 T1 M06
N30 G00 X-5 Y0 Z0
N40 G01 X0 Y0 Z-3
N50 G01 X0 Y55
N60 G01 X10 Y65
N70 G01 X65 Y65
N80 G01 X65 Y15
N90 G02 X50 Y0 R15 F0.23
N100 G01 X0 Y0 F100
N110 G01 Z3
N120 M05 M30

9. Exercise
Write a CNC Milling program for a FANUC controlled machine for the given component. Use
Incremental coordinate system. Take the depth of cut 1mm, speed 1200rpm. Assume suitable feed

DR. AHMAD MOSTAFA CAD/CAM Lab. 9|EXPERIMENT 6

You might also like