Machining Technology at HCC

There is no standardized format for writing a CNC program that is compatible with all machine control models. Each MCU manufacturer has developed its own unique programming format. Each one has minor differences, but the principles contained in the context of a program are the same among them all. These programs that I have written will relate most closely to Fanuc-type controllers; however, the principles may be applied to any manufacturer's programming format (see the specific machine's programming manual).

I have several projects per semester. By the end of the semester, I have created many programs and machined the entire things and that really is inspirational. Here are some of the projects I have done in the shop.

Rough & Finish

CNC Lathe Project 1

Lathe Simulator

Lathe Simulator

The G71 Roughing cycle will rough out material on a part defining the finished part shap. The G70 Finishing cycle can be used to finish cut paths that are defined and roughed out with stock removal cycles G71. After execution of the Q block, a rapid (G00) is executed returning the machine to the start position that was saved earlier during G70 initialization. The program then returns to the block following the G70 call.

Groove & Thread

Turning Operation

Turning Operation

Lathe Simulator

The G75 canned cycle can be used for grooving an outside diameter with a chip break. The G76 canned cycle can be used for threading both straight or tappered (pipe) threads.

%
O00021
(PROGRAMMER: FRANCIS NGUYEN)
(VERSION: 2020)
(STOCK 2.5" O.D. ALUMINUM)
(T101 O.D. ROUGH TOOL x 1/32 TNR)
(T202 O.D. FINISH TOOL x 1/64 TNR)
(T303 GROOVING TOOL x 0.118")
(T404 O.D. THREADING TOOL x 0.19")

G53 G00 X0.0 Z0.0 T0 (SENDING HOME FOR A TOOL CHANGE)
T101 (TOOL #1 AND OFFSET #1)
G50 S2000 (SPINDLE SPEED CLAMP AT 2000 RPM)
G97 S1200 M03 (CANCEL CSS, 1200 RPM, SPINDLE ON FORWARD)
G54 G00 X2.6 Z0.1 M08 (RAPID X2.6, Z0.1 TO START POINT, COOLANT ON)
G96 S600 (CSS ON, AT 600 SURFACE SPEED)
G01 Z0.0 F0.01
X-0.063 (FEED DOWN X-0.063 TO FACE END OF PART)
G00 X2.6 Z0.1 (RAPID TO X2.6, Z0.1 START POINT ABOVE PART)

(ROUGH PART PROFILE)
(D - DEPTH OF ROUGHING PASSES)
(P - STARTING BLOCK NUMBER OF PATH TO ROUGH)
(Q - ENDING BLOCK NUMBER OF PATH TO ROUGH)
(U - AMOUNT OF MATERIAL TO BE LEFT ON DIA)
(W - AMOUNT OF MATERIAL TO BE LEFT ON FACES)

G71 P100 Q200 U0.01 W0.005 D0.05 F0.01 (G71 ROUGH CYCLE)
N100 G42 G00 X0.72 (PNN START #100, RAPID X0.72, CUTTER COMP. ON)
G01 Z0.0 F0.005 (G71 PART GEOMETRY)
X0.82 (POINT 1)
X1. Z-0.09 (POINT 2)
Z-1.5 (POINT 3)
X1.45 (POINT 4)
Z-3. (POINT 5)
X1.7 (POINT 6)
Z-3.5 (POINT 7)
X1.95 (POINT 8)
Z-4.425 (POINT 9 EXTEND 0.125)
N200 G40 G00 X2.6 (QNN END #200, CANCEL CUTTER COMP. FEED X TO 2.6)
G97 S1200 M09 (CANCEL CSS, 1200 RPM, COOLANT OFF)
G28 (SENDING HOME FOR A TOOL CHANGE)
M01 (OPTIONAL STOP COMMAND)

(FINISH PART PROFILE)
T202 (TOOL #2 AND OFFSET #2)
G50 S2000 (SPINDLE SPEED CLAMP AT 2000 RPM)
G97 S1800 M03 (CANCEL CSS, 1800 RPM, SPINDLE ON)
G54 G00 X2.6 Z0.1 M08 (RAPID TO X2.6, Z0.1 START POINT ABOVE PART)
G96 S900 (TURN ON CSS TO 900)
G70 P100 Q200 (DEFINE A G70 FINISH PASS OF PART GEOMETRY)
G97 S1800 M09 (CANCEL CSS, BACK TO RPM MODE)
G28 (SENDING HOME FOR A TOOL CHANGE)
M01 (OPTIONAL STOP COMMAND)

(GROOVING CYCLE)
T303
G97 S500 M03
G54 G00 X1.6 Z0.1 M08
Z-1.418 (1.30 + 0.118 GROOVING TOOL = 1.418)

(I - X AXIS PECKING DEPTH INCREMENT, RADIUS VALUE)
(K - Z AXIS SHIFT INCREMENT BETWEEN PECKING CYCLES)

G75 X0.750 Z-1.5 I0.05 K0.1 F0.005
G00 X1.8
Z-2.918 (2.800 + 0.118 GROOVING TOOL = 2.918)
G75 X1.250 Z-3.0 I0.05 K0.1 F0.005
G00 X2.6 M09
G28 (SENDING HOME FOR A TOOL CHANGE)
M01

(THREADING CYCLE)
T404
G97 S500 M03

(SINGLE DEPTH = 0.61343 / TPI)
(SINGLE DEPTH = 0.61343 / 8 = 0.0767)
(X START POINT = MAJOR DIA. + 2 X SINGLE DEPTH)
(X START POINT = 0.9905 + 2 X 0.0767 = 1.1439)
(PITCH = 1/ TPI)
(PITCH = 1/ 8 = 0.125)
(Z START POINT = 4 X PITCH)
(Z START POINT = 4 X 0.125 = 0.5)

G54 G00 X1.1439 Z1.5 M08 (X START POINT)
Z0.5 M23 (Z START POINT, CHAMFER AT END OF THREAD ON)

(K - THREAD HEIGHT, RADIUS VALUE)
(D - FIRST PASS CUTTING DEPTH)
(F - 1/TPI)
(X - MIN MINOR DIAMETER)
(Z - THREAD LENGHT)

G76 X0.8206 Z-1.3 K0.0767 D0.0192 F0.125 (16 PASSES)
G00 X2.6 M09
G28 (SENDING HOME FOR A TOOL CHANGE)
M01

(PARTING PART)
T303
G97 S500 M03
G54 G00 X2.6 Z0.1 M08
Z-4.418 M08 (4.30 + 0.118 GROOVE TOOL = 4.418)
G75 X0. I0.05 F0.005
G00 X2.6 M09
G28 (SENDING HOME FOR A TOOL CHANGE)
M30 (END OF PROGRAM AND RESET)
%

Circular Pocket Milling

CNC Mill Project 1

CNC Mill Project 1

Mill

This G13 code implies the use of G41 cutter compensation left and will be machining in a counterclockwise direction. G13 is usually prefered instead of G12, since G13 will be climb cutting when used with a standard right handed tool.

%
O00100
(PROGRAMMER: FRANCIS NGUYEN)
(VERSION: 2020)
(STOCK 4.5" X 2.5" X 0.75" ALUMINUM)
(1ST QUADRANT)
(T1 3" FACEMILL)
(T2 1/2" FLAT ENDMILL 0.500" dia)
(T3 1/2" SPOT DRILL)
(T4 #7 DRILL 0.201" dia)
(T5 1/4-20 UNC TAP 0.250" dia)
(T6 1/2 DRILL 0.5" dia)

(FACE TOP CLEAN)
(T1 3" FACEMILL)
G00 G40 G49 G80 G90
T1 M06 (T1 3" FACEMILL)
S1200 M03 (SET SPINDLE SPEED TO 1200 RPM)
G90 G54 G00 X-2.0 Y1.25
G43 H01 Z1.0 (RAPID TO 1.0 ABOVE PART)
G01 Z0. F28.0 M08 (COOLANT ON)
X7.1
G00 Z1. M09
G53 G49 Z0. M05
M01

(CENTER DRILL 4 TAP HOLES)
(T3 1/2" CENTER DRILL 0.500" dia)
T3 M06
S1200 M03 (SET SPINDLE SPEED TO 1200 RPM)
G90 G54 G00 X1.95 Y0.75
G43 H03 Z1.
G01 Z.1 F25. M08
G81 G99 Z-.125 R.1 F6.0 (G99 R PLANE)
M98 P10000 (Subprogram call)
M01

(DRILL THRU FOUR 1/4-20 HOLES)
(T4 #7 DRILL 0.201")
T4 M06 (T4 #7 DRILL 0.201")
S1200 M03 (SET SPINDLE SPEED TO 1200 RPM)
G90 G54 G00 X1.95 Y0.75
G43 H04 Z1.
G01 Z.1 F25. M08
G83 G99 Z-0.871 Q0.075 R.1 F6.0 (G99 R PLANE)
M98 P10000 (Subprogram call)
M01

(CENTER DRILL 2 POCKET HOLES)
(T3 1/2" CENTER DRILL 0.500" dia)
T3 M06
S1200 M03 (SET SPINDLE SPEED TO 1200 RPM)
G90 G54 G00 X1.125 Y1.25
G43 H03 Z1.
G01 Z.1 F25. M08
G81 G99 Z-.2 R.1 F6.0 (G99 R PLANE)
X3.375
G80 G00 Z1. M09
G53 G49 Z0. M05
M01

(DRILL THRU 2 HOLES)
(T6 1/2 DRILL 0.5" dia)
T6 M06
S1200 M03 (SET SPINDLE SPEED TO 1200 RPM)
G90 G54 G00 X1.125 Y1.25
G43 H06 Z1.
G01 Z.1 F25. M08
(Q - PECKING EQUAL INCREMENTAL DEPTH AMOUNT)
G83 G99 Z-1.05 Q0.075 R.1 F6.0 (G99 R PLANE)
X3.375
G80 G00 Z1. M09
G53 G49 Z0. M05
M01

(CONTOUR & CUT AROUND THE PERIMETER)
(T2 1/2" FLAT ENDMILL 0.500" dia)
T2 M06 (T2 1/2" FLAT ENDMILL 0.500" dia)
S4790 M03 (SET SPINDLE SPEED TO 4790 RPM)

(1ST PASS ROUGHING)
G90 G54 G00 X-1.0 Y-1.0 (STARTING X Y )
G43 H02 Z1.0
G01 Z.1 F30.0 M08 (COOLANT ON)
Z-0.25 (FEED TO FINAL DEPTH)
G41 D02 X0.3 (START BOTTOM LEFT)
Y2.2 (POINT 2 ROUGHING)
X4.2 (POINT 7 ROUGHING)
Y0.3 (POINT 9 ROUGHING)
X-1. (POINT 15 ROUGHING)
Z.1
G00 Z1.0 M09

(2ND PASS FINISH)
G01 Y-1.0 M08 (COOLANT ON)
Z-0.25 (FEED TO FINAL DEPTH)
X0.3 (START BOTTOM LEFT)
Y2.2 (POINT 2 FINISH)
X1.863 (POINT 3 FINISH)
G02 X1.96 Y2.125 R0.1 (POINT 4 FINISH)
G03 X2.54 R0.3 (POINT 5 FINISH)
G02 X2.637 Y2.2 R0.1 (POINT 6 FINISH)
G01 X3.7 (POINT 7 FINISH)
X4.2 Y1.7 (POINT 8 FINISH)
Y.8 (POINT 9 FINISH)
X3.911 Y.3 (POINT 10 FINISH)
X2.637 (POINT 11 FINISH)
G02 X2.54 Y0.375 R0.1 (POINT 12 FINISH)
G03 X1.96 R0.3 (POINT 13 FINISH)
G02 X1.863 Y0.3 R0.1 (POINT 14 FINISH)
G01 X.6 (POINT 15 FINISH)
G02 X.3 Y0.6 R0.3 (POINT 1 FINISH)
G01 Y3. (POINT 2 EXIT)
Z.1
G40 G00 Z1. M09

(TWO 1.25" CIRCULAR POCKET MILLING)
G00 X1.125 Y1.25 (XY POSITION TO CENTER OF CPM1)
Z0.1 M08 (RAPID TO 0.1 ABOVE PART)
G01 Z0.0

(I - Radius of the first circle and must be greater than Tool Radius)
(K - Radius of finished circle)
(L - Loop count for repeating deeper cuts)
(Q - Radius increment must be used with K)
(Z - Depth of cut or increment with G91)

(Z = 1.05 depth / 5 = 0.21)
(K = 1.25 dia / 2)
(Q = K - I = 0.325 x 2 = 0.65 / L = 0.13)

G13 G91 Z-0.21 I0.3 K0.625 Q0.13 D02 F15.0 L5 (I, K, Q & G91)
G90 G00 Z1.0 (SWITCH TO ABSOLUTE, RAPID 1.0 ABOVE PART)
X3.375 (POSITION TO CENTER OF CPM2)
G01 Z0.0
G13 G91 Z-0.18 I0.3 K0.625 Q0.13 D02 F15.0 L5 (I, K, Q & G91)
G90 G00 Z0.1 M09 (SWITCH TO ABSOLUTE, RAPID 1.0 ABOVE PART, COOLANT OFF)
G53 G49 Z0. M05
M01

(TAPPING FOUR 1/4-20 HOLES)
(TAPPING HAS TO RUN 100%)
(T5 1/4-20 UNC TAP 0.250" dia)
T5 M06 (T5 1/4-20 UNC TAP 0.250" dia)
S60 (DO NOT NEED M03 FOR TAPPING)
G90 G54 G00 X1.95 Y0.75
G43 H05 Z1.
G01 Z.1 F25. M08

(J - TAPPING RETRACT SPEED)
(F = RPM/TPI = 60/20 = 3.0)
G84 G99 Z-0.9 R.1 J3 F3.0 (CAN ALSO USE G84.1 FOR TAPPING)
M98 P10000 (Subprogram call)
M30
%

%
O10000 (HOLE LOCATIONS)
(PROGRAMMER: FRANCIS NGUYEN)
(VERSION: 2020)

X2.55 (2)
Y1.75 (3)
X1.95 (4)
G80 G00 Z1.0 M09
G53 G49 Z0.0 M05
M99 (Return to main program)
%

Text Engraving

CNC Mill Project 4

Mill

G47 lets you engrave a line of text, or sequential serial numbers, with a single G-code.

E - Plunge feed rate units/min
F - Engraving feedrate units/min
I - Angle of rotation -360. to +360. default is 0
J - Height of text in in/mm minimum = 0.001 inch default is 1.0 inch
P - 0 for literal text engraving
1 for sequential serial number engraving
32-126 for ASCII characters
R - Return plane
X - X start of engraving
Y - Y start of engraving
Z - Depth of cut

Macros

Macros add capabilities and flexibility to the control that are not possible with standard G-code. Some possible uses are: families of parts, custom canned cycles, complex motions, and driving optional devices. The possibilities are almost endless.

A Macro is any routine/subprogram that you can run multiple times. A macro statement can assign a value to a variable, read a value from a variable, evaluate an expression, conditionally or unconditionally branch to another point within a program, or conditionally repeat some section of a program.

Here is an example that I want to mill one side from 4.8" to 4.5".

Mill Simulator

%
O00011
(PROGRAMMER: FRANCIS NGUYEN)
(VERSION: 2020)
(FACING WITH MACROS)
(4TH QUADRANT)
(T2 1/2" FLAT ENDMILL 0.500" dia)

G00 G40 G49 G80 G90
T2 M06 (T2 1/2" FLAT ENDMILL 0.500" dia)
S4000 M03 (SET SPINDLE SPEED TO 4000 RPM)
G54 X5.0 Y-3.0
G43 H02 Z1. (RAPID TO 1.0 ABOVE PART)
G01 Z.1 F25. M08 (COOLANT ON)
Z-0.855

#100 = 4.8 (NUMBERS STORED IN VARIABLE CAN BE OFF BY 1 LEAST SIGNIFICANT DIGIT)

(FACE PART TO 4.5)
WHILE [#100 GT 4.49] DO1 (WHILE LOOP TERMINATES WHEN #100 = 4.48 OR < 4.5)
G41 D02 G01 X#100 F70.
Y0.5
Y-3.0
#100 = #100 - 0.02 (DECREMENT BY 0.02)
END1

G40 X5.0
M09 (TURN OFF CC)
G00 Z1. M05
G91 G28 Z0.0
G28 G49 X0. Y0.
M30
%

Five-Axis Programming

Most five-axis programs are rather complex and should be written using a CAD/CAM software package such as SolidWorks and MasterCam. It is necessary to determine the pivot length and gauge length of the machine, and input them in these programs.

Create the CAD drawing is the first step in computer aided manufacturing so that its geometry may later be used for creating the machining operations. After a drawing has been created, the next step in CAM is to define the toolpath, or the path that the tool will follow in order to machine the part.

Three-dimensional surface milling is an area where the CAM software really begins to demonstrate its potential. Without CAM software, all but the simplest surface toolpaths would be virtually impossible. The final step in CAM programming is to take all of the defined toolpath data and allow the CAM software to write a CNC program.

Machining simulation that works perfectly in the virtual environment may not work physically without careful planning and consideration. Some of the major factors include choosing adequate fixtures to firmly hold the stock to the jig table, checking to ensure that cutters would not collide with fixtures and jig table, and verifying that the syntax and semantics of the G-code are compatible with the CNC machine at the shop floor.

Conversational-Type Programming

Not all CNC machines must be programmed with G- and M-codes. Some machines have a special type of MCU that allows conversational programming. Conversational programming was developed to simplify the machine programming process. There are many different types of conversational MCU brands, including Southwest Industry's Proto-TRAK machines, Bridgeport's EZ-Trak, Fanuc's FAPT and CAP, and Mazak's Mazatrol controls.

The advantages are that it requires much less programming knowledge, can often be faster for simple features, and can easily be performed at the machine on the shop floor. The disadvantages revolve mostly around the lack of flexibility: the only operations that can be performed are those provided by the manufacturer. It is for these reasons that conversational controls are usually most useful for repair work, prototyping, or low-volume production machines. When high production quantities require highly efficient programs or complex machining scenarios, the versatility of a G- and M-code programming method is usually more suitable.

SOLIDWORKS vs Mastercam

Both Mastercam and SOLIDWORKS can create model geometry and generate NC code. For 3D modeling, SOLIDWORKS is the world’s most widely used design software for a reason. It has a clear advantage for anyone routinely performing the design of products or fixtures.

For CNC programming, Mastercam is the World’s #1 CNC Programming software for a reason. It is powerful and easy to use and supports a wide range of machines and technologies.

SOLIDWORKS CAM is a low-cost option for users whose primary needs are design rather than manufacturing, but Mastercam offers a breadth and depth of features that cannot be matched for machine shops and programmers.