FB_WriteAdsSymByName

FB_WriteAdsSymByName 1:

The function block FB_WriteAdsSymByName enables writing of any value to another controller using the symbol name.

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

FB_WriteAdsSymByName 2: Inputs

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

Name

Type

Description

bWrite

BOOL

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

sNetId

T_AmsNetID

AMS NetID of the ADS device to which the value is to be transmitted.

nPort

T_AmsNetID

AMS port number of the ADS device to which the value is to be transmitted.

sVarName

STRING(255)

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

nSrcAddr

PVOID

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

nLen

UDINT

Length in bytes of the variable to be written.

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 write process.

FB_WriteAdsSymByName 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