Skip to content

Commit

Permalink
remove ADC_MEDIAN
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianmiriuta committed Jan 5, 2021
1 parent 384b978 commit e8844c4
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 41 deletions.
5 changes: 0 additions & 5 deletions src/main/drivers/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 6 additions & 26 deletions src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion src/main/target/DYS35ARIA/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/main/target/FURLING45MINI/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/main/target/KISS24A/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/main/target/RAZOR32V2/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/main/target/SUCCEX50AV2/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/main/target/SUCCEXMINI40A/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/main/target/TYPHOON32V2/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/main/target/WRAITH32/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/main/target/WRAITH32MINI/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/main/target/WRAITH32V2/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e8844c4

Please sign in to comment.