Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY
This function block diagnoses and controls reference voltage outputs. Reference voltage types depend on HW, 5V and 10V outputs are supported.
The function block uses internally S_ADCToVoltageOrCurrent function block to convert ADC values to voltage, and S_ValidateAI function block to validate voltage values.
Depending on the input parameter S_i_ReferenceType5V, the function block uses either VALUE_AT_AD_MAXIMUM.U_REF_5V or VALUE_AT_AD_MAXIMUM.U_REF_10V as voltage value at AD maximum value.
Also depending on the input parameter S_i_ReferenceType5V, the function block uses either G_REF_5V_OVERVOLT_LIMIT or G_REF_10V_OVERVOLT_LIMIT for diagnosing voltage high in both inputs.
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:
|
Parameter |
Data type |
Unit |
Range |
Description |
S_i_Tolerance |
SAFEDINT |
‰ |
0 - 1000 |
Limit for voltage mismatch diagnosis. |
S_i_ReferenceType5V |
SAFEBOOL |
- |
- |
Is used REF type 5V. |
S_i_DiagnosticDelay |
SAFEUINT |
ms |
0 - 100 |
Delay time for diagnostics. |
i_pEventCode |
POINTER TO EventCode |
- |
≠ 0 |
Pointer to application variable which is type EventCode. |
TRUE: All initialization parameters ok. |
FALSE: Error in initialization parameter(s). |
The function block validates reference voltage by comparing measurement channel 1 with channel 2 and given high and low limits and that the channel voltages differ no more than given tolerance. The tolerance voltage is calculated per mil of channel 1 voltage. Tolerance is monitored only when REF control is active (i_RefControl = TRUE).
Short circuit and external voltage situations are diagnosed too.
The validated voltage is written to S_o_Voltage if:
• The control is enabled, i.e. i_Enable is TRUE
• No fault (including initialization) has been diagnosed
The function block validates reference voltage by comparing measurement channel 1 with channel 2 and given high and low limits and that the channel voltages differ no more than given tolerance. The tolerance voltage is calculated per mil of nominal reference voltage (5000mV or 10000mV depending on used REF mode). Tolerance is monitored only when REF control is active (i_RefControl = TRUE).
Short circuit and external voltage situations are diagnosed too.
The validated voltage is written to S_o_Voltage if:
• The control is enabled, i.e. i_Enable is TRUE
• No fault (including initialization) has been diagnosed
Input variable name |
Data type |
Unit |
Range |
Description |
i_Enable |
BOOL |
- |
- |
Enable POU operation |
i_RefControl |
BOOL |
- |
- |
Reference output control status request |
i_ADValueCh1 |
DWORD |
- |
0 - G_ADC_MAXIMUM_VALUE |
Measured channel 1 AD value |
i_ADValueCh2 |
DWORD |
- |
0 - G_ADC_MAXIMUM_VALUE |
Measured channel 2 AD value |
Output variable name |
Data type |
Unit |
Range |
Description |
o_RefControl |
BOOL |
- |
- |
Reference output control status. |
S_o_Voltage |
SAFEDINT |
mV |
- |
Validated reference voltage. |
o_Status |
Status |
- |
- |
Status of output value. See Status struct. |
See Diagnostic Interface library description of error status and event code functionality.
Conditions |
S_o_Voltage |
o_RefControl |
o_Status. OutputValid |
o_Status error status |
Event code FunctionID |
Event code EventID |
i_Enable TRUE AND init parameter error AND i_pEventCode valid |
0 |
FALSE |
FALSE |
ParameterError |
REF_CONTROL |
PARAMETER_ERROR |
i_Enable TRUE AND init parameter error AND |
0 |
FALSE |
FALSE |
ParameterError |
- |
- |
i_Enable TRUE AND init parameters ok AND ( i_ADValueCh1 > G_ADC_MAXIMUM_VALUE OR i_ADValueCh2 > G_ADC_MAXIMUM_VALUE ) |
0 |
FALSE |
FALSE |
ParameterError |
REF_CONTROL |
PARAMETER_ERROR |
i_Enable rises AND init parameters ok AND input valid |
Calculated voltage of channel 1 |
i_RefControl |
TRUE |
- |
NO_FUNC |
NO_ERROR |
i_Enable TRUE AND init parameters ok AND (channel 1 voltage > G_REF_5V_OVERVOLT_LIMIT OR channel 2 voltage > G_REF_5V_OVERVOLT_LIMIT) |
0 |
FALSE |
FALSE |
Output High |
REF_CONTROL |
OUTPUT_TOO_HIGH |
i_Enable TRUE AND init parameters ok AND i_RefControl TRUE AND voltages ok AND channel difference > tolerance |
0 |
FALSE |
FALSE |
ValueMismatch |
REF_CONTROL |
DATA_MISMATCH |
i_Enable TRUE AND init parameters ok AND i_RefControl FALSE AND voltages ok AND (channel 1 voltage > G_REF_EXT_VOLT_LIMIT OR channel 2 voltage > G_REF_EXT_VOLT_LIMIT) |
0 |
FALSE |
FALSE |
ExternalVoltage |
REF_CONTROL |
EXTERNAL_VOLTAGE |
i_Enable TRUE AND init parameters ok AND i_RefControl TRUE AND voltages ok AND (channel 1 voltage < G_REF_5V_SHORTCUT_VOLT_LIMIT OR channel 2 voltage < G_REF_5V_SHORTCUT_VOLT_LIMIT) |
0 |
FALSE |
FALSE |
OverCurrent |
REF_CONTROL |
VOLTAGE_SHORTCUT |
Function block is included in hardware specific diagnostic program. It is automatically generated to code template when MultiTool Creator is used. |
Reference voltage diagnostic is a safe-context POU. |
Definitions: |
VAR_INPUT (* Reference Voltage Control Inputs *) i_Enable: BOOL := FALSE; // Enable operation i_RefVoltageControl: BOOL := FALSE; // Application request for 5V reference i_5VRefChannel1: DWORD := DWORD#0; // Filtered ADC value for 5V reference i_5VRefChannel2: DWORD := DWORD#0; // Filtered redundant ADC value for 5V reference
END_VAR
VAR_OUTPUT (* Reference Voltage Control Outputs *) o_RefControlStatus: EPEC_SHWD.Status; // FB status o_RefControl_EC: EPEC_DITF.EventCode; // Event code o_RefControl: BOOL; // 5V ref voltage control status for controlling FB function S_o_RefVoltage: SAFEDINT; // Measured voltage
END_VAR
VAR init_ok: BOOL; // Initialization status refControl: EPEC_SHWD.S_RefControlAndDiagnostics; // POU instance
END_VAR
|
Init: |
(* Reference voltage control and diagnostic *) init_ok := refControl.Init( S_i_Tolerance := G_IO.REFCONTROL_TOLERANCE, // Maximum voltage tolerance (per mil) S_i_ReferenceType5V := TRUE, // Ref output nominal voltage 5V (FALSE = 10V) S_i_DiagnosticDelay := G_IO.REFCONTROL_DIAGNOSTIC_DELAY, // Delay time (ms) for error diagnostic i_pEventCode := ADR(o_RefControl_EC) // Event code pointer for FB );
|
Code: |
(* Reference voltage control and diagnostic *) refControl( i_Enable := i_Enable, // Enable operation i_RefControl := i_RefVoltageControl, // Control request status i_ADValueCh1 := i_5VRefChannel1, // Filtered ADC value for 5V reference i_ADValueCh2 := i_5VRefChannel2, // Filtered redundant ADC value for 5V reference S_o_Voltage => S_o_RefVoltage, // Measured reference voltage o_RefControl => o_RefControl, // Reference voltage control status for FW function o_Status => o_RefControlStatus // FB ststus );
|
Source file topic100439.htm
Last updated 19-Dec-2024