Well Set Out G Code CNC (CNC Programming)

Well Set Out Code

Contact David 07834 858 407

Well Set Out CNC Code

CNC Training Centre Reviews

30 five star ratings on Google (just saying)

Well Set Out CNC Code is really important. It can save lots of time spent trawling through code trying to find the section you’re looking for. Simple things like leaving gaps after the tool change line can really help.

The program runs exactly the same but……

Look at the two examples of the same program

Well Set-Out

g code cnc
Uncluttered CNC Code

Not Well Set-Out

g code cnc
Cluttered CNC Code
  • Notice where the gaps are.
  • They give clarity to what’s happening in your program.
  • Try to create your own convention and always lay your program out in the same way.
  • Notice how your eyes are drawn to the tool change lines. These are usually the first things you are looking for.

Read On

It’s like reading a book without paragraphs, and page numbers. It also makes it easy to spot mistakes with well set out CNC code.

Dog reading a book

This is my dog, his name s “Get Back Here You Bastard”

See if you can find the simple error in the well set out code and let me know what it is. That way I will know you’re concentrating.

Clue: if you are the fortunate owner of a Haas machine it will spot this for you and alarm out.

 


Meaningful Comments

Insert meaningful comments. Remember you might not see this code for two years and you won’t remember what you did or how you were thinking at the time.

When you eventually come back to this code you’ll be scratching your arse for hours trying to figure it out.

You’ll think:

“Why the fuck did I do that”

A little comment will explain everything

 

Well Set Out CNC Code
An Elephant and my wife never forget

Come on Get a Grip

Yes you will figure it out eventually but that’s the same with the human genome project.

Well Set Out CNC Code
It takes time to remember what you were doing

Why do I need Well Set Out CNC Code (Things To Do)

  1. Leave gaps at strategic points in the program.
  2. Loads and loads of comments, write them as you would say it, (don’t try to be posh).
  3. Always make the order of the code the same.
  4. Write an SOP (Standard Operating Procedure) for how you want your code laid out.
  5. Make the tool change lines stand out these are the key points.
  6. Use N numbers at strategic points so that you can easily find things.
  7. Don’t use too many N numbers or you will get confused they are like E numbers they can drive you crazy. They also take up loads of memory.
  8. The machine setter and operator are your customers and you need to make their lives as easy as possible. Give em code that’s easy to read.
  9. If your writing X50. Y50. Z50. don’t write Z50. Y50. X50. Yes it will run OK trouble is it’s bloody confusing.
  10. Someone suggested adding M01 after each tool so I’m adding this in. (Thanks Michael)

An M1 or M01 is an optional stop which means you have the choice to stop at each tool. (Very useful if you want to stop at the next tool and you can’t stand around.)

Continuity

When you arrange the program in the same way every time it will be easy to spot mistakes. If you always put your spindle start and speed at the end of the first position line like this.

G90 G0 G54 X50. Y50. S1500 M03

Were you to miss out the speed you would have a very good chance of noticing it because the line will look wrong.

G90 G0 G54 X50. Y50. M03

Tidy neat code is the same as a neat tidy workshop. It’s much easier to find things.

Thanks for reading my post.

Please contact me if you require:

  • CNC programming training.
  • Want to learn CNC programming.
  • Fanuc control training.
  • Yasnac programming training.
  • Any type of CNC course.
  • Fanuc training courses
  • CNC lathe training
  • CNC Vertical Machining Centre training

Services offered at CNC Training Centre

Edgecam Training.

Siemens Sinumerik Training

Classroom programmer training.

Onsite CNC Machine Training.

Training on all controls and machines.

Mazak Training Fanuc Training

Don’t forget we offer training on all types of Mazak Machines and all Fanuc Controls 6m to 31i Oi old to young.


G02 G03 Circular Interpolation

G02 G03 Circular Interpolation

On a Fanuc or Haas control G02 G03 are the two G codes we use to move around clockwise and counterclockwise circles. You don’t need the leading zeros so from now on I will call them G2 and G3.

And by the way never use the letter O it’s number zero

GO2 GO3 looks almost exactly the same as G02 G03. But your control will blow it’s mind and get real mad with you.

It will also do some really weird shit like trying to start a new program. Anyway just don’t do it.

