Unit V CNC Part Programming
Unit V CNC Part Programming
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
• 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.
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