Merge branch 'issue/24-Change-ERR_FLAG_MEAS_ADC_UNSTABLE' of mhu/reflow-oven-control-sw into dev

This commit is contained in:
Mario Hüttel 2021-01-26 22:49:54 +01:00 committed by Gogs
commit ba9247be69
6 changed files with 45 additions and 49 deletions

View File

@ -873,34 +873,7 @@ FILE_PATTERNS = *.c \
*.hxx \ *.hxx \
*.hpp \ *.hpp \
*.h++ \ *.h++ \
*.cs \ *.dox
*.d \
*.php \
*.php4 \
*.php5 \
*.phtml \
*.inc \
*.m \
*.markdown \
*.md \
*.mm \
*.dox \
*.doc \
*.txt \
*.py \
*.pyw \
*.f90 \
*.f95 \
*.f03 \
*.f08 \
*.f18 \
*.f \
*.for \
*.vhd \
*.vhdl \
*.ucf \
*.qsf \
*.ice
# The RECURSIVE tag can be used to specify whether or not subdirectories should # The RECURSIVE tag can be used to specify whether or not subdirectories should
# be searched for input files as well. # be searched for input files as well.

View File

@ -87,9 +87,16 @@ and can be changed in code using
.. doxygenfunction:: adc_pt1000_set_moving_average_filter_param .. doxygenfunction:: adc_pt1000_set_moving_average_filter_param
After initial startup and after each change of the filter constant, the filter will set the :ref:`safety_flags_adc_unstable` flag for a defined sample count of: The moving average filter is considered unstable, if the input to output difference is greater than
.. doxygendefine:: ADC_FILTER_STARTUP_CYCLES .. doxygendefine:: ADC_PT1000_FILTER_UNSTABLE_DIFF
In this case, the :ref:`safety_flags_adc_unstable` flag will be set until the filter output converges within the range for at least
.. doxygendefine:: ADC_PT1000_FILTER_STABLE_SAMPLE_COUNT
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. The moving average filter's output signal is the Low Frequency (LF) PT1000 resistance signal used for internal PT1000 measurements.

View File

