FB_WriteAdsSymByName

FB_WriteAdsSymByName 1:

Writing any desired value to another controller with the aid of the symbol name.

On a rising edge at the bWrite input the block writes the value to which the pointer nSrcAddr points into the variable sVarName of the selected ADS device (e.g. PLC). The ADS device is indicated by the AMS-NetId (sNetId) and the AMS Port number (nPort).

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

eComMode := eAdsComModeSecureCom: Following each write 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 write procedure. This mode should be used when values are exchanged very frequently.

VAR_INPUT

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

bWrite: This block writes the contents of the variable to which pointer nSrcAddr points into the variable sVarName of the selected ADS device.

sNetId: AMS-NetId of the ADS device to which the value is to be transmitted.

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

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

nSrcAddr: Address of the variable in which the value to written is located.

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

tTimeout: Time until processing is aborted.

eComMode: Enum used to specify whether the handle of the PLC variable is released again after each write 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