Skip to content

Commit d752e64

Browse files
authored
Merge pull request #7521 from iNavFlight/dzikuvx-simplify-dynamic-notch
Simplify dynamic notch setup and set ON by default
2 parents a645f46 + e67f1ff commit d752e64

7 files changed

Lines changed: 7 additions & 55 deletions

File tree

docs/Settings.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -788,17 +788,17 @@ Enable/disable dynamic gyro notch also known as Matrix Filter
788788

789789
| Default | Min | Max |
790790
| --- | --- | --- |
791-
| OFF | | |
791+
| ON | | |
792792

793793
---
794794

795795
### dynamic_gyro_notch_min_hz
796796

797-
Minimum frequency for dynamic notches. Default value of `150` works best with 5" multirors. Should be lowered with increased size of propellers. Values around `100` work fine on 7" drones. 10" can go down to `60` - `70`
797+
Minimum frequency for dynamic notches. Default value of `150` works best with 5" multirotors. Should be lowered with increased size of propellers. Values around `100` work fine on 7" drones. 10" can go down to `60` - `70`
798798

799799
| Default | Min | Max |
800800
| --- | --- | --- |
801-
| 150 | 30 | 1000 |
801+
| 50 | 30 | 1000 |
802802

803803
---
804804

@@ -812,16 +812,6 @@ Q factor for dynamic notches
812812

813813
---
814814

815-
### dynamic_gyro_notch_range
816-
817-
Range for dynamic gyro notches. `MEDIUM` for 5", `HIGH` for 3" and `MEDIUM`/`LOW` for 7" and bigger propellers
818-
819-
| Default | Min | Max |
820-
| --- | --- | --- |
821-
| MEDIUM | | |
822-
823-
---
824-
825815
### eleres_freq
826816

827817
_// TODO_

src/main/blackbox/blackbox.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,6 @@ static bool blackboxWriteSysinfo(void)
18091809
BLACKBOX_PRINT_HEADER_LINE("gyro_lpf_hz", "%d", gyroConfig()->gyro_main_lpf_hz);
18101810
BLACKBOX_PRINT_HEADER_LINE("gyro_lpf_type", "%d", gyroConfig()->gyro_main_lpf_type);
18111811
#ifdef USE_DYNAMIC_FILTERS
1812-
BLACKBOX_PRINT_HEADER_LINE("dynamicGyroNotchRange", "%d", gyroConfig()->dynamicGyroNotchRange);
18131812
BLACKBOX_PRINT_HEADER_LINE("dynamicGyroNotchQ", "%d", gyroConfig()->dynamicGyroNotchQ);
18141813
BLACKBOX_PRINT_HEADER_LINE("dynamicGyroNotchMinHz", "%d", gyroConfig()->dynamicGyroNotchMinHz);
18151814
#endif

src/main/fc/settings.yaml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ tables:
144144
- name: rssi_source
145145
values: ["NONE", "AUTO", "ADC", "CHANNEL", "PROTOCOL", "MSP"]
146146
enum: rssiSource_e
147-
- name: dynamicFilterRangeTable
148-
values: ["HIGH", "MEDIUM", "LOW"]
149-
enum: dynamicFilterRange_e
150147
- name: pidTypeTable
151148
values: ["NONE", "PID", "PIFF", "AUTO"]
152149
enum: pidType_e
@@ -280,16 +277,10 @@ groups:
280277
max: 10
281278
- name: dynamic_gyro_notch_enabled
282279
description: "Enable/disable dynamic gyro notch also known as Matrix Filter"
283-
default_value: OFF
280+
default_value: ON
284281
field: dynamicGyroNotchEnabled
285282
condition: USE_DYNAMIC_FILTERS
286283
type: bool
287-
- name: dynamic_gyro_notch_range
288-
description: "Range for dynamic gyro notches. `MEDIUM` for 5\", `HIGH` for 3\" and `MEDIUM`/`LOW` for 7\" and bigger propellers"
289-
default_value: "MEDIUM"
290-
field: dynamicGyroNotchRange
291-
condition: USE_DYNAMIC_FILTERS
292-
table: dynamicFilterRangeTable
293284
- name: dynamic_gyro_notch_q
294285
description: "Q factor for dynamic notches"
295286
default_value: 120
@@ -298,8 +289,8 @@ groups:
298289
min: 1
299290
max: 1000
300291
- name: dynamic_gyro_notch_min_hz
301-
description: "Minimum frequency for dynamic notches. Default value of `150` works best with 5\" multirors. Should be lowered with increased size of propellers. Values around `100` work fine on 7\" drones. 10\" can go down to `60` - `70`"
302-
default_value: 150
292+
description: "Minimum frequency for dynamic notches. Default value of `150` works best with 5\" multirotors. Should be lowered with increased size of propellers. Values around `100` work fine on 7\" drones. 10\" can go down to `60` - `70`"
293+
default_value: 50
303294
field: dynamicGyroNotchMinHz
304295
condition: USE_DYNAMIC_FILTERS
305296
min: 30

