PT1000 Temperature Value Processing

The PT1000 temperature sensor is the sensing element used for determining the Reflow Oven Temperature.

The PT1000 value processing is enabled by default and not intended to be turned off.

PT1000 Value Sampling

The following block diagram shows the processing chain of the temperature signal.

../_images/pt1000.svg

ADC

The internal ADC of the STM32F407 controller is used to sample the analog signal from the Analog Frontend. The ADC is triggered by the hardware Timer TIM2 each millisecond, which results in a sampling frequency of 1 kHz. The ADC module provides an analog value watchdog, which is used to detect wirebreaks and other hardware errors that result in a wrong resistance measurement.

The sample frequency is controlled by

ADC_PT1000_SAMPLE_CNT_DELAY 1000U

The delay value programmed into the sample timer.

whereas the ADC Peripheral module is defined by

ADC_PT1000_PERIPH ADC3

Prefilter

The analog value prefilter is used to filter outliers. It is triggered after a certain amount n of values have been sampled by the ADC. The filter then removes the two most extreme values and computes the average of the remaining n - 2 values. By default n is configured to:

ADC_PT1000_DMA_AVG_SAMPLES 6U

The amount of samples to take to prefilter the analog signal.

Therefore, by default, the resulting datastream has a sampling rate of 1/6 kHz. This depends on the ADC_PT1000_SAMPLE_CNT_DELAY and n

Watchdog

The analog watchdog supervises the measured value of the ADC. It is configured by the following defines:

ADC_PT1000_LOWER_WATCHDOG 200U

Lower value for valid input range for PT1000 measurement.

If the input of the PT1000 sensor is below this value, an error is thrown. This is used to disable the temperature control loop

ADC_PT1000_UPPER_WATCHDOG 4000U

Upper value for valid input range for PT1000 measurement.

If the input of the PT1000 sensor is above this value, an error is thrown. This is used to disable the temperature control loop

ADC_PT1000_WATCHDOG_SAMPLE_COUNT 25U

Number of ADC samples the value has to be outside the Watchdog limit (ADC_PT1000_UPPER_WATCHDOG and ADC_PT1000_LOWER_WATCHDOG) in order to produce a watchdog error.

The watchdog will set the ERR_FLAG_MEAS_ADC_WATCHDOG error flag.

ADC Value to Ohm

This block converts the analog value to an Ohm resistance value. The formula is:

\[R(V) = \frac{V}{4096} \cdot 2500~\Omega\]

The equation is implemented in

ADC_TO_RES(adc) ((float)(adc) / 4096.0f * 2500.0f)

Conversion macro: ADC value to resistance.

and applied during the Exponential Moving Average Filter.

Exponential Moving Average Filter

The external moving average filter filters the measured resistance value. It’s equation is:

\[y[n] = (1-\alpha) y[n-1] + \alpha x[n]\]

The filter constant alpha defaults to the define

ADC_PT1000_FILTER_WEIGHT 0.005f

Moving average filter coefficient for PT1000 measurement.

and can be changed in code using

void adc_pt1000_set_moving_average_filter_param(float alpha)

Set moving average filter parameters.

The sampled resistance value is filtered with an exponential average filter specified by following difference equation:

\( y[n] = (1-\alpha)y[n-1] + \alpha x[n] \)

Parameters
  • alpha:

The moving average filter is considered unstable, if the input to output difference is greater than

ADC_PT1000_FILTER_UNSTABLE_DIFF 20

Difference in Ohm between filter input and output that determines if the filter is stable or unstable.

In this case, the ERR_FLAG_MEAS_ADC_UNSTABLE flag will be set until the filter output converges within the range for at least

ADC_PT1000_FILTER_STABLE_SAMPLE_COUNT 200

Sample count, the moving average filter has to be within ADC_PT1000_FILTER_UNSTABLE_DIFF for the filter to be considered stable.

samples. If the input value keeps changing or oscillating, the error flag will be permanently set.

The moving average filter’s output signal is the Low Frequency (LF) PT1000 resistance signal used for internal PT1000 measurements.

Reading and Converting the PT1000 Value

Calibration

The functions

void adc_pt1000_set_resistance_calibration(float offset, float sensitivity_deviation, bool active)

and

void adc_pt1000_get_resistance_calibration(float *offset, float *sensitivity_deviation, bool *active)

are used to set the resistance calibration internally. For a guide on how to calibrate the deivce, see the corresponding Calibration usage page.

The calibration is calculated the following way:

../_images/calibration.svg

The final calibrated PT1000 resistance is calculated as:

\[R_{PT1000_{corr}} = (R_{PT1000_{LF}} - O) \cdot (1 + \sigma)\]

The default values, if no calibration is loaded / executed, are:

Offset

Sensitivity Deviation

0

0

Get Calibration Corrected Value

The PT1000 value is available through the following function. If a calibration is set, it is applied.

int adc_pt1000_get_current_resistance(float *resistance)

Get the current resistance value.

If the resistance calibration is enabled, this function applies the calculations of the raw resistance reading and returns the corrected value.

If an ADC error is set, the status is negative. The status is 2 during the first measurements with a given filter setting. Technically, the resistance value is correct but the filter is not stable yet.

Return

Status

Parameters
  • [out] resistance: Resistance output in Ohms

Converting the Value

The valid range for conversion is between

TEMP_CONVERSION_MIN_RES 1000

and

TEMP_CONVERSION_MAX_RES 2200

By default, the valid range is:

\[1000~\Omega \le R_{PT1000} \le 2200~\Omega\]
int temp_converter_convert_resistance_to_temp(float resistance, float *temp_out)

Convert PT1000 resistance to temperature in degrees celsius.

Return

0 if ok, -1 if value is below conversion range, 1 if value is above conversion range,-1000 in case of pointer error

Parameters
  • resistance: PT1000 resistance value

  • [out] temp_out: Temperature output

The cvonversion function is based on a lookup table with linear interpolation between the data points. The lookuptable is stored as a header file and can, if necessary, be recreated using the create-temp-lookup-table.py script.