Lecture 3
Lecture 3
Word Address
NG;
Programming
• Character: an G00 X-3.75
alphanumeric character or punctuation mark
G00 X-3.75
• Address: a letter describing the meaning of a number following the letter
• Word: an address followed by a number, used to describe machine motions
and dimensionsN010 G00 X-3.75 Y2.5
• Block: a complete command to the CNC machine (one or more words,
depending on the information needed
N010 G00 toY2.5
X-3.75 command a CNC operation)
• Program: a sequence of blocks describing
N020 G00 Z1. the motions of a CNC machine to
manufacture a part .
.
.
.
N0100 M30
CNC – Computer Numerical Control
Word Address Programming
General Syntax (arrangement of addresses in a block):
• O – program number (optional), used to identify programs in the MCU memory.
Ex: O0001, O9999
• N – sequence number (optional). MCU executes a program block by block
regardless of the sequence number entered.
Ex: N0001, N9999
• G – preparatory functions, usually placed at the beginning of a block and used to
prepare the CNC controller to act in a particular mode when processing the other
words in a block. The mode is indicated by the numerical value following the G
address.
Ex: G00 (Rapid positioning at maximum feedrate),
G01 (linear interpolation at a programmed feedrate)
G20 (inch mode)
G28 (return to reference point)
G90 (absolute positioning)
G91 (incremental positioning)
CNC – Computer Numerical Control
Word Address Programming
G code categories:
– Modal: the G code specification will remain in effect for all
subsequent blocks unless replaced by another associated modal G
code.
– Nonmodal: the G code specification will only affect the block in
which it appears.
Ex: N0010 G91G01X1.0F10.0
N0020 X2.0 G91, G01, G90 and
N0030 Y2.0 G00 are modal
N0040 G90G00Y0
N0050 G28 G28 is non-modal
• X, Y, Z, … – dimension words, used to specify the movement of the
programming axes (Cartesian coordinate system).
CNC – Computer Numerical Control
Word Address Programming
• F – feed rate, the rate at which the spindle moves along a programming
axis.
– F is modal
– English system: in/min
– Metric system: mm/min
Ex: F10. – a feedrate of 10 in/min,
F10 – a feedrate of 0.001 in/min (Fanuc controllers)
• S – spindle speed, the speed at which the spindle rotates (rpm)
– Spindle rotation should be specified prior to axis movement
• M – miscellaneous machine function, used to specify machine functions
other than dimensional or axis movements
Ex: M03 (spindle on, clockwise)
M05 (spindle off)
M08 (coolant on)
M09 (coolant off)
M30 (program end)
CNC – Computer Numerical Control
CNC – Computer Numerical Control
Linear Interpolation
Machine a rectangular block 3” 2” 0.5”. Cutter ½” end mill.
Part zero: X 0 & Y 0 at lower left-hand corner. Z 0 at top of the part.
CNC – Computer Numerical Control
Linear Interpolation
Machine a rectangular block 3” 2” 0.5”. X=M.HOME
X0 & Y0 at lower left-hand
Y=M.HOME
corner. Z0 at top of the part. CutterX=-0.5
½” end mill.
Z=M.HOME
O0001 Y=-0.25
X=-0.5
Z=1.0
N0010 G20 G90 X=-0.25 X=3.25
Y=-0.25
Y=-0.5
N0020 G92 Y=2.25 Y=2.25
N0030 T01 M06 Z=.25
Z=M.HOME
Z=-0.55 Z=-0.55
N0040 M03 S800 X=-0.5
N0050 G00 X-.5 Y-.5 X=-0.5
X=-0.25
Y=-0.5 X=3.25
N0060 G00 Z.25 X=-0.5
Y=-0.25
Y=-0.25
Z=.25 Y=-0.25
N0070 G01 Z-.55 F5.0 Y=-0.5
Z=-0.55
Z=-0.55 Z=-0.55
N0080 G01 X-.25 Y-.25 Z=-0.55
N0090 Y2.25
N0100 X3.25
N0110 Y-.25 Z Y
N0120 X-.5
N0130 Z.25
N0140 G00 Z 1.0 X
N0150 M05
N0160 G28
N0170 M30
CNC – Computer Numerical Control
Circular Interpolation
Circular Interpolation commands G02 & G03 – for cutting a circular contour
• It moves the tool along a circular path from the initial (current) position to
the final position at a programmed feedrate
Note:(1) Circular interpolation is executed on a plane. Plane selection
(modal commands): G17 – XY (default), G18 – XZ, G19 – YZ
(2) Tool motion direction: G02 – clockwise; G03 – counterclockwise
(3) Absolute or Incremental coordinates are being used
• General Syntax: G02 (G03) Xn Yn (Zn) In Jn (Kn) (Fn)
CNC – Computer Numerical Control
Circular Interpolation
Initial position of ½” tool
Example: Y
N010 G90 (Absolute)
N020 G17 (XY Plane) X
N040 G01 X3.0 Y.25 F10.0 2 J
N040 G02 X4.125 Y-3.9486 I0. J-2.25 R2
Y
60
Calculation:
End Position:
X=3+2.25cos(60) 3
Y=-2-2.25sin(60)
I and J: (center-initial) X
I=3-3
End position
J=-2-0.25
CNC – Computer Numerical Control
Circular Interpolation
Circular Interpolation via Radius Specification – coding the radius (R) of
the circular arc instead of I, J, and K
General Syntax: G02 (G03) Xn Yn (Zn) Rn (Fn)
CNC – Computer Numerical Control
G-code for Turning
DEF WORK
PS LC, [0,0], [96,90]
END
DRAW
G00 X500 Z500
G50 S2500
NLAP1 G81
G00 G42 X50 Z98
G01 X60 Z88 F0.15
Z80
G02 X70 Z75 L5
G03 X80 Z70 L5
G01 Z60
G02 X80 Z35 L40
G01 Z25
X90 Z20
X95
G40
G80
G00 X95 Z100 S670 T010101 M03 M08
CNC – Computer Numerical Control
G-code for Turning
DEF WORK
PS LC, [0,0], [96,90]
END ---------------- ROUGH CUT --------------------
DRAW
G00 X500 Z500 NT1 G96 S130
G50 S2500 G85 NLAP1 D3 F0.3 U1.0 W0.1
NLAP1 G81 G00 X95 Z100
G00 G42 X50 Z98 G97 X500 Z250 S930
G01 X60 Z88 F0.15 M01
Z80 X95 Z100 T020202
G02 X70 Z75 L5
G03 X80 Z70 L5 ---------------- FINISH CUT -------------------
G01 Z60
G02 X80 Z35 L40 NT2 G96 S180
G01 Z25 G87 NLAP1
X90 Z20 G00 X95 Z100 M05 M09
X95 M02
G40
G80
G00 X95 Z100 S670 T010101 M03 M08