FB_EcSoeRead

FB_EcSoeRead 1:

The function block FB_EcSoeRead allows to read drive parameters with the "Servo Drive Profile over EtherCAT"(SoE) protocol. This requires the slave to have a mailbox and to support the SoE  protocol. The parameter to be read is specified by the parameters nIdn (Identification number), nElement and nDriveNo .

VAR_INPUT

VAR_INPUT
    sNetId      : T_AmsNetId; 
    nSlaveAddr  : UINT; 
    nSubIndex   : BYTE; 
    nIdn        : WORD;
    nElement    : BYTE;
    nDriveNo    : BYTE;
    bCommand    : BOOL
    pDstBuf     : DWORD; 
    cbBufLen    : UDINT; 
    bExecute    : BOOL;
    tTimeout    : TIME := DEFAULT_ADS_TIMEOUT; 
END_VAR

sNetId: This is a string that contains the AMS network identifier of the EtherCAT master device.

nSlaveAddr: Fixed address of the EtherCAT slave to which the SoE read command should be sent to.

nIdn: Identification number of the parameter that is to be read.

nElement: Element number of the parameter that is to be read. The following values are allowed:

Value

Description

0x01

Data Status

0x02

Name (read only)

0x04

Attribute

0x08

Unit

0x10

Minimum

0x20

Maximum

0x40

Value

0x80

Default

nDriveNo: Number of the drive.

bCommand: This parameter should be set, if the internal command execution should be used.

pDestBuf:The address (pointer) of the receive buffer.

cbBufLen:The maximum available buffer size for the data to be read, in bytes.

bExecute: The block is activated by a rising edge at this input.

tTimeout: Maximum time allowed for the execution of the function block.

VAR_OUTPUT

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

bBusy: This output is set when the function block is activated and remains set until an acknowledgement is received.

bError: This output is set up after the bBusy output has been reset if there has been an error in transmission of the command.

nErrId: Supplies the ADS error code associated with the most recently executed command if the bError output is set.

Example for an implementation in ST: 

PROGRAM TEST_SoERead
VAR
    fbSoERead   : FB_EcSoERead;
    sNetId      : T_AmsNetId := '172.16.2.131.2.1';
    bExecute    : BOOL;
    nSlaveAddr  : UINT := 1006;
    nIdn        : WORD := 15;
    nElement    : BYTE := 0;
    nDriveNo    : BYTE := 0;
    bCommand    : BOOL := FALSE;
    val         : UINT;
    bError      : BOOL;
    nErrId      : UDINT;
END_VAR
fbSoERead(sNetId:= sNetId,nSlaveAddr :=nSlaveAddr, nIdn := nIdn, nElement:=nElement, nDriveNo := nDriveNo, bCommand:=bCommand, pDstBuf:= ADR(val), cbBufLen:=SIZEOF(val),bExecute:=bExecute);
bError:=fbSoERead.bError;
nErrId:=fbSoERead.nErrId;

Requirements

Development environment

Target system type

PLC libraries to be linked

TwinCAT v2.10.0 or higher

PC or CX (x86)

TcEtherCAT.lib
( Standard.Lib; TcBase.Lib; TcSystem.Lib, TcUtilities.Lib are included automatically )

TwinCAT v2.10.0 Build >= 1301 or higher

CX (ARM)