Syntax
$<variable name>$
Valid IEC base types for variables and expressions: INT
, SINT
, USINT
, UINT
, DINT
, UDINT
, BYTE
, WORD
, DWORD
, REAL
, and LREAL
. Exceptions include 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 (block numbers). IEC expressions and variables are replaced by their current values only in the online decoder POU. 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 changed in the Offline values of variables dialog. You open the dialog by means of the command or the Variables button in the properties of the CNC object.
Using a global variable in offline mode
Declare the variables in the global variable list.
Use the variables in the CNC editor in at least one location.
Execute the
command.⇒ The Offline values of variables dialog opens.
Specify the desired values in the table.
Example
VAR_GLOBAL
rVal_x1: REAL:=100;
rVal_y1: REAL:=50;
END_VAR
// CNC-Editor
N0 G01 X$rVal_x1$ Y0 F50 E30 E-30
N10 G01 X0 Y$rVal_y1$
N20 G01 X0 Y0
Behavior in online mode
When the decoder POU processes the program online as a program variable with SMC_CNC_REF
, variables can be used. The variables are replaced at the time when the decoder processes the respective 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. This is because the path is generated offline and passed as an unchangeable data structure of the application. In this case, the editor replaces the variable with its offline value for display in offline mode.
See also