FB_EcCoeSdoReadEx
 
The function block FB_EcCoeSdoReadEx allows data to be read from an object directory of an EtherCAT slave via 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. Via bCompleteAccess := TRUE the parameter can be read with subelements.
 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_VARName  | Type  | Description  | 
|---|---|---|
sNetId  | T_Ams  | String containing the AMS network ID of the EtherCAT master device. (Type: T_AmsNetId)  | 
nSlave  | 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  | BOOL  | If bCompleteAccess is set, the whole parameter can be read in a single access.  | 
 Outputs
VAR_OUTPUT
    bBusy  : BOOL;
    bError : BOOL;
    nErrId : UDINT;
    cbRead : UDINT;
END_VARName  | Type  | Description  | 
|---|---|---|
bBusy  | BOOL  | This output is set when the function block is activated, and remains set until 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.  | 
cbRead  | UDINT  | Number of successfully read data bytes  | 
Prerequisites
Development environment  | Target platform  | PLC libraries to include  | 
|---|---|---|
TwinCAT v3.1.0  | PC or CX (x86, x64, Arm®)  | Tc2_EtherCAT  |