G Code Alias M Code Alias (How to use them)

G Code Alias M Code Alias (How to use them)

Category : Macro

G Code Alias. What is an alias Wikipedia?

Alias, it’s not just about James Bond

Alias, in the case of CNC Programming means you are using a G code or an M code to call a program.

For example you could set up G181 to call program O9010

G181 would be an alias for program O9010

These are special 9000 series programs and you set them in your parameters.

M Code Alias Fanuc Parameter 6080

G Code Alias Fanuc Parameter 6050

If you have a Haas machine it’s parameter 81 to 90 for M code alias.

It’s parameter 91 to 100 for G code alias.

So if you look above at parameter 91.

Then enter 181.

When you write G181 in a program or in MDI.

The control would go into program O9010

Therefore you can use a G code to access O9010 through to O9019. You can’t use any G code it has to be one that is not used.

 

It’s important to check that these 9000 programs are not used by things such as probing cycles. So be sure to check before altering.

The same thing applies with M codes (Programs 9000 to 9009).

You may be asking why you would want to do this. Well it means that you can fully automate your Macro.

You first of all place your macro code in one of these program numbers then when you want to use it you just use the G or M code you allocated to the program.

G Code Alias, M Code Alias, It Gets Way Better

Imagine you set 100 in parameter 81, when you issue an M100 the control will jump into program O9000

G Code Alias

This is very simple but you can see how exciting it can get. I didn’t sleep for a week when I first discovered this. Just make up your own M code to do any old shit you want.

In your parameters you can alter a setting so that 9000 programs can’t be viewed or edited. So no one gets to tinker with your precious code. Below is Haas but you can do it on any control.

Welcome to the grown up world of macro because now you can make an M code that an operator can freely use but never access or alter. So to him it’s just a regular M code.

Oh don’t forget to tell him what it does otherwise he’ll never be arsed to use it.

You may well ask why can you do this with M codes and G codes. Well with M codes that’s really all you can do.

Let me explain….

With a G Code Alias………

You can add parameters. You know like when you use a G81 drilling cycle.

G81 calls a program that drills holes. You control the depth and feed etc with parameters.

Once you call a G81 it knows all about drilling holes. Like when it gets to the bottom it has to get the hell out of there.

G81 Z-20. R1. F100

  • G81 calls the cycle
  • Z-20. is the depth
  • R1. is the point to rapid to
  • F100. is the feedrate

The Z the R and the F are the parameters that pass into the program.

With an M Code Alias………

None of the above. It’s just an M code. Very useful I must say but you can’t pass parameters to it.

Toolchange (Fanuc Controls)

Ever worked on a machine where you have to write extra code to stop the spindle and take the tool up to zero before you can tool change?

Well that’s what M6 does, just tool change.

What most machines do is use an alias for M6.

So it’s not really M6?

Nope…..

M6 uses an alias. So in your parameters you make M6 access a 9000 program. That way you can put any old bollocks in the 9000 program.

When you subsequently use M6 it goes into this program which contains everything you could ever want for a tool-change.

  • Stop spindle
  • Turn off coolant
  • Return Z to zero
  • Feed the dog
  • Change the tool

And all with just an M6.

If you have one of these old machines you could make your own alias.

G Code Alias Passing Parameters?

This is where it gets clever and it gets complicated.

But……

You have me to hold your hand.

OK so you set G181 to access program O9010.

G181 A50. C20. Z-10.

This G181 would pass the values of A, C and Z through to program 9010

9010 would then use the values to do it’s business.

Mmmmm how does that work?

These guys below are know as the macro variable gnomes and each one has his own letter and his own macro variable.

G Code Alias

If you think I’m joking then go into your programming department and ask them. Say you want to learn about the macro variable gnomes.

It took me ages to do those stupid fuckin gnomes. Then I realized it wasn’t even funny but I couldn’t bear to get rid of them.

Below is a table that shows the corresponding variable for each letter. Forget the gnomes, it’s just a failed experiment.

What this means is that if you put a value in A it will register in #1 and if you put a value in Z it will register in #26.

Then in your 9000 series program it can use those values. It’s like a secret way to get information into your macro program.

First of all put 181 in parameter 91.

G Code Alias

 

This means that G181 would call program O9010.

Lets create a drilling program the same s G81  we will call it G181.

It’s no different to G81 but it will demonstrate the use of Alias.

In other words it’s completely fuckin useless but at least I’ll get my point across.

G181 Z-20. R1. F200.

The G181 above will call O9010 and pass the values for Z, R and F into it.

#26 (Z)
#18 (R)
#9  (F)

Remember The List

G Code Alias

This is how O9010 Looks

O9010 (My Drilling Cycle)
G0 Z#18 
G1 Z#26 F#9
G0 Z#18
M99

Explanation

G181 Z-20. R1. F200.

O9010 (My Drilling Cycle Linked to G181)
G0 Z#18
#18 is the value passed from the letter R
R had a value of 1 so #18 is assigned the value 1
The machine will rapid to Z1.

G1 Z#26 F#9
#26 is the value passed from Z
Z had a value of -20. therefore #26 is assigned the value -20
Machine will feed to Z-20.
#9 is the value passed from the letter F
F had a value of 200 so #9 is assigned the value of 200
Machine will use a feed-rate of 200 mm per minute.

G0 Z#18 
#18 is the value passed from the letter R.
R had a value of 1 so #18 is assigned the value 1
Machine will rapid back to Z1.

M99

This is Only the Tip of The Iceberg

See this post for grown up Macro programming

Thanks for watching and reading

If you have been affected by any of the issues in this post or need CNC Counselling then contact me.

Siemens 828 840 Sinumerik Training

Or call us 

If you want to learn to program CNC Milling Machines

Look no further Contact CNC Training Centre


Log out of this account

Leave a Reply

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