CNC Milling – Sub Program
Semester 6
A CNC milling job with a sub program on the Haas TM-1 vertical milling machine. Turn the 3D model, then study the drawing, tool, codes and program below.
3D Model
Loading 3D model…
Drag to rotate · Scroll or pinch to zoom · Right-drag or two fingers to pan
Engineering Drawing
Tool & Machining Sequence
This job uses one tool only. T1 mills round the profile, 0.25 mm deeper on each pass, until the step is 1 mm deep.
01. Profile Milling with a Sub Program
Tool: T1 – Ø10 end mill, 4 flutes, coated (
T1 M06)
Work zero G54, no cutter radius compensation (G40), absolute (G90), mm (G21)
Spindle: M03 S1500
Coolant ON: M08
Sub program N1 run four times: M97 P1 L4
Each pass 0.25 mm deeper (G91 G01 Z-0.25) – 1 mm in all
Cutter radius compensation left: G41 D01, off again with G40
Feed: F300
Coolant
The coolant is soluble oil mixed with water. M08 switches it on and M09 switches it off.
Why it looks like milk
Soluble oil contains an emulsifier. When it is mixed into water, the oil breaks up into very small drops that stay spread through the water. These drops scatter the light, so the mixture turns milky white. This mixture is called an emulsion.
What the coolant does
- Cools: the water carries the heat away from the tool tip and the work, so the tool lasts longer and the size stays correct.
- Lubricates: the oil reduces the friction between the chip and the tool, which gives a better surface finish.
- Flushes: it washes the chips away from the cutting zone.
- Stops rust on the work and the machine.
G & M Codes
The codes for this machine.
Preparatory functions (G codes)
- G00
- Rapid positioning
- G01
- Linear interpolation
- G02
- Circular interpolation, clockwise (CW)
- G03
- Circular interpolation, counter-clockwise (CCW)
- G20
- Dimensions in inch
- G21
- Dimensions in mm
- G28
- Return to home
- G40
- No cutter radius compensation
- G41
- Cutter radius compensation – left
- G42
- Cutter radius compensation – right
- G54–G57
- Work zero (zero offset)
- G90
- Absolute dimensions
- G91
- Incremental dimensions
Miscellaneous functions (M codes)
- M00
- Program stop
- M01
- Optional stop
- M02
- Program end without reset
- M03
- Spindle clockwise (CW)
- M04
- Spindle counter-clockwise (CCW)
- M05
- Spindle stop
- M06
- Tool change
- M08
- Coolant ON
- M09
- Coolant OFF
- M30
- Program end with reset
- M97
- Local sub program call
- M99
- Sub program return
Other words
- N
- Sequence or block number
- T
- Tool selection
- S
- Spindle speed in rpm
- F
- Feed in mm/min
- R
- Radius of circle
- P
- Program line number (go to N…)
- L
- Repeats of the sub program call
- D
- Tool diameter offset number. The diameter is entered on the Offset page, in the Diameter column.
CNC Milling Program & Simulation
Press Play to run the program on the 3D plate: the end mill goes round the profile four times, 0.25 mm deeper each time, and the running block is highlighted. View brings the 3D view back to the start while the program goes on. Tap a cutting block to see it on the top view, or tap the top view to find its block.
O00001
G28
T1 M06
G54 G40 G90 G21
M03 S1500
M08
G00 X-20 Y25
G00 Z10
G01 Z0 F100
M97 P1 L4
G00 Z10
G28
M09
M05
M30
N1
G91 G01 Z-0.25
G90 G01 G41 X3 Y25 F300 D01
G01 X3 Y42
G01 X8 Y47
G01 X37 Y47
G02 X47 Y37 R10
G01 X47 Y3
G01 X3 Y3
G01 X3 Y25
G01 G40 X-20 Y25
M99
Operating the Machine
Follow these cards in order – from switching on, through zero return, work offset and entering the program, to simulation and the actual run.
⚠ Do not operate the machine from this page alone – always work under the guidance of an instructor or an experienced person. We are not responsible for any loss, damage or injury that results from using this information.
Safety first
- Wear safety shoes. No loose clothes; tie back long hair.
- Close the door before Cycle Start. Never open it or reach inside while the spindle is turning.
Machine ON
- Compressor ON
- Main panel ON
- Stabilizer ON
- Select three phase (press Menu three times)
- Machine main power ON
- Power ON
Note: the Menu button checks that all three phases have voltage. At switch-on the screen shows R–N 230 V; the first press shows Y–N 230 V, the second B–N 230 V and the third the three-phase condition OK.
Running setup
Alarm
- Reset (low air pressure)
- Reset (emergency)
- Reset (servo ON)
Setting
- Page down
- Bring the cursor to line 51 – Safety override switch
- Write enter
- Y (to confirm) – the switch is now ON
Zero return
- Zero return
- All
- Hand jog (twice)
- Select the axis (X, Y, Z)
- Select 0.1
- Turn the hand wheel (the table moves)
Note: the first Hand jog press opens another page; the second opens the jog window. Only then can the axes be moved after zero return.
Work offset
- Offset
- Work offset page – G54
- Bring the tool to position
- Part zero set (X, Y and Z together)
Note: only one tool is used, so no tool length offset is taken. X, Y and Z are all set in G54.
⚠ Important: do not run the machine without taking the work offset.
New program
- List program
- Left arrow key (into the directory)
- Type O and the 5-digit number
- Write enter
- MEM (to open the program)
- Edit (to change the program)
Note: a new number shows New program and makes a new program. A number that already exists is marked with a star (*).
Simulation
- MEM
- Home
- Setting (twice)
- Keep a hand on Reset and press Cycle Start
- F4
- Single block
- Keep a hand on Reset and press Cycle Start, until the program ends (M30)
Note: Home takes the cursor to the first line of the program. In MEM, the first Setting press opens the settings page and the second the graphics window; outside MEM the machine shows a wrong-entry message.
⚠ Important: if the machine moves, press Reset.
Running the program
- MEM
- Home (the cursor goes to the first line)
- Keep a hand on Reset and press Cycle Start
⚠ Important: if there is any movement that is not in the program, press Reset.
Machine OFF
- Press the emergency stop
- Power OFF
- Machine main power OFF
- Stabilizer OFF
- Main panel OFF
- Compressor OFF
Viva Questions
Tick one answer for each question, then press Submit.