If you want to know how to do this on your Heidenhain control you need to read this article.

Oh and please don’t call it interpolation as it annoys the shit out of me.

  • Linear interpolation is movement in a straight line.
  • Circular interpolation in moving in a circle.
  • Interpolation is movement.
  • CNC Training Centre Reviews

    30 five star ratings on Google (just saying)

Now that’s the telling off out of the way let’s move on. It’s ok I don’t hold a grudge.

Which one of you bastards said interpolation?

Let’ Talk About Milling A Shape

When you are milling a shape and you want to move in a circular motion you use G2 or G3

For a clockwise arc use G2 and for a counter clockwise arc use G3.

They both work the same way. On a modern control you programme the endpoint (an XY figure on a milling machine) and the radius you require.

Then your CNC controller magically creates your circle. You can programme any arc like this with one exception.

Do you know what it is?

Ok I will tell you later, it’s OK to not know. (Just means you are little thick).

Lets go back to school.

Remember construction? Of course you do.

We are going to mill the top section of this part

G02 G03

Let’s see what the control has to do to work out where the centre of the circle is.

It knows its current position and in your G3 line you tell it the end point and the radius you want.

G02 G03

Well it gets out its little compasses and draws two circles at the radius you told it.

G02 G03

 

It positions the compass first on the start point and draws an arc. Then on the end point and draws an arc.

Where these two arcs cross it places the point of the compass. Now it can strike an arc that touches your start point and your end point.

Get yourself a pair of compasses and try it. It’s great fun.

 

G02 G03

 

That’s how the maths works.

Tell me did you really believe that inside your CNC machine there is a little man with a pair of compasses?

Fuckin hell I give up.

Sorry I lied it’s all done with simple trigonometry. But at least I tricked you into understanding the principle.

 

g02 g03 lathe

So you should now begin to work out why you get an alarm when the radius is too small. Your two arcs just don’t cross. In other words you are trying to fit an arc between two point that simply miss one another.

G2 G3 No Pot of Gold

Your control will give you an alarm “End Point Not Found” which makes sense because it can’t find one. It’s like the pot of gold at the end of the rainbow.

 

G02 G03

Oh Before you Go More on G02 G03

What about the question. When can you not use endpoint and radius with G02 and G03 ?

Answer: When you want to machine a full circle using G02 and G03.

You can do it but you would have to break it into two halves. I’m not going to explain anymore because this method is for wimps and peole who can’t be arsed to read my articles.

You know who you are, ordering Chicken Korma in an Indian Restaurant.

Well…… what follows is a full, blow your bollocks off, shit your pants the next day, vindaloo.

And Now Ladies and Gentlemen the Infamous I and J

At the CNC Training Centre we don’t get too excited about I and J when it comes to programming circles. That’s because you don’t need to worry your pretty head about it anymore. You almost never need it.

Did he say almost?

Well yes almost. You could programme forever and never bother about using I and J with G02 G03. So just go off and watch some porn for awhile and I will explain to the real programmers when you can use it.

In the old days I and J was the only way to programme an arc. You would tell the control where the centre of the circle is and the endpoint. This is cumbersome and a bit tricky. That’s why I’m not telling you about it.

Anyway one really good simple way to use I and J is for a full circle. Oh and it’s bloody easy. That is once I’ve explained it to you.

Click here for more info on full circle

When I was a boy hundreds of years ago I had a toy called a Spiro Graph.

Spirograph those were the days

It consisted of a series of plastic gears. You stuck your pen in a hole in the gear and rotated it around another gear. With a bit of practice you could make some really nice pictures. Kept us happy for hours. The crime rate dropped dramatically in my area when these things came out.

What’s this to do with CNC programming you ask? Well if you tried to use end point and radius for a full circle this is what you would get:

If your start point was X0 Y0 you would program G3 X0 Y0 R100. assuming radius was 100mm.

So in a full circle your endpoint is the same as your start point. There are millions of circles the computer could pick. It would be just like the shapes above. If you do the compass trick you will see what I mean. That’s why it’s impossible.

In Comes I and J

G02 G03

So some clever bloke thought fucks this I’ll invent I and J.

If we use I and J there are four options as above.

You would simply program as below for a full circle (20mm Radius)

  • G3 I-20.
  • G3 I20.
  • G3 J20.
  • G3 J-20.

