R-Parameters
Arithmetic Parameters
The arithmetic parameters, for short known as R
-parameters, are interpreter variables that are named by an expression of the form “R<n>”. Since ‘n’ is an integer in the range 0..999
, a total of 1000 R
-parameters are available. The first 900 values R0..R899
of these are local variables for the NC
channel. They can only be accessed by the interpreter of the channel. The R
-parameters R900..R999
are declared globally. They exist only once for each NC
, and all channels access the same storage. This kind of accessibility organization makes it possible to exchange data (e.g. for part tracing, collision avoidance etc.) beyond channel boundaries.
Assigning a Value to an R-Parameter
Assigning a value to an R
-parameter is merely possible within Structured Text. There are two ways of assigning a value to an R
-parameter. The value can be assigned directly or the rSet
function can be employed. The function rSet
is suitable to use when the index of the R
-parameter to be assigned should not be determined until runtime.
Structured Text: Assigning an R-Parameter Value Directly
R<n> := LReal;
Example
!R1 := 7;
Structured Text: Assigning an R-Parameter Value with the “rSet” Function
rSet(index := LINT, value := LREAL)
Example
!rSet(1, 7);
Reading an R-Parameter Value
There are two ways of reading an R
-parameter. An R
-parameter can be used in G
-Code directly or it can be extracted within Structured Text using the rGet
function. The function rGet
extracts an R
-parameter value according to its index.
Structured Text: Reading an R-Parameter Value with the “rGet” Function
rGet(index := LINT) : LREAL
G-Code Example: Extracting an R-Parameter Value Directly
!R1 := 7;
N10 G01 X=R1 F6000
G-Code Example: Extracting an R-Parameter Value with the “rGet” Function
!R1 := 7;
N10 G01 X={rGet(1)} F6000
Example: Assigning and Extracting
{
VAR
valueR1 : LREAL;
END_VAR
rSet(1, 7);
valueR1 := rGet(1);
R2 := 10;
R3 := R1 + R2;
!N10 G01 X=R1 Y0 Z=R2 F6000
!N20 G01 X={rGet(3)}
MSG(toString('R1 = ', valueR1, ',R2 = ', rGet(2), ', R3 = ', R3));
}
M02
Output:
R1 = 7.000000, R2 = 10.000000, R3 = 17.000000
R-Parameters in Subroutines (Functions) Within a subroutine (function) an |
Requirements
Development Environment | Target System |
---|---|
TwinCAT V3.1.4024.4 or 4022.32 | PC or CX (x86 or x64) |