Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Cascaded dynamic notches. #7078
This PR improves the dynamic notch by replacing the notch filter with 2 narrow notches offset from the FFT calculated center. Additional changes to defaults include disabling glpf2, and setting dynamic gyro lowpass minimum to 150 Hz bi-quad for an improvement in filter latency while improving motor noise attenuation.
An additional debug mode has been added. This is not critical, but a convenience to prevent unnecessary hacking of existing debug modes while testing.
The before/after static filter option has been removed. An "auto" option has been added to fft range to select a recommended range based on dynamic gyro lowpass max. gyro_lowpass_hz no longer sets the dynamic gyro lowpass minimum, to help make configuration easier for pilots.
@ctzsnooze will provide a summary of testing.
User CLI is now simplified such that the first lowpass filter will remain at the lowpass 1 value until the throttle has been increased enough that the 'throttle derived motor frequency' line has exceeded that minimum value. As throttle increases further, the cutoff frequency rises along the cubic curve to reach the max dynamic value at full throttle. Setting max to 0, or indeed any value below min, disables dynamic lowpass behaviour, and lowpass 1 becomes static, 'like usual'. This behaviour applies independently to gyro and D filtering, and makes it easy for the user to enable of disable the rise.
Typically a user would enable dynamic lowpass filtering to reduce prop wash by reducing delay as throttle increases.
The dynamic notch filtering works best when the first gyro lowpass is configured as a biquad.
The max value should be set around or just above the maximum motor noise frequency (actual peak rpm / 60). This encourages good dynamic notch tracking at high throttle, by allowing sufficient high frequency noise into the FFT from which the optimal position of the dynamic notch can be set. Values of 500 on 5" quads, 600-650 on 4" and upwards to 800Hz on smaller setups are not out of the question. If this filter isn't set high enough, the FFT won't track high properly and will drop down and may worsen delay. The first gyro filter should be configured as a biquad to strongly suppress above its cutoff value. The second, fixed gyro lowpass should be disabled and is not helpful. The end result at full throttle is very little gyro delay at all, since there is only one singly lowpass filter at very high cutoff, and no other filtering except for the dynamic notch itself.
The min dynamic filter value sets the strength of the gyro filtering at low throttle. This encourages good dynamic notch tracking at low throttle values by removing high frequency noise which typically exists as harmonics above the fundamental motor frequency. One those harmonics are removed, the dynamic notch can and will drop quite low. If the min value is set low, noise attenuation at zero throttle will be stronger, at the expense of slower deeper and probably worse prop wash. If the min value is set too high, motors may warm up in gentle flying, and the dynamic notch may track above the intended noise peak.
Nov 16, 2018
The development of this branch has now reached a really good point. It gives a big improvement in dynamic notch filter performance over the classic single notch.
The amount of general lowpass filtering required becomes less, and because the new notches are narrower, there is less delay and better prop wash handling for any given amount of noise suppression.
The Q and width factors default to values that preferentially do best with noise control. Higher Q (narrower notch), and to a lesser extent narrower width, will reduce delay further at the expense of allowing motor noise to escape around the side of the notch. Q and width parameters are therefore exposed into the CLI for hardcore tuners, but since in the past the dynamic notch Q factor wasn't exposed, we could lock them into #defines later, perhaps once we get more confirmation that the defaults are reasonable.
The main / only issue is CPU load on F411 and F3 boards; there are now two notches to move around dynamically. We would appreciate any advice on how to optimise code performance to minimise CPU hit.
@ctzsnooze , has anyone completed very thorough comparisons of the single notch (with dynamic LPFs) vs. the dual notch (with the same dynamic LPF) settings? If all is as anticipated, the dual should show less noise in the Plasma graphs vs. the single, and if that is the case the dynamic LPFs minimum can be raised to reduce latency.
Basically, from what I saw a couple weeks ago (below test results), we needed dyn notch Q factors more around 2.0+ to get the same latency. Loosely following, I think that is where the defaults are landing; with a reduced separation between the dual dynamic notch, centers to compensate for the sharper (narrower) notches. I don't want to piss in the cheerios, but strive to be very confident, with clear data backup, this change is resulting in more attenuation for the same or less latency.
This should be a comp. of current Master defaults vs. the PR defaults. To make sure a simple flash up (since most just fly stock nowadays -- as they should expect those to be the best) will be an improvement and not get worse. With the dynamic notch improvements PR and the dynamic LPFs PR, we were not adding a filter, so this was not a concern. Here we are adding a filter so being varied cautious that it is indeed more attenuation and less latency comp is critical.
My results from Q = 1.2 and Q = 3.0. Seemed like 3.0 was too high, or the width between the notches needed to be reduced. I know folks have been testing, but I have not seen a graphic yet like the below making the direct comparison so it is very clearly a winner.
I'm sorry I have not been more active recently to muster up the testing needed, I have my excuses but won't waste your time with excuses. I'll try to get in there to getter done, but if someone beats me to it or already has the data, great even better!
Comparisons against Master build 1263 vs. the PR build with a 5" quad.
I should note the pilot felt prop wash was better on build #1263. That said, looking at the logs, I'm not seeing a distinct betterment by running spectrographs on PID Error. More detailed review of the logs is needed. That said, my understand with this PR is that of dual notch gap is set to 0 (W=0) then it is back to a single notch so users can have either way. Single Notch or Dual Notch.
Complements of @kmitchel :
The gap between the notches straddles the motor noise peak as detected by the FFT. W is a percentage of the FFT detected peak frequency. Therefore, at a 400hz FFT motor peak, the notch gap with a W=10% is 80hz (40hz + 40hz). This is done because the notches naturally get wider with a fixed Q approach. So as a result, they can be made wider to attenuate more motor noise with the same amplitude reduction.
@spatzengr I can try to add this debug modes to the Blackbox, to show a tag more legible.
But I'm not too sure about the units of each field. Some of them seem degrees/second, but others seem ms, etc. If you have time, open an issue/feature in the Blackbox github with this image and the units of each field and I can try to add it.