Download as pdf or txt
Download as pdf or txt
You are on page 1of 61

UNIT – V CNC PART PROGRAMMING

Course Outcome :- Prepare CNC part programs for simple components

CURRICULUM
 Definition and importance of various positions like
machine zero, home position, work piece zero and
programme zero.
 CNC part programming : programming format and
structure of part programme.
 ISO G and M codes for turning and milling- meaning
and applications of important codes
 Simple part programming for turning using ISO format
having straight turning, taper turning(linear
interpolation) and convex/concave turning (circular
interpolation)
 Simple part programming for milling using ISO format.
UNIT – V CNC PART PROGRAMMING
Course Outcome :- Prepare CNC part programs for simple components

CURRICULUM

 Importance, types, applications and format for : canned


cycles, Macro, Do loops, Sub routine.
 CNC turning and milling part programming using canned
cycle, Do loops and sub routine.
 Need and importance of various compensations : Tool
length compensation, pitch error compensation, Tool radius
compensation, Tool offset.
 Simple part programming using various compensations.
 Virtual CNC machine simulators. Generation of shop
generating shop documentation using a CAM software,
Cycle time sheets, tool list with tool layout, spindle
utilization graphs, program for different control system and
different configuration of machines.
Machine Zero (Home Position)
 Definition :- The position on the machine which is specified
by the manufacturer and with respect to which all other
point are defined is called as machine zero.
 It is also called as home position or machine reference point.
 Machine zero represents the position of the cutting tool
when the tool is at home position.
 The position of the machine zero point varies from
manufacturer to manufacturer.
Machine Zero (Home Position)
Work Piece Zero (Program Zero)
 It is the position of the cutting tool on the work piece (with
respect to the work piece). It can be selected anywhere on
the work piece.
 This position is specified by part programmer and may vary
for different program.
 The entire program is written with respect to the work piece
zero position.
CNC PART PROGRAMMING : NC WORDS
 The most important
component in the CNC
system is the part
programming.
 Even a slight error in
the program can
change the dimensions
of the final component.
 The part programming
uses various words like
G-words, N-words etc.
to write a CNC
program.
 A NC word is a
collection of characters
used to form an
instruction.
PROGRAMMING FORMATS
PROGRAMMING FORMATS
PROGRAMMING FORMATS
PROGRAMMING FORMATS
PART PROGRAMMING
• Part programming is defined as the procedure
through which the sequence of processing steps
to be performed on a CNC machine is planned or
documented
• Part programming can also be defined as the way
in which the blocks of instructions are
planned(written) such that after its execution on
the CNC machine the required shape is obtained
on the work piece in minimum possible time.
• Part programming is an important feature of a
CNC system. It is complete set of instructions for
machining a component on CNC machine.
STRUCTURE OF PART PROGRAM
• Every program consists of a fixed structure which
consist of three parts
1. Start of program : It contains the program
number, preparatory information like the
spindle start, coolant on, tool change etc.
2. Contents of program : it contains the movement
of the tool in the desired path, each block moves
the tool such that the required path is generated
till the program is executed.
3. End of program : it contains the end remarks like
move the tool to home position, coolant on/off,
spindle stop, end program etc.
STEPS TO WRITE A PART PROGRAM
• The part program varies from programmer to programmer.
Steps to write a program
 Study the given component carefully
 Decide the path to be followed by the cutter
 Write the co-ordinates of all the points in a separate table
 Then start writing the initial blocks of program
 The first few blocks are generally same for most of the
programs. This gives the preliminary information about the
machine and about the preparation of a machine
 In the upcoming blocks the tool is moved from the first
position till the last position
 After the last tool position is machined bring the tool above
the work piece surface
 Finally the ending blocks are common for all the programs.
