Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telemetry based rpm notch filter #7271

Merged
merged 3 commits into from Jan 8, 2019

Conversation

Projects
None yet
5 participants
@joelucid
Copy link
Contributor

joelucid commented Dec 22, 2018

Here comes my little xmas gift 馃槃:

Based on #7264 this feature provides a configurable motor harmonics filter using live rpm telemetry via dshot. Both gyro and the dterm have one filter bank of notch filters which filter up to the first three harmonics of each motor's frequency.

Since dshot rpm telemetry gives us real-time information on current rpm for each motor these notch filters can be extremely narrow, causing minimal latency for flight relevant gyro signals. Per default a Q of 5 is used which means the 3db bandwidth of - say - a 300hz filter would be [292.5,307.5].

The filter bank is extremely effective at eliminating motor noise. On a semi-clean quad it's possible to fly without any other gyro filters and without the dynamic notch, adding only a 150hz biquad lpf on D. Here's what that looks like:

rpm_filter

The resulting latency reductions are very significant, strongly improving flight performance.

The defaults implement filters in the first 3 harmonics on gyro and the first harmonic on D. That makes for a total of 16 filters per axis. Some care has been taken to implement the necessary but expensive filter updates as cheaply as possible, by cloning filter settings between axis and staggering filter updates over multiple loops.

The filter bank uses the following settings:

gyro_rpm_notch_harmonics = 3
Allowed range: 0 - 3

gyro_rpm_notch_q = 500
Allowed range: 1 - 1000

gyro_rpm_notch_min = 100
Allowed range: 50 - 200

dterm_rpm_notch_harmonics = 1
Allowed range: 0 - 3
Default value: 1

dterm_rpm_notch_q = 500
Allowed range: 1 - 1000

dterm_rpm_notch_min = 100
Allowed range: 50 - 200

These are self-explanatory. Q is configured 100x, so default is 5. Setting harmonics to 0 switches the filter bank off.

When the frequency for some filters goes below the minimum frequency only one harmonic is allowed to linger there. Any other harmonics get parked at 1000hz.

@joelucid joelucid referenced this pull request Dec 22, 2018

Merged

Dshot telemetry #7264

@butterSnake

This comment has been minimized.

Copy link

butterSnake commented Dec 24, 2018

I'm excited for this!

@stawiski
Copy link
Contributor

stawiski left a comment

Some refactoring suggestions. Cheers!

Show resolved Hide resolved src/main/drivers/pwm_output_dshot.c Outdated
Show resolved Hide resolved src/main/fc/init.c Outdated
Show resolved Hide resolved src/main/interface/cli.c Outdated
Show resolved Hide resolved src/main/sensors/rpm_filter.c
Show resolved Hide resolved src/main/sensors/rpm_filter.c Outdated
Show resolved Hide resolved src/main/drivers/pwm_output_dshot.c
Show resolved Hide resolved src/main/drivers/pwm_output_dshot.c Outdated
Show resolved Hide resolved src/main/drivers/pwm_output_dshot.c Outdated
Show resolved Hide resolved src/main/drivers/pwm_output_dshot.c Outdated
Show resolved Hide resolved src/main/drivers/pwm_output.h Outdated

@joelucid joelucid force-pushed the joelucid:rpm_filter branch 5 times, most recently from a128a65 to b6805ff Jan 3, 2019

Show resolved Hide resolved src/main/sensors/rpm_filter.c Outdated

@joelucid joelucid force-pushed the joelucid:rpm_filter branch from 2e6943f to a78226f Jan 7, 2019

@joelucid joelucid force-pushed the joelucid:rpm_filter branch from a78226f to 8d4ed72 Jan 7, 2019

@joelucid

This comment has been minimized.

Copy link
Contributor Author

joelucid commented Jan 7, 2019

@mikeller, rebased & squashed

@mikeller
Copy link
Member

mikeller left a comment

Except for the debug[] overflow this looks good, safe for some cosmetic / stylistic remarks.

Show resolved Hide resolved src/main/flight/pid.c Outdated
Show resolved Hide resolved src/main/sensors/gyro.c Outdated
Show resolved Hide resolved src/main/sensors/rpm_filter.c Outdated
Show resolved Hide resolved src/main/sensors/rpm_filter.c Outdated
Show resolved Hide resolved src/main/sensors/rpm_filter.c Outdated
Show resolved Hide resolved src/main/sensors/rpm_filter.c Outdated
Show resolved Hide resolved src/main/sensors/rpm_filter.c Outdated
Show resolved Hide resolved src/main/sensors/rpm_filter.c
Show resolved Hide resolved src/main/sensors/rpm_filter.h Outdated
Show resolved Hide resolved src/main/sensors/rpm_filter.h Outdated

@mikeller mikeller added this to the 4.0 milestone Jan 8, 2019

@mikeller mikeller merged commit 05996be into betaflight:master Jan 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.