Supported platforms: CODESYS 3.5

 

ResistanceSensor (FB)

Description

This FB calibrates linear resistance sensor value i_InputValue (mV) to SI unit (°C, bar, km/h, kg, etc…).

To operate correctly it is required that sensor operates linearly.

Calibrated output value and alarm/warning limits are the same unit than input variables i_OutputMin and i_OutputMax.  

 

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 linear resistance 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_ResistanceHigh

- i_ResistanceLow

- i_OutputMin

- i_OutputMax

- 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_ResistanceHigh

DINT

-

Maximum resistance value of the sensor (Ohm).

i_ResistanceLow

DINT

-

Minimum resistance value of the sensor (Ohm).

i_OutputMin

DINT

-

Minimum SI-unit value of the sensor, corresponds to i_ResistanceLow.

i_OutputMax

DINT

-

Maximum SI-unit value of the sensor, corresponds to i_ResistanceHigh.

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 alarm limit for calibrated value.

i_HighWarningLimit

DINT

-

High warning limit for calibrated value.

i_LowWarningLimit

DINT

-

Low warning limit for calibrated value.

i_LowAlarmLimit

DINT

-

Low alarm limit for calibrated value.

i_EnableHighAlarm

BOOL

FALSE/TRUE

High value alarm in use.

i_EnableHighWarning

BOOL

FALSE/TRUE

High value warning in use.

i_EnableLowWarning

BOOL

FALSE/TRUE

Low value warning in use.

i_EnableLowAlarm

BOOL

FALSE/TRUE

Low value 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 SI-unit value.

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 topic100750.htm

Last updated 13-Jun-2024