Category Archives: Fanuc Mill

Fanuc Display – Relative Position

Category : Fanuc Mill Fanuc Turn


Fanuc Display (Relative Position) is used only by the operator.

Fanuc Display

You can reset Fanuc Display (Relative Position) just like you would on a manual machine with a DRO. So use it for setting or even measurements. One thing to remember is it will not retain it’s position when you turn the machine off. The control in the video is a Fanuc 18i on a big vertical lathe but all other Fanuc controls are similar.

Subscribe to my YouTube channel (I beg you)

“Read More”

Ten Things You Might Not Know About The Fanuc Sub Program

Sub Program Fanuc

Here are ten things you might not know about Fanuc sub programs,

Fanuc CNC controls are the most common controls in the world so it might be useful to have a good understanding of how sub programs are called and used.

(1) You Can Call a Sub Program By Name.

Yes you heard it here the program can be called by it’s name or it’s number. When calling by name don’t use the P.

Just put the name of the program in these things <> with an M98 and your away.


The only problem with this is that the syntax needs to be spot on so if you have got complicated names for your your sub routines then you might be in the shit.

I always call mine names like ALBERT that are easy to remember.

(2) You can use internal sub routines on a Fanuc Control.

Some people call these local sub programs. It just means it’s tagged on the end of your program which makes them nice n easy to look after. A bit like a pet Goldfish or a pet fly.

I bought mine from the local pet store. I asked the assistant if he sold pet flies and he said no. I said “well there are loads in the window”.

Anyway he sold me one (£15) his name is Paul


This is not him this is Steve.

Internal Sub-Routines

By typing M98 Q500 your control will look for N500 within your current program. This is great because you can add the sub programs to the end of your main program. Don’t forget to leave big gaps so you can clearly see where and what they are. Oh and mind your P’s and Q’s.

M98 P500 (Call O500 externally)