PREPARATORY FUNCTIONS (G-CODES)
• The preparatory word prepares the control unit
to execute the instructions given in the part
program.
• The G codes directs the CNC machine to process
the co-ordinate data in a particular manner.
• The preparatory code is represented in two digits
preceded by the letter G.
• More than one G code can be written in same
block but they must be from the different group.
• E.g. N30 G90 G21 X40 Y50 F100 EOB
PREPARATORY FUNCTIONS (G-CODES)
Group G-code Meaning
G00 Rapid Positioning
G01 Linear interpolation
01
G02 Circular interpolation (Clockwise)
G03 Circular interpolation (Counter Clockwise)
00 G04 Dwell
G10 Tool length offset value
G17 XY plane selection
02 G18 ZX plane selection
G19 YZ plane selection
06 G20 Programming in inch units
G21 Programming in metric units
00 G28 Automatic return to reference point
G40 Cutter diameter compensation cancel
07 G41 Cutter diameter compensation left
G42 Cutter diameter compensation right
PREPARATORY FUNCTIONS (G-CODES)
Group G-code Meaning
03 G90 Absolute Positioning
G91 Incremental Positioning
05 G94 Feed rate in mm/min in case of Milling machine
G95 Feed rate in mm/rev in case of Milling machine
G98 Feed rate in mm/min in case of lathe machine
G99 Feed rate in mm/rev in case of lathe machine
MISCELLANEOUS FUNCTIONS (M-CODES)
• The miscellaneous functions are used to
specify certain miscellaneous functions like
spindle start and stop, Coolant ON and OFF
etc.
• The miscellaneous functions is represented in
two digits preceded by the letter M.
• Only one M-code can be programmed in a
block.
MISCELLANEOUS FUNCTIONS (G-CODES)
M-Code Meaning
M00 Program stop
M01 Optional stop
M02 Program end
M03 Spindle start (Clockwise)
M04 Spindle start (Counter Clockwise)
M05 Spindle stop
M06 Tool change
M07 Thru spindle coolant ON
M08 Coolant ON
M09 Coolant OFF
M30 Program end
M98 Call subroutine
M99 End of subroutine
G-CODE
• G00 code –
 It is used for rapid transverse of cutting tool. The G00 code is used
to move the tool from one point to other point when cutting is not
performed.
 The tool moves with the rapid feed available on the machine.
 Thus the G00 code does not require feed rate to be specified.

• G01 code –
 It represents linear interpolation.
 It is used for straight line movements for the operations like slot
milling etc.
 The G01 code is used to move the tool from one point to other
point when either cutting is to be performed or tool has to be
moved to touch the work piece.
• Feed rate has to be specified with G01 command.
G-CODE
• G02 code –
 It represents clockwise circular interpolation
and use for machining arcs and circles by
movement of tool in clockwise direction.

• G03 code –
 It represents counter clockwise circular
interpolation and use for machining arcs and
circles by movement of tool in counter
clockwise direction.

• G04 code -
 The G04 command causes the program to wait
for a specified amount of time.
 The time can be specified in seconds with the
“X” prefixes or in milliseconds with the “P”
prefixes
 E.g. G04 X1.5
G04 P1500
AXIS OF CNC MACHINES
CO-ORDINATE SYSTEM USED IN CNC MACHINES
CO-ORDINATE SYSTEM USED IN CNC MACHINES
CO-ORDINATE SYSTEM USED IN CNC MACHINES
CANNED CYCLE
 When a same operation has to be repeated for number of
times the program becomes lengthy, time consuming,
tedious and uses more computer memory space.
 All these factors can be eliminated by the use of canned
cycle.
 Canned cycle s written in the main program but it reduces
the length of program.
 The canned cycle may be defined as a set of instructions
stored in the memory of the system, to perform a fixed
sequence of operations.
 Canned cycle is used for repetitively and common used
machining operation and it is stored in the memory under
the G codes.
 It is used for repetitive operation where material is to be
cut in multiple passes.
 It reduces the length of program and its complexity.
CANNED CYCLE-Importance
 When a same operation has to be repeated for number
of times the program becomes lengthy, time
consuming, tedious and uses more computer memory
space.
 All these factors can be eliminated by the use of
canned cycle.
 Canned cycle s written in the main program but it
reduces the length of program.
 There are special codes for the use of canned cycle.
 E.g. In a turning operation, if the number of pass is four
or five then the same can be written in a single block
with the help of canned cycle.
 In a drilling operation if more number of holes are to
be drilled then canned cycle is very useful.
Macros
 Macro program is a part program that combines
standard CNC program with additional control features
for more power and flexibility.
 Macro programming is the highest level of G-code
programming. It offers the most flexibility and the
greatest potential power of any of the G-code
programing techniques.
 Following potential things are possible with CNC macro
programming.
 Adjust Feeds and Speeds for material variations
 Make it easier to rework parts or change lot sizes
 Custom deep hole drill cycles – In case of deep hole
drilling is needed, then it can be subprogram so it can
be shared across all the G-code and then call that
subprogram as needed.
DO Loops
 Whenever a operation is to be repeated over a number of times, a
DO loop comes into the picture.
 Instead of writing the same blocks of instruction for different co-
ordinates, a do loop is used to write the program.
 It repeats a series of instructions in a single block for the specified
number of times.
 Thus a do loop reduces the time required to write a program, the
number of blocks and also the memory required.
 A do loop statement is given in the main program itself. There is no
