FB_EcCoeSdoReadEx

FB_EcCoeSdoReadEx 1:

The FB_EcCoeSdoReadEx function block allows data to be read from an object dictionary of an EtherCAT slave through an SDO (Service Data Object) access. This requires the slave to have a mailbox and to support the “CANopen over EtherCAT” (CoE) protocol. The nSubIndex and nIndex parameters allow the object that is to be read to be selected. The parameter with subelements can be read via bCompleteAccess := TRUE.

FB_EcCoeSdoReadEx 2: Inputs

VAR_INPUT
    sNetId          : T_AmsNetId; (* AmsNetId of the EtherCAT master device.*)
    nSlaveAddr      : UINT; (* Address of the slave device.*)
    nSubIndex       : BYTE; (* CANopen Sdo subindex.*)
    nIndex          : WORD; (* CANopen Sdo index.*)
    pDstBuf         : PVOID; (* Contains the address of the buffer for the received data. *)
    cbBufLen        : UDINT; (* Contains the max. number of bytes to be received. *)
    bExecute        : BOOL; (* Function block execution is triggered by a rising edge at this input.*)
    tTimeout        : TIME := DEFAULT_ADS_TIMEOUT;(* States the time before the function is cancelled. *)
    bCompleteAccess : BOOL; (* access complete object*)
END_VAR

Name

Type

Description

sNetId

T_Ams
NetId

String containing the AMS network ID of the EtherCAT master device. (Type: T_AmsNetId)

nSlave
Addr

UINT

Fixed address of the EtherCAT slave to which the SDO upload command should be sent.

nSubIndex

BYTE

Subindex of the object that is to be read.

nIndex

WORD

Index of the object that is to be read.

pDstBuf

PVOID

Address (pointer) to the receive buffer

cbBufLen

UDINT

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

bExecute

BOOL

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

tTimeout

TIME

Maximum time allowed for the execution of the function block.

bComplete
Access

BOOL

If bCompleteAccess is set, the whole parameter can be read in a single access.

FB_EcCoeSdoReadEx 3: Outputs

VAR_OUTPUT
    bBusy  : BOOL;
    bError : BOOL;
    nErrId : UDINT;
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.

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_EtherCAT