FB_CoE_DiagHistory_Read

FB_CoE_DiagHistory_Read 1:

The function block FB_ReadCoEDiagHistory can read EtherCAT slaves that support the CoE Diag History Object. The EtherCAT slave must comply with the ETG standard.

Syntax

VAR_INPUT
    sNetId          :  T_AmsNetId;
    nSlaveAddr      :  UINT;
    bEnable         :  BOOL;
    bAck            :  BOOL;
    tTimeout        :  TIME := DEFAULT_ADS_TIMEOUT;
    tReadInterval   :  TIME := T#10S;
    stOptions       :  ST_CoE_DiagHistory_Options;
END_VAR
VAR_IN_OUT
    aDiagHistory    :  ARRAY[*] OF ST_CoE_DiagHistory_Entry;
END_VAR
VAR_OUTPUT
    bBusy           :  BOOL; 
    bValid          :  BOOL;
    bError          :  BOOL;
    hrErrorCode     :  HRESULT; 
    ipErrorMessage  :  I_TcMessage := fbResult; 
    stInfo          :  ST_CoE_DiagHistory_Info;
END_VAR

FB_CoE_DiagHistory_Read 2: Inputs

Name

Type

Description

sNetId

T_AmsNetId

NetID of the slave

nSlaveAddr

UINT

Port address of the slave

bEnable

BOOL

Pulse: the Diag History is read out once.
Continuous: the Diag History is read out repeatedly (see tReadInterval).

With each new edge, everything is reset. The connection is then re-established and the slave is read.

bAck

BOOL

All messages are acknowledged when bAck is triggered.

tTimeout

TIME

Timeout for the respective ADS reads/writes in the function block. The default ADS timeout here is five seconds.

tReadInterval

TIME

Time interval between repeated reading of the slave with a permanent "bEnable" signal. The default is a time interval of 10 seconds.

stOptions

ST_CoE_DiagHistory_Options

Controls for handling CoE Diag History

FB_CoE_DiagHistory_Read 3: Inputs/outputs

Name

Type

Description

aDiagHistory

ARRAY[*] OF ST_CoE_DiagHistory_Entry

An array of any length from ST_CoE_DiagHistory_Entry is assigned to this In-Out variable. The FB automatically adapts to the length of the array. If it is too short, older messages in the slave's Diag History Object are ignored. If it is too long, superfluous entries are deleted.

A length greater than 250 makes no sense here, as the ETG standard defines a maximum of 250 messages for the Diag History Object.

FB_CoE_DiagHistory_Read 4: Outputs

Name

Type

Description

bBusy

BOOL

Simple busy signal, indicates that the function block is reading a slave.

bValid

BOOL

The Diag History Object has been successfully read and the messages issued are valid.

bError

BOOL

Becomes TRUE as soon as an error situation occurs.

hrErrorCode

HRESULT

Returns an error code if the bError output is set.

ipErrorMessage

I_TcMessage

Returns detailed information if a bError output is set. The interface pointer used here is always valid (not equal to zero) and is of the type I_TcMessage. In particular, the corresponding error is immediately visible as plain text in the PLC OnlineView.

stInfo

ST_CoE_DiagHistory_Info

Provides information from the read EtherCAT Slave Diag History Object. This includes, among other things, the Buffer Mode used and information on the available messages. This output is only updated after a successful read operation.

Requirements

TwinCAT version

Hardware

Libraries to be integrated

TwinCAT 3.1 >= Build 4024.57

x86, x64, ARM

Tc3_EtherCATDiag