A variable is like a box that you can put numbers in. The box has a name that cannot be changed once given. The inside of the box, the value of the variable, can be changed, though.
A variable is named using a hash sign (#) followed by a number.
This is a variable:
#100
If we want to assign a value to the variable (put a number in the box), we write like this:
#100=12.5
From now on, we can use the variable instead of a fixed number in our CNC program.
Like this:
G00 X50 Y#100
Besides numbers, a variable can also be NULL. It means that it has not got a value assigned to it. NULL and 0 are not the same thing.
There are different ranges of variables.
Variable range
|
Type
|
Function
|
#0
|
NULL
|
#0 is read-only and cannot be given another value than NULL. It is used to set other variables to NULL or to compare variables.
|
#1 - #33
|
Local variables
|
These are used to pass arguments to macros and are local to the macro only.
|
#100 - #199
|
Common variables
|
These are common variables that are shared between macros and main programs. They will be cleared to NULL when a new program starts or when you exit the simulator.
|
#500 - #999
|
Common permanent variables
|
These variables are remembered between runs and even when you exit the simulator.
|
#300 - #399
|
Simulator specific reserved range
|
In this range, which is not used by the Fanuc controller, we store some system values specific to the simulator.
|
#1000 - #9999
|
System variables
|
These variables contain information from the CNC controller or, in this case, the simulator. We have made them empty so users can assign simulator values to any numbers for maximal flexibility. On a Fanuc controller, they are fixed.
|
In your programs, you typically use the common variables. Only use the local ones when you fully understand their behavior. For example, how they change when using nested macros. Be very careful with system variables if you are going to run the program on a real machine, as they can change things in the CNC controller in unexpected ways. In the simulator, you normally use these to read values like the current position, feed, and tools, for example.