Supported platforms: CODESYS 3.5

 

KTYSensor (FB)

Description

This FB calibrates measured resistance of a KTY sensor to temperature (°C).

The FB has built-in calibration base curve for KTY sensors, which can be adjusted with two input variables.

 

The type of used KTY sensor can be selected with i_ResAt25degC input.

This input defines the sensor’s nominal resistance at 25°C temperature and shifts the calibration curve accordingly.

 

The input i_CalibrationOffset can be used to fine tune the calibration curve.

 

A KTY sensor can only  be used for measuring temperatures between -50°C and 150°C, because of fixed base curve calibration points.

 

Enabled alarm/warning limits are sanity checked: i_HighAlarmLimit > i_HighWarningLimit > i_LowWarningLimit > i_LowAlarmLimit. Deviation cause parameter error.

 

The output values o_CalibratedValue and o_Resistance are set to zero if i_Enable is FALSE, or parameter error is diagnosed.  

 

All internal FB initializations are done on the rising edge of i_Enable.

All errors are reset on the rising edge of i_Enable.

 

Limitations

This FB can only be used with a KTY temperature sensor connected to a voltage input.

 

The FB uses internally

- S_VoltageToResistance FB from SafeConversion library.

- S_ValueDiagnostic FB from SafeDataValidation library.

 

Following parameters are taken into use at the rising edge of i_Enable:

- i_ResAt25DegC

- i_CalibrationOffset

- i_InternalPullUpResistance

- i_InternalPullDownResistance

- i_HighAlarmLimit

- i_HighWarningLimit

- i_LowWarningLimit

- i_LowAlarmLimit

- i_EnableHighAlarm

- i_EnableHighWarning

- i_EnableLowWarning

- i_EnableLowAlarm

- i_DiagnosticDelay

+ Any initialized event code.

 

Inputs

Input variable name

Data type

Range

Description

i_Enable

BOOL

FALSE/TRUE

Enable operation.

i_InputVoltage

DINT

-

Measured voltage (mV) of sensor.

i_ReferenceVoltage

DINT

-

Measured supply voltage (mV) of sensor.

i_ResAt25DegC

DINT

-

Nominal resistance value of the KTY sensor.

i_CalibrationOffset

DINT

-

Fine tune offset resistance value (Ohm).

i_InternalPullUpResistance

EPEC_HW. PULL_UP_RESISTANCE

ENUM

Internal pull-up resistance of AI input (Ohm).

i_InternalPullDownResistance

EPEC_HW. PULL_DOWN_RESISTANCE

ENUM

Internal pull-down resistance of AI input (Ohm).

i_HighAlarmLimit

DINT

-

High temperature alarm limit value in °C.

i_HighWarningLimit

DINT

-

High temperature warning limit value in °C.

i_LowWarningLimit

DINT

-

Low temperature warning limit value in °C.

i_LowAlarmLimit

DINT

-

Low temperature alarm limit value in °C.

i_EnableHighAlarm

BOOL

FALSE/TRUE

High temperature alarm in use.

i_EnableHighWarning

BOOL

FALSE/TRUE

High temperature warning in use.

i_EnableLowWarning

BOOL

FALSE/TRUE

Low temperature warning in use.

i_EnableLowAlarm

BOOL

FALSE/TRUE

Low temperature alarm in use.

i_DiagnosticDelay

UINT

-

Diagnostic delay for alarms and warnings (ms).

Outputs

Output variable name

Data type

Range

Description

o_CalibratedValue

DINT

-

Calibrated temperature in °C.

o_Resistance

DINT

-

Calculated resistance of the sensor.

o_HighAlarm

BOOL

FALSE/TRUE

Calibrated value high alarm status.

o_HighWarning

BOOL

FALSE/TRUE

Calibrated value high warning status.

o_LowWarning

BOOL

FALSE/TRUE

Calibrated value low warning status.

o_LowAlarm

BOOL

FALSE/TRUE

Calibrated value low alarm status.

o_ParameterError

BOOL

FALSE/TRUE

Error in input parameters.

 

EventCodeInit (Public Method)

This optional method sets pointer for event code.

 

Inputs

Input variable name

Data type

Description

i_Enable

BOOL

Enable operation.

i_pEventCode

POINTER TO EPEC_DITF.EventCode

Pointer to signal event code value provided by the application.

 

 

Example code

 

Pull-up to 5 V is selected in MultiTool Creator's AI configuration when using resistance sensors.

 

 

Example implementation is made with EC44 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;

 

 

 

 

 

 

 

 

See also

 

 

 

 

Source file topic100748.htm

Last updated 13-Jun-2024