standard G code assigned for programming a do loop.
 The do loop code has the following format
 G25 P___Q___L__
 G25 – signals the start of a loop
 P – specifies the beginning block number of the loop.
 Q – specifies the ending block number of the loop.
 L – specifies the number of times to perform the loop.
Subroutine or Subprogram
 When an identical machining operation is to be performed repeatedly
then the general method of forming a program will be lengthy, time
consuming, tedious and will use more computer memory space.
 In such case subroutine is a powerful time saving technique.
 A subroutine is an independent program similar to any usual program.
 It is stored in the computer’s memory under separate program number.
 When required a subroutine can be called anywhere in the main program
and for any number of times.
 After execution of subroutine the controller returns back to the main
program and continues with the main program.
 In order to call the subroutine in the main program, the miscellaneous
code M98 is used and the block of instructions is as shown below :
 N100 M98 P95 L1 EOB
 M98 – instructs the controller to jump to a subroutine.
 P95 – tells the controller that 95 (example) is the program number
 L1 - instructs the controller to execute the subroutine one time.
 In order to end the subroutine and to return back to the main program a
miscellaneous code M99 is used.
Difference between Subroutine and Canned cycle
Sr.No. Subroutine Canned Cycle

1 It is the separate program which It is not a program but part of the main
is called in the main program program.

2 It is called and ended by It is called and ended by preparatory


miscellaneous function function
Q
3 It is used when multiple passes It is used when multiple passes are
are required at different location. required at the same location.

4 One point is given in every block Directly the final point is given in the block
of instruction till the operation is of instruction
completed.
Tool Offset
 A programmer writes a part program
considering work zero. But the tool is at
home position before the program is
executed. Thus there is a difference in
distance between programmed tool path
and actual tool path. This variation is called
as tool offset.
 Thus, a tool offset is the distance from the
tool tip to work piece surface along X,Y and
Z direction.
 The tool offset for lathe and milling is
shown in fig. As there is no G code for
taking tool offset, T code is used.
 The tool offset value is feed along with the
tool number while writing the program. The
format is Tx Ty, Where Tx = represent tool
number in the tool magazine & Ty = represent
the tool offset.
e.g. M06T05T12 where M06 – Tool Change
T05 – Tool Number T12 – offset value is
stored in number 12.This type of offset is
called as tool geometry offset.
Tool Offset
Further different work piece mounted on CNC machine have different lengths
(cylindrical work piece) or different dimensions (rectangular work piece). Any
two work piece mounted on CNC machine does not have exact dimension.
So it is important to know the exact distance of the tool tip from its home
position to the work piece. This is obtained form the tool offset. The method
of taking tool offset for lathe is shown in fig. a
In order to take X offset, the tool is touched to the cylindrical surface of the
work piece and the work piece diameter value is input in X offset.
In order to take Z offset, the tool is touched to the face of the cylindrical
surface of the work piece as shown in fig. b and zero(0) value is input in Z
offset.
Tool Offset
In case of X-offset for milling, the tool is touched to
the work piece along Y axis as shown in fig a and a
zero(0) value is input.
Similarly to set Y-offset, the tool is touched along X
axis as shown in fig. b and zero(0) value is input.
Tool offset remains active till it is cancelled. It is
generally cancelled when there is a tool change.
Other wise, there is no need to cancel tool offset.
Cutter Radius Compensation
A work piece is machined by the periphery of the cutting tool and not by the
center of the cutter (tool tip).
A part program has to be developed for the exact size of the cutter to be used
on the machine.
But during actual machining, if a smaller diameter cutter is selected, it will
result in a larger work piece.
Similarly larger diameter cutter will result in smaller work piece.
It is therefore necessary to compensate for the different diameter cutter by
using cutter radius compensation.
When cutter compensation is used, the cutter diameter can be ignored and
the tool path can be developed for the center line of the tool rather than the
point on the periphery.
Compensation is done by offsetting the tool path by the distance equal to the
radius of the cutter.
This value is entered into the memory of the control system under the address
D01 or D02 etc.
When the offset file is called, the tool path will automatically be offset by the
tool radius.
For any change in the cutter diameter, this offset can be changed. There is no
need make any change in the part program.
Cutter Radius Compensation
Cutter compensation can be made to the right or to
the left of the part to be machined.
The direction in which the cuter path has to be
shifted is decided by the direction of cut.
Cutter compensation direction is controlled by G-
code. The following Three G-codes are used for
cutter radius compensation.
G-40 cutter compensation cancel
G-41 cutter diameter compensation left
G-42 cutter diameter compensation right
The format of cutter compensation will look like
N050 G41 D01 EOB

You might also like