NC PRG
NC PRG
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.
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
M03 Spindle clockwise
M04 Spindle counterclockwise
M05 Spindle stop
M06 Tool change (see Note below)
M30 End of program
In principle, all codes are either modal or non-modal. Modal code stays in effect until
cancelled by another code in the same group. The control remembers modal codes.
This gives the programmer an opportunity to save programming time. Non-modal
code stays in effect only for the block in which it is programmed. Afterwards, its function
is turned off automatically. For instance G04 is a non-modal code to program a dwell.
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
G00
Rapid traverse
G00 Xx Yy Zz
G01
Linear interpolation
G01 Xx Yy Zz Ff
Tool motion
Illustration
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 G03 Xx Zz Ii Kk
G03 Yy Zz Jj Kk
Command group
Gcode
Illustration
G17
G19
XY - Plane selection
ZX - Plane selection
YZ - plane selection
Command group
G-code
G20 or
G70
Unit Selection
G21 or
G71
Metric unit selection
Command group
Gcode
Function and
Command
Statement
Cutter
Offset and
diameter
G40
compensation
compensation
cancel
Illustration
Illustration
Cutter
G41 diameter
cancellation
left
Cutter
G42 diameter
compensation
righ
Command
group
G-code
Illustration
G00
Rapid traverse
G00 Xx Zz
G01
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
Tool
motion
O5678
N02 G21
N03 M03 S1000
N04 G00 X0 Y0
N05 G00 Z-10.0
N06 G01 X50.0
N07 G01 Y20.0
N08 G02 X25.0
Y45.0 R25.0
N09 G03 X-25.0
Y45.0 R25.0
N10 G02 X-50.0
Y20.0 R25.0
N11 G01 Y0.0
N12 G01 X0.0
N13 G00 Z10.0
N14 M05 M09
Program number
Metric programming
Spindle start clockwise with 1000rpm
Rapid motion towards (0,0)
Rapid motion towards Z=-10 plane
Linear interpolation
Linear interpolation
Circular interpolation clockwise(cw)
Circular interpolation counter clockwise(ccw)
Circular interpolation clockwise(cw)
Linear interpolation
Linear interpolation
Rapid motion towards Z=10 plane
Spindle stop and program end