Notch filter is not a notch filter?

I think it has impact on ALT_HOLD and LOITER, but please let me know if I’m wrong!

Sure, but this is about improving latency and response which are hardly concerns in ALT_HOLD and LOITER

Actually I’m using GUIDED and I’m trying to have fast response and control :slight_smile:

Today I was able to test the increase in the notch filtering a lot, also opening up bandwidth, and I have almost cancelled the first resonance frequency and the cluster around, is almost flat now, all thanks to your post filtering option.

In the last test I’ve disabled the low pass filter setting it to 0. Not only I was able to fly very well, but also I didn’t notice almost any change in the log, even if here is clearly logged with the LPF…

So I think I’ve found a possible bug in the notch filtering skipping low pass filter, commented on you pull.

2 Likes

After the above test with @guglie, I’ve made an AUTOTUNE roll finally with a working notch filter: a perfectly done center frequency andyp1per’s notch filter at 120 dB and 240 bandwith! and gyro FILT at 110, in 2 different way: mainloop at 800 and after mainloop at 1600.

The autotune procedure at mainloop 1600 was incredibly SHARPER, more PRECISE, even though the performed velocity was higher, and I guess at 2400 will be even better!

Thanks again @andyp1per, today a lot of evidence emerge from the flying in front of our eyes :slight_smile:

What FC do you have? I thought i read that anything over about 1000Hz in the main loop leads to instability.

Its a Pixracer, ESC Dshot 600,1404 motors and 5" for 190g total weight.

I thought i read that anything over about 1000Hz in the main loop leads to instability.

Fortunatly not true! Its only that the telemetry and probably logs don’t works above 1000Hz, master @tridge is working on this and there is a branch where telemetry works already.
Also in the Ardupilot 2019-2020 Roadmap here http://ardupilot.org/dev/docs/roadmap.html

We could see " 4kHz+ loop rate PIDs"

P.S.: I’ve fly 2 complete battery few hours ago with mainloop set at 1600, and was top of the top performance to date, no joke. I 'm really temped to try tomorrow at 2400 :slight_smile:

1 Like

We’re going to have some very well performing copters soon! I already think mine is flying better than my betaflight copter now… (Probably just because I’m more used to it now, flying it every day).
I need GPS coordinates and the flight path in my ground station, otherwise I’d try higher loop rates.

This notch build is working for me, too, but I haven’t done a lot of testing yet…

I updated the nano builds with the fix that @guglie suggested. My light testing seems to indicate that the fix works ok, but I have not tested these builds.

I’m flying all day with @guglie fix, without a single issue.
Also @guglie made a further version with the same notch for the accelerometer ! wonderfull, finally alt hold its working much better, and also the accel fft is becoming amazing good as the gyro’s one after the notch cure.

Thanks all, we need 4k main loop soon :slight_smile:

After all day making wonderfull autotune with notch fix with main loop at 1600, I’ve just tried to push main loop to 2400 but the FC don’t works. Please master @tridge suggest how to help you to evolve Ardupilot to 4k an beyond

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.