FB_EcGetAllCrcErrors

FB_EcGetAllCrcErrors 1:

The FB_EcGetAllSlaveCrcErrors function block allows the CRC error counters of all the slaves connected to the master to be read. The CRC errors at the individual ports of a slave are added.

In order to read the CRC errors of the individual ports (A, B and C) of a slave, it is necessary to call the FB_EcGetSlaveCrcError function block.

In order to read the CRC errors of the individual ports (A, B, C and D) of a slave, it is necessary to call the FB_EcGetSlaveCrcErrorEx function block.

FB_EcGetAllCrcErrors 2: Inputs

VAR_INPUT
    sNetId       : T_AmsNetId;
    pCrcErrorBuf : POINTER TO ARRAY[0..EC_MAX_SLAVES] OF DWORD;
    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)

pCrcErrorBuf

POINTER TO ARRAY [0..EC_MAX_SLAVES] OF DWORD

The address of an array of DWORDs into which the CRC error counter is to be written.

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.

FB_EcGetAllCrcErrors 3: Outputs

VAR_OUTPUT
    bBusy   : BOOL;
    bError  : BOOL;
    nErrId  : UDINT;
    nSlaves : UINT; 
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. Error 1798 (0x706) indicates a null pointer at the buffer address. Error 1797 (0x705) indicates inadequate buffer size.

nSlaves

UINT

The number of slaves connected to the master.

Example of an implementation in ST:

PROGRAM TEST_GetAllSlaveCrcErrors
VAR
    fbGetAllSlaveCrcErrors : FB_EcGetAllSlaveCrcErrors;
    sNetId                 : T_AmsNetId := '172.16.2.131.2.1';
    bExecute               : BOOL;
    crcErrors              : ARRAY[0..255] OF DWORD;
    nSlaves                : UINT := 0;
    bError                 : BOOL;
    nErrId                 : UDINT;
END_VAR

fbGetAllSlaveCrcErrors(sNetId:= sNetId, pCrcErrorBuf := ADR(crcErrors), cbBufLen:= SIZEOF(crcErrors), bExecute:=bExecute);
nSlaves := fbGetAllSlaveCrcErrors.nSlaves;
bError := fbGetAllSlaveCrcErrors.bError;
nErrId := fbGetAllSlaveCrcErrors.nErrId;

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_EtherCAT