Supported platforms: CODESYS 2.3, CODESYS 3.5
SCD_KTYSensor FB scales the ADC value to temperature (°C). This function block uses a built-in calibration base curve (in SCD_SetKTYScale (FB)) for KTY sensors which can be adjusted with two input variables.
KTY sensor type can be selected with i_ResAt25degC input. This input defines the sensor’s typical resistance in 25°C temperature and shifts the calibration curve accordingly. (The typical resistance in 25°C is told in the sensor’s data sheet).
However, there are some differences in individual sensors and therefore it might be necessary to fine tune the calibration curve for better accuracy. For that purpose there is i_CalibrationOffset input. i_CalibrationOffset shifts the calibration curve, keeping the curve shape. Shift amount is given in Ohms at 25°C. The ideal value for calibration offset is normally found only by testing.
Reference voltage level (V) |
Connection type |
CalibrationOffset (Ohm@25°C) |
+10V |
Voltage input (type 2) |
30 |
+5V |
Voltage input (type 2) |
5 |
+10V |
Current input (type 1) |
out of spec |
+5V |
Current input (type 1) |
70 |
Example values for Infineon KTY sensor (1000Ohm@25°C).
The FB also calculates the sensor’s resistance for diagnostics.
The sensor’s nominal calibration curve is only valid with a certain supply current, therefore the curve may also need fine tuning because of differences in supply current in different type of connections. Also, the reference voltage (sensor supply voltage) level affects the calibration offset. (Supply current is much bigger when using current input i.e. 220ohm pull-down resistor.)
Sensor connected to voltage input (type 2) with internal pull-up resistor.
Sensor connected to current input (type 1) with internal pull-down resistor.
This function block can be used only with KTY temperature sensors. |
This sensor type will work only when connected either to voltage input with 2k2ohm pull-up resistor, (or to current input with 220ohm pull-down resistor). |
This function block can be used only for measuring temperatures between -50°C and 150°C because of fixed base curve calibration points. Degrees of Celsius is used in calculation, therefore the return value is always °C. |
Preferred connection type for KTY sensor is voltage input (type 2) with internal pull-up resistor. |
When i_Enable changes to FALSE, outputs stay unchanged until i_Enable changes back to TRUE. |
Output resistance and temperature are always calculated, despite of diagnosed value errors and warnings. |
Input variable name |
Data type |
Range |
Description |
i_Enable |
BOOL |
TRUE/FALSE |
Enables calculation of outputs |
i_SensorAIValue |
WORD |
hardware specific |
AD converter value from sensor |
i_SensorAIType |
BYTE |
0..G_ADScaleArrMax |
Defines the AI type (mA or V) and range |
i_ResAt25degC |
INT |
0..5000 Ohm |
Sensor’s typical resistance in Ohm value at 25°C |
i_CalibrationOffset |
INT |
-200..200 Ohm |
Resistance offset value in Ohm at 25°C for fine tuning calibration curve. |
i_SensorValueErrorLimitHigh |
WORD |
0..5000 Ohm |
High error limit for sensor resistance value in Ohms |
i_SensorValueErrorLimitLow |
WORD |
0..5000 Ohm |
Low error limit for sensor resistance value in Ohms |
i_CalibratedValueAlarmLimitHigh |
INT |
-50..150°C |
High alarm limit for temperature output value in °C |
i_CalibratedValueWarningLimitHigh |
INT |
-50..150°C |
High warning limit for temperature output value in °C |
i_CalibratedValueWarningLimitLow |
INT |
-50..150°C |
Low warning limit for temperature output value in °C |
i_CalibratedValueAlarmLimitLow |
INT |
-50..150°C |
Low alarm limit for temperature output value in °C |
i_ReferenceAIValue |
WORD |
hardware specific |
AD converter value of the reference voltage that is used to supply the sensor. |
i_ReferenceAIType |
BYTE |
0..G_ADScaleArrMax
|
Defines the AI range of reference measurement |
i_EnableCalibratedValueOutput |
BOOL |
TRUE/FALSE |
Enables temperature calculation, when false temperature output value is 0°C. |
i_EnableSensorValueErrors |
BOOL |
TRUE/FALSE |
Enables sensor resistance value diagnostics |
i_EnableCalibratedValueHighAlarm |
BOOL |
TRUE/FALSE |
Enables temperature high alarm |
i_EnableCalibratedValueHighWarning |
BOOL |
TRUE/FALSE |
Enables temperature high warning |
i_EnableCalibratedValueLowWarning |
BOOL |
TRUE/FALSE |
Enables temperature low warning |
i_EnableCalibratedValueLowAlarm |
BOOL |
TRUE/FALSE |
Enables temperature low alarm |
i_ErrorDelay |
UINT |
0..65535 ms |
Error delay in milliseconds |
Input variable name |
Data type |
Range |
Description |
i_Enable |
BOOL |
TRUE/FALSE |
Enables calculation of outputs |
i_SensorAIValue |
WORD |
hardware specific |
AD converter value from sensor |
i_SensorAIType |
ADData |
G_AIType struct |
Defines the AI type (mA or V) and range |
i_ResAt25degC |
INT |
0..5000 Ohm |
Sensor’s typical resistance in Ohm value at 25°C |
i_CalibrationOffset |
INT |
-200..200 Ohm |
Resistance offset value in Ohm at 25°C for fine tuning calibration curve. |
i_SensorValueErrorLimitHigh |
WORD |
0..5000 Ohm |
High error limit for sensor resistance value in Ohms |
i_SensorValueErrorLimitLow |
WORD |
0..5000 Ohm |
Low error limit for sensor resistance value in Ohms |
i_CalibratedValueAlarmLimitHigh |
INT |
-50..150°C |
High alarm limit for temperature output value in °C |
i_CalibratedValueWarningLimitHigh |
INT |
-50..150°C |
High warning limit for temperature output value in °C |
i_CalibratedValueWarningLimitLow |
INT |
-50..150°C |
Low warning limit for temperature output value in °C |
i_CalibratedValueAlarmLimitLow |
INT |
-50..150°C |
Low alarm limit for temperature output value in °C |
i_ReferenceAIValue |
WORD |
hardware specific |
AD converter value of the reference voltage that is used to supply the sensor. |
i_ReferenceAIType |
ADData |
G_AIType struct
|
Defines the AI range of reference measurement |
i_EnableCalibratedValueOutput |
BOOL |
TRUE/FALSE |
Enables temperature calculation, when false temperature output value is 0°C. |
i_EnableSensorValueErrors |
BOOL |
TRUE/FALSE |
Enables sensor resistance value diagnostics |
i_EnableCalibratedValueHighAlarm |
BOOL |
TRUE/FALSE |
Enables temperature high alarm |
i_EnableCalibratedValueHighWarning |
BOOL |
TRUE/FALSE |
Enables temperature high warning |
i_EnableCalibratedValueLowWarning |
BOOL |
TRUE/FALSE |
Enables temperature low warning |
i_EnableCalibratedValueLowAlarm |
BOOL |
TRUE/FALSE |
Enables temperature low alarm |
i_ErrorDelay |
UINT |
0..65535 ms |
Error delay in milliseconds |
Output variable name |
Data type |
Range |
Description |
o_SensorValue |
INT |
0..5000 Ohm |
Sensor resistance value in Ohm, calculated from sensor ADC value. |
o_CalibratedValue |
INT |
-50..150°C |
Temperature value based on calibration |
o_ParameterError |
BOOL |
TRUE/FALSE |
Always FALSE. Included in the block for compatibility reasons |
o_SensorValueErrorHigh |
BOOL |
TRUE/FALSE |
Sensor value too high |
o_SensorValueErrorLow |
BOOL |
TRUE/FALSE |
Sensor value too low |
o_CalibratedValueHighAlarm |
BOOL |
TRUE/FALSE |
Temperature over the high alarm limit |
o_CalibratedValueHighWarning |
BOOL |
TRUE/FALSE |
Temperature over the high warning limit |
o_CalibratedValueLowWarning |
BOOL |
TRUE/FALSE |
Temperature below the low warning limit |
o_CalibratedValueLowAlarm |
BOOL |
TRUE/FALSE |
Temperature below the low alarm limit |
Output variable name |
Data type |
Range |
Description |
o_SensorValue |
INT |
0..5000 Ohm |
Sensor resistance value in Ohm, calculated from sensor ADC value. |
o_CalibratedValue |
INT |
-50..150°C |
Temperature value based on calibration |
o_SensorValueErrorHigh |
BOOL |
TRUE/FALSE |
Sensor value too high |
o_SensorValueErrorLow |
BOOL |
TRUE/FALSE |
Sensor value too low |
o_CalibratedValueHighAlarm |
BOOL |
TRUE/FALSE |
Temperature over the high alarm limit |
o_CalibratedValueHighWarning |
BOOL |
TRUE/FALSE |
Temperature over the high warning limit |
o_CalibratedValueLowWarning |
BOOL |
TRUE/FALSE |
Temperature below the low warning limit |
o_CalibratedValueLowAlarm |
BOOL |
TRUE/FALSE |
Temperature below the low alarm limit |
Source file Topic000251.htm
Last updated 24-Apr-2025