@ -1 +1 @@
<mxfile host="Electron" modified="2020-12-04T19:49:16.513Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/13.9.9 Chrome/85.0.4183.121 Electron/10.1.5 Safari/537.36" etag="Qvxq7f7HYa78jbdpfCma" version="13.9.9" type="device"><diagram name="Page-1" id="099fd60b-425b-db50-ffb0-6b813814b670">7Vxbc9o4FP41zOw+hLEtXx9pgGanaZNtOs3uvjDCFuDEICqLAPn1K2HZ2JYwhJhLkuYhQceyZJ/Lp3MjDXA5XnwmcDr6igMUNQwtWDRAu2EYnquz35ywTAiWDRLCkIRBQtLXhLvwGQmiJqizMEBxYSLFOKLhtEj08WSCfFqgQULwvDhtgKPirlM4RBLhzoeRTL0PAzpKqK6lrelXKByO0p11TVzpQ/9xSPBsIvZrGGCw+kkuj2G6lpgfj2CA5zkS6DTAJcGYJp/Gi0sUcdambEvu6264mj03QRO6yw3oyvTGtNf99jBvYXS/aN3YDxe6IR6OLlOGoIDxRwwxoSM8xBMYddbUT6uXRnxZjY3Wc64xnjKizogPiNKlEDacUcxIIzqOxFW0COk/4nb++V/+uWmJUXuRu9Re5ga3iIRjRBERtJgS/IgucYTJ6tmBa/SBbfPZE0qW2RZ8kNuDD9ebrEbpLoMwinLrBRZyA5PRZWYL/sd4RnzBuQfwS3uGXxc9//sM/gUWP90huhDWQCEZIlohCSeZx7mf20CI8jPC7L3Jkk0gKII0fCpqLxRGMMzmZbfe4pA9sqEJewW2UEdhrnqq6OkSyYOKu9bqxD7kHmNNWinZSxTOecsKt69arUa7a+/ptFC361bDggJVaEvVYz/BaCZ2arXZSnbE3uFTn7BPQ5rxJadST4jQkGH8Neyj6BbHIQ3xhF3qY0rxmPM+BWMuiADGo0y7YBQO+VSf8ZiLKq9G6bItMYdy9eNrTfm+48WQn5BNFLFzivB5TdhnQoY+bQbQX+kxheJJVvuGhM1MxnMU8zdhKwQh27ktXyopBdKZWjgqNfJsB0A7t1juWtvquO1KVeLviBaVshdXDasIJZ4w7fn6GHXEjFHuBDXtAymLbp0PtLjgNeDS9GqAFzQJWtw/YsMJnqCE0g05T1VH3Q76tD/8mDL8KOedF/qkYHgOCqXb+yhUtQbUepp9CHVS+1RuyaVyd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4CzCFqyxHI+fjSOKjT5GLj+LbRqoSmaoY4rNFBdtDuTAOANfLmp0rHfGgGI3M+ZJN7A0fMP+cKNU2pyNr0Ti3l7/GbVLT51/Gbb6mN6S8vOSzMR0jbV7fzl6W71dMspYqDtlfT1EGkO+WjqEvSryUiXI+Q/KtV9FXge7jyS1a3SFqVDJvviudilkf/yturwYbZlWKBUm0tGr20qAM00F5qu2ywnR/FgEKODZBWAHBCl5YGLhmHDMQ/wxbcxtZvRWBJ2Eb5WWeu7YtY6pwInifitUgya9UHm/AZX4TYcrLEAyPXWrDazrslo3QjKpZn37+Y5pTybYbmym6eq7RzOzZND2I9Z27Fkw1GVdg5nOHIKdPXFcd7+lHQkfFSbKXkRQBEZ6QcymS9G5wr9TW4evxjXy8H9D/O/J1fRqtb61rq++VxxfOgvPj52bhRVHP8SuzfyttQnauyaKqjjOzhK3hoSb9vhMKS8U0fjKxvaHR7QOXvBWrm982H9Km4DxzozdsuF/ZsZnc5oLjnDmV5ukuoQwviTIFJcqyB2hpRXCcIpRRpA4TXVJQg2XP/DpMSzXf9TKtD5Hw==</diagram></mxfile> <mxfile host="Electron" modified="2021-01-26T21:12:06.071Z" agent="5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/14.1.8 Chrome/87.0.4280.88 Electron/11.1.1 Safari/537.36" etag="PrKjQ8DyGBUrBwv3aoCi" version="14.1.8" type="device"><diagram name="Page-1" id="099fd60b-425b-db50-ffb0-6b813814b670">7Vxbd6M4Ev41Pmf3IT7cL49ObHfmTHqS7cx07+yLj4xlWx2MHJAvya9fCQQGJGPHBl/S0w9pKGQJqr66qKqgpd/N1l9CMJ9+xSPotzRltG7p3ZamuY5K/zLCW0JQLUtPKJMQjThtQ3hG75ATFU5doBGMCgMJxj5B8yLRw0EAPVKggTDEq+KwMfaLq87BBAqEZw/4IvUHGpFpQnVMZUO/h2gyTVdWFX5lCLyXSYgXAV+vpenj+F9yeQbSufj4aApGeJUj6b2WfhdiTJ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ePk7Ni8gt5WiltStW0UJ8HjcQSPTSpIy5lXVfW5vKqxzEU1Vzb+sCkqv+FQ/kzGjvHp4zVrXcQdeVqfumlpFpixDBN/1V15nM4EwBbhGJdNnotlkxz0zpJyMktJkKxbPBe4OpK4tbGGK10s+GfFwU1RUOn7QKwNfv59hl1K9GqmI4hLWlxsbp8h5lB+zeKiKSqOrLbYnOKIOfj4qxysLTRpiflVdaYUxuqSrbnakMr8rvXu4X/Cx5fftYe38Y8/jf8tHUkLb+ePzsPjlwr3oX7YfZymgb7UP6/tm6uq401FKW81gbddNEGEtYopbGZNecZjsqLPXCu3T1Qfss0LY7fYWfK4IPMFC9zS7CBjerlLrxeGlD+JRYpqFcSJTIrQE3lCQUiDeIlNiY3/X0GU7CNT88+j1mAYzTNeXJs7kGyZBXFWuIPSTkLyHmVjqVqp7ESbdTUR1FGScJTia8w3JwyhpIK46s+knCrZcMLW83KIfaO5bce1TFO1NUPVbVcpNerV1+ay/SmrX3i+lOaWzSfuoE/98OHwOErDs6/OpgI0xI+V6Jqo4eV3DGrTcDFd/FuQhCtpYueZukvkI8KeokvVK/kQwFndZA2CMJ1i5Ch1ek11AsgDFjG3FueelNad1ro1O/ToLvkUy/Uzf/f+U/bBngNYT083Xy5OrN7m89B67/8=</diagram></mxfile>

View File

