1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 16:55:36 +03:00

Simplify and improve Dynamic Notch

Remove prevCenterFreq[axis]
Simpler peak detection:
- cubes, not squares
- only look one bin either side
More accurate frequency determination
Updated annotations and explanations
Whitespace fixes
fftStartBin can't be less than 1
Dynamic PT1 smoothing
biquad filter on centerFreq removed
centerFreq's now floats

Limits and better min max logic

constrain within nyquist limits

If gyro rate was 2khz and dynamic notch range max, this will keep the notch max to 960hz.

Simple fixes

Get lowest min above and below the peak

First go at setting DN range by a maxHz

increment the PG version in gyro.c

MSP correct size

Resolve comments from Mike and Rav.

Fis msp, deprecating range
This commit is contained in:
ctzsnooze 2019-12-31 12:28:38 +11:00 committed by mikeller
parent 6497830a1b
commit 7b2e075b3a
9 changed files with 165 additions and 161 deletions

View file

@ -1686,7 +1686,7 @@ static bool mspProcessOutCommand(int16_t cmdMSP, sbuf_t *dst)
#endif
// Added in MSP API 1.42
#if defined(USE_GYRO_DATA_ANALYSE)
sbufWriteU8(dst, gyroConfig()->dyn_notch_range);
sbufWriteU8(dst, 0); // DEPRECATED 1.43: dyn_notch_range
sbufWriteU8(dst, gyroConfig()->dyn_notch_width_percent);
sbufWriteU16(dst, gyroConfig()->dyn_notch_q);
sbufWriteU16(dst, gyroConfig()->dyn_notch_min_hz);
@ -1696,7 +1696,6 @@ static bool mspProcessOutCommand(int16_t cmdMSP, sbuf_t *dst)
sbufWriteU16(dst, 0);
sbufWriteU16(dst, 0);
#endif
#if defined(USE_RPM_FILTER)
sbufWriteU8(dst, rpmFilterConfig()->gyro_rpm_notch_harmonics);
sbufWriteU8(dst, rpmFilterConfig()->gyro_rpm_notch_min);
@ -1704,6 +1703,12 @@ static bool mspProcessOutCommand(int16_t cmdMSP, sbuf_t *dst)
sbufWriteU8(dst, 0);
sbufWriteU8(dst, 0);
#endif
#if defined(USE_GYRO_DATA_ANALYSE)
// Added in MSP API 1.43
sbufWriteU16(dst, gyroConfig()->dyn_notch_max_hz);
#else
sbufWriteU16(dst, 0);
#endif
break;
case MSP_PID_ADVANCED:
@ -2497,7 +2502,7 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP,
if (sbufBytesRemaining(src) >= 8) {
// Added in MSP API 1.42
#if defined(USE_GYRO_DATA_ANALYSE)
gyroConfigMutable()->dyn_notch_range = sbufReadU8(src);
sbufReadU8(src); // DEPRECATED: dyn_notch_range
gyroConfigMutable()->dyn_notch_width_percent = sbufReadU8(src);
gyroConfigMutable()->dyn_notch_q = sbufReadU16(src);
gyroConfigMutable()->dyn_notch_min_hz = sbufReadU16(src);
@ -2507,7 +2512,6 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP,
sbufReadU16(src);
sbufReadU16(src);
#endif
#if defined(USE_RPM_FILTER)
rpmFilterConfigMutable()->gyro_rpm_notch_harmonics = sbufReadU8(src);
rpmFilterConfigMutable()->gyro_rpm_notch_min = sbufReadU8(src);
@ -2516,6 +2520,15 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP,
sbufReadU8(src);
#endif
}
if (sbufBytesRemaining(src) >= 1) {
#if defined(USE_GYRO_DATA_ANALYSE)
// Added in MSP API 1.43
gyroConfigMutable()->dyn_notch_max_hz = sbufReadU16(src);
#else
sbufReadU16(src);
#endif
}
// reinitialize the gyro filters with the new values
validateAndFixGyroConfig();