G Code Groups What Use Are They?

G Code Groups What Use Are They?

Category : Fanuc Haas New Stuff

G Code Groups, every G code is in a group and I remember looking at G codes for years thinking why on earth do they do that?

I thought it was just to satisfy the geeks, it gave them more bullshit to talk about and confuse the shit out of me.

Anyway now I’m all grown up, I know exactly why G Codes are in groups.

The good news is today I am going to tell you why and….. I am going to give you a practical example.

(Be sure to read on for a free cheese on toast recipe)

Here is a list of G codes and the groups that they are in

G Code
G Code List with Groups

Hass G Code Groups do vary a little.

Now I know this is boring but please try to keep focused it gets exciting soon honestly.

If you are loosing the will to live already then off you go, this video is amazing.

I know it’s only two of us now but I will carry on. I wrote this article a bit back about macro for the over 18’s.

When you start to write serious macros you need to write alarms to protect the operator just in case he types in bollocks instead of an R number or some such thing. I told you all about this in another article.

Anyway there is also a thing I call tidying up after yourself. This is not like when you cook a meal and your ungrateful boyfriend expects you to tidy up the kitchen just because it looks like a post war bomb site.

I made cheese on toast and I must say it tasted great. Cooking’s got to be easier than this G Code shit.

Simple G Code Cheese On Toast

Ingredients and Tools
Cheese
Toast
Blow torch

Method:
Melt cheese onto toast with a blow torch
Always Wash Your Hands Before Cooking (especially if you just took a shit)

Tidy Up Your Mom Does Not work Here

I honestly thought all baths were self cleaning till I moved in with my girlfriend.

What this is about is putting things back as they were. So the G Codes that were in use before going into your macro need to be restored before coming back out of the macro.

For example most machines when you issue an M6 command jump into a macro programme. See this article

The macro programme might look something like this.

09101                           (TOOL CHANGE MACRO)
G80G40G49             (CANCEL ACTIVE G CODE) 
M9                               (COOLANT OFF)
G28 G91 Z0              (SEND TOOL BACK TO ZERO)
M19                             (SPINDLE ORIENTATION)
M6                               (TOOL CHANGE)
M99

What this macro actually does is all the crap you can’t be arsed with.

In your main programme you would have to do all this every time you want a tool change. You don’t see any of this because the programme is not visible. The M6 aliases programme 9101. 

The machine knows you are too fuckin thick to understand it so it hides it away.

But Not Anymore

So when you programme M6 you get programme 9101 running behind the scenes.

So as I said your an advanced G Code programmer now so I expect a bit more from you. “What me” you say. “Yes you” I saw it on your CV”.

Oh and you just swapped the control into G91 in the macro above (you naughty boy)

So for example if the machines was in rapid G0 and absolute G90 the guy who called the tool-change will expect it to stay that way.

G28 G91 Z0 (THE EVIDENCE)

So when the control comes out of your tool change macro it’s in G91, not good.

This could easily cause a collision. You say “ah but the programmer should use G90 when he states the first position”.

Right, We Need To Talk

As I said you are an adult now and in the adult world of Macro programming you tidy up and you take responsibility for the G codes you change.

I’ll be honest with you now, lots of people who should know better don’t do this. A good example are probing macros.

Anyway what shall we do about it?

We Do This

09101(TOOL CHANGE MACRO)
#1=#4001                  (STORES ACTIVE G CODE IN GROUP 1)
(G0 1 G2 G3)

#3=#4003                (STORES ACTIVE G CODE IN GROUP 3)
(G90 G91)

#14=#4014             (STORES ACTIVE G CODE IN GROUP 14)
(G54 G55 G56 G57 G58 G59)

G80G40G49             (CANCEL EVERYTHING) 
M9                               (COOLANT OFF)
G28 G91 Z0              (SEND TOOL BACK TO ZERO)
M19                             (SPINDLE ORIENTATION)
M6

G#1 G#3 G#14            (RESTORE G CODES)
M99

OK What’s Going On Here

#1=#4001(STORES G CODE GROUP 1)
(G0 1 G2 G3)

#3=#4003(STORES G CODE GROUP 3)
(G90 G91)

#14=#4014(STORES G CODE GROUP 14)
(G54 G55 G56 G57 G58 G59)

The lines above take the G codes from three groups.

  • G0 G1 G2 G3
  • G90 G91
  • G54 G55 G56 G57 G58 G59

It stores those values in #1 #3 and #14

So if the machine were in feed (G1) it would store 1 in #1

If the machine were in absolute (G90) it would store 90 in #3

And if the machine were in work offset G59 it would store 59 in #14

The four thousand system variable looks into the various G code groups.

Now Let’s Magic Them Back

Magic Back The G Codes

Restore The G Code Groups

At the end of the programme we have

G#1 G#3G#14

Which is the same as.

G1 G90 G59

This would depend on the state of the machines before you went into the macro.

So what we have done is restore the G codes back to their original values before we started tampering with them.

That way if the machine crashes you can say “look mate I never touched a thing”

 


Log out of this account

Leave a Reply

WP to LinkedIn Auto Publish Powered By : XYZScripts.com