@ -45,7 +45,6 @@ static float IN_SECTION(.ccm.bss) filter_alpha;
static volatile float IN_SECTION(.ccm.bss) pt1000_res_raw_lf; static volatile float IN_SECTION(.ccm.bss) pt1000_res_raw_lf;
static volatile int * volatile streaming_flag_ptr; static volatile int * volatile streaming_flag_ptr;
static uint32_t IN_SECTION(.ccm.bss) filter_startup_cnt;
static volatile float IN_SECTION(.ccm.bss) adc_pt1000_raw_reading_hf; static volatile float IN_SECTION(.ccm.bss) adc_pt1000_raw_reading_hf;
static volatile uint16_t dma_sample_buffer[ADC_PT1000_DMA_AVG_SAMPLES]; static volatile uint16_t dma_sample_buffer[ADC_PT1000_DMA_AVG_SAMPLES];
static volatile uint32_t IN_SECTION(.ccm.bss) adc_watchdog_counter; static volatile uint32_t IN_SECTION(.ccm.bss) adc_watchdog_counter;
@ -188,7 +187,6 @@ void adc_pt1000_set_moving_average_filter_param(float alpha)
{ {
filter_alpha = alpha; filter_alpha = alpha;
safety_controller_report_error_with_key(ERR_FLAG_MEAS_ADC_UNSTABLE, MEAS_ADC_SAFETY_FLAG_KEY); safety_controller_report_error_with_key(ERR_FLAG_MEAS_ADC_UNSTABLE, MEAS_ADC_SAFETY_FLAG_KEY);
filter_startup_cnt = ADC_FILTER_STARTUP_CYCLES;
} }
void adc_pt1000_set_resistance_calibration(float offset, float sensitivity_deviation, bool active) void adc_pt1000_set_resistance_calibration(float offset, float sensitivity_deviation, bool active)
@ -305,18 +303,27 @@ static inline __attribute__((optimize("O3"))) void adc_pt1000_filter(float adc_p
{ {
float alpha; float alpha;
float res; float res;
static uint8_t old_state = 0;
if (filter_startup_cnt > 0) { static uint32_t stable_sample_counter = 0;
filter_startup_cnt--;
if (filter_startup_cnt == 0)
safety_controller_ack_flag_with_key(ERR_FLAG_MEAS_ADC_UNSTABLE, MEAS_ADC_SAFETY_FLAG_KEY);
}
res = ADC_TO_RES(adc_prefiltered_value); res = ADC_TO_RES(adc_prefiltered_value);
if (ABS(res - pt1000_res_raw_lf) > 20) if (ABS(res - pt1000_res_raw_lf) >= ADC_PT1000_FILTER_UNSTABLE_DIFF) {
stable_sample_counter = 0;
alpha = ADC_PT1000_FILTER_WEIGHT_FAST; alpha = ADC_PT1000_FILTER_WEIGHT_FAST;
else if (old_state != 1) {
safety_controller_report_error_with_key(ERR_FLAG_MEAS_ADC_UNSTABLE, MEAS_ADC_SAFETY_FLAG_KEY);
old_state = 1;
}
} else {
alpha = filter_alpha; alpha = filter_alpha;
if (old_state != 2) {
stable_sample_counter++;
if (stable_sample_counter >= ADC_PT1000_FILTER_STABLE_SAMPLE_COUNT) {
safety_controller_ack_flag_with_key(ERR_FLAG_MEAS_ADC_UNSTABLE, MEAS_ADC_SAFETY_FLAG_KEY);
old_state = 2;
}
}
}
pt1000_res_raw_lf = (1.0f - alpha) * pt1000_res_raw_lf + pt1000_res_raw_lf = (1.0f - alpha) * pt1000_res_raw_lf +
alpha * res; alpha * res;
@ -395,7 +402,7 @@ void DMA2_Stream0_IRQHandler(void)
DMA2->LIFCR = lisr; DMA2->LIFCR = lisr;
if (lisr & DMA_LISR_TCIF0) { if (lisr & DMA_LISR_TCIF0) {
/* Samples Transfered */ /* Samples transferred */
adc_val = adc_pt1000_dma_avg_pre_filter(); adc_val = adc_pt1000_dma_avg_pre_filter();
adc_pt1000_raw_reading_hf = adc_val; adc_pt1000_raw_reading_hf = adc_val;

View File

@ -44,6 +44,17 @@
*/ */
#define ADC_PT1000_FILTER_WEIGHT_FAST 0.05 #define ADC_PT1000_FILTER_WEIGHT_FAST 0.05
/**
* @brief Difference in Ohm between filter input and output that determines if the filter is stable or unstable.
*/
#define ADC_PT1000_FILTER_UNSTABLE_DIFF 10
/**
* @brief Sample count, the moving average filter has to be within @ref ADC_PT1000_FILTER_UNSTABLE_DIFF for the filter
* to be considered stable
*/
#define ADC_PT1000_FILTER_STABLE_SAMPLE_COUNT 200
/** /**
* @brief ADC channel number of PT1000 sensor input * @brief ADC channel number of PT1000 sensor input
*/ */
@ -64,12 +75,6 @@
*/ */
#define ADC_PT1000_PIN 2U #define ADC_PT1000_PIN 2U
/**
* @brief The cycle count the moving average filter is labeled 'instable' after startup of the measurement or changing
* the alpha value @ref ADC_PT1000_FILTER_WEIGHT
*/
#define ADC_FILTER_STARTUP_CYCLES 800U
/** /**
* @brief The delay value programmed into the sample timer * @brief The delay value programmed into the sample timer
*/ */

View File

@ -582,6 +582,10 @@ static int report_error(enum safety_flag flag, uint32_t key, bool prevent_error_
} else { } else {
ret = 0; ret = 0;
} }
flag &= ~flags[i].flag;
if (!flag)
break;
} }
} }