FB_EcCoeReadBIC

FB_EcCoeReadBIC 1:

The function block FB_EcCoeReadBIC can be used to read the BIC from the object directory of an EtherCAT slave via SDO (Service Data Object) access. For this the slave must have a mailbox and support the "CANopen over EtherCAT (CoE)" protocol and the object directory must contain an object 0x10E2:01 with the BIC.

FB_EcCoeReadBIC 2: Inputs

VAR_INPUT
    sNetId     : T_AmsNetId; 
    nSlaveAddr : UINT; 
    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 SDO upload command should be sent.

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.

FB_EcCoeReadBIC 3: Outputs

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

sBICValue

STRING(1023)

This output contains (after an error-free run) the BIC of the EtherCAT slave after the bBusy output has been reset, e.g. "„1P193995SBTN0002agdw1KEL7411                        Q1    2P112104020018".

stMSID

ST_SplittedBIC

This output contains (after an error-free run) the substrings of the BIC of the EtherCAT slave after the bBusy output has been reset.

The following substrings are assigned for the above BIC:
sItemNo = "193995"
sBTN = "0002agdw"
sDescription = "EL7411"
sQuantity = "1"
sBatchNo = "112104020018"

Sample of an implementation in ST

PROGRAM TEST_EcCoEReadBIC
VAR
    fbCoEBIC   : FB_EcCoEReadBIC;
    sNetId     : T_AmsNetId := '172.16.2.131.2.1';
    bExecute   : BOOL := TRUE;
    nSlaveAddr : UINT := 1006;
    sCoEBIC    : STRING(1023);
    stCoEBIC   : ST_SplittedBIC;
    bError     : BOOL;
    nErrId     : UDINT;
END_VAR

fbCoEBIC(sNetId:= sNetID, nSlaveAddr:= nPort, bExecute:= bExecute, tTimeout:= T#5s);;
IF NOT fbCoEBIC.bBusy THEN
     bExecute := FALSE;
     IF NOT fbCoEBIC.bError THEN
          stCoEBIC   := fbCoEBIC.stMSID;
          sCoEBIC    := fbCoEBIC.sBICValue;
     END_IF
     fbCoEBIC(bExecute:= bExecute);
END_IF

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_EtherCAT