ADSREADEX

ADSREADEX 1:

This function block allows execution of an ADS read command, to request data from an ADS device.

VAR_INPUT

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

T_AmsNetId

T_AmsPort

NETID : is a string containing the AMS network ID of the target device to which the ADS command is directed.   

PORT : contains the port number of the ADS device.

IDXGRP : contains the 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 : contains the 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 : contains the number of data to be read in bytes.

DESTADDR : contains the address of the buffer which is to receive the data that has been read. The programmer is himself responsible for dimensioning the buffer to a size that can accept 'LEN' bytes. The buffer can be a single variable, an array or a structure, whose address can be found with the ADR operator.

READ : the ADS command is triggered by a rising edge at this input.

TMOUT : specifies the time until the abortion of the function.

VAR_OUTPUT

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

BUSY : if the function block is activated, this output is set. It remains set until feedback is received.

ERR : if an ADS error should occur during the transfer of the command, then this output is set once the BUSY output is reset.

ERRID: supplies the ADS error number or the device-specific error number when the ERR output is set.

COUNT_R: number of successfully read data bytes.

 

Sample of a call in FBD:

PROGRAM MAIN
VAR
    fbAdsReadEx : ADSREADEX;
    bRead       : BOOL;
    bBusy       : BOOL;
    bError      : BOOL;
    nErrId      : UDINT;
    cbRead      : UDINT;
    Buffer      : ARRAY[1..10] OF BYTE;
END_VAR

ADSREADEX 2:

In this sample, an ADS read command is sent to an ADS device with network address '172.16.2.209.1.1' and port number 801. This port number could, for instance, be used to address the PLC's first runtime system. The service to be executed is encoded in the index group and the index offset parameters. Here, 10 bytes of PLC variable data in the flags area are to be read starting from byte offset 100. If successful, 10 bytes of data are copied to the address of the Buffer variable.

 

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v2.7.0 & TwinCAT v2.8.0

BC9xxx (165) firmware version >= 0xB6

TcAdsBC.Lb6