CNC Part Programming
CNC Part Programming
CNC Part Programming
Most controllers allow suppressing the leading zeros when entering data. This is known
as leading zero suppression. When this method is used, the machine control reads the
numbers from right to left, allowing the zeros to the left of the significant digit to be
omitted. Some controls allow entering data without using the trailing zeros.
Consequently it is called trailing zero suppression. The machine control reads from left
to right, and zeros to the right of the significant digit may be omitted.
(3) Types of CNC codes
(3.1) Preparatory codes
The term "preparatory" in NC means that it "prepares" the control system to be ready
for implementing the information that follows in the next block of instructions.
A preparatory function is designated in a program by the word address G followed by
two digits. Preparatory functions are also called G-codes and they specify the control
mode of the operation.
(3.2) Miscellaneous codes
Miscellaneous functions use the address letter M followed by two digits. They perform a
group of instructions such as coolant on/off, spindle on/off, tool change, program stop,
or program end. They are often referred to as machine functions or M-functions. Some
of the M codes are given below.
M00 Unconditional stop
M02 End of program
In principle, allM03
codes
are either
modal or non-modal. Modal code stays in effect until
Spindle
clockwise
cancelled by another
code counterclockwise
in the same group. The control remembers modal codes.
M04 Spindle
This gives theM05
programmer
an opportunity to save programming time. Non-modal
Spindle stop
code stays inM06
effectTool
only
for the(see
blockNote
in which
it is programmed. Afterwards, its function
change
below)
is turned off automatically.
For
instance
G04
is
a non-modal code to program a dwell.
M30 End of program
After one second, which is say, the programmed dwell time in one particular case, this
function is cancelled. To perform dwell in the next blocks, this code has to be
reprogrammed. The control does not memorize the non-modal code, so it is called as
one shot codes. One-shot commands are non-modal. Commands known as "canned
cycles" (a controller's internal set of preprogrammed subroutines for generating
commonly machined features such as internal pockets and drilled holes) are non-modal
and only function during the call.
On some older controllers, cutter positioning (axis) commands (e.g., G00, G01, G02,
G03, & G04) are non-modal requiring a new positioning command to be entered each
time the cutter (or axis) is moved to another location.
Command
group
Gcode
Illustration
Tool motion
G00
Rapid traverse
G00 Xx Yy Zz
G01
Linear interpolation
G01 Xx Yy Zz Ff
Circular Interpolation in
clock-wise direction
G02 G02 Xx Yy Ii Jj
G02 Xx Zz Ii Kk
G02 Yy Zz Jj Kk
Circular interpolation in
counter- clockwise
direction
G03 Xx Yy Ii Jj
G03 Xx Zz Ii Kk
G03 G03 Yy Zz Jj Kk
G17
Plane
Selection
G18
XY - Plane selection
ZX - Plane selection
YZ - plane selection
G19
G20
or
G70
Unit
Selection
G21
or
G71
Metric unit selection
G40
Offset
and
G41
compensatio
n
Cutter diameter
compensation
cancel
Cutter diameter
cancellation left
Cutter diameter
compensation
right
G42
Tool
motion
G00
G01
Rapid traverse
G00 Xx Zz
Linear interpolation
G01 Xx Zz
G02
Circular Interpolation in
clock-wise direction
G02 Xx Zz Ii Kk
(or)
G02 Xx Zz Rr
G03
Circular interpolation in
counter- clockwise
direction
G03 Xx Zz Ii Kk
(or)
G03 Yy Zz Rr
Program number
Metric programming
Spindle start clockwise with 1000rpm
Rapid motion towards (0,0)
In the above example, the program statements from N70 to N100 are repeated once when the
statement N160 is executed. Usually the G25 is used after a mirror statement. Illustrative example
geometry and its program are given below (Figure 30.3).
Example:
30.4 Mirroring
The mirroring command is used when features of components shares symmetry about one or more axes
and are also dimensionally identical. By using this code components can be machined using a single set
of data and length of programs can be reduced.
G10 cancellation of mirroring image
G11 Mirror image on X axis
G12 Mirror image on Y axis
G13 Mirror image on Z axis
Example:
Scaling
Scaling function is used to program geometrically similar components with varying
sizes.
Syntax: G72 Kk, where k is the scaling factor.
The scaling command can be cancelled by using the statement G72 K1.0.
Example:
Pattern rotation is used to obtain a pattern of similar features. G73 code is used to
rotate the feature to form a pattern.
Syntax G73 Aa, where 'a' is the angle of rotation. This command is cumulative, and the
angle gets added up on time the program is executed. So all the rotational angle
parameters should be cancelled using the code G73.
The unconditional jump code G25 is used in conjunction with this code to achieve the
desired rotation.
The following example (Figure 30.7) depicts the case of a pattern which needs to be
programmed through G73.
Example:
first two digits are used to call the particular tool and last two digits are used to
represent tool offset in the program. The tool offset is used to correct the values entered
in the coordinate system preset block. This can be done quickly on the machine without
actually changing the values in the program.
Using the tool offsets, it is easy to set up the tools and to make adjustments
Feed rate control
Cutting operations may be programmed using two basic feed rate modes:
1. Feed rate per spindle revolution
2. Feed rate per time
The feed rate per spindle revolution depends on the RPM programmed.