Category Archives: New Stuff

Reset #100-#149 Fanuc Parameters 6001

Category : New Stuff

If you write macro program you will probably know that 500 series variables stay in the machine even when you switch it off.

Unfortunately the 100 series variables don’t stay around. This parameter when changed means these little blighters will retain their values even if you turn off the machine.

Modal and non modal G codes

Modal and non modal G codes

Modal and non modal G codes

Let Me explain

We all know that programming can be complicated. So let me explain to you how it all works. This article explains the real meaning of Modal and non modal G codes.

Modal means that once a command is issued it stays in the control.

How Can you Actually Use This?

If you issue a G0 or G00 command the machine is in rapid and you do not need to re-state it.

Rapid means all motors are flat out, like a teenager in a Ferrari.

Every move from then on will be a rapid move unless you tell it otherwise. The G code that changes it must be in the same group. For example G0 G1 G2 and G3 are all in the same group a bit like The Beatles used to be.

The other day I was talking to  a “young person” who hadn’t even heard of the Beatles. I mean fuckin hell, am I really really old or are they doomed to be forgotten?

By the way my definition of a young person seems to get older every day.

Imagine being called a “young person”. You hear politicians on the telly saying “oh yes I was talking to one of those young people the other day”.

God I hate the fuckin telly, well apart from Love Island, Naked Attraction, Embarrassing Bodies, Goggle-box, Coronation Street, Emmerdale Farm, East Enders, and Strictly Come Dancing.

To be really honest I watch everything but in my defence I never stop complaining and throwing Pot Noodles at the TV.

Here’s one I made before the program

My TV’s are covered in dents and scratched from various foreign bodies being thrown at them. Obviously I have a TV in every room and toilet. They all still work even when the noodles trickle inside.

I have five, toilets not TV’s. My mother said “you must use loads of water, not to mention lavatory paper”

I said “mummy darling don’t you understand that you can’t shit or a piss in five toilets at the same fuckin time”

Obviously I didn’t say toilet in front of my mother it’s always lavatory.

Oh Yea I Was Saying I Hate The Telly

I saw this thing on the Internet 8 huge Emmerdale Spoilers .

Now I know a lot of you CNC Programmers out there are big fans of the show but I got to say it.

Spoiler I mean how in the fuck can you spoil something that’s already a mind numbing piece of crap!!

When I hear the music to that show it gets me really enthusiastic about emptying the cat trays that are heaving with piss and shit. (I know you are not supposed to leave them for over a week but in my defence I am getting into a routine now)

“Come on Dave the swearing gets worse, the Americans won’t like it”

I admit this is a rant too far and I wouldn’t blame you for going to a different website.

This guy writes serious stuff about G Codes unfortunately for you, almost every post and video is full of mistakes and often blatantly wrong.

Anyway you deserve it for not sticking with me through  difficult times.

I shouldn’t say this but there are so many mistakes in these articles I don’t know how the fuck he gets away with it. Well that’s the Internet folks.

His new series of training videos is called “Learn The Five Quickest Ways to get Instantly Dismissed as a CNC Machinist”

Modal and non modal G codes

G0 Rapid.
G1 Feed.
G2 Clockwise arc.
G3 Counter-clockwise arc

It is pretty obvious that these would have to replace one another because if you had them on the same line they would contradict one another.

You can’t go around a clockwise circle and in a straight line at the same time.

Tigers Fighting About modal G Codes

G0 X0 Y0 (Rapid to X0 Y0)
(Control says “ok I get it, rapid again, no need to repeat yourself, I heard you the first time”)

Modal and non modal G codes. How do they actually Work?

There are not many non modal commands G53 and G4

Can’t think of anymore right now.

G4 is a dwell if this were modal it would cause many problems

G0 X50. Y50.     (Rapid move)
G4 X5.                  (Five second dwell)
X0                        (This would be a rapid command not another dwell because it remembers the G0)

It remembers the G0 but conveniently forgets the G4.

