Issue #24: Implement new handling for Unstable flag.
* Unstable flag will now be set, whenever the output of the moving average filter differs more than 10 Ohms from the measured prefilterd input.
This commit is contained in:
parent
67b079fe33
commit
20a65fd7f9
@ -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 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 uint16_t dma_sample_buffer[ADC_PT1000_DMA_AVG_SAMPLES];
|
||||
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;
|
||||
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)
|
||||
@ -305,18 +303,22 @@ static inline __attribute__((optimize("O3"))) void adc_pt1000_filter(float adc_p
|
||||
{
|
||||
float alpha;
|
||||
float res;
|
||||
|
||||
if (filter_startup_cnt > 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);
|
||||
}
|
||||
static uint8_t old_state = 0;
|
||||
|
||||
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) {
|
||||
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;
|
||||
if (old_state != 2) {
|
||||
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 +
|
||||
alpha * res;
|
||||
|
@ -44,6 +44,11 @@
|
||||
*/
|
||||
#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 ADC channel number of PT1000 sensor input
|
||||
*/
|
||||
@ -64,12 +69,6 @@
|
||||
*/
|
||||
#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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user