CNC Program Quiz What’s Wrong?

CNC Program Quiz What’s Wrong?

CNC Program

I got a desperate call from a customer asking me what was wrong with the CNC program below as he kept getting alarms.

The machine is a Horizontal Mazak running an (G Code) CNC program. It’s a thread milling CNC program.

I found quite a few errors in the code quite quickly and congratulating myself confidently told him to run the program.

This guy has been my best friend since I was 17 and I couldn’t resist a bit of sarcasm (we call it piss taking here in England).

You have to be careful when you have a go at Garry. Ever since our days together as apprentices at Rolls Royce (circa 1971) whenever I took the piss out of him he would get me back 10 fold.

(It’s no coincidence that Rolls Royce went bust in 1971)

I remember my first time at arc welding nervously trying to master the technique. Garry thought it might be amusing to smash a large mallet into the underside of the metal clad welding both.

I have always been the type of person who jumps and alarms quite easily.

Panic struck I threw the complete welding torch into the air and spontaneously evacuated my bowels. It sparked and flashed around the cabinet, which I had long since vacated, for a good minute before the instructor intervened.

I was the subject of ridicule and derision for the next few days by the whole of the Rolls Royce training school (about 200 teenagers).

For the younger generation, it was in those strange halcyon days when the UK invested in manufacturing. Oh and we had Black Sabbath, Led Zeppelin, Deep Purple and the fuckin Osmonds.

CNC Program

The CNC Program

Anyway enough of that. So yea I thought the program was OK but it alarmed out again.

A sarcastic laugh ensued and comments about “how the Mighty Fall”.

Needless to say I hadn’t found the real error in the code.

I have to call it a school boy error, mind you when I was at school I couldn’t even write my fuckin’ name, let alone error check a complex CNC Program.

I must have demonstrated this a hundred times on a whiteboard. My students took it all in but obviously I didn’t….. So what’s the error?

N30 T16 T72 M06 (5/8″ THREADMILL)

G90 G0 G54 X0 Y35. S3000 M3
G0 Z2.0
G01 Z-20. F1000.
G41 Y-10.548 F263.
G03 X0 Y22.003 Z.907 I0 J11.002
G03 X0 Y0 Z1.814 I0 J-11.455
G03 X0 Y-22.003 Z.907 I0 J-11.002
G40 X0 Y10.548
G90 Z2.
G0 Z50.

Some hints If You Haven’t Got It Yet

When you are in cutter compensation the machine is reading ahead so the alarm my well be a few lines in front of where you are.

There are errors which are more a matter of discipline but won’t cause alarms.

When I check word documents I always put my finger on each word as I read the document.

I find that when you read it your brain is making the same mistake as when you wrote it.

Biggest clue read this on Modal Information.


If you have been affected by any of the issues in this post or need CNC Counselling then contact me.

If you want to learn to program CNC Milling Machines

Look no further Contact CNC Training Centre





Neil McDonald

November 23, 2020 at 7:33 pm

No G01 after the final G03!

Patrick Geraghty

November 25, 2020 at 9:10 am

Tool call and tool change on same line.
No G43 tool length offset
G41 line no D for tool dis offset
No G1 to cancel G3

Lewis Mackenzie

May 15, 2022 at 7:00 am

There are quite a few mistakes.
Firstly there is no G43 line for length compensation. There is no H or D value for the selected cutting tool.
The biggest problem in my opinion is that when he selected G3 which is a modal code, he did not change to G1 when he cancelled his compensation in the G40 line.


    May 19, 2022 at 7:08 pm

    Mazak doesn’t need G43 or H and D. You can set it to do this by parameter if you need compatability with orther controls but most people don’t bother.
    Your last comment is correct.
    Thanks for commenting it’s much appreciated.

Craig Watson

May 18, 2022 at 5:40 am

G76 is a simple program standard for lathe and milling provide you apply the correct machine axis and correct pitch.

Log out of this account

Leave a Reply

WP to LinkedIn Auto Publish Powered By :