You are on page 1of 1

PROGRAM STRUCTURE

A CNC part program consists of one or more blocks of commands. When viewing the
program, a block is the same as a line of text. Blocks shown on the CRT are always
terminated by the ; symbol which is called an EOB (End Of Block). Blocks are made up
of alphabetical address codes which are always an alphabetical character followed by a
numeric value. For instance, the specification to move the X-axis would be a number
proceeded by the X symbol.
Programs must begin and end with a percent (%) sign. After the first percent (%) sign, the
program must have a program number beginning with the letter O (not zero) and then the
number that defines that program (four digit number for older machines and five digit
number for newer machines). Those program numbers are used to identify and select a
main program to be run, or as a subprogram called up by the main program. The % will "not"
be seen on the control, but they must be in the program when you load it into the control.
And they will be seen when you download a program from the machine. The % signs are
automatically entered in for you, if you entered the program in on the HAAS control.
A program may also contain a / symbol. The / symbol, sometimes called a slash, is
used to define an optional block. If a block contains this symbol, any information that
follows the slash in a program block, will be ignored when the BLOCK DELETE button is
selected when running a program.
On the following page is a sample program as it would appear on the CRT. The words
following the : are not part of the actual program but are put there as further explanation.
This program will rough and finish turn and face for a part with two diameters along with
drilling and tapping for a 3/8-16 x 1.0 deep threaded hole one end.
% :Program must begin and end with a %
O00018 ; :Letter O and a five digit program number
(CNC LATHE PROGRAM EXAMPLE) ; :Comment statement between parenthesis
N1 (Rough O.D.) ; :First operation
G28 ; :Return to machine zero for a tool change, cancel tool offset
T101 (O.D. TOOL x .031 TNR) ; :Select tool 1 with offset 1
G50 S2600 ; :Set spindle speed max. clamp 2600 RPM
G97 S414 M03 ; :Cancel CSS, 415 spindle speed, on forward
G54 G00 X3.6 Z0.1 MO8 ; :Work offset, rapid X, Z axes, coolant on
G96 S390 ; :CSS on at 390 SFM, coolant on
G00 Z0.005 ; :Rapid to .005 from the end of part
G01 X-0.063 F0.005 ; :Rough face end of part
G00 X3.6 Z0.1 ; :Rapid to start point above part
G71 P10 Q20 U0.01 W0.005 D0.1 F0.01 ;:Rough turning G71 canned cycle using the path
defined
:between N10 thru N20, leaving .010 stock on the X-axis
:diameters, .005 stock on the linear faces, with 0.1 depth
:of cut each pass, feeding .010 per revolution.
N10 G42 G00 X0.82 ; :N10 is the starting block called by the P block in the G71
G01 Z0. F0.004 ; :line that difines in it the geometery to rough out.
19
JANUARY 2005 PROGRAMMING

X0.9 ;