Notch filter is not a notch filter?

This is somewhat off topic, but I was just out flying…
The last thing Betaflight does a bit better is handle the throttle curve for these overpowered copters…
I have a pretty good smooth power response over the range of my throttle throw in BF. In AP, there’s too much room on the low end (nothing useful before 1/2 throttle), then it really jumps up in power for the top half of the throw. So I go from hovering to rocketing into the sky w/ just a twitch of the thumb.

I guess I could work w/ throttle curves in my transmitter to get it to my liking, but I like to have everything set up in the copter itself, so it’s independent of my transmitter.

Have you tried playing with the MOT_THST_EXPO parameter?

I thought the copter throttle curve looked wrong when I was adding one for quadplane. This is a plot comparing the one for copter (blue) and the one I used (expo is 0.2 for all curves):
image

These are 2 parameter curves with only hover thrust and expo selectable. It would probably be better to use a 4 or 5 point curve instead.

Keep in mind that the Copter throttle expo uses just a single exponent in order to keep things simple and easy to configure, as most users won’t know what to do with it (and won’t need to, really).

It assumes that any inflection points and strongly nonlinear parts of the curve are at the top and bottom ends of the throttle range, which get chopped off by MOT_SPIN_MIN and MOT_SPIN_MAX. The remaining curve can be reasonably approximated by a single exponent.

Hi all,

Great to see this all going so well. On the question of loop rates. We are have some more work to do before we can increase loop rates above 1k. The attitude controller needs to be broken up so that the rate loops can be run at a faster rate than the attitude loops. This needs some additional filter design work to be done and an input slew function to be implemented. I have done most of this work and will add the slew function in the final step. We will get this done but it requires a significant change in the fast loop structure so it isn’t a change to be taken lightly or rushed.

This is my PID filter changes that add filtering to the rate request to reduce the noise that enters through the EKF and low frequency RC input.

@wicked1 I added the parameter ACRO_THR_MID to define the mid point of the throttle when using manual throttle modes. This then uses an expo function to smoothly transition through the throttle range. When it is set to 0 it defaults to the hover throttle so you can switch from alt hold to stab without needing to change the throttle position.

@kd0aij Can you go into a little more detail about what you thought looked wrong and what you did in your curves and your thought processes behind them?

@Anubis That is pretty much correct. The expo function is chosen to linearise the thrust curve of the battery/esc/motor/propeller. The equations used are based on the thrust of a propeller driven by a brushless DC motor from a variable voltage source. So the expo equations used are basically the solution to a perfect propeller thrust curve combined with a motor efficiency and RPM range. Then as Anubis said we remove the strongly nonlinear component at the top where the ESC no longer increases thrust (changes from ESC to ESC). The lower end tends to fit this curve very well but we remove that to avoid sync issues and very high current issues with the ESC.

So the MOT_THST_EXPO, MOT_SPIN_MIN and MOT_SPIN_MAX should be used to ensure linear behaviour of the motors to maximise the quality of the tuning. ACRO_THR_MID should be used to get the desired feel from the throttle when in manual throttle flight modes.

I hope that helps explain my thinking on these parts of the code.

1 Like

That’s exactly what I was looking for, thanks!

@Leonardthall I think “expo” should reduce the slope of the throttle curve near center stick (hover thrust), so that is what I implemented in this PR: https://github.com/ArduPilot/ardupilot/pull/10996
The curve is generated here: https://github.com/kd0aij/ardupilot/blob/0a2e1db96271f659c0822c818bf6df98b8ffd195/libraries/AP_Math/AP_Math.cpp#L109

Thank you @andyp1per, with your post filtering log I think I have found another filtering problem:

To me it seems that the LPF is not working at all.

I’ve been flying and logging Andy’s notch firmware all day. It’s great!! I was able to see my notch was too narrow and too deep… I have basically a flat line now… Freq 245hz, Bandwidth 50hz, attenuation 15db.

I honestly can’t tell much difference in flight characteristics from this round of fine tuning, but the logs sure look good :).

If you want I’ll put up a build of master with all my PR’s. I’ve been flying with this today and it works pretty well. I have gyro filter at 100 and PID filters at 110 and it flies pretty smooth. I think the main thing is that it means that less noise gets into the motors. It would be interesting to see if you notice any difference in flight time - I think noise in the motors will reduce this. Unfortunately my testing was cut short by a balance lead coming loose followed by a forced landing upside down! Some repairs required including a new motor as the shaft sheared clean off.

I’m not sure, but I think you need to bear in mind that the LPF’s only attenuate noise, they don’t completely eliminate it. So you will see noise above the LPF filter frequency if the input is great enough. betaflight has multiple cascading filters and still that does not remove all the noise. I see attenuation with the LPF so I think it is working ok. betaflight 4.0 seems to have settled on 2 cascading 1p filters for both gyro and D term. I will probably try this next.

1 Like

Yes, that would be great. I’ll continue testing for you.

That’s a shame about the ‘landing’, but that’s all part of it. I usually order an extra one of everything these days, so I’m ready for repairs (at least for these small relatively inexpensive copters).
I’m always nervous while flying… If I fly at home, my options are over dense woods where it can get stuck in a tree, or over roads where a car might hit it if it crashes on the street. That has happened!

I have a spare motor, fortunately. With the notches it seems that they are more effective when narrower and BF seem to cascade a lot of filters rather than trying to make them wide. Problem for us is that the latency introduced is related to the loop time - so BF at a nominal 2k loop is going to introduce far less latency than us at 800Hz (or even 400Hz). As AP allows higher loop frequencies the more filters we can introduce and the better we do.

1 Like

By the way I added another Notch filter on accelerometer as well and it improved ALT_HOLD performance.

If you want to test it has parameters beginning with NOTCA_

Will a 400MHz H7 MCU (like in SpRacing H7 Extreme) allow faster loop rates while preserving serial comms ?

I don’t think it’s that simple. BF does 8k loop rates no problem on F4 CPUs. I think the serial issues are because there is tight coupling between the different loops and some of them need to be allowed to run more independently.

I did a LOT of testing of Andy’s firmware over the past several days… Was out in the country w/ plenty of open space. Did several 2-3 kilometer flights, which seems like a lot when you’re flying a tiny 110mm size copter. Everything was great… Other than my personal PID’s need some tuning… At about 1k out, when I left the field and started flying over dense woods I started oscillating pretty badly at about a 4hz frequency. So bad I had to take my left thumb off the stick because it was doing more harm than good. After a minute of slow deep breathes I was able to get my oscillations damped and continued the flight :D.

The country and desert are great!! I get at least 10x the range away from civilization, compared to flying around my suburban home.

I’ll share also here, as it’s related

1 Like

Looks nice, thanks. I would say do a PR for ardupilot in the tools directory

Thanks, done here https://github.com/ArduPilot/ardupilot/pull/11603