Variables and calculation of variables

A complete variable programming list is contained in the overview of commands under Variable programming (V.).

On the one hand, variables mean an internal data item of the decoder with fixed name assignment; on the other hand, they refer to self-defined variables whose designation is essentially freely selectable. With the exception of external variables (V.E...), their validity and utilisation are limited exclusively to a particular NC channel.

General syntax:

V.<NAME_1>.<NAME_2>.<NAME_3>.{<NAME_n>.}

V.

indicates access to the variables

<NAME_1>.

Defines the global data designation:

 

"A."

represents axis-specific variables

"SPDL."

"SPDL_PROG."

represents spindle-specific variables

"G."

represents inter-axis variables globally valid in the channel

"E."

represents external variables

"P."

represents self-defined variables valid up to the end of the main program (M2, M30),

"S."

represents self-defined variables valid throughout the main program.

"L."

represents self-defined local variables that are valid until the current program level is left by return (M17, M29),

"CYC."

represents variables that may only be used in cycle programs (L CYCLE).

<NAME_2>.

specifies the data name

<NAME_3>.

e.g. indicates the index if a distinction is made between several identical data.

Programming axis identification

The last identification code represents the axis code of axis-specific and several group-specific variables. Here, the designations

                                             ".X" or "[0]"

                                             ".Y" or "[1]"

                                             ".Z" or "[2]"

must be selectively used if the name "X" is assigned to the axis with the index 0, the name "Y" is assigned to the axis with the index 1 and the name "Z" is assigned to the axis with index 2 in the channel parameter list.

Example

Absolute value of the X axis:

Example

Logical axis number of the S spindle:

Programming Example

The lines N20/N30 cause a linear interpolation in X direction by the value of the variables V.A.BZP.Y, i.e. the reference point offset in Y direction.

N10 G92 X0 Y40 Z0
;Reference point offset
N20 G91 G01 F1000 XV.A.BZP.Y
N30 XV.A.BZP[1]
;here: axis index 1 == Y
N40 M30

The content can be read by all variables and a value can also be assigned to several of them. The access type is firmly given for each variable, however generally only a reading access is allowed. Because for most of the variables a writing access is not practical.

Programming Example

Here, the 2nd zero offset vector for the axis with the index 1 is assigned the value 100:

N10 V.G.NP[2].V[1] = 100
...

The EXIST function (see Section Arithmetical expressions <expr>) checks whether a variable exists at all.

Programming Example

The EXIST request for an axis-specific variable checks whether a specific axis is found at all in the NC channel.

N10 G90 Y0
N20 $IF EXIST[V.A.LOG_AX_NR.X] == TRUE
N30 X-10
;X axis is in channel, approach position –10
N40 $ELSE
N50 #CALL AX [X,1,0]
;X axis not in channel, request first
N60 $ENDIF
M30

Before access to an external variable, a check is made whether access is possible at all:

N10 G90 Y0
N20 $IF EXIST[V.E.POS_1] == TRUE
N30 XV.E.POS_1
;Move X axis to position POS_1
N40 $ELSE
N50 #MSG ["V.E.POS_1 not found!"]
;message is output.
N55 M0
;Stop
N60 $ENDIF
M30