Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY

 

How to validate temperature sensors

This section describes how the temperature is measured and validated with two different types of sensors.

The readings must be converted to temperature values before validation. Valid temperature is then limit checked.

 

It is also possible to validate two sensors of the same type by validating AI voltages before converting voltage to resistance, which is not included in the following example.

 

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).

 

 

Example code

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.

 

 

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:

 

 

 

 

Initialization

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:


ValidateTemperatureValue.Init(

S_i_InvertedCh2:=FALSE ,

S_i_DiagnosticDelay:=UINT#1000 ,

S_i_SafeOutputValue:=DINT#0 ,

S_i_Tolerance:= DINT#100,

S_i_SumValue:=DINT#0 ,

i_pEventCode:= ADR(S_Inputs.o_EventCodeMain_KTYTempSensor) ,

i_pEventCodeCh2:=ADR(S_Inputs.o_EventCodeMain_LinearTempSensor) );



 

Validation init with SafeDataValidation V1.0.1.0 or newerValidation init with SafeDataValidation V1.0.1.0 or newer

Init method:


ValidateTemperatureValue.Init(

S_i_InvertedCh2:=FALSE ,

S_i_DiagnosticDelay:=UINT#1000 ,

S_i_SafeOutputValue:=DINT#0 ,

S_i_Tolerance:= DINT#20,

S_i_SumValue:=DINT#0,

S_i_ReferenceValue := DINT#100, // example uses 100 C as tolerance reference

i_pEventCode:= ADR(S_Inputs.o_EventCodeMain_KTYTempSensor) ,

i_pEventCodeCh2:=ADR(S_Inputs.o_EventCodeMain_LinearTempSensor) );



 

 

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

 

 

See also

 

 

Source file topic100379.htm

Last updated 13-Jun-2024