VMC Programming
VMC Programming
M IN
L ER
M
A OR
G R
NT
P RO
C O
C
UC
V M
FA N
CNC PROGRAMMING LANGUAGE?
Upon successful
CNC machine are very accurate and powerful industrial robots developed jointly by Mr. john T
persons, IBM and Massachusetts Institute and Technology Servomechanism laboratory in the
1950’s.
Most CNC machine tools use a language set by the Electronics Industry Association (EIA) in the
1960’s.
The official name of the language is RS-274D, but every one refers it “G-CODE” or “G&M-CODE”
because many of the words of this language begin with the latters G or M.
Most machines have a vocabulary of at least a 100 words, but only about 30 that are use often. These
30 words are best memorized because they appear in almost every CNC program and knowing them
helps you work most efficiently.
“G&M codes, along with co-ordinates and other parameters, comprised what is called a CNC
PROGRAM.
CNC LAUNGAUGE AND
STRECTURE
CNC program list instruction to be performed in the order they are written. They read like a book, left-right and
top-down. Each sentence in a CNC program is written on a separate line, called a block. Block are arranged in a
specific sequence that promotes safety, predictability and readability, so it is important to adhere to a standard
program structure.
X X- co-ordinate
Y Y- co-ordinate
Z Z- co-ordinate
A,B,C :- 4TH/5TH AND 7TH AXIS rotary motion.
Rotation about the X,Y or Z-axis respectively. The angel is in degrees and up to three decimal
places precision. G01 A30.513 B90;
D :- TOOL DIAMETER REGISTER.
Used to compensate for tool diameter wear deflection. D is accompanied by an integer that is the
same as the tool number(T1 uses D1, etc.). No decimal point is used. It is always used in
conjunction with G41 or G42 and a XY move(never an arc).
When called, the control reads the register and offset the tool path left (G41) or (G42) by the
value in the register. G01 G41 X1.0 D1;
F :- FEED RATE.
Sets the feed rate when matching lines, arc or drill cycle. Feed rate can be inches per minute
(G94) or inverse time (G93). Feed rates can be up to three decimal places accuracy (for tap
cycle) and require a decimal point . G01 X1.0 Y0 F18 ;
G :- PREPARATORY CODE / PROGRAM CODE.
Always accompanied by an integer that determines its meaning. Most G-CODES are model.
G02 X1.0 Y1.0 R1.0 ;
H :- TOOL LENGTH COMPENSATION REGISTER.
This code call a tool length offset register on the control. It is always acompained by an integer (H1,H2
etc.)G43 and Z co-ordinate. G43 H1 Z1.0 ;
I/J/K :- ARC CENTER or DRILL CYCLE DATA.
For arc moves (G02/G03), This the incremental X/Y/Z- distance from the arc start point to arc center.
Certain drill cycles also use I/J/K as an optional parameter. G02 X1.0 Y2.025 I0 J1.25 ; G02 X1.0 Y2.025 I0
J1.25 ; G02 X1.0 Y2.025 I0 K1.25 ;
M :- MISCELLANEOUS CODE / MACHIN CODE.
Always accompanied by an integer that determines its meaning. Most M-CODES are model. M08;
N :- BLOCK NUMBER.
Block numbers can make the CNC program easier. N100 T2 M06 ;
O :- PROGRAM NUMBER.
Programs are stored on the control by their program number. O0002 ;(PROJECT 1).
P :- DELAY.
Dwell (delay) in seconds. accompanied by G4 unless used within certain drill cycles. G04 P0.1;
Q :- DRILL CYCLE OPTIONAL DATA.
This incremental feed distance for pass in a peck drill cycle. G83 X1.0 Y1.0 Z-5.0 R1.0 Q0.1 P5 F5 ;
R :- ARC RADIUS or DRILL CYCLE OPTIONAL DATA.
Arc can be defined using the arc radius R or I,J,K vectors. I,J,K are more reliable then R so it is
recommended to use them instead. R is also used by drill cycles as the return plane Z value. G83 Z-5.0 F12
R0.1 Q0.1 P5 ;
S :- SPINDLE SPEED .
Spindle speed in revolutions per minute (RPM). It is an integer value with no decimal , and always used in
conjunction with M03(CW) or M04 (CCW). S200 M03;
T :- TOOL NUMBER.
Selects tool . It is an integer value always accompanied by M06(tool change). T01 M06 ;
X/Y/Z :- CO-ORDINATES .
Co-ordinate data for the x/y/z –axis. Up to four places after the decimal are allowed and travelling zeros are
not used. Co-ordinates are model, so there is no need to repeat them in subsequent blocks if they do not
change. G01 X1.0 Y1.0 F500 ;
% :- PROGRAM START or END.
All program begin and end with % on a block by it self.
G & M CODES.
G-codes CODE MEANING
G00 RAPID MOTION (POSITIONING)
G01 LINIER INTERPOLATION SPECIFIED FEED RATE
G02 CIRCULAR INTERPOLATION C.W (ARC)
G03 CIRCULAR INTERPOLATION C.C.W (ARC)
G04 DWELL
G15 POLAR CO-ORDINATE SYSTEM CANCEL
G16 POLAR CO-ORDINATE SYSTEM ACTIVE
G17 XY PLANE SELECTION
G18 XZ PLANE SELECTION
G19 YZ PLANE SELECTION
G20 INCH MODE
G21 MATRIC MODE
G28 RETURN TO MACHINE HOME POSITION
G40 CUTTER DIAMETER COMPENSATION CANCEL
G41 CUTTER DIAMETER COMPENSATION LEFT SIDE
G42 CUTTER DIAMETER COMPENSATION RIGHT SIDE
G43 TOOL LENGTH COMPENSATION +VE DIRECTION
G44 TOOL LENGTH COMPENSATION -VE DIRECTION
G49 TOOL LENGTH COMPENSATION CANCEL (G43&G44)
G51 SCALEING ON / MIRROR ON (G50- G51 OFF)
G52 LOCAL CO-ORDINATE SYSTEM SETTING (DATTUM SHIFT)
G53 MACHINE CO-ORDINATE SYSTEM
G54-G59 WORKPICE CO-ORDINATE SYSTEM (1-6)
G68 CO-ORDINATE SYSTEM ROTATION ON
G69 CO-ORDINATE SYSTEM ROTATION OFF
G80 CANNED CYCLE CANCEL (G81-G85)
G81 NORMAL DRILLING CYCLE
G82 DRILLING CYCLE WITH DWELL
G83 PECK DRILLING CYCLE (DEEP HOLE DRILLING CYCLE)
G84 TAPPING CYCLE
G85 REAMING CYCLE
G90 ABSOLUTE MODE
O1234;
PROGRAM
G28 G90 X0 Y0 Z0 ;
T01 M06 ; { DRILL BIT DIA 10 }
S2000 M03 ;
G00 G54 G90 G80 G94 G17 X0 Y0 ;
G00 Z20.0 ;
M08 ;
G83 G98 Z-16.0 Q0.2 R1.0 K0 F200 ;
X20.0 Y20.0 ;
X60.0 Y20.0 ;
X60.0 Y60.0 ;
X20.0 Y60.0 ;
G00 G80 Z50.0 ;
M05 M09 ;
G28 G90 X0 Y0 Z0 ;
M30 ;
POLAR DRILLING
O1234;
G28 X0 Y0 Z0 ;
CYCLE
T01 M06 ; { DRILL BIT DIA 10 }
S2000 M03 ;
G00 G54 G90 G80 G94 G17 X0 Y0 ;
G00 Z10.0 ;
M08 ;
G16 ;
G83 G98 X18.0 Y0 Z-22.0 Q0.3 R1.0 F200 ;
G91 Y60 K5 ;
G00 G15 G80 Z50.0 ;
M05 ;
M09 ;
G00 Z200 ;
M30 ;
O1234; ROTATIO
G28 G90 X0 Y0 Z0 ;
T01 M06 ; { DRILL BIT DIA 10 }
N
S2000 M03 ;
G00 G54 G90 G80 G94 G17 X0 Y0 ;
G00 Z50.0 ;
M08 ;
G83 G98 Z-32.0 Q0.2 R1.0 K0 F200 ;
X10.0 Y0 ;
X25.0 Y0 ;
G68 X0 Y0 R134.0 ;
X10.0 Y0 ;
X25.0 Y0 ;
G00 G69 G80 Z50.0 ;
M05 M09 ;
G28 G90 X0 Y0 Z0 ;
M30 ;
LINE PROGRAM SUB & MAIN (slot)
MAIN PROGRAM SUB PROGRAM
O1234; O1212;
G28 G90 X0 Y0 Z0 ; G00 G54 G90 X-30.0 Y-
T01 M06 ; { END MILL DIA 20.0 } 20.0 ;
S2000 M03 ; G01 G91 Z-0.3 F200 ;
G00 G54 G90 G80 G17 X-30 Y-20.0 ; G01 G90 X-50 Y-20 ;
G00 Z50.0 ; G03 X-60 Y-30 R10 ;
G01 Z0.0 F200 ;
G01 X-60 Y-50 ;
M08 ;
G02 X-50 Y-60 R10 ;
G40 D01 ;
G01 X-30 Y-60 ;
M98 P301212 F500 ;
G01 X-20 Y-50 ;
G00 Z50.0 ;
M05 ;
G01 X-20 Y-30 ;
M09 ; G01 X-30 Y-20 ;
G28 G90 X0 Y0 Z0 ; M99 ;
M30 ;
CONTURE / CORE
MAIN PROGRAM SUB PROGRAM
O1234;
PROGRAM O1212;
G01 G91 Z-0.2 F200;
G28 G90 X0 Y0 Z0 ;
T01 M06 ; { END MILL DIA 10.0 }
G01 G90 X75 Y0 F500 ;
S2000 M03 ;
G02 X80 Y5 R5 ;
S2000 M03 ;
G01 G90 X30 Y25 ;
S2000 M03 ;
G01 G90 X8.0 Y0 ;
G28 G90 X0 Y0 Z0 ;
T01 M06 ; { END MILL DIA 3.0 }
PROGRAM
S2000 M03 ;
M05 ;
G00 G54 G90 G80 G17 X5.0 Y5.0 ;
G00 Z50.0 ;
M09 ;
G01 Z0 F200 ; G28 G90 X0 Y0 Z0 ;
M08 ; M30 ;
G40 D01 ;
M98 P161212 F500 ; SUB PROGRAM
G01 Z1.0 F500 ; O1212;
G51 X0 Y0 I-1000 J1000 ; G00 G54 G90 X5 Y5 ;
M98 P161212 F500 ; G01 G91 Z-0.3 F200 ;
G01 Z1.0 F500 ;
G01 G90 X35.0 Y5.0 ;
G51 X0 Y0 I-1000 J-1000 ;
G01 X35.0 Y35.0 ;
M98 P161212 F500 ;
G01 X5.0 Y5.0 ;
G01 Z1.0 F500 ;
G51 X0 Y0 I1000 J-1000 ;
M99 ;
M98 P161212 F500 ;
G00 Z50.0 ;