Merge branch 'issue/21-calibration' of mhu/reflow-oven-control-sw into dev

This commit is contained in:
Mario Hüttel 2020-11-16 18:44:59 +01:00 committed by Gogs
commit d51c73d694
5 changed files with 9 additions and 8 deletions

View File

@ -132,7 +132,7 @@ and
.. doxygenfunction:: adc_pt1000_get_resistance_calibration .. doxygenfunction:: adc_pt1000_get_resistance_calibration
:outline: :outline:
are used to set the reistance calibration internally. For a guide on how to calibrate the deivce, see the corresponding :ref:`usage_calibration` usage page. are used to set the resistance calibration internally. For a guide on how to calibrate the deivce, see the corresponding :ref:`usage_calibration` usage page.
The calibration is calculated the following way: The calibration is calculated the following way:
@ -147,13 +147,13 @@ The calibration is calculated the following way:
OFFSET [label="Offset", description="Offset Correction :math:`O`"]; OFFSET [label="Offset", description="Offset Correction :math:`O`"];
OUT [shape=endpoint, description="Corrected Value"]; OUT [shape=endpoint, description="Corrected Value"];
LF -> SENS -> OFFSET -> OUT LF -> OFFSET -> SENS -> OUT
} }
The final calibrated PT1000 resistance is calculated as: The final calibrated PT1000 resistance is calculated as:
.. math:: .. math::
R_{PT1000_{corr}} = R_{PT1000_{LF}} \cdot (1 + \sigma) + O R_{PT1000_{corr}} = (R_{PT1000_{LF}} - O) \cdot (1 + \sigma)
The default values, if no calibration is loaded / executed, are: The default values, if no calibration is loaded / executed, are:

View File

@ -14,3 +14,4 @@ reflow-controller.includes
*.includes *.includes
*.config *.config
*.files *.files
*.user.*

View File

@ -216,7 +216,7 @@ void adc_pt1000_get_resistance_calibration(float *offset, float *sensitivity_dev
static inline float adc_pt1000_apply_calibration(float raw_resistance) static inline float adc_pt1000_apply_calibration(float raw_resistance)
{ {
if (calibration_active) if (calibration_active)
return pt1000_res_raw_lf * (1.0f + pt1000_sens_dev) + pt1000_offset; return (raw_resistance - pt1000_offset) * (1.0f + pt1000_sens_dev);
else else
return raw_resistance; return raw_resistance;

View File

@ -30,9 +30,9 @@
enum calibration_shell_state {CAL_START = 0, CAL_WAIT_RES1, CAL_MEAS_RES1, CAL_WAIT_RES2, CAL_MEAS_RES2}; enum calibration_shell_state {CAL_START = 0, CAL_WAIT_RES1, CAL_MEAS_RES1, CAL_WAIT_RES2, CAL_MEAS_RES2};
void calibration_calculate(float low_measured, float low_setpoint, float high_measured, float high_setpoint, void calibration_calculate(float low_measured, float low_setpoint, float high_measured, float high_setpoint,
float *sens_deviation, float *sens_corrected_offset) float *sens_deviation, float *offset)
{ {
if (!sens_deviation || !sens_corrected_offset) if (!sens_deviation || !offset)
return; return;
float delta_y; float delta_y;
@ -45,7 +45,7 @@ void calibration_calculate(float low_measured, float low_setpoint, float high_me
sens_corr_mult = delta_x / delta_y; sens_corr_mult = delta_x / delta_y;
*sens_deviation = sens_corr_mult - 1.0f; *sens_deviation = sens_corr_mult - 1.0f;
*sens_corrected_offset = low_setpoint - low_measured * sens_corr_mult; *offset = (high_setpoint * low_measured - low_setpoint * high_measured) / (high_setpoint - low_setpoint);
} }

View File

@ -27,7 +27,7 @@
#include <shellmatta.h> #include <shellmatta.h>
void calibration_calculate(float low_measured, float low_setpoint, float high_measured, float high_setpoint, void calibration_calculate(float low_measured, float low_setpoint, float high_measured, float high_setpoint,
float *sens_deviation, float *sens_corrected_offset); float *sens_deviation, float *offset);
float *calibration_acquire_data_start(uint32_t count, volatile int *flag); float *calibration_acquire_data_start(uint32_t count, volatile int *flag);