Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY, CODESYS 3.5 SP19 SAFETY
This section contains two examples of temperature validation. The first one describes how the temperature is measured and validated with two different types of sensors. The second one describes how the validation is done with two NTC sensors connected to control unit's TI pin.
Two different types of sensorsTwo different types of sensors
The readings must be converted to temperature values before validation. Valid temperature is then limit checked.
|
This example uses the following libraries: SafeConversion library SafeSensorCalibration library
SafeDataValidation library
|
|
S_ADCToVoltageOrCurrent POU is included in the code template generated by MultiTool Creator.
|
The following image is an architecture example for temperature sensor validation.
S_RefVoltage in the example image is the measured supply voltage for the input.
MultiTool code template provides pull-up measurement for AI pins (for products where they are available).
The following example demonstrates temperature reading of two safety related AIs, KTYTempSensor and LinearTempSensor defined in MultiTool Creator.
|
When the following example is used with non-safety I/O, the I/O variables are generated in Inputs program instead of S_Inputs. |
|
Pull-up to 5 V is selected in MultiTool Creator's AI configuration when using resistance sensors.
|
|
This example is implemented with AI mode where resistance conversion is not included in code template. With TI mode the resistance conversion is included in code template and can be omitted from application code. TI mode is not supported by all products.
|
|
Example implementation is made with SC52 unit which has pull-up measurement available. For products which does not have AI pull-up measurement (e.g. SL84), use hardcoded 5000 mV value for voltage to resistance conversion's S_i_RefVoltage.
// SL84 does not have pull-up measurements, assume 5V pullup S_TEMP_PULLUP_VOLTAGE: SAFEDINT := DINT#5000; |
Safe PRG:
|
|
Init method:
IF NOT initDone THEN initDone:=TRUE;
KTYSensorResistance.Init( S_i_InternalPullUpResistance:=EPEC_HW.PULL_UP_RESISTANCE.R_2K2 , S_i_InternalPullDownResistance:=EPEC_HW.PULL_DOWN_RESISTANCE.R_82K , S_i_OutputResistanceHigh:=DINT#4500 , S_i_OutputResistanceLow:=DINT#1000 , S_i_DiagnosticDelay:=UINT#1000 , i_pEventCode:= ADR(S_Inputs.o_EventCodeMain_KTYTempSensor));
PT1000SensorResistance.Init( S_i_InternalPullUpResistance:=EPEC_HW.PULL_UP_RESISTANCE.R_2K2 , S_i_InternalPullDownResistance:=EPEC_HW.PULL_DOWN_RESISTANCE.R_82K , S_i_OutputResistanceHigh:=DINT#1400 , S_i_OutputResistanceLow:=DINT#843 , S_i_DiagnosticDelay:=UINT#1000 , i_pEventCode:=ADR(S_Inputs.o_EventCodeMain_LinearTempSensor) );
|
Validation init with SafeDataValidation V1.0.0.7Validation init with SafeDataValidation V1.0.0.7
Init method:
TemperatureValueDiagnostic.Init( S_i_HighErrorLimit:=DINT#100 , S_i_LowErrorLimit:=DINT#-5 , S_i_EnableHighError:=TRUE , S_i_EnableLowError:=TRUE , S_i_DiagnosticDelay:= UINT#1000, S_i_SafeOutputValue:= DINT#0, i_pEventCode:=ADR(S_Inputs.o_EventCodeMain_KTYTempSensor) );
END_IF |
Two NTC sensors connected to TI pinTwo NTC sensors connected to TI pin
The following example demonstrates temperature reading of two safety related TIs defined in MultiTool Creator.
|
All products do not support TI pin mode
|
|
This example uses the following libraries: SafeConversion library SafeSensorCalibration library
SafeDataValidation library
|
|
S_ADCToVoltageOrCurrent and S_VoltageToResistance POUs are included in the code template generated by MultiTool Creator.
|
Safe PRG:
|
|
Init method:
IF NOT initDone THEN initDone := TRUE; |
S_LinearSensor (FUN)
S_KTYSensor (FUN)
S_NTCSensor (FUN)
S_ValidateAI (FB)
S_ValueDiagnostic (FB)
Source file topic100379.htm
Last updated 21-Feb-2025