A typical CNC program has (3) parts:
1) Preparation: This portion of the program selects the work and tool offsets, selects the cutting tool, turns on the coolant, sets spindle speed, and selects absolute or incremental positioning for axis motion.
2) Cutting: This portion of the program defines the tool path and feed rate for the cutting operation.
3) Completion: This portion of the program moves the spindle out of the way, turns off the spindle, turns off the coolant, and moves the table to a position from where the part can be unloaded and inspected.
This is a basic program that makes a 0.100" (2.54 mm) deep cut with Tool 1 in a piece of material along a straight line path from X = 0.0, Y = 0.0 to X = - 4.0, Y = - 4.0.
NOTE: A program block can contain more than one G-code, as long as those G-codes are from different groups. You cannot place two G-codes from the same group in a program block. Also note that only one M-code per block is allowed.
O40001 (Basic program) ;
(G54 X0 Y0 is top right corner of part) ;
(Z0 is on top of the part) ;
(T1 is a 1/2" end mill) ;
(BEGIN PREPARATION BLOCKS) ;
T1 M06 (Select tool 1) ;
G00 G90 G17 G40 G49 G54 (Safe startup) ;
X0 Y0 (Rapid to 1st position) ;
S1000 M03 (Spindle on CW) ;
G43 H01 Z0.1 (Tool offset 1 on) ;
M08 (Coolant on) ;
(BEGIN CUTTING BLOCKS) ;
G01 F20. Z-0.1 (Feed to cutting depth) ;
X-4. Y-4. (linear motion) ;
(BEGIN COMPLETION BLOCKS) ;
G00 Z0.1 M09 (Rapid retract, Coolant off) ;
G53 G49 Z0 M05 (Z home, Spindle off) ;
G53 Y0 (Y home) ;
M30 (End program) ;
These are the preparation code blocks in the sample program O40001:
|Preparation Code Block||Description|
|%||Denotes the beginning of a program written in a text editor.|
|O40001 (Basic program) ;||O40001 is the name of the program. Program naming convention follows the Onnnnn format: The letter “O”, or “o” is followed by a 5-digit number.|
|(G54 X0 is at the center of rotation) ;||Comment|
|(Z0 is on face of the part) ;||Comment|
|(T1 is an end face cutting tool) ;||Comment|
|T101 (Select tool and offset 1) ;||T101 selects the tool, the offset 1, and commands the tool change to Tool 1.|
|G00 G18 G20 G40 G80 G99 (Safe startup) ;||
This is referred to as a safe startup line. It is good machining practice to place this block of code after every tool change. G00 defines axis movement following it to be in Rapid Motion mode. G18 defines the cutting plane as the XZ plane. G20 defines the coordinate positioning to be in Inches. G40 cancels Cutter Compensation. G80 cancels any canned cycles. G99 puts the machine in Feed per Rev mode.
|G50 S1000 (Limit spindle to 1000 RPM) ;||G50 limits the spindle to a max of 1000 RPM. S1000 is the spindle speed address. Using Snnnn address code, where nnnn is the desired spindle RPM value.|
|G97 S500 M03 (CSS off, Spindle on CW) ;||
G97 cancels constant surface speed (CSS) making the S value a direct RPM of 500. S500 is the spindle speed address. Using Snnnn address code, where nnnn is the desired spindle RPM value. M03 turns on the spindle.
Note: Lathes equipped with a gearbox, the control will not select high gear or low gear for you. You must use a M41 Low Gear or M42 High Gear on the line before the Snnnn code. Refer to M41 / M42 Low / High Gear Override for more information on these M-codes.
|G00 G54 X2.1 Z0.1 (Rapid to 1st position) ;||G00 defines axis movement following it to be in Rapid Motion mode. G54 defines the coordinate system to be centered on the Work Offset stored in G54 on the Offset display. X2.0 commands the X Axis to X = 2.0. Z0.1 commands the Z Axis to Z = 0.1.|
|M08 (Coolant on) ;||M08 turns on the coolant.|
|G96 S200 (CSS on) ;||G96 turns on CSS. S200 specifies a cutting speed of 200 ipm to be used along with the current diameter to calculate the correct RPM.|
These are the cutting code blocks in the sample program O40001:
|Cutting Code Block||Description|
|G01 Z-0.1 F.01 (Linear feed) ;||G01 defines axis movements after it to be in a straight line. Z-0.1 commands the Z Axis to Z = -0.1. G01 requires address code Fnnn.nnnn. F.01 specifies the feedrate for the motion is .0100" (.254 mm)/Rev.|
|X-0.02 (Linear feed) ;||X-0.02 commands the X Axis to X = -0.02.|
|Completion Code Block||Description|
|G00 Z0.1 M09 (Rapid retract, Coolant off) ;||G00 commands the axis motion to be completed in rapid motion mode. Z0.1 Commands the Z Axis to Z = 0.1. M09 commands the coolant to turn off.|
|G97 S500 (CSS off) ;||G97 cancels constant surface speed (CSS) making the S value a direct RPM of 500. On machines with a gearbox, the control automatically selects high gear or low gear, based on the commanded spindle speed. S500 is the spindle speed address. Using Snnnn address code, where nnnn is the desired spindle RPM value.|
|G53 X0 (X home) ;||G53 defines axis movements after it to be with respect to the machine coordinate system. X0 commands the X Axis to move to X = 0.0 (X home).|
|G53 Z0 M05 (Z home, spindle off) ;||G53 defines axis movements after it to be with respect to the machine coordinate system. Z0 commands the Z Axis to move to Z = 0.0 (Z home). M05 turns off the spindle.|
|M30 (End program) ;||M30 ends the program and moves the cursor on the control to the top of the program.|
|%||Denotes the end of a program written in a text editor.|
Absolute (XYZ) and incremental positioning (UVW) define how the control interprets axis motion commands. When you command axis motion using X, Y, or Z, the axes move to that position relative to the origin of the coordinate system currently in use. When you command axis motion using U(X), V(Y), or W(Z), the axes move to that position relative to the current position. Absolute programming is useful in most situations. Incremental programming is more efficient for repetitive, equally spaced cuts.
The Tnnoo code selects the next tool (nn) and offset (oo).
FANUC Coordinate System:
T-codes have the format Txxyy where xx specifies the tool number from 1 to the maximum number of stations on the turret; and yy specifies the tool geometry and tool wear indices from 1 to 50. The tool geometry X and Z values are added to the work offsets. If tool nose compensation is used, yy specifies the tool geometry index for radius, taper, and tip. If yy = 00 no tool geometry or wear is applied.
Tool Offsets Applied by FANUC:
Setting a negative tool wear in the tool wear offsets moves the tool further in the negative direction of the axis. Thus, for O.D. turning and facing, setting a negative offset in the X-axis results in a smaller diameter part and setting a negative value in the Z-axis results in more material being taken off the face.
Note: There is no X or Z motion required prior to performing a tool change and it wastes time in most cases to return X or Z to the home position. However, you must position X or Z to a safe location prior to a tool change in order to prevent a crash between the tools and the fixture or part.
Low air pressure or insufficient volume reduces the pressure applied to the turret clamp/unclamp piston and slows down the turret index time or does not unclamp the turret.
To load or change tools:
1. Press [POWER UP/RESTART] or [ZERO RETURN] and then [ALL]. The control moves the tool turret to a normal position.
2. Press [MDI/DNC] to toggle to MDI mode.
3. Press [TURRET FWD] or [TURRET REV]. The machine indexes the turret to the next tool position. Shows the current tool in the Active Tool window in the lower right of the display.
4. Press [CURRENT COMMANDS]. Shows the current tool in the Active Tool display in the upper right of the screen.
Tool Nose Compensation (TNC) is a feature that lets you adjust a programmed tool path in for different cutter sizes, or for normal cutter wear. With TNC. you only need to enter minimal offset data when you run a program. You do not need to do additional programming.
Tool Nose Compensation is used when the tool nose radius changes, and cutter wear is to be accounted for with curved surfaces or tapered cuts. Tool Nose Compensation generally does not need to be used when programmed cuts are solely along the X- or Z-axis. For taper and circular cuts, as the tool nose radius changes, under or overcutting can occur. In the figure, suppose that immediately after setup, C1 is the radius of the cutter that cuts the programmed tool path. As the cutter wears to C2, the operator might adjust the tool geometry offset to bring the part length and diameter to dimension. If this were done, a smaller radius would occur. If tool nose compensation is used, a correct cut is achieved. The control automatically adjusts the programmed path based on the offset for tool nose radius as set up in the control. The control alters or generates code to cut the proper part geometry.
Cutting path without tool nose compensation:
 Tool Path
 Cut after wear
 Desired cut.
Cutting path with tool nose compensation:
 Compensated tool path
 Desired cut and programmed tool path.
Note: The second programmed path coincides with the final part dimension. Although parts do not have to be programmed using tool nose compensation, it is the preferred method because it makes program problems easier to detect and resolve.
When you use M97:
When you use M98:
Canned Cycles are the most common use of subprograms. For example, you might put the X and Y locations of a series of holes in a separate program. Then you can call that program as a subprogram with a canned cycle. Instead of writing the locations once for each tool, you write the locations only once for any number of tools.
When program calls a subprogram, the control first looks for the subprogram in the active directory. If the control cannot find the subprogram, the control uses Settings 251 and 252 to determine where to look next. Refer to those settings for more information.
To build a list of search locations in Setting 252:
To see the list of search locations, look at the values of Setting 252 on the Settings page.
This code calls a subprogram (subprogram) referenced by a line number (N) within the same program. A Pnn code is required and must match a line number within the same program. This is useful for subprograms within a program as it does not require a separate program. The subprogram must end with an M99. An Lnn code in the M97 block will repeat the subprogram call nn times.
O69701 (M97 LOCAL SUBPROGRAM CALL) ;
M97 P1000 L2 (L2 will run the N1000 line twice) ;
N1000 G00 G55 X0 Z0 (N line that will run after M97 P1000 is run) ;
S500 M03 ;
G00 Z-.5 ;
G01 X.5 F100. ;
G03 ZI-.5 ;
G01 X0 ;
Z1. F50. ;
G28 U0 ;
G28 W0 ;
P - The subprogram number to run
L - Repeats the subprogram call (1-99) times.
(<PATH>) - The Subprogram’s directory path
M98 calls a subprogram in the format M98 Pnnnn, where Pnnnn is the number of the program to call, or M98 (/Onnnnn), where is the device path that leads to the subprogram.
The subprogram must contain an M99 to return to the main program. You can add an Lnn count to the M98 block M98 to call the subprogram nn times before continuing to the next block.
When your program calls an M98 subprogram, the control looks for the subprogram in the main program’s directory. If the control cannot find the subprogram, it then looks in the location specified in Setting 251. Refer to page 208 for more information. An alarm occurs if the control cannot find the subprogram.
The subprogram is a separate program (O00100) from the main program (O00002).
O00002 (PROGRAM NUMBER CALL);
M98 P100 L4 (CALLS O00100 SUB 4 TIMES) ;
M99 (RETURN TO MAIN PROGRAM) ;
O00002 (PATH CALL);
M98 (USB0/O00001.nc) L4 (CALLS O00100 SUB 4 TIMES) ;
M99 (RETURN TO MAIN PROGRAM) ;
To make this site work properly, we sometimes place small data files called cookies on your device. Most big websites do this too.
A cookie is a small text file that a website saves on your computer or mobile device when you visit the site. It enables the website to remember your actions and preferences (such as login, language, font size and other display preferences) over a period of time, so you don’t have to keep re-entering them whenever you come back to the site or browse from one page to another.
USD prices DO NOT include customs duty, customs fees, insurance, VAT, or freight.
CNY prices include customs duty, customs fees, insurance, and VAT. DOES NOT include freight.
This price includes shipping cost, export and import duties, insurance, and any other expenses incurred during shipping to a location in France agreed with you as a buyer. No other mandatory costs can be added to the delivery of a Haas CNC Product.
KEEP UP WITH THE LATEST HAAS TIPS AND TECHNOLOGY...
HAAS TOOLING ACCEPTS THE FOLLOWING:
2800 Sturgis Rd., Oxnard, CA 93030 / Toll Free: 800-331-6746
Phone: 805-278-1800 / Fax: 805-278-2255