ItpWriteRParams

ItpWriteRParams 1:

The ItpWriteRParams function block writes R-parameters into the NC.

ItpWriteRParams 2:

Outdated version

The sole purpose of the function block is to ensure compatibility with existing projects. For new projects please use the function block ItpWriteRParamsEx.

VAR_INPUT

VAR_INPUT
    bExecute       : BOOL;
    nChnId         : UDINT;
    pAddr          : PVOID;
    nIndex         : DINT;
    nCount         : DINT;
    tTimeOut       : TIME;
END_VAR

bExecute: A rising edge starts the write operation.

nChnId: ID of the NC channel whose R-parameters are to be written.

pAddr: Address of the variables containing the data to be written. Data are used directly from the specified address, i.e. nIndex is not to be interpreted as offset from pAddr. The data are usually in an array of type LREAL, which has to be defined by the user.

nIndex: Describes the index of the R-parameter to be written from an NC perspective.

nCount: Number of R-parameters to be written

tTimeOut: ADS Timeout-Delay

VAR_OUTPUT

VAR_OUTPUT
    bBusy     : BOOL;
    bErr      : BOOL;
    nErrId    : UDINT;
END_VAR

bBusy: This output remains TRUE until the function block has executed a command, but at the longest for the duration supplied to the 'Timeout' input. While Busy = TRUE, no new command will be accepted at the inputs. Please note that it is not the execution of the service but its acceptance whose time is monitored.

bErr: This output is switched to TRUE as soon as an error occurs during the execution of a command. The command-specific error code is contained in ‘nErrId’. Is reset to FALSE by the execution of a command at the inputs.

nErrId: Contains the command-specific error code of the most recently executed command. Is reset to 0 by the execution of a command at the inputs. The error numbers in ErrId can be looked up in the ADS error documentation or in the NC error documentation (error codes above 0x4000).

Sample

In this example the parameters R90 to R99 are written from an NC perspective.

VAR
    arrfRParam90to99 : ARRAY[0..9] OF LREAL;
    fbWriteRParam    : ItpWriteRParams;
    n                : INT := 0;
    bWriteParam      : BOOL := FALSE;
END_VAR
FOR n:=0 TO 9 DO
    arrfRParam90to99[n] := 90 + n;
END_FOR

fbWriteRParam(
 bExecute := bWriteParam,
 nChnId     := 2,
 pAddr     := ADR( arrfRParam90to99[0] ),
 nIndex     := 90,
 nCount     := 10, 
 tTimeOut := T#200ms );

Requirements

Development environment

Target platform

PLC libraries to be linked

TwinCAT v3.1.0

PC or CX (x86 or x64)

Tc2_NCI