ADSREAD

ADSREAD 1:

The function block executes an ADS read command to request data from an ADS device.

ADSREAD 2: Inputs

VAR_INPUT
    NETID     : T_AmsNetId;
    PORT      : T_AmsPort;
    IDXGRP    : UDINT;
    IDXOFFS   : UDINT;
    LEN       : UDINT;
    DESTADDR  : PVOID;
    READ      : BOOL;
    TMOUT     : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR

Name

Type

Description

NETID

T_Ams
NetId

String containing the AMS network ID of the target device to which the ADS command is addressed (type: T_AmsNetId).

PORT

T_Ams
Port

Port number of the ADS device (type: T_AmsPort)

IDXGRP

UDINT

Index group number (32-bit, unsigned) of the requested ADS service. This value is to be found in the ADS table of the addressed device.

IDXOFFS

UDINT

Index offset number (32-bit, unsigned) of the requested ADS service. This value is to be found in the ADS table of the addressed device.

LEN

UDINT

Number of data to be read in bytes

DESTADDR

PVOID

Address of the buffer that is to receive the read data. The programmer is responsible for dimensioning the buffer such that it can accommodate LEN bytes. The buffer can be a single variable, an array or a structure, whose address can be found with the ADR operator.

READ

BOOL

The ADS command is triggered by a rising edge at this input.

TMOUT

TIME

Indicates the time before the function is canceled.

ADSREAD 3: Outputs

VAR_OUTPUT
    BUSY    : BOOL;
    ERR     : BOOL;
    ERRID   : UDINT;
END_VAR

Name

Type

Description

BUSY

BOOL

This output remains TRUE until the function block has executed a command, but at the longest for the duration supplied to the Timeout input. No new commands are accepted at the inputs as long as BUSY = TRUE. Note that it is not the execution of the service but its acceptance whose time is monitored.

ERR

BOOL

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 ERRID. If the function block has a timeout error, ERR is TRUE and ERRID is 1861 (hexadecimal 0x745). Is reset to FALSE by the execution of a command at the inputs.

ERRID

UDINT

ADS error code or command-specific error code of the last executed command. Is reset to 0 by the execution of a command at the inputs.

Example of calling the block in ST:

Example of calling the block in FBD:

ADSREAD 4:

Here the error status of axis no. 6, as an element with a size of 4 bytes, is interrogated and written into the dataArr buffer. The IDXGRP 00004006 (hex) and the IDXOFFS 00000001 (hex) can be found in the NC-ADS documentation.

Requirements

Development environment

Target system type

PLC libraries to include (Category group)

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_System (System)