src/main/flight/gyroanalyse.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,11 @@ FILE_COMPILE_FOR_SPEED
6060
void gyroDataAnalyseStateInit(
6161
gyroAnalyseState_t *state,
6262
uint16_t minFrequency,
63-
uint8_t range,
6463
uint32_t targetLooptimeUs
6564
) {
66-
state->fftSamplingRateHz = DYN_NOTCH_RANGE_HZ_LOW;
6765
state->minFrequency = minFrequency;
6866

69-
if (range == DYN_NOTCH_RANGE_HIGH) {
70-
state->fftSamplingRateHz = DYN_NOTCH_RANGE_HZ_HIGH;
71-
}
72-
else if (range == DYN_NOTCH_RANGE_MEDIUM) {
73-
state->fftSamplingRateHz = DYN_NOTCH_RANGE_HZ_MEDIUM;
74-
}
75-
76-
// If we get at least 3 samples then use the default FFT sample frequency
77-
// otherwise we need to calculate a FFT sample frequency to ensure we get 3 samples (gyro loops < 4K)
78-
const int gyroLoopRateHz = lrintf((1.0f / targetLooptimeUs) * 1e6f);
79-
80-
state->fftSamplingRateHz = MIN((gyroLoopRateHz / 3), state->fftSamplingRateHz);
81-
67+
state->fftSamplingRateHz = lrintf(1e6f / targetLooptimeUs / 3); // Looptime divided by 3
8268
state->fftResolution = (float)state->fftSamplingRateHz / FFT_WINDOW_SIZE;
8369

8470
state->fftStartBin = state->minFrequency / lrintf(state->fftResolution);

src/main/flight/gyroanalyse.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ STATIC_ASSERT(FFT_WINDOW_SIZE <= (uint8_t) -1, window_size_greater_than_underlyi
6868
void gyroDataAnalyseStateInit(
6969
gyroAnalyseState_t *state,
7070
uint16_t minFrequency,
71-
uint8_t range,
7271
uint32_t targetLooptimeUs
7372
);
7473
void gyroDataAnalysePush(gyroAnalyseState_t *gyroAnalyse, int axis, float sample);

src/main/sensors/gyro.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ PG_RESET_TEMPLATE(gyroConfig_t, gyroConfig,
124124
.gyroDynamicLpfMaxHz = SETTING_GYRO_DYN_LPF_MAX_HZ_DEFAULT,
125125
.gyroDynamicLpfCurveExpo = SETTING_GYRO_DYN_LPF_CURVE_EXPO_DEFAULT,
126126
#ifdef USE_DYNAMIC_FILTERS
127-
.dynamicGyroNotchRange = SETTING_DYNAMIC_GYRO_NOTCH_RANGE_DEFAULT,
128127
.dynamicGyroNotchQ = SETTING_DYNAMIC_GYRO_NOTCH_Q_DEFAULT,
129128
.dynamicGyroNotchMinHz = SETTING_DYNAMIC_GYRO_NOTCH_MIN_HZ_DEFAULT,
130129
.dynamicGyroNotchEnabled = SETTING_DYNAMIC_GYRO_NOTCH_ENABLED_DEFAULT,
@@ -355,7 +354,6 @@ bool gyroInit(void)
355354
gyroDataAnalyseStateInit(
356355
&gyroAnalyseState,
357356
gyroConfig()->dynamicGyroNotchMinHz,
358-
gyroConfig()->dynamicGyroNotchRange,
359357
getLooptime()
360358
);
361359
#endif

src/main/sensors/gyro.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@ typedef enum {
4141
GYRO_FAKE
4242
} gyroSensor_e;
4343

44-
typedef enum {
45-
DYN_NOTCH_RANGE_HIGH = 0,
46-
DYN_NOTCH_RANGE_MEDIUM,
47-
DYN_NOTCH_RANGE_LOW
48-
} dynamicFilterRange_e;
49-
50-
#define DYN_NOTCH_RANGE_HZ_HIGH 2000
51-
#define DYN_NOTCH_RANGE_HZ_MEDIUM 1333
52-
#define DYN_NOTCH_RANGE_HZ_LOW 1000
53-
5444
typedef struct gyro_s {
5545
bool initialized;
5646
uint32_t targetLooptime;
@@ -78,7 +68,6 @@ typedef struct gyroConfig_s {
7868
uint16_t gyroDynamicLpfMaxHz;
7969
uint8_t gyroDynamicLpfCurveExpo;
8070
#ifdef USE_DYNAMIC_FILTERS
81-
uint8_t dynamicGyroNotchRange;
8271
uint16_t dynamicGyroNotchQ;
8372
uint16_t dynamicGyroNotchMinHz;
8473
uint8_t dynamicGyroNotchEnabled;

0 commit comments

Comments
 (0)