Using Variables

 

Syntax

$<variable name>$

Valid IEC base types for variables and expressions: INT, SINT, USINT, UINT, DINT, UDINT, BYTE, WORD, DWORD, REAL, and LREAL. Excep­tions are the O parameter for M functions (which expects a variable of type SMC_M_PARAMETERS) and G36/G37 (where string variables are also permitted).

Variables or expressions can be defined for all words, except N words (line numbers). IEC expressions and variables are replaced by their current values only in the online decoder function block. This happens when the line is decoded, which is some time before the element is processed in the interpolator.

The value of a variable in offline mode is set by using the command Set variables in the CNC menu or in the Properties view of the CNC object.

Example

$CNC[1].X$

Global array element of a structure

Behavior in online mode

When the decoder function block processes the program online as a program variable with SMC_CNC_REF, variables can be used. The vari­ables are replaced at the time when the decoder processes the respec­tive line. Using variables in G code programs that are read online requires additional preparation with SMC_VARLIST. If the CNC program is compiled as SMC_OUTQUEUE, then the variable mechanism does not work, because the path is generated offline and passed as an unchange­able data structure of the application. In this case, the editor replaces the variable with its offline value for display in offline mode.

See also