Modal and non modal G codes

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.

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)
Y50.
(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

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)

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.

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.

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

What’s This all About?

This is what G codes 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 parameter.

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

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 “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 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 a ritual slaughter when there was a full moon.

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.

Modal non Modal G Codes

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 it means and what it is all for. Oh and don’t blame me when your fingers wear out.

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.

Feed-rates are the same 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. 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’re just made 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 CAD system may do). Then you will need to remember to change each one.

That’s not all

Loads of articles on CNC Programming, enjoy yourself:

Checking CNC Programmes

Using a Decimal Point

CNC Programming

Zeros Not required on Haas Control

Sub-Programming

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:

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.


Log out of this account

Leave a Reply

CNC Training Centre
WP to LinkedIn Auto Publish Powered By : XYZScripts.com