My third wife was a bit like that she said I slapped her in the face but conveniently forgot that this was only after she kicked me in the bollocks and chopped off my left ear with a potato peeler.

The machine will do the G4 dwell and then completely forget it. If you really want another dwell you’d have to repeat the G4. Otherwise it’s like being told it’s your turn to feed the dog, the command is ignored.

Yes folks you can use X or P for a dwell command. I use X cos I love the feeling when the operator comes back to me n says “Dave you got this wrong”.

First of all I ignore him because my name is David and I don’t answer to Dave.

When he finally gets through to me, I love that feeling of power and superiority when I explain to him it works with P and X.

G53 is a machine position command.

If you use a non modal command you have to repeat it for every line you want to use it on.

G53 Z0;
G53 X0 Y0;

“Wake Up State” Modal and non modal G codes.

What’s This all About?

These are the G codes that are active when you turn on the control. Wake Up State, not to be confused with getting out of bed with a steaming hangover after a night on the piss.

Modal and none modal G codes
Wake up state

This wake up state cannot be guaranteed as you can change this state by parameters.

There is also a parameter which controls what happens when you press the reset button. So for example pressing reset may cancel a canned cycle. (Or not).

Modal and non modal G codes
Worn out reset button
Your modal G codes will change when……
  1. You press reset.

  2. When you first turn on your machine (Wake Up State)

  3. You read an M30 at the end of a program.

M Codes

These are not actually called modal but the same applies once you start the spindle (M3) you do not need to write it again until you want to stop or reverse it. M4 will start the spindle in reverse CCW. M5 will stop spindle.

No need to programme M05 just M5 will do try reading this.


Speeds are modal but your machine may wake up with a speed of zero.
So in MDI if a speed is active and you program M3 the spindle will start at the active speed (so be careful). 

If you program just a speed S2000

If the spindle is running it will change. If the spindle is not running it will change but not start. When you later start the spindle it will be at the new RPM.

When you program just a speed the machine becomes a smart arse. It laughs at you saying “Fuck off sucker, I’m not starting the spindle cos you didn’t ask me”

Wasted Code

When I first started programming CNC machines in 1905 each program had loads of information at the beginning. None of us knew what the fuck it meant and no-one dared to alter it or take any of it out.

It could only be altered after a religious ceremony and the ritual slaughter of a Gerbil when there was a full moon.



Did someone say Gerbil

You could be fired on the spot for even talking about these G Codes.

If only we had known about Modal and non modal G codes life would have been so much better.
So now I am all grown up, I say “do everything for a reason”. Consider your Modal and non modal G codes.

The program on the right has wasted code.


Oh and in the early day’s we often used to turn the machine off and back on again which usually sorted most problems.

No one knew why the fuck we did this but because it seemed to work we always did it.

Women often say why do men keep putting their hands down their pants. The answer is we don’t know but we do it anyway. Well I don’t know maybe you do know why.

Coming back to turning the machine off and on again. Imagine if you didn’t have a G50 in your CNC lathe program and it was set to a very low speed in another program that you had just been running.

You could wonder why you machine was running so slow. Obviously if you turn the machine off this would reset. Everything would work fine again.

So let’s see how this works.

You may want to include this line at the beginning of your program as a standard thing.

G40 G80 G90 G21

G40 Cancel tool radius compensation.
G80 Cancel canned cycle.
G90 If you state this at the beginning of each tool then you don’t need this at the start of the program.
G21 Metric, if you never change to inches you don’t need this at program start.

Here is an article on well set out CNC Code.

Anyway if you must write a load of bollocks at the beginning of your program please learn what each G Code means and why it’s there. Oh and don’t blame me when your fingers wear out.

It’s just not good enough to say “the bloke on nights always puts that in”

And That’s Not All with Modal and non modal G codes

If you are running short on memory these are things to look at. Some CAD systems will output loads of unnecessary shit but you need to sort your post processor to stop this. It’s quite easy to fix. Loads of leading and trailing zeros to get rid of.