And that’s it.

G02 G03

So these are the four options

 

G02 G03

So there you have a fantastic way to programme a full circle without having to break it down into two halves or be clever like a newsreader or some twat off mastermind.

Why do you only need the I and not X and Y Dave?

For fucks sake don’t call me Dave my name is David.

I had this really nice guy phone me from Africa the other day. He explained to me that he needed to get his inheritance of 10 million pounds out of England and if I helped him he would give me £20,000. All I had to do was give him all my bank and credit card details. Oh and a small one off payment of £1000.

Of course I agreed, what a bargain. Just as I was about to do this the cheeky bastard called me Dave.

I immediately told him to fuck off. I just hate being called Dave.

I gave him my 96 year old mothers phone number because I thought at least she can benefit from it all. Her name is Mary so he couldn’t shorten that. She only has £1200 in savings so it would be doing her a massive favour.

 

Explanation

You don’t need to re-state the X  and Y because you are already at the endpoint

Click here for more info on full circle

If you want to do this on a Sinumeric Siemens 840D read this

Thanks For Reading

Don’t forget there’s loads more folks.

And a YouTube channel

Services offered at CNC Training Centre

Edgecam training.

Classroom programmer training.

Onsite CNC Machine Training.

CNC Training on all controls and machines.

Mazak Training Fanuc Training

Siemens Sinumerik

Don’t forget we offer training on all types of Mazak Machines and all Fanuc Controls 6m to 31i Oi old to young.

CNC Training Centre Reviews

30 five star ratings on Google (just saying)


 


CNC Course

Category : New Stuff News

CNC Course

Precision Machining with Expert Training

If you’re looking to enhance your CNC machining skills or start a career in precision engineering, these CNC courses are the perfect opportunity.

CNC Course

Based in Barwell, Leicestershire, THE CNC Training Centre offers hands-on learning with real CNC machines and simulators, ensuring you gain practical experience in CNC milling, turning, and advanced mill-turn operations.

Why Take a CNC Course?

CNC (Computer Numerical Control) machines are essential in modern manufacturing, used in industries such as aerospace, automotive, and medical engineering.

Learning how to program and operate CNC machines can open up excellent career opportunities and improve efficiency for businesses.

The CNC courses cater to:

•Beginners looking to enter the industry

•Experienced machinists wanting to upgrade their skills

•Companies seeking to train their staff in the latest CNC programming techniques

What The CNC Courses Cover

We provide two-day intensive training courses, offering a structured learning approach to CNC programming and operation. Our 2026 courses include:

•Introduction to CNC Programming – Learn the basics of G-code, tool paths, and setting up CNC machines.

•Advanced CNC Milling and Turning – Focus on complex multi-axis machining, tool compensation, and cycle optimisation.

•Mill-Turn Programming – Master advanced mill-turn techniques on real machines.

Why Choose Our CNC Training?

•Expert Instructor – Experienced CNC machinist who offer industry-relevant insights.

•Small Class Sizes – We ensure personalised instruction to maximise learning.

•CNC Training Centre is equipped with the latest CNC Simulators.

CNC Course

Enrol in a CNC Course Today

Whether you’re a beginner or an experienced machinist, these CNC courses will help you improve your skills and stay competitive in the industry.

Contact us today to book your place on our next CNC course and take the next step in your machining career.

Get in Touch

Contact CNC Training Centre

 

 

Start your journey in precision machining today with our expert-led CNC training!


Heidenhain The Best Bits

There is some great shit on a Heidenhain 530 and 640 controls. So lets list them. If your not using these features then you certainly should be.

Loads more Heidenhain stuff.

Heidenhain Filter File Type

When you switch from Edit to Program Run or Test Run you need to select the program you want. Unlike Fanuc when you switch from edit to program your program is not automatically selected.

This button to the rescue.

Heidenhain

Select your mode for example Test Run then press PGM MGT

You will see this screen

Heidenhain

There are two buttons here that on a personal level get me in an absolute frenzy.

SELECT TYPE and LAST FILES

Press SELECT TYPE first.

From here you can select the file type you want to display, best to chose .H which means you will only see the Heidenhain files.

It also means that when you create a file by pressing NEW FILE (in the edit mode) you get Heidenhain by default not ISO G code.

