Sample program 13: Reading the BIC from the CoE

The Beckhoff Identification Code (BIC) is used for the unambiguous visual and electronic identification of Beckhoff products and was introduced continually into the ongoing device production from 2020 onwards. Refer also to the introductions in the chapter “Version identification of EtherCAT devices”/”Beckhoff Identification Code (BIC)”Beckhoff Identification Code (BIC). The BIC contains several components, in particular the unambiguous BTN.

The BIC is also stored electronically in the ESI EPROM in all Beckhoff EtherCAT devices and can be read there by the EtherCAT Master (e.g. TwinCAT). A reading function is available for this in the TC3 EtherCAT lib from 2020 onwards.

Some of these EtherCAT devices are so-called intelligent slaves with a local microcontroller, which offers a so-called CoE directory for parameterization. The BIC can be mapped there by the firmware in index 0x10E2 for reading. In the course of continuous product maintenance, this function is gradually being introduced into the EtherCAT devices.

The function block described here, for example, reads all entries from the CoE object 0x10E2 and copies them into a structure variable field "patManFactSpecIdCode" provided for the purpose. In the first step, the function block reads the number of stored BIC entries and in the second step the individual data sets.

Note about the modular devices: if several sub-devices with so-called sub-BICs to be identified are installed in an EtherCAT device, 0x10E2:1 bears the BIC of the main device, while the BICs of the sub-devices are located in the subsequent indices.

Function block FB_GET_BIC

This function block is intended for an environment of a TwinCAT 3 project; i.e. a project must first be present or created. See further explanations within chapter “Sample programs”/” Preparation to start the sample program (tpzip file/ TwinCAT 3)”.

The declarations of the function block are as follows:

Inputs:

    userNetId            : T_AmsNetId; // NetId of EtherCAT device to be read
    userSlaveAddr        : UINT;   // Address of EtherCAT device to be read
    bExecute             : BOOL;   // Execute fb by rising edge

Outputs:

    bDone                : BOOL;   // TRUE = FB Execution done
   nNumOfSubIndizies     : BYTE;   // Number of read BICs via Sub-Ids
   // Array with struct of BIC entries:
    patManFactSpecIdCode :
      ARRAY[0..nMAXINDEXSUBINDIZES] OF POINTER TO T_MAN_FACT_SPEC_ID_CODE; // BICs data
    bError               : BOOL;

The function block is executed with a rising edge at the input "bExecute". The EtherCAT address "userSlaveAddr" of the box module and the "userNetId" are to be transferred. Successful execution is indicated by "bDone" (TRUE = successfully executed). After successful execution, the entries from the CoE object 0x10E2 exist in the pointer field “patManFactSpecIdCode”. The number of read entries is given by “nNumOfSubIndizies”. The following figure shows a filled structure with test data:

Sample program 13: Reading the BIC from the CoE 1:
Test data to illustrate the content of patManFactSpecIdCode[0]^ of the FB

The data type needed for FB_GET_BIC is:

TYPE T_MAN_FACT_SPEC_ID_CODE:
STRUCT
      Article_number       :STRING(FB_GET_BIC.aLengthOfDataEntry[0]);
      BTN                  :STRING(FB_GET_BIC.aLengthOfDataEntry[1]);
      Article_description  :STRING(FB_GET_BIC.aLengthOfDataEntry[2]);
      Quantity             :STRING(FB_GET_BIC.aLengthOfDataEntry[3]);
      Batch_number         :STRING(FB_GET_BIC.aLengthOfDataEntry[4]);
      ID_serial_number     :STRING(FB_GET_BIC.aLengthOfDataEntry[5]);
      Variant_number       :STRING(FB_GET_BIC.aLengthOfDataEntry[6]);
END_STRUCT
END_TYPE

With the stored data lengths within FB_GET_BIC:

aLengthOfDataEntry    : ARRAY[0..nNumOfDataIds] OF BYTE := [8, 12, 32, 6, 14, 12, 32];

The function block is available as a .tpzip file in the following download (as a .zip file) and also contains the necessary library references (Tc2_EtherCAT, Tc3_DynamicMemory), the necessary data structure and a call in MAIN:
PLC_GET_BIC