X0.000 same as:
X050.000 same as:

Feed-rates are modal too so you only need to state them once and then again when you wish to change them. 

It is best to state all of the modal information you require at the start of each section of code. Just after the tool change is the best place.

Try to program each tool as a section, as if it were a program on it’s own.

Each tool should have all the necessary information to run on its own. Nothing should be assumed at the start of each tool. Oh and always take into account Modal and non modal G codes.

Modal and none modal G codes

But There is a Catch

Be careful when using MDI with Modal and non modal G codes as you do not know what G codes are active. All controls will have a screen displaying active G codes.

There are loads of them on this screen, don’t worry if you don’t know what they all are (even Fanuc don’t really know, they just make them up).

How Can you Actually Use This?

If for example in a section of program you have only one feed rate then that is all you will need to alter. If it’s repeated in several places (which your pesky CAD  system may do). Then you will need to remember to change each one.

I very much doubt that you enjoyed reading this article but their are loads more

Loads of articles on CNC Programming, enjoy yourself:

Checking CNC Programmes

Using a Decimal Point

CNC Programming

Zeros Not required on Haas Control


G0 Cancels Canned Cycle

Modal and non Modal

G28 Verses G53

An introduction to Macro Programming

Just an Address will do…

Turning Basics G50

Letter O number Zero

Running Order

Leading and Trailing Zeros

Jumping Sections of Program

Well Set Out Code

Thanks for reading my article.

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.
  • CNC lathe training
  • CNC Vertical Machining Centre training
  • If you have won the lottery and you want to give some money away.

Services offered at CNC Training Centre

Classroom programmer training.

Onsite CNC Machine Training.

CNC Programming and 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.

G91 Non modal Haas Setting 29

Now I don’t want to appear sexist here but sometimes my wife will be awake at night worrying about whether or not she left a gas ring turned on.

Now me I worry about different things I mean how can you compare a gas explosion to a collision on a CNC Machine.

(I really should clean that cooker)

Anyway my point is if you worry about G91 and if you left one active in a program and it causes a collision.

Help is at hand. Now this maybe another piece of useless shit and you might wish you had stayed on Facebook, reading your mates post, ruminating on the benefits of vegan cheese and how you can’t tell the difference. (I have tried and it’s really nice once you get the thought of eating semtex out of your brain).

Don’t set me off about vegans. Just answer one question, if they don’t like meat why do they have to keep banging on “I’ve just eaten this burger and you would think it was real beef”

Anyway if you change setting 29

G91 becomes non modal read this article if you need to know more

Anyway what it means is that if you wrote some code like this

G90 G0 X0 Y0
G81 G98 Z-20. R1. F100.
G91 X50
G90 X100.

You would have to write it like this

G90 G0 X0 Y0
G81 G98 Z-20. R1. F100.
G91 X50
G91 X10.
G91 X20.
G91 X30.
X100. (This would go back to G90 automatically)

“That’s daft” I hear you say.

Well not really because it means that if you ever forget to switch back to absolute (G90) it doesn’t matter because it never got swapped in the first place.

Every time you want G91 you need to write it in that block of code.

 Best Website with Crack Program:

Using Macro System Variables

Category : Macro New Stuff

Macro System Variables, I often get random emails from people asking me all sorts of questions.

I got one only the other day it began “Hi David, your articles are shit”

I don’t answer every email I get, but I try to answer when I think there is an appropriate response or I feel I can help.

Macro System Variables

Macro System Variables

Anyway someone called Neil from America (I think) asked me if I would create a tool setting macro. This involves using Macro System Variables

There is a really annoying thing on a Fanuc control (well actually there are quite a few). This one really pisses me off because I find myself making excuses for the control. I mean like I designed the fuckin thing.

For one, I am nowhere near clever enough and don’t even work for Fanuc. (I am available Mr. Fanuc, sorry I dissed your control)

To set a tool length it’s a really convoluted procedure. You first zero out the Z on the REL display.

