Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY

 

How to use event code system

This section describes how to use event codes in safety libraries.

 

All common safety library function blocks and some of functions use the event code system. These POUs have an event ID for each error status.

If an error is diagnosed, the corresponding event code is also set to the EventCode structure.

 

The EventCode is given to the POU with the initialization input parameter i_pEventCode. In function blocks, the event code pointer input is set by the Init method.

 

The event code is not changed if the code has been set by another POU. In this case, the FunctionID is another POU's  ID. The event code can be changed if the FunctionID is NO_FUNC.

 

See DiagnosticInterface library's DataTypes for used enumerations and structures.

 

A safety library POU can reset the event code only on the rising edge of the i_Enable input.

 

Event codes in safety libraries are used only for diagnostic purposes.

 

The event code’s DeviceID and ChannelID are application defined static values set to all EventCode structures at the initialization. ChannelIDs can be used when multiple event codes (diagnostic channels) are required for a functionality. See Operation with multiple channels below.

 

The event code’s EventID and FunctionID are set by the POU that diagnoses the error.

 

Epec EventLog library does not currently support EventCodes used by safety libraries. Events in EventLog are triggered by a boolean condition.

Currently, it may be easier to trigger events using error booleans in the safety library o_Status outputs.

Initialization

A pointer to the used event code structure is given to a function block's initialization method as an input parameter.

Functions have no initialization method; all parameters are given at each call.

 

When Epec MultiTool Creator is used, an event code variable is generated for each input I/O pin.

In a safety control unit the variables are located in S_Inputs / Inputs.

Application functionalities should use the code template event code variables when the corresponding I/O pin is used. The same event code variable is chained to subsequent POUs. See How To Guides for examples.

 

The pointed structure is also used as event code output, i.e. the POU writes its own diagnosed event codes there.

If the POU has several signal inputs (channels), they all must have a pointer to their own event code structure.

 

The following image is an example of POU interface. Event code pointer is given to the Init method.

 

Supply and reference voltage inputs are diagnosed with system level priority.

Erroneous supply or reference voltage shall be used as a condition to disable safety functionalities (see also How to use S series and E series HW diagnostics).

These values do not need separate event code set up for the function blocks.

 

Operation

Diagnostic statuses are reset at the rising edge of i_Enable. Also, the event code's:

  • EventID is set to NO_ERROR

  • FunctionID is set to NO_FUNC

  • The main channel id is restored to ChannelID

 

 

If a safety library POU diagnoses an error, it writes

  • Corresponding error code to pointed event code’s EventID

  • POU specific function ID to pointed event code’s FunctionID

 

 

If an error is diagnosed, all the subsequent blocks are disabled and the corresponding EventCode contains EventID and FunctionID of the diagnosed error.

 

 

Operation with multiple channels

In addition to the main signal channel, a POU may have validation or signal sub-channel inputs.

An EventCode structure is required for every input channel / SRDO. The i_pEventCode pointed structure is used by the signal channel.

Each validation channel has its own structure pointer input, typically named i_pEventCodeCh2.

 

If the main channel has no error, but a preceding POU in sub-channel has diagnosed an error, the ChannelID, FunctionID and EventID of the event code is copied from the erroneous sub-channel (i_pEventCodeCh2 pointed structure) to the main channel (i_pEventCode pointed structure).

 

 

An architecture example

The following image gives an example of how an event code variable is chained from POU to POU using multiple event channels.

 

 

See also

 

 

Source file topic100374.htm

Last updated 19-Dec-2024