We have an Andi CNC with a Fanuc 18I controller. I am just learning how to do custom macros and parametric programming, and do not completely understand the different types of variables described in the manual. They talk about local variable #1 - #33, and common variables #100 - #149 and #50 - #531. Are the local variables the same variables I am probably using to set my diameter and height offsets with (i.e. when I use H14, and go to my offset screen and set variable 14)? If that is true, when I page through my variables, I cannot get to variables higher than 99. Also, if I am using variables 500 and up, do I need to set the initial value of these in the program itself, or is there a variable screen I can go to to set these?
This assumes you are using a Fanuc controller… There are 3 types of variables - Local, Common and System variables.
Local variables are "local" to the program that is currently executing. They can be set and read only in that program. As soon as control is passed to another program, such as when a subprogram is called, that program has its own set of local variables which can be set, read, etc. When control passes back to the original program, its set of local variables is restored. For instance, if you set variable #1 to 100 in the main program, then call a subprogram, var #1 is now empty. You can set and use var #1 in the sub without overwriting the value of #1 in the main. When you return to the main program, var #1 retains its original value of 100. This is useful because you can use local variables at will within subprograms without having to keep track of the local variables you are using in other programs for fear of overwriting them. If you watch the macro variable screen as programs execute, you can see the local variable sets change as control is passed from one program to another. You can pass a value to a local variable when calling a subprogram with the G65 command.
Common variables are "common" to all programs. Set the variable in one program and *all* of the other programs see the same value. They are retained even after program execution stops. They can be set within a program or by the operator on the macro variable screen. You can even create screen labels for some of them to make it easier for operators to set values. One of the things that we use them for is when we have a choice of profiles on a part. The operator can set variable 500, which may have a screen label of "PROFILE#", to the desired profile number and then the program uses this to select the correct tool, spindle, cutter comp and height offset.
System variables are special variables that represent values in various registers of the control. For instance, when you call H14, you are referring to offset register 14. The value of offset register 14 can be read or set by accessing system variable #2014. Some system variables are read only and cannot be set. There are system variables for reading the absolute X, Y, or Z position of the machine (read only). We sometimes use this set of variables to read the machine position if we need to come back to that exact same point after a series of calculated moves which may have introduced rounding errors when executed.
All of this should be in your operator manual. If you don't have one, get one! The book is not always clear in its descriptions, so write a lot of little test programs until it is clear just how things work. Always start out simple and work up to the complicated stuff.
Comment from contributor A:
On our Andi machine, you can find the Macro variables by choosing Offset, then using the right arrow button below the screen to see the Macro option.