You then bring down a tool and get the control to record the Z position by pressing Z then the soft key INP C.

Macro System Variables

Here’s a couple of videos showing you how.

Origin Z

Use INP C to Enter Offset


Once the Z has been set you can measure as many tools as you want. Just bring each tool down to the setting block and press Z then  INP C.

Macro System Variables

Here comes the problem…..

If you turn turn off the machine or, for some reason, you have to reference it again you will lose your REL Z position. You will now have to set it again.

Oh and if you don’t notice you’ll be in deep shit. (Your tool length will be wrong!!!)

There are ways around this by using a work offset, but to be honest it’s all a pain in the fuckin arse.

Oh and one other thing. Make sure you write the offset to the correct tool because you can write it to any tool.


Check the Z zero position each time before setting tools.

A good guide is to slap a good old steel rule or a tape measure against the tool for a rough check.

Macro System Variables to the Rescue

For years I have used a work around on Fanuc Controls. First of all you need to establish where your setting block is. In my case it’s a table probe.

Oh and you need macro (it is an option so if you don’t have it look away now.

To do this you need to note down your machine position in Z when you touch your block or setting probe.

This will later be stored in a variable to be used to calculate the tool length.

Try to set your block in a known position so that each time the Z figure is the same. You may even be able to fix it to the machines table. Don’t weld it, the boss won’t like it.

Read on to see how this variable can be written to automatically with a calibration programme.

The Programme…  OK Let’s Do This

  1. Bring the spindle nose down to touch your setting block. this is the value you will write into #102 (Mine says -500.877)
  2. Call your tool to be measured into the spindle in MDI (T06 M06;)
  3. Bring the tool down to the setting probe.
  4. Run the programme below.

O9001(Tool Measurement Macro)
1.  #100=#4120 (Grab Tool Number);
This will cause the machine to store the current tool number in #100

2. #101=#5023 (Store Machine Z Position);
This will cause the machine to store the current Z position in #101 

3. #102=-500.877 (Setting Block Z);
This is the figure you recorded from the position of the setting block.

4. #150=#102-#101 (Calculate Tool Length);
Now we can calculate the tool length by taking the known position from the current position.

This will give us a minus figure, we will reverse this in the code below.

5. #150=-#150 (Reverse Z Figure);

6. G90 G10 L10 P#100 R#150
This puts the tool length into the correct offset.

7. G28 G91 Z0 (Return Z To Zero Return);
8. G90;

More Explanation (Macro System Variables)

System variables know shit.

What I mean by this is that system variables contain information about the system. Some are read only and some you can write to, like the tool offsets for instance.

You can ask the system loads of stuff like.

  • What speed do you have stored?
  • What’s the tool in the spindle?
  • What position are you in?
  • What modal G codes do you have.
  • How old is my auntie Joan?
  • Do I have a fat arse?

These are all stored in special Macro System Variables except the last two.

You can read them and sometimes you can write to them. It’s not like that bloke at work who thinks he knows every fuckin thing. Sometimes he’ll listen, but most of the time he has to tell you.

No, no macro system variables follow special rules.

Anyway (The Explanation)

O9001(Tool Measurement Macro)

1.  #100=#4120 (Grab Tool Number);

2. #101=#5023 (Store Machine Z Position);

3. #102=-500.877 (Setting Block Z);

4. #150=#102-#101 (Calculate Tool Length);

5. #150=-#150 (Reverse Z Figure);

6. G90 G10 L10 P#100 R#150

7. G28 G91 Z0 (Return Z To Zero Return);
8. G90;

The first line 1. looks into system variable #4120 which contains the number of the current tool in the spindle.

You ask what this is and then put it in #100. Obviously you can’t write to this variable.

The next line 2. asks where the machine is in Z (Machine Position) #5023. Again you can’t write to this but you can store it in #101.

Line 3. stores the value that you measured early in #102. This is where your measuring block is from zero return.

In line 4. you take these values away from one another to give you the tool length

Macro System Variables

This ends up as a minus figure so we need to reverse it. We do this on line 5.

5. #150=-#150 (Reverse Z Figure);

6. G90 G10 L10 P#100 R#150

Line 6. is a standard G10 because we have L10 this means it writes to tool lengths. P is the tool number and R is the tool length.

I always stick a G90 at the front of this G10 in case some twat  leaves the machine in G91 in which case it will add to the existing tool length. (Oh dear total fuckin dog shit mayhem)

So You Want To Use Macro Like An Adult?

Lots of programmers use macro in a very complex and confusing way but I think that is the way they want it so you think “wow he must be a clever bastard.

In my opinion a good macro should have a really simple interface.

I’ll show you mine.


Yep that’s all it is

M200 is aliased to my programme O9001 meaning if you run M200 it goes into my programme 9001 and returns.

Don’t forget you can run M200 in MDI too.

Read this article if you don’t know how to alias a macro to an M code or a G code.

More Macro System Variables

Now what we could also do is when we bring the spindle nose down to set the original Z figure, we could make the machine store this in #500 instead of my #102

500 series variables stay in the control even when it’s switched off. These variables are the cockroaches of macro programming (they survive anything).

In the event of a nuclear war the survivors would be as follows:

  • 500 system variables
  • Some cockroaches.
  • Ozzy Osbourne.
  • Keith Richards.
  • My mother in law.

The code for this is really simple. Just one line in fact,

All you need do is bring your spindle down to the setting block. Then run M300, which I have aliased to programme 9002

Or if you like just run programme 9002

O9002 (Calibrate Table Block);
#500=#5023 (Z Machine Position);

Word Of Caution

Don’t use M99 at the end of your Macro unless you are calling it with an M Code Alias. Otherwise it will be stuck in a never ending loop.

So Now It’s Simple

Bring the spindle down to setting block and run M300.

This sets #500. If the block is in the same place then this is not needed.

Call the tool you want to measure to the spindle in MDI otherwise it won’t be registered in #4120

T20 M06;

Bring the tool down to the block and run M200.

Or simply type M200 into MDI and run it.

This will then store the tool length in the correct offset.

Please contact me if you require:

  • Fanuc training.
  • CNC programmer training.
  • Want to Learn CNC programming.
  • Fanuc programming   training.
  • Any type of CNC course.

Don’t forget to watch my Tutorial Videos

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

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

[contact-form-7 id=”2706″ title=”Contact Form”]


G96, G97 and How To Calculate Surface Speeds

Basic Turning

Basic Turning
G96 Hamsters Large wheel Small wheel
Call us for CNC Training and hamsters

Basic Turning, in the early days of CNC Turning G96 was one of the things that really made a massive difference.

It meant that instead of having to turn a part at a fixed speed and feed, the part could be programmed in G96 which was a constant surface speed.

Where diameters changed, particularly when facing, it made a massive improvement to tool life and surface finish as well as speeding up the whole process.

G97 Speed In RPM

In Basic Turning when you program G97 your machine will start the chuck up at a speed in RPM. So if you program.
G97 S1500 M3
Your chuck will start revolving clockwise at 1500 rpm.

G97 for Drilling Tapping and Screwcutting

When drilling  a hole you are on the centreline of the machine so you just want plain old simple RPM.

When tapping or spot drilling it’s the same.

Screw Threading (G76) can only be done in G97


G96 however means meters per minute. This is a surface speed.
G96 S200 M3
Your machine would start up at a surface speed of 200 meters a minute. Now your RPM would depend on where on the diameter the tool was positioned.

Basic Turning

If the tool was positioned  at a 100mm diameter it would be as if the tool were able to run around this diameter at  a speed 200 meters a minute.
It’s a bit like being on a running machine if you ran at 200 meters a minute and placed various diameters under your feet the large ones would turn at slow rpm and the small ones would turn at high rpm. (Just like the hamsters above)

Basic Turning

 That’s why on a manual lathe it is hard to face a large diameter without changing speed half way.


You know when you face a part on a CNC Lathe and you hear that change in pitch? It’s the spindle increasing in RPM as it gets closer to the center of the part.

When it gets to the center your spindle is flat out so the G50 becomes crucial.

The G50 restricts the speed of the machine.

G50 S2000 machine will go no higher than 2000 rpm.


G96 G97 hamster on a Wheel

Did you have a pet hamster as a child?

I know it’s a random question but bear with me there is a point to this.

Well maybe you still have a Hamster and that’s not a problem. Time you fuckin grew up but it’s not for me to judge.

Anyway I did and his name was Harold Wilson (British Prime Minister at the time).

Well I bought my hamster loads of different wheels to play on just like the one above.

My hamster suffered with depression on account of being stuck in a cage all day and not having a girlfriend oh and he had a lot of credit card debts too.

These wheels varied in diameter from about 6 inches to a massive 2 foot one. They kept him happy all night. He was so tired he slept all day.

Harold could only run so fast but I noticed when he was on the small 6 inch wheel it absolutely whizzed around. Now on the big two foot diameter one it took him ages just to get it to spin around once.

Basic Turning
G96 G97 all about hamsters

Harold Had G96

A CNC machine in G96 will give a lovely finish because the surface speed always remains the same.

So even though Harold ran at 200 metres a minute (this is fuckin lightening speed for a hamster)

The wheels ran at different RPM depending on what diameter they were.

Harold Was a Clever Bastard

Oh by the way Harold had a tail (unlike other hamsters) and a maths qualification.

He knew that if he multiplied the diameter of the wheel by .00312 it would give him the circumference of whatever wheel he was running on in meters.

200 mm wheel (.00312 x 200 = .6864)

All he now needed to do was divide this answer into the speed he was running at and he would know how many RPM his wheel was revolving at.

If he was running at 200 meters a minute not only would he be fuckin knackered but the wheel would be running at 291 rpm

200 / .6864 = 291

Basic Turning Manual Machining

Using a manual machine you have to compromise. At the outside your speed is too fast and when you get to the centre you are too slow.

Manual Lathe

On a CNC lathe we would normally program in mm per revolution as well because the speed is changing all the time so we need our feed to be locked into the speed.
With a machining centre our cutter is always revolving at the same speed so the feed can be constant in mm per minute.

Someone out there will be thinking “what happens in G96 when you get to the centre of the part”. Well the spindle will be flat out!

Could be a problem. That’s where your G50 comes in to restrict the speed. Very important! CNC Basics G50

cnc turning basics
G50 Warning

Watch the video

See how surface speeds are translated to speeds in RPM. There are many converters online that you can use for this and I do recommend their use. It will also mean you don’t have to watch my tedious video.
When I train people at the CNC Training Centre my emphasis is on understanding not memorising. I usually start by saying “please don’t remember all the things I am telling you”.

 In the early days training students in Basic Turning I remember them saying to me the next day that they had G codes floating around in their head from the lessons the day before.

Basic Turning
G96 and G97

What I really mean is that the most important thing is to understand what the machine can do and the concepts of programming and Basic Turning.
You could say “I know there is a G code that makes the machine run in RPM” so all you need is a list of G codes.

If you can be bothered to work through the simple maths above. It will help you to fully understand how G96 is works.

Here is a list of Basic Turning G Codes.

The ones you use every day you will remember whether you want to or not.

G96 Whoopee It’s amazing

So use G96 for everything.

Except for:

  • Drilling.
  • Tapping
  • Threading (Screw cutting)
  • Cutting the Lawn

If you feel you have been affected by any of the issues mentioned in this post please Contact me

If you liked this video, please don’t forget to subscribe to my YouTube channel by going to: CNC Training Centre

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.

Classroom programmer training.

Onsite CNC Machine Training.

CNC 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.

WP to LinkedIn Auto Publish Powered By :