Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY
This function block monitors that the input signal value is between given error limits.
This function block can diagnose any numeric value (quantity). |
Init method is used to initialize the necessary static calculation parameters for the function block instance.
The method shall be called at least once before the actual function block can be called, i.e. at the application initialization phase.
The method checks the validity of input parameters. However, none of the function block outputs are affected by the initialization.
A parameter error is diagnosed if: • Init method is not called before the main FB call OR • i_pEventCode = 0 OR • S_i_HighErrorLimit ≤ S_i_LowErrorLimit
|
Parameter |
Data type |
Unit |
Range |
Description |
S_i_HighErrorLimit |
SAFEDINT |
- |
> S_i_LowErrorLimit |
High error limit for value |
S_i_LowErrorLimit |
SAFEDINT |
- |
< S_i_HighErrorLimit |
Low error limit for value. |
S_i_EnableHighError |
SAFEBOOL |
- |
- |
Enable high error diagnostic. |
S_i_EnableLowError |
SAFEBOOL |
- |
- |
Enable low error diagnostic. |
S_i_DiagnosticDelay |
SAFEUINT |
ms |
- |
Delay time for diagnostics. |
S_i_SafeOutputValue |
SAFEDINT |
- |
- |
Safe output value in case of error |
i_pEventCode |
POINTER TO EventCode |
- |
≠ 0 |
Pointer to application variable which is type EventCode. Used with POUs that handle signal data. |
TRUE: All initialization parameters ok. |
FALSE: Error in initialization parameter(s). |
This POU monitors that input value S_i_Value is between given error limits. The monitoring is active when the input value i_Enable is true, input parameters are valid and the corresponding error monitoring is enabled.
The high error is diagnosed if the high error diagnostic is enabled and input value > high error limit for diagnostic delay time.
The low error is diagnosed if the low error diagnostic is enabled and input value < low error limit for diagnostic delay time.
The block sets o_Status.OutputValid state TRUE if signal is between given error limits and operation is enabled, i.e. i_Enable is TRUE
If if input value is out of given limits continuously over S_i_DiagnosticDelay time, then
• S_o_Output is set to given safe value,
• Status o_Status.OutputValid is set FALSE,
• The corresponding Error bit in o_Status variable is set TRUE, and
• The corresponding EventID is set to i_pEventCode
All function block statuses, including errors are reset on rising edge of i_Enable.
Input variable name |
Data type |
Range |
Description |
i_Enable |
BOOL |
- |
Enable POU operation |
S_i_Value |
SAFEDINT |
- |
Monitored value |
Output variable name |
Data type |
Range |
Description |
S_o_Output |
SAFEDINT |
- |
Monitored output value. |
o_Status |
Status |
- |
Monitored signal status. |
See Diagnostic Interface library description of error status and event code functionality.
Conditions |
S_o_Output value |
o_Status. OutputValid |
o_Status error status |
Event code FunctionID |
Event code EventID |
i_Enable TRUE AND init parameter error AND i_pEventCode valid |
S_i_Safe OutputValue |
FALSE |
ParameterError |
VALUE_ DIAGNOSTIC |
PARAMETER_ERROR |
i_Enable TRUE AND init parameter error AND |
S_i_Safe OutputValue |
FALSE |
ParameterError |
- |
- |
i_Enable rises AND init parameters ok AND S_i_Value between error limits |
S_i_Value |
TRUE |
- |
NO_FUNC |
NO_ERROR |
i_Enable TRUE AND init parameters ok AND S_i_EnableHighError TRUE AND S_i_Value > S_i_HighErrorLimit |
S_i_Safe OutputValue |
FALSE |
ValueHighError |
VALUE_ DIAGNOSTIC |
INPUT_TOO_HIGH |
i_Enable TRUE AND init parameters ok AND S_i_EnableLowError TRUE AND S_i_Value < S_i_LowErrorLimit |
S_i_Safe OutputValue |
FALSE |
ValueLowError |
VALUE_ DIAGNOSTIC |
INPUT_TOO_LOW |
MultiTool Creator generated code do not include this function block. |
Location of the POU instance depends on the application: Non-safe inputs are handled in non-safe context, safe inputs are handled in safe context. The example code applies to both. |
Non-safe Definitions: |
|
EngineTempValid: ValidateAI; // temperature validation FB, not included to this example. EngineTempValidStatus: EPEC_SDV.Status; // status of temperature validation FB S_EngineTemperature: SAFEDINT; // valid temperature value
EngineTempAlarmDiagnostic: S_ValueDiagnostic; EngineTempAlarmStatus: EPEC_SDV.Status; EngineTemperatureEC: EPEC_DITF.EventCode;
TempHighAlarmLimit: SAFEDINT := DINT#150; // alarm and warning limits, degrees of celsius TempLowAlarmLimit: SAFEDINT := DINT#-50;
|
Init at non-safe PRG: |
|
EngineTemperatureEC.DeviceID := DeviceIDs.EngineTemperature; // from app specific device enumeration EngineTemperatureEC.ChannelID := ChannelIDs.Ch1; EngineTemperatureEC.FunctionID := EPEC_DITF.FunctionIDs.NO_FUNC; EngineTemperatureEC.EventID := EPEC_DITF.ErrorIDs.NO_ERROR;
(* init alarm FB *) EngineTempAlarmDiagnostic.Init( S_i_HighErrorLimit := TempHighAlarmLimit, S_i_LowErrorLimit := TempLowAlarmLimit, S_i_EnableHighError := TRUE, S_i_EnableLowError := TRUE, S_i_DiagnosticDelay := 1000, // 1 s delay S_i_SafeOutputValue := DINT#0, i_pEventCode := ADR(EngineTemperatureEC) );
|
Code at non-safe PRG: |
|
EngineTempAlarmDiagnostic( i_Enable := EngineTempValidStatus.OutputValid, // validation status S_i_Value := S_EngineTemperature, S_o_Output => , o_Status => EngineAlarmStatus );
|
|
|