Chapter - 7, CNC Programming
Chapter - 7, CNC Programming
Prepared By:
Dishank Upadhyay
Mechatronics Department
TeamLease Skills University
Vadodara
Outline
• CNC Control System • Tool Compensations
• Absolute & Incremental • Macros
dimensions method • Canned Cycles
• Introduction of programming • Thread cutting Cycle
• Procedure • Mirror image
• CNC coordinate system • Constant speed programming
• Axes and motion nomenclature • Programming examples
• Structure and form of part – Turning centers
programming – Milling centers
• Word address format
• Preparatory Functions (G Code)
• Miscellaneous Functions (M
Codes)
Coding System
• 3 primary NC block formats used in the industry
are
1. Fixed Sequential format
2. Tab sequential format
3. Word Address format
• It is the binary coded decimal or BCD System
• Newer coding system is ASCII (American Standard
Code for Information Interchange).
1. Fixed Sequential Format
• Each block consist of exactly the same number of words entered in a specific order.
• Each word consist of a fixed number of digits
• Example
– 0050 00 + 0025400 + 0012500 - 0010000 0000 00
– 0060 01 + 0025400 + 0012500 - 0010000 0200 08
• Explaination
– 0060 = block number
– 01 = Preparatory code
– + 0025400 = X Axis Value = 25.40 mm
– + 0012500 = Y Axis Value = 12.50 mm
– - 0010000 = Z Axis Value = -10.00 mm
– 0200 = Feed rate = 200 mm/min
– 08 = Miscellaneous = Coolant ON
2. Tab Sequential Format
• Same as the fixed sequential format
• Difference is “TAB” character precedes each words within the block, except for the first word
• Each word consist of a fixed number of digits
• Example
– 0050 TAB 00 TAB + 0025400 TAB + 0012500 TAB - 0010000 TAB 0000 TAB 00 EOB
– 0060 TAB 01 TAB + 0025400 TAB + 0012500 TAB - 0010000 TAB 0200 TAB 08 EOB
• Explaination
– 0060 = block number
– 01 = Preparatory code
– + 0025400 = X Axis Value = 25.40 mm
– + 0012500 = Y Axis Value = 12.50 mm
– - 0010000 = Z Axis Value = -10.00 mm
– 0200 = Feed rate = 200 mm/min
– 08 = Miscellaneous = Coolant ON
2. Word Address Format
• Used in all modern CNC machine tools.
• Much easier to use
• Example:
– N110 G01 X131.4 Y-36.65 f0.15
• Explaination
– N110 = Word
– X,Y = Address
– 131.4,-36.65 = Numeric Data
• String characters are essential
• Following sets of characters are generally used.
– Alphabet : A to Z
– Digits = 0- 9
– Operator = + , - , / , * , =
– Special Characters = () , (.),
2. Word Address Format
CNC Part Program
(N10 G17 G91 G40 N20 G01 X1.0 Y 1.0 N 30 …..
• Part program is made up of NC Blocks
• NC block has one or more NC Words
• NC word consist of an address followed NC Block
N20 G01 X1.0 Y1.0
by numeric information
• Part Program = NC Block + Prog Block +
EOB NC Word
• EOB code = ; (Necessary in every block) G01
1. Absolute Programming
• Coordinates have absolute value with respect to its origin
• Sign of each movement is depending on reference/origin point
2. Incrmental Programming
• Measurement is not from part origin
• It is from the previous point.
Diameter & radius Programming
Data input units
• All cnc machines permits programming in either “Inch” or in “mm”.
• It may be noted that when switching from one data mode to another, units of
following items may be changed
1. Feedrate
2. Coordinate position
3. Offset values
4. Unit of scale for manual pulse generator
5. Spindle speed
• It is not advised to switch data mode, so we have to use data input units.
1. G20 = inch Programming
2. G21 = Metric or mm Programming
• G20,G21 are modal codes.
Spindle Speed Control
• Spindle speed control consist of controlling 2 things
1. Direction
2. Spindle speed
1. Direction
– M words are used to specify direction of rotation of spindle
• M 03 = Clockwise direction
• M 04 = Counter Clockwise direction
• M 05 = Stops the spindle rotation
2. Spindle speed
– It is programmed using a “S” code following by 4 digit word
– For 550 rpm = S550 is used.
– Spindle speed modes are
• G97 = constant RPM mode (RPM)
• G98 = Constant surface speed (feet per minute)
Feedrate control
• Cutting operation may be programmed using 2 basic
feedrate mode.
1. Turning Centre = G98(Per minute) , G99 (per revolutions)
2. Machining centre = G94 (per minute) , G95 (Per
revolution)
• Example
– G98 F50 = Feedrate of 50 mm per revolution
– G99 F0.2 = Feedrate of 0.2 mm per revolution
Tool and tool offset
• Word “T” is used followed by 2 or 4 digits indicating the
number of tool to load from the ATC.
• Example:
– T 00 = includes tool offset number and tool number
– T 0000 = last 2 tool offset number, first 2 tool number
– T00H00 = last 2 tool offset number, first 2 tool number
Program Control
• Codes used are
– M00, M01, M02, M30
• M00 = Program stop
– Temporary stops, when we press start button program will resume from where it
was stopped
• M01 = Optional stop
– Gives the option to stop the program
• M02 = End Program
– Stop the spindle and stop the coolant
• M30 = Program stop and rewind
– Reset all registered values to the initial mode.
G00 – Rapid Traverse
• Rapid traverse – to save time – move one position to another
quickly
• Typical rapid traverse rates are 10m/min to 25 m/min
• Speed Accelerated at start of the block and decelerated at
end of block
• Dogleg effect
• in incremental U = X , W = Z.
• Feed rate cannot be programmed with G00.
G00 – Rapid Traverse
• Syntax:
• Absolute Programming
– G00 X_________ Z___________
• Incremental Programming
– G00 U_________ W__________
G01 – Linear Interpolation
• Linear cutting or straight cutting command
• Syntax:
– G00 X______ Z_______ F_______
• Where F = Feedrate
• Used to cut segment of straight line
between 2 straight points
• Programming of 2 axis at a time, tool will
move simultaneously in both the axis as
shown in figure.
• For taper cutting also both the axis are
programmed together.
Example - 1
• Write a manual part program for the part shown in figure, assume that the part is
already rough turned and the tool is required to be programmed for finish turning.
– For facing use : T03 with Feedrate : 0.1 mm/rev
– For Finish Turning : T03 with feedrate : 0.15 mm/rev
Example – 2 – Rough Turning
• Write a manual part program for the part shown in figure, assume that the part is
already rough turned and the tool is required to be programmed for finish turning.
– For facing use : T03 with Feedrate : 0.1 mm/rev
– For Rough Turning : T03 with Feedrate 0.2 mm/rev & D.O.C 4 (max)
– For Finish Turning : T03 with feedrate : 0.15 mm/rev & D.O.C 1.5(max)
G02/G03 – Circular Interpolation
• G02 : Clockwise Direction
• G03 : Anti-Clockwise Direction
• Tool cuts an arc or even a full circle.
• Tool moves to the two axis
simultaneously.
• Following information is required
1. Cutting Direction (G02/G03)
2. Arc End point Coordinates
3. Radius of arc or centre of arc
G02/G03 – Circular Interpolation
• Method 1 : Radius of arc programming
• Syntax:
– G02/G03 X__ Z__ R__ F__
– G02/G03 U__ W__ R__ F__
– Where
– X,Z :
– U,W :
– R: Radius of Arc
– F : Feedrate
G02/G03 – Circular Interpolation
• Method 2 : Centre of arc programming
• Syntax:
– G02/G03 X__ Z__ I___ K___ F___
– G02/G03 U__ W__ I____ K___ F____
– Where
– X,Z :
– U,W :
– I,K are incremental distance from the arc start point to the
arc centre in X,Z axis respectively.
– F : Feedrate
• I,K codes should not be mixed with R Code. If this
codes are mixed, the R code will take precedence
over the other codes.
Example
• Write a manual part program for the part shown in figure, assume that the part is
already rough turned and the tool is required to be programmed for finish turning.
– For facing use : T03 with Feedrate : 0.1 mm/rev
Tool Compensations
• 3 kinds of tool compensations used on turning centres.
1. Geometrical Offset
2. Wear Offset
3. Tool Nose Radius Compensations
Geometrical Offset
Wear Offset
• T 0507 : Tool 5 offset by 7
• T 0000 : Tool 5 offset cancel
Tool nose radius compensation
• G40, G41, G42
• G41 : Offset to left
• G42 : Offset to right
• G40 : cancel any tool nose radius
compensations
Thank You