FB_EcSoeRead

The function block FB_EcSoeRead can be used to read drive parameters by means of the “Sercos over EtherCAT (SoE)” protocol. To this end the slave must have a mailbox and support the SoE protocol. The drive parameter to be read is specified with the parameters nIdn (identification number), nElement and nDriveNo.
 Inputs
 Inputs
VAR_INPUT
    sNetId     : T_AmsNetId; 
    nSlaveAddr : UINT; 
    nIdn       : WORD;
    nElement   : BYTE;
    nDriveNo   : BYTE;
    bCommand   : BOOL
    pDstBuf    : PVOID; 
    cbBufLen   : UDINT; 
    bExecute   : BOOL;
    tTimeout   : TIME := DEFAULT_ADS_TIMEOUT; 
END_VAR| Name | Type | Description | 
|---|---|---|
| sNetId | T_AmsNetId | String containing the AMS network ID of the EtherCAT master device. (Type: T_AmsNetId) | 
| nSlaveAddr | UINT | Fixed address of the EtherCAT slave to which the SoE read command is to be sent. | 
| nIdn | WORD | Identification number of the parameter to be read | 
| nElement | BYTE | Element number of the parameter to be read | 
| nDriveNo | BYTE | Drive number | 
| bCommand | BOOL | This parameter should be set if internal command execution is to be used. | 
| 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. | 
nElement
Element number of the parameter to be read. The following values are permitted:
| Value | Description | 
|---|---|
| 0x01 | Data status | 
| 0x02 | Name (read only) | 
| 0x04 | Attribute | 
| 0x08 | Unit | 
| 0x10 | Minimum | 
| 0x20 | Maximum | 
| 0x40 | Value | 
| 0x80 | Default | 
 Outputs
 Outputs
VAR_OUTPUT
    bBusy  : BOOL;
    bError : BOOL;
    nErrId : UDINT;
    cbRead : UDINT;
END_VAR| Name | 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 | 
Example of 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;Prerequisites
| Development environment | Target platform | PLC libraries to include | 
|---|---|---|
| TwinCAT v3.1.0 | PC or CX (x86, x64, Arm®) | Tc2_EtherCAT |