Below is a whole program, short but real in form: a 100 × 60 × 10 mm aluminium plate with a rectangular pocket 4 mm deep and two drilled holes. First read it straight through, then we take it apart line by line.
The program
O1001 (PLATE 100X60 - POCKET AND 2 HOLES)
N10 G21 G17 G90 G40 G80 G49
N20 T01 M06 (END MILL D10)
N30 G54 G00 X-15. Y-15.
N40 G43 H01 Z50.
N50 S2400 M03
N60 M08
N70 G00 Z5.
N80 G01 Z-2. F120
N90 G41 D01 X10. Y10. F400
N100 G01 X90.
N110 G01 Y50.
N120 G01 X10.
N130 G01 Y10.
N140 G01 Z-4. F120
N150 G01 X90. F400
N160 G01 Y50.
N170 G01 X10.
N180 G01 Y10.
N190 G40 G01 X-15. Y-15.
N200 G00 Z50. M09
N210 M05
N220 T02 M06 (DRILL D8)
N230 G54 G00 X25. Y30.
N240 G43 H02 Z50.
N250 S1800 M03 M08
N260 G00 Z5.
N270 G81 Z-12. R2. F150
N280 X75. Y30.
N290 G80
N300 G00 Z50. M09
N310 M05
N320 G91 G28 Z0.
N330 M30
What each block does
N10 — The header. Millimetres, XY plane, absolute coordinates, cutter radius compensation cancelled, canned cycles cancelled and length offset cancelled. Everything is declared so nothing is inherited from the previous program. This is the line that saves you half the frights.
N20 — Tool. Picks the 10 mm end mill from the magazine. The text in brackets is a comment: the machine ignores it, but whoever reads the program at six in the morning is grateful for it. Always comment the tools.
N30 — Work offset and approach. Activates G54 and positions at X-15 Y-15, off the part. Always approach from outside the material.
N40 — Length offset. G43 with H01 tells the machine how long that tool is. Without it, the tip is not where the control thinks it is. It goes up to Z50, a safe height.
N50 and N60 — Spindle and coolant. 2,400 rpm clockwise, and coolant on. In that order, not the other way round.
N70 and N80 — Entering the material. Rapids down to Z5, which is above the part, and from there in G01 at 120 mm/min down to Z-2. You go in slowly, always.
N90 — Cutter radius compensation. G41 with offset D01 switches compensation to the left while moving to the first point of the profile. Note that compensation is switched on during a linear move and off the profile, never on an arc and never stationary. The feed goes up to 400: now it is really cutting.
N100 to N130 — The first pass. The rectangle of the pocket, point by point, at 2 mm depth. Because compensation is active, the coordinates are those of the finished part, not those of the cutter centre. That is the whole point of G41.
N140 to N180 — The second pass. Goes down to Z-4 and repeats the same path. Two passes of 2 mm instead of one of 4: the tool suffers less and the finish comes out better.
N190 — Cancelling compensation. G40 while moving away to a point outside. Leave G41 active and the next tool works offset, and you will not understand why.
N200 and N210 — Retract. Up to Z50 and coolant off on the same line, then stop the spindle. Now it is clear for the change.
N220 to N260 — The second tool. The whole ritual repeats: change, work offset, position, its own length offset (H02, not H01), a different spindle speed because it is a drill, coolant and approach. Every tool has its own offset. Reusing the previous one is among the most expensive mistakes there are.
N270 — The canned cycle. G81 is simple drilling: down to Z-12 at 150 mm/min, and R2 is the retract plane, the height it returns to between holes. One line replaces five.
N280 — The second hole. Coordinates only. The cycle is still active and repeats in full at every new point you give it. Which is why it has to be cancelled.
N290 — G80. Cancels the cycle. Forget it and the next move you program drills where it should not.
N300 to N310 — Final retract. Same as before.
N320 — Return to machine home. G91 G28 Z0 sends the Z axis to the machine reference point, in incremental. It leaves the table clear for clamping the next part.
N330 — M30. End and rewind.
The pattern that repeats
Strip out the numbers and you will see that every tool always does the same thing:
change → work offset and position → length offset → spindle and coolant → approach → cut → retract → switch off
When you open a three-thousand-line CAM program, look for the M06s. Between any two of them you have exactly that sequence. What sits in between is a lot, but it is always the same thing.
How to practise this without a machine
Take a program from your own shop, print it, and mark with a highlighter where each tool starts and ends. Then, for each cutting block, ask yourself: what depth is it at? at what feed? is compensation on? Ten minutes a program, three or four programs, and it sticks.
Next step: you can now read a whole program. The last thing before the quiz is to know the mistakes that break the part, the tool, or something worse.