FB_ReadAdsSymByName

FB_ReadAdsSymByName 1:

The function block FB_ReadAdsSymByName enables reading of any value from another controller using the symbol name.

On a positive edge at the bRead input the function block reads the value of the variable sVarName from the selected ADS device (e.g. PLC). The ADS device is indicated by the AMS-NetId (sNetId) and the AMS Port number (nPort). The value is written into the variable to which nDestAddr points.

The internal mode of operation of the function block can be changed with the aid of the eComMode input:

FB_ReadAdsSymByName 2: Inputs

VAR_INPUT
    bRead            :  BOOL;
    sNetId           :  T_AmsNetId;
    nPort            :  T_AmsPort := 851;
    sVarName         :  STRING(255);
    nDestAddr        :  PVOID;
    nLen             :  UDINT;
    tTimeout         :  TIME := DEFAULT_ADS_TIMEOUT;
    eComMode         :  E_AdsComMode := eAdsComModeSecureCom;
END_VAR

Name

Type

Description

bRead

BOOL

The function block reads the content of the variables sVarName of the selected ADS device and writes it to the variable to which the pointer nDestAddr points.

sNetId

T_AmsNetID

AMS-NetId of the ADS device from which the value is to be read.

nPort

T_AmsNetID

AMS Port number of the ADS device from which the value is to be read.

sVarName

STRING(255)

Symbol name of the variable to be read on the selected ADS device (max. 255 characters).

nDestAddr

PVOID

Address of the variable into which the read value is written.

nLen

UDINT

Length of the variable to be read in bytes.

tTimeout

TIME

Time until processing is aborted.

eComMode

E_AdsComMode

Enum used to specify whether the handle of the PLC variable is released again after each read process.

FB_ReadAdsSymByName 3: Outputs

VAR_OUTPUT
    bBusy     :  BOOL;
    bError    :  BOOL;
    nErrorId  :  UDINT;
END_VAR

Name

Type

Description

bBusy

BOOL

The transmission is active.

bError

BOOL

An error occurred during the transmission.

nErrorId

UDINT

ADS error number if an error has occurred.

Requirements

Development environment

required TC3 PLC library

TwinCAT v3.1.0

Tc2_DataExchange