Heidenhain

Any program you create will automatically have the dot H extension meaning it will be a Heidenhain file.

Just write it in and the dot H will be added.

It also makes it a lot less complicated when looking for programs as you won’t see all the other stuff.

Heidenhain Quick Acess to Last File

Now onto the next little beauty LAST FILES

Go on give him a nudge, he’s your best friend.

What this does is give a list of all the recently used files, so yours will most likely be at the top, or at worst very near.

If you are using a lot of directories and shit. This will make it very simple and you wont have to trawl through loads of folders to find what you were working on.

Therefore when you switch modes you can instantly get the last file you were working on.

All you need do is press OK.

Heidenhain Are You Unprotected?

Oh yea another thing, cursor across and you’ll see PROTECT and UNPROTECT.

Heidenhain

This puts a little padlock next to your program. This stops that naughty apprentice from deleting your programs, unless of course he really wants to.

Don’t just Whip Out Your Stick

Now if you are an upstanding honest citizen you will know that you should never just whip out your stick. Especially in a crowded bar.

Always safely disconnect your memory stick not just yank it out like some decaying tooth.

You might need to press the MORE FUNCTIONS button first.

You’ll love this button if you like to do things properly.

Just press it, you never know it might save you from wiping a memory stick clean.

Undelete, (Well Kind Of)

You can restore a program back to how it was before you got your little mitts on it, just press CANCEL CHANGE.

Heidenhain

These boxes will be greyed out. This means the document is the same as when you opened it up.

Once you make a change it looks like this.

If you press CANCEL CHANGE your document will go back to how it was when you originally opened it. These buttons will be greyed out again.

If you press STORE then you document will be saved as it is and you wont be able to restore it.

Can be useful for old gits like me who often can’t remember what the were doing. It’s useful just to go back to when you first opened the program.

SAVE AS and Why Not?

The SAVE AS button is also very useful if you want to keep your original document and start with a new copy.

Now you might be thinking all this is no big deal. Well actually you are wrong because you can’t do any of this on a Fanuc control or a Haas

The Devil is in The Detail

Loads of stuff we don’t look at every day, and I’ll admit to being the worlds worst.

Sometimes I’m on the phone to my mate and my wife will say “what did he say”. I’ll say “don’t know wasn’t listening”.

I mean I admit my friends are incredibly boring but maybe I should pay more attention to detail.

Not suggesting you do what I do and it’s probably the main reason why I have no mates, other than you guys reading this.

But here is an example if you look in the directory it will tell you the program that is active in Edit, Full Run and Test modes with the letters M E and S.

How cool is that?

M (Memory)

E (Edit)

S (Test Run)

Padlock (File Locked)

Tool Names

Using tool names as opposed to numbers means you can select them directly from the tool table. This is a much quicker way.

Heidenhain

After TOOL CALL press TOOL NAME

By pressing SELECT you can pick at tool straight from your tool list.

LBL NAME

When using labels why not use something that you understand?

Just press LBL NAME

Call your Label “6mm Holes”

Makes your program more readable.

What The Fuck are These For

In a nutshell it means you can look through the program but keep your cursor where it is. So you don’t loose where you are.

Useful, Mmmm maybe?

You decide.

 

 

 

 

 

 

 

 

 

 

 

 

 


Star Mechatronics Search Paths

Onsite Training Enquiry

CNC Training Call David: 07834 858 407

 

CNC Training Centre Reviews

30 five star ratings on Google (just saying)

On a sliding head machine you are running two simultaneous programs. It can be quite difficult to see where various wait codes synchronise.

First of all you need to be in the edit mode.

Cursor across until you see SYNC SCROLL

Now press it

The SINGLESCROLL button will take you back. Now as you cursor through both programs will scroll together. When you find a wait code it will turn blue. The opposite screen will keep scrolling till it finds the corresponding wait code.

Press the TOP button to return to top of program

BOTTOM will take you to the end

If you type in a wait code number for example 200

When you press M.NUM it will find it. Use the NEXSYN to jump to next wait code and use PRESYN to get to previous sync code.

Learn loads more Fanuc stuff on this website

 


Careers in CNC

View all current vacancies in CNC

Click here

Call David: 07834 858 407