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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calculate throttle based harmonic notch using FFT averaging #20230
Conversation
4b0c943
to
7750b4e
Compare
Can you add a PR description? |
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider allocating when disarmed if the RCn_OPTION exists
8f4f180
to
dc44a0a
Compare
@tridge I have addressed your comments and tightened up the testing. Currently it's not possible to enable the notch dynamically because it involves allocating the filters which is done at startup. It would be possible to change this to be dynamic with some work, but probably should be a separate PR and I am still not sure about creating filters in-flight. Another option would be simply to enable the notch by default but keep the reference at 0. This would allocate the data structures without them being used. |
@tridge actually making the default for INS_HNTCH_ENABLE = 1 works quite well. This seems like a good solution. |
@tridge we could also consider switching on FFT by default on H7 |
f7ac2cc
to
3b000b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to find what memory cost this is compared to master
e1ade42
to
2d6a390
Compare
2d6a390
to
da5eb34
Compare
debaeb1
to
acc21a8
Compare
562527e
to
20e7377
Compare
notch tuning using FFT averaging allocate scratch space for peak finding return all detected peaks to caller
initialize FFT tune
calculate averaged FFT frequency and enable notch scale notch frequency down to FFT_MINHZ calculate harmonics for averaging correctly expose enable flag
add harmonic test for FFT averaging reduce configuration for averaged FFT test enable harmonic notch in-flight
allocate harmonic notch filter if FFT is enabled
Tested on my miniquad |
Memory on this branch:
with notch tuning active:
with notch tuning disabled:
master:
with FFT disabled:
So difficult to see much of an effect outside of noise |
Users struggle with harmonic notch setup. On 2Mb boards we have the possibility of using the in-flight FFT to setup the throttle-based harmonic notch. Normally the in-flight FFT can struggle to track noise peaks in noisy builds, but if the FFT's are averaged over a factor of N then the noise is reduced by 1/sqrt(N). This PR introduces the ability to average FFTs in-flight controlled by RC input (function 163). The user hovers, engages 163, hovers for some period, disengages 163 and the lands. The function will setup the appropriate harmonic notch options and scaling factors such that if the user then reboots they will have an enabled and accurate throttle-based notch.
Setup procedure:
FFT_ENABLE = 1
SERVO9_OPTION = 162