FB_EcGetAllSyncUnitSlaveAddr

FB_EcGetAllSyncUnitSlaveAddr 1:

The FB_EcGetAllSyncUnitSlaveAddr function block allows the addresses of all the slaves connected to the master to be read. When the call is successful, the buffer passed in the parameter pAddrBuf contains the addresses of all the slaves as an array of UINTs.

FB_EcGetAllSyncUnitSlaveAddr 2: Inputs

VAR_INPUT
    sNetId    : T_AmsNetId;
    nObjectId : OTCID
    pAddrBuf  : POINTER TO ARRAY[0..EC_MAX_SLAVES] OF UINT; 
    cbBufLen  : UDINT 
    bExecute  : BOOL; 
    tTimeout  : TIME := DEFAULT_ADS_TIMEOUT; 
END_VAR

Name

Type

Description

sNetId

T_AmsNetId

The network address of the TwinCAT computer on which the function block is to be executed can be specified here. An empty string may be specified for the local computer.

nObjectId

OTCID

Object Id of the Sync Unit to be used, see Sync Unit

pAddrBuf

POINTER TO ARRAY [0..EC_MAX_SLAVES] OF UINT

Address of an array of UINTs into which the addresses of the individual slaves are to be written.

cbBufLen

UDINT

Maximum available buffer size (in bytes) for the data to be read.

bExecute

BOOL

The function block is enabled by a positive edge at this input.

tTimeout

TIME

Maximum time allowed for the execution of the function block.

FB_EcGetAllSyncUnitSlaveAddr 3: Outputs

VAR_OUTPUT
    bBusy   : BOOL;
    bError  : BOOL;
    nErrId  : UDINT;
    nSlaves : UINT; 
END_VAR

Name

Type

Description

bBusy

BOOL

This output is set when the function block is activated, and remains set until a feedback is received.

bError

BOOL

This output is set after the bBusy output has been reset when an error occurs in the transmission of the command.

nErrId

UDINT

Supplies the ADS error code associated with the most recently executed command if the bError output is set. Error 1798 (0x706) indicates a null pointer at the buffer address. Error 1797 (0x705) indicates inadequate buffer size.

nSlaves

UINT

The number of slaves connected to the master.

Requirements

Development Environment

Target platform

PLC libraries to include

TwinCAT v3.2.4024.14

PC or CX (x86, x64, Arm®)

Tc2_EtherCAT >= 3.3.17.0