FB_EcCoeSdoWriteEx

FB_EcCoeSdoWriteEx 1:

The FB_EcCoeSdoWriteEx function block permits an object from the object directory of an EtherCAT slave to be written by means of an SDO download. 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 written to be selected. Via bCompleteAccess := TRUE the parameter can be written with sub-elements.

FB_EcCoeSdoWriteEx 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.*)
    pSrcBuf         : PVOID; (* Contains the address of the buffer containing the data to be send. *)
    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 download command should be sent.

nSubIndex

BYTE

Subindex of the object that is supposed to be written.

nIndex

WORD

Index of the object that is supposed to be written.

pSrcBuf

PVOID

Address (pointer) to the transmit buffer

cbBufLen

UDINT

Number of date to be sent in bytes

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.

bCompleteAccess

BOOL

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

FB_EcCoeSdoWriteEx 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