FB_ReadAdsSymByName

FB_ReadAdsSymByName 1:

The block enables the reading of any value from another controller with the aid of the symbol name.

On a rising edge at the bRead input the 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 block can be changed with the aid of the eComMode input:

eComMode := eAdsComModeSecureCom: Following each read procedure the handle of the PLC variable is released again. This mode should be used when values are exchanged very slowly.

eComMode := eAdsComModeFastCom: As long as the sVarName, sNetID and nPort inputs do not change, the handle of the PLC variable will not be released after each read procedure. This mode should be used when values are exchanged very frequently.

VAR_INPUT

bRead        : BOOL;
sNetId       : T_AmsNetId;
nPort        : T_AmsPort := AMSPORT_R0_PLC_RTS1;
sVarName     : STRING;
nDestAddr    : DWORD;
nLen         : UDINT;
tTimeout     : TIME := DEFAULT_ADS_TIMEOUT;
eComMode     : E_AdsComMode := eAdsComModeSecureCom;

bRead: This block reads the contents of the sVarName variable of the selected ADS device and writes it into the variable to which pointer nDestAddr points.

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

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

sVarName: Symbol name of the variable to be read on the selected ADS device.

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

nLen: Length of the variable to be read in bytes.

tTimeout: Time until processing is aborted.

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

VAR_OUTPUT

bBusy        : BOOL;
bError       : BOOL;
nErrorId     : UDINT;

bBusy: Transmission is active.

bError: An error occurred during the transmission.

nErrorId: ADS error number if an error has occurred.

Requirements

Development environment

Target system

Required libraries

TwinCAT 2.11 R3/x64 from Build 2247

PC/CX

TcDataExchange library from V1.1.0