FB_EcGetLastProtErrInfo

FB_EcGetLastProtErrInfo 1:

The function block FB_EcGetLastProtErrInfo can be used to read additional error information relating to the most recent mailbox protocol error. An error-free mailbox command resets the last error every time.

FB_EcGetLastProtErrInfo 2: Inputs

VAR_INPUT
    sNetId     : T_AmsNetId; 
    nSlaveAddr : UINT;
    eProtocol  : E_EcMbxProtType := eEcMbxProt_FoE;
    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, whose error information is to be read.

eProtocol

E_EcMbxProtType

EtherCAT mailbox protocol type

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_EcGetLastProtErrInfo 3: Outputs

VAR_OUTPUT
    bBusy  : BOOL;
    bError : BOOL;
    nErrId : UDINT;
    info   : ST_EcLastProtErrInfo; 
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.

info

ST_EcLastProtErr
Info

Structure with additional error information

Sample in ST:

A rising edge at bGet triggers reading of additional error information relating to the most recent mailbox protocol error.

PROGRAM MAIN
VAR
    fbGetInfo : FB_EcGetLastProtErrInfo := ( sNetID := '172.16.6.195.2.1',
                        nSlaveAddr := 1004,
                        eProtocol := eEcMbxProt_FoE,
                        tTimeout := DEFAULT_ADS_TIMEOUT );
    bGet : BOOL;
    bBusy : BOOL;
    bError : BOOL;
    nErrID : UDINT;
    sInfo : T_MaxString;
END_VAR

fbGetInfo( bExecute:= bGet,
        bBusy=>bBusy,
        bError=>bError,
        nErrId=>nErrId );

sInfo := BYTEARR_TO_MAXSTRING( fbGetInfo.info.binDesc );

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_EtherCAT