M98Q500 (Call N500 in main program.

Oh and read this too.

Sub Program

Just one other thing. Watch your n numbers it’s easy to get them mixed up. Try and use a convention.

This Is What I Do

N1-N99 (Tool change lines)
N26 M6 T26

N100 to N900 (Local Sub routines)

N1000 to N9999 (Anything else)

(3) You Can Jump Back To a Specific N Number

If you put a P at the end of your sub program next to the M99 after completing the sub program it will return to the main program at the corresponding N number.

M99 P800 will make it return to N800 in the main program it came from.

Sub Program

The above example calls sub program O500 when it gets to M99 it returns to the main program. The P800 means it will return at the line N800

Oh by the way I think this is useless but if you can think of a use please let me know.

(4) There Are Two Ways to Call a Sub Program

M98 P500 L4 (Call program O500 four times.

M98 P40500 (Call program O500 four times) watch out as the digits need to be the correct number.

The last four digits are the program number. The digits before them are the number of repetitions.

There must be four digits for the program number so you need the leading zeros (0500).

Sub Program

This method is a bit convoluted but at least I’ve included it and you never know when you might come across it.

I suggest always use the same method.

(5) M99 Has More Than One Use

M99 normally ends a sub-program but it can also be used in a main program to make it continuous. If you replace M30 (Stop and rewind) with M99 the program will constantly loop around. This is useful for multi pallet machines and barfed lathes.

Oh and don’t forget the EOB or you’ll get an alarm.

M99 ;

(6) You can use M99 to Jump over a Section of Code

M99 P100 will jump to N100

Impress your mates with this one it saves an awful lot of block skips


Sub Program

(7) You Can Call Sub-Programs From The MDI Screen

M98 P500 L6 (Call program O500 six Times)

This will work fine in MDI

(8) You Can Use a G or M Code to Call a Sub-Program

You can use a G Code alias to call a sub program. By setting certain parameters you can create your own G code which will then call a program specified by certain parameters.

Read this article

(9) You Can Have an Movement on the Line That Calls a Sub-Program

Although I have often shit my pants proving out programs, I mean an XY or Z movement not a a bowel movement.

X50. M98 P500 machine will move to X50. then call out the sub program.

(10) On your check screen it will show you how many times you have entered your sub program.

Each time you enter a sub program your control will show you a count down.

(11) You Can Call Sub Programs that are Not in Your Current Folder

When you call sub programs the control will look in your current folder. If it is in a different folder you can still call it.

<//from cnc memory/folder/folder/program>

Sub Program

The format for this is really important.

Also you will get a format error when you try and type it in. Easy fix….. go to CHANGE EDITOR

I have nearly 27,000 followers on LinkedIn and it has some real perks. One is that when I couldn’t get this to work. A quick post on LinkedIn got me some clues many thanks to Volker Hänig.

Shit, that’s 11 things.

Try to ignore one of them so there are only 10, maybe the one you already knew



CNC Sub Program

On or Offsite CNC Training
Tel: David 07834 858 407

CNC Sub Program, all CNC machines will have some form of sub programs.

 This article deals with G code (ISO) type programming but most of the features talked about will be available in some form on any CNC control. 

A CNC sub program is a branch from your main program into another program.

After completing this, your control will return to the main program and continue where it left off.

It’s like the branches of a tree.

Sub Program 

Probably the most common use of a CNC Sub Program would be for a tool change position. You could have a sub program which took the machine to a position for tool change. Your machine probably does this anyway but it’s hidden.

The advantage of this is that you could use it for any program and you don’t have to keep writing it. It is going to be very reliable because you know you never touched it. (Honest governor). 

You could use a sub-program for a set of hole positions, call it out once to spot drill and again to drill and again to tap. Just use it as many times as you want.Got to be good for the environment too.

CNC Sub Programme


Some controls have internal sub programs Haas and Yasnac as well as Heidenhain and Siemens have this facility.

You can do it on a certain Fanuc controls but it is an option.

It means you can stuff these at the end of your program and jump into them the same way as you would an external one. 

CNC Sub ProgrammeCNC Sub ProgrammeCNC Sub Programme

Why would I want to do that you say?

Easier to manage is the quick answer.

You know when you save your main program there are no pesky sub programs lurking that you forgot to save. They are all built into your main program.

Normally you would call your sub-program once only and you don’t need to tell it “oh I want this once” it says “come on mate I know that I’m not stupid.

But you can call it several times and if you get into incremental programming, and I hope you do, you will definitely find a need for this.

Sometimes with sub-programs it’s what you don’t put in that matters. What I mean is if your milling and you put the feed in the sub-program you are stuck with it. If it’s not there then you can state the feed externally and use a different one every time.

On Machines Like The BMC 800 from Toshiba

Tosnuc 888

This machine has the Tosnuc 888 control.

It uses G72 followed by the dollar sign, oh and for the repeat command it uses L but don’t forget the comma.


Yes Tosnuc uses anything for a program name up to eight characters. So that it doesn’t get confused by the L you have to put in a comma.

Tosnuc 888

By the way on this control (Tosnuc 888) you don’t use M99 at the end of your sub program you just use M30 and it works correctly.

Don’t try this on your Fanuc or Haas control as M30 means stop and rewind and that’s what it will do. Then it will just sit laughing at you.

Ok now you can watch the video.

CNC Milling sub programming examples.


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:

  • Fanuc training.
  • CNC programming training.
  • Want to learn CNC programming.
  • Fanuc programming training.
  • Yasnac programming training.
  • Any type of CNC course.

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.

Modal and non modal G codes

On or Offsite CNC Training
Tel: David 07834 858 407

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.

G84 Rigid Tapping Program Example

G84 Rigid Tapping Program Example

For On-site CNC Training Contact David: 0783 858 407

G84 is a tapping canned cycle.

G84 taps holes.

This simple part has four M12 holes, drilled, countersunk and tapped. The datum is the centre of the part so the holes positions are.

X55. Y55.
X-55. Y55.
X-55. Y-55.
X55. Y-55.

G84 Rigid Tapping Program Example

G84 Rigid Tapping Program Example

Here is the CNC code

G84 Rigid Tapping Program Example

The machine first moves to X-55. Y-55. and rapids the Z axis to 3mm above the part.

G84 Rigid Tapping Program Example

The G95 selects feed per revolution which means we only need to program the tap pitch for the feed-rate.

See full rigid tap G84 Rigid Tapping Program Example

The M29 engages the rigid tapping mode and the S800 is the speed. (It does not start the spindle)

It then rapids the Z axis down to 1mm above the part R1.

The G84 Cycle instructs it to tap a hole deep (Z-17.) at a feed of 1.75mm per revolution (F1.75) 

So it feeds at 1.75mm per revolution with the spindle turning clockwise to depth.

At the bottom of the hole it reverses the spindle and feeds back to the initial point.

This initial point was in the line.

G84 Rigid Tapping Program Example

This is because of the G98.

If it were G99 it would return to 1mm above the job (R1.)

See explanation of G98 and G99

Once the cycle is active each time it sees a position it repeats the tapping process.

When the G80 is programmed it no longer taps holes.

Single block and feedhold do not work in a tapping cycle.

Why? You ask.


Now watch the video to see it all in action (not breaking the tap).


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




WP to LinkedIn Auto Publish Powered By :