From e8844c4b2a7c06b31b3df2810cd1ab7b7f190cfb Mon Sep 17 00:00:00 2001 From: Adrian Miriuta Date: Tue, 5 Jan 2021 15:48:39 +0100 Subject: [PATCH] remove ADC_MEDIAN --- src/main/drivers/input.c | 5 ---- src/main/main.c | 32 +++++--------------------- src/main/target/DYS35ARIA/target.h | 1 - src/main/target/FURLING45MINI/target.h | 1 - src/main/target/KISS24A/target.h | 1 - src/main/target/RAZOR32V2/target.h | 1 - src/main/target/SUCCEX50AV2/target.h | 1 - src/main/target/SUCCEXMINI40A/target.h | 1 - src/main/target/TYPHOON32V2/target.h | 1 - src/main/target/WRAITH32/target.h | 1 - src/main/target/WRAITH32MINI/target.h | 1 - src/main/target/WRAITH32V2/target.h | 1 - 12 files changed, 6 insertions(+), 41 deletions(-) diff --git a/src/main/drivers/input.c b/src/main/drivers/input.c index c56c557..22c1ef7 100644 --- a/src/main/drivers/input.c +++ b/src/main/drivers/input.c @@ -125,11 +125,6 @@ void inputDshotCommandRun(void) { #else uartPrint("# "); #endif - #if (!defined(USE_ADC_MEDIAN)) - uartPrint("KALMAN "); - #else - uartPrint("MEDIAN "); - #endif #if (!defined(USE_PWM_FREQUENCY_48kHz)) uartPrint("24kHz "); #else diff --git a/src/main/main.c b/src/main/main.c index bd319aa..f58d1de 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -3,11 +3,7 @@ medianStructure motorCommutationIntervalFilterState; #if (defined(USE_ADC)) - #if (defined(USE_ADC_MEDIAN)) - medianStructure adcVoltageFilterState, adcCurrentFilterState; - #else - kalmanStructure adcVoltageFilterState, adcCurrentFilterState; - #endif + kalmanStructure adcVoltageFilterState, adcCurrentFilterState; #endif int main(void) { @@ -34,24 +30,15 @@ int main(void) { medianInit(&motorCommutationIntervalFilterState, MOTOR_BLDC_MEDIAN); #if (defined(USE_ADC)) - #if (defined(USE_ADC_MEDIAN)) - medianInit(&adcVoltageFilterState, 113); - medianInit(&adcCurrentFilterState, 113); - #else - kalmanInit(&adcVoltageFilterState, 25000.0f, 7); - kalmanInit(&adcCurrentFilterState, 25000.0f, 7); - #endif + kalmanInit(&adcVoltageFilterState, 25000.0f, 7); + kalmanInit(&adcCurrentFilterState, 25000.0f, 7); #endif // start with motor off motor.Step = 1; motor.Direction = escConfig()->motorDirection; motor.ComplementaryPWM = escConfig()->motorComplementaryPWM; - #if (defined(USE_ADC_MEDIAN)) - motor.BemfZeroCounterTimeoutThreshold = 71; - #else - motor.BemfZeroCounterTimeoutThreshold = 13; - #endif + motor.BemfZeroCounterTimeoutThreshold = 13; #if defined(SUCCEXMINI40A) motor.BemfZeroCounterTimeoutThreshold = 313; #endif @@ -155,15 +142,8 @@ int main(void) { // adc filtering #if (defined(USE_ADC)) - #if (defined(USE_ADC_MEDIAN)) - medianPush(&adcCurrentFilterState, adcRaw.current); - adcScaled.current = medianCalculate(&adcCurrentFilterState) * ADC_CURRENT_FACTOR + escConfig()->adcCurrentOffset; - medianPush(&adcVoltageFilterState, adcRaw.voltage); - adcScaled.voltage = medianCalculate(&adcVoltageFilterState) * ADC_VOLTAGE_FACTOR + ADC_VOLTAGE_OFFSET; - #else - adcScaled.current = ((kalmanUpdate(&adcCurrentFilterState, (float)adcRaw.current) * ADC_CURRENT_FACTOR + escConfig()->adcCurrentOffset)); - adcScaled.voltage = ((kalmanUpdate(&adcVoltageFilterState, (float)adcRaw.voltage) * ADC_VOLTAGE_FACTOR + ADC_VOLTAGE_OFFSET)); - #endif + adcScaled.current = ((kalmanUpdate(&adcCurrentFilterState, (float)adcRaw.current) * ADC_CURRENT_FACTOR + escConfig()->adcCurrentOffset)); + adcScaled.voltage = ((kalmanUpdate(&adcVoltageFilterState, (float)adcRaw.voltage) * ADC_VOLTAGE_FACTOR + ADC_VOLTAGE_OFFSET)); if ((escConfig()->limitCurrent > 0) && (ABS(adcScaled.current) > escConfig()->limitCurrent)) { inputDisarm(); diff --git a/src/main/target/DYS35ARIA/target.h b/src/main/target/DYS35ARIA/target.h index 52ed177..2640f20 100644 --- a/src/main/target/DYS35ARIA/target.h +++ b/src/main/target/DYS35ARIA/target.h @@ -12,7 +12,6 @@ // CYCLETIME_MAINLOOP kalman->400us (+-10%), median->150us (+-10%) #define USE_PWM_FREQUENCY_48kHz -#define USE_ADC_MEDIAN // hw constants #define HBRIDGE_DEAD_TIME 11 // with 0 FD6288 builtin 200ns H_Bridge gets warm ??? (why) diff --git a/src/main/target/FURLING45MINI/target.h b/src/main/target/FURLING45MINI/target.h index 5aa7963..b84eadc 100644 --- a/src/main/target/FURLING45MINI/target.h +++ b/src/main/target/FURLING45MINI/target.h @@ -14,7 +14,6 @@ // CYCLETIME_MAINLOOP kalman->400us (+-10%), median->150us (+-10%) #define USE_PWM_FREQUENCY_48kHz -//#define USE_ADC_MEDIAN // hw constants #define HBRIDGE_DEAD_TIME 0 // (in 20.833ns cycles at 48MHz) (FD6288 has a builtin 200ns deadtime) diff --git a/src/main/target/KISS24A/target.h b/src/main/target/KISS24A/target.h index 16474a2..2604870 100644 --- a/src/main/target/KISS24A/target.h +++ b/src/main/target/KISS24A/target.h @@ -16,7 +16,6 @@ // CYCLETIME_MAINLOOP kalman->400us (+-10%), median->150us (+-10%) #define USE_PWM_FREQUENCY_48kHz -#define USE_ADC_MEDIAN // hw constants #define HBRIDGE_DEAD_TIME 11 // (in 20.833ns cycles at 48MHz) diff --git a/src/main/target/RAZOR32V2/target.h b/src/main/target/RAZOR32V2/target.h index 0c7d9e2..ac11b3f 100644 --- a/src/main/target/RAZOR32V2/target.h +++ b/src/main/target/RAZOR32V2/target.h @@ -12,7 +12,6 @@ // CYCLETIME_MAINLOOP kalman->500us, median->100us #define USE_PWM_FREQUENCY_48kHz -//#define USE_ADC_MEDIAN // hw constants #define HBRIDGE_DEAD_TIME 0 // (in 20.833ns cycles at 48MHz) (FD6288 has a builtin 200ns deadtime) diff --git a/src/main/target/SUCCEX50AV2/target.h b/src/main/target/SUCCEX50AV2/target.h index 4342097..a68f6d6 100644 --- a/src/main/target/SUCCEX50AV2/target.h +++ b/src/main/target/SUCCEX50AV2/target.h @@ -12,7 +12,6 @@ // CYCLETIME_MAINLOOP kalman->400us (+-10%), median->150us (+-10%) #define USE_PWM_FREQUENCY_48kHz -#define USE_ADC_MEDIAN // hw constants #define HBRIDGE_DEAD_TIME 11 // (in 20.833ns cycles at 48MHz) (FD6288 has a builtin 200ns deadtime) diff --git a/src/main/target/SUCCEXMINI40A/target.h b/src/main/target/SUCCEXMINI40A/target.h index 1650a2e..8153369 100644 --- a/src/main/target/SUCCEXMINI40A/target.h +++ b/src/main/target/SUCCEXMINI40A/target.h @@ -12,7 +12,6 @@ // CYCLETIME_MAINLOOP kalman->500us, median->100us #define USE_PWM_FREQUENCY_48kHz -//#define USE_ADC_MEDIAN // hw constants #define HBRIDGE_DEAD_TIME 9 // (in 20.833ns cycles at 48MHz) (FD6288 has a builtin 200ns deadtime) diff --git a/src/main/target/TYPHOON32V2/target.h b/src/main/target/TYPHOON32V2/target.h index c1bac0f..3b86959 100644 --- a/src/main/target/TYPHOON32V2/target.h +++ b/src/main/target/TYPHOON32V2/target.h @@ -13,7 +13,6 @@ // CYCLETIME_MAINLOOP kalman->500us, median->100us #define USE_PWM_FREQUENCY_48kHz -//#define USE_ADC_MEDIAN // hw constants #define HBRIDGE_DEAD_TIME 0 // (in 20.833ns cycles at 48MHz) (FD6288 has a builtin 200ns deadtime) diff --git a/src/main/target/WRAITH32/target.h b/src/main/target/WRAITH32/target.h index 33f89ef..ba3eee2 100644 --- a/src/main/target/WRAITH32/target.h +++ b/src/main/target/WRAITH32/target.h @@ -12,7 +12,6 @@ // CYCLETIME_MAINLOOP kalman->400us (+-10%), median->150us (+-10%) #define USE_PWM_FREQUENCY_48kHz -#define USE_ADC_MEDIAN // hw constants #define HBRIDGE_DEAD_TIME 0 // (in 20.833ns cycles at 48MHz) (FD6288 has a builtin 200ns deadtime) diff --git a/src/main/target/WRAITH32MINI/target.h b/src/main/target/WRAITH32MINI/target.h index f9dceb0..df56361 100644 --- a/src/main/target/WRAITH32MINI/target.h +++ b/src/main/target/WRAITH32MINI/target.h @@ -12,7 +12,6 @@ // CYCLETIME_MAINLOOP kalman->400us (+-10%), median->150us (+-10%) #define USE_PWM_FREQUENCY_48kHz -#define USE_ADC_MEDIAN // hw constants #define HBRIDGE_DEAD_TIME 7 // (in 20.833ns cycles at 48MHz) (FD6288 has a builtin 200ns deadtime) diff --git a/src/main/target/WRAITH32V2/target.h b/src/main/target/WRAITH32V2/target.h index da4a252..24cd542 100644 --- a/src/main/target/WRAITH32V2/target.h +++ b/src/main/target/WRAITH32V2/target.h @@ -12,7 +12,6 @@ // CYCLETIME_MAINLOOP kalman->500us, median->100us #define USE_PWM_FREQUENCY_48kHz -//#define USE_ADC_MEDIAN // hw constants #define HBRIDGE_DEAD_TIME 0 // (in 20.833ns cycles at 48MHz) (FD6288 has a builtin 200ns deadtime)