Handling noise and the Roll/pitch/gyro filters

Hi all,

I’ve been thinking about the gyro filter and the associated FLTD and FLTT.

We set them according to propeller size, but I can’t imagine one value fits all. I’m a bit confused still on how these work, there is some information out there about them but not much. I know that the average user is not suppose to set these to other values than the initial tuning guide says to but on my quest to learn as much as possible I would love to know more about them.

What I know is based on what @Leonardthall has posted on other topics and YouTube content from @andyp1per. My understanding of the filters is than a higher frequency setting would make my control loop fun faster. That would introduce more noise since I’m filtering out less but be useful for race drones where fast control is needed.

If I lower the values I’ll remove more noise but the control will be slower. This can be used on larger machines where movements are much slower. But a too low value will make is so slow that it won’t be able to effectively control itself.

I’m unsure about how to measure the effect of these filters, and how to know when to higher or lower them. I would love to learn more about how they affect performance and how to tune them for a specific aircraft.

Maybe someone with a bit more knowledge can explain how they work.

Best regards!

The only way to make the control loop run faster is to increase the SCHED_LOOP_RATE.

1 Like

Hm, there’s something regarding control that works faster and slower if I change the filter value ai think.

Maybe I’ve mixed stuff up

You are trying to filter out gyro signal due to noise but retain gyro signal due to movement. The faster the possible movement in your copter (generally smaller == faster) the higher filters need to go to not filter out important signal but the higher the filters are set the more likely you are letting noise through which will look like movement to the control loops. So very low settings of INS_GYRO_FILTER and ATC_RAT…FLTD will filter out all of the noise very effectively, but if your copter can flip in a millisecond then a filter than only sees changes in 10s of milliseconds will not be very helpful.

1 Like

All the filters except the notch are low pass filters with the parameter value setting the cut-off frequency. Not directly related to loop rate.

1 Like

Ok, than loop speed was just a miss interpretation by me.

Does the does the cut-off mean it filters out all movements at higher frequency’s?

So a value of 1hz, would that mean it can only detect movement once every second, or something else?

Thanks!

Thanks!

How do I know if I set it to low, and more importantly, how do I measure the noise I’m filtering and when I can have it set higher?

I’ve read something about the rate values in the log. It says something like normalized output. I think I’ve read that that should be kept below 10% if possible.

You can read a textbook about Digital Signal Processing but this illustration summarizes filters pretty well I think.

1 Like

That’s a really helpful picture!

Thanks!

Question about the notch filter shown on graphs above.
Is the bandwidth of the notch filter a “width” of the notch around notch frequency ?

Also another question relating to practical setting bandwidth of the notch filter.
In documentation it is suggested that bandwidth should be half of the frequency to which notch filter applies, say 40Hz bandwidth for 80Hz frequency.
However, in other part of documentation it is suggested that more precise would be to fly with FFT engine enabled to determine both base frequency and bandwidth (and reference throttle, as well for mode 1 - throttle scaling).
Well, when I did this, in my case measured bandwidth was about the same as frequency, F = 85Hz, B = 86Hz.
It is mentioned in documentation that larger (wider ?) bandwidth may cause slower reactions ?
This is camera drone (480mm size with 10 inch props), rather than a racer drone, so I prefer more stability over the reaction time.
Thus, I am not sure if I should use B = 42Hz (half frequency) or actually measured B = 86Hz before performing autotune.
I flown with B = 86Hz to measure effectiveness of the notch and it worked quite good, but I am not sure how bandwidth that large will affect autotune results.

Yes, right.

I’m not sure of the exact context this appeared in the Wiki but I think it pertains to a BW that would extend down into the control range. I witnessed this by mistake once with a center frequency and BW such that the low end of the notch was <35Hz as I recall.

  1. Thanks Dave for confirming the bandwidth role/definition in notch filtering, now I’m more informed about the “mechanics” of how it works and may make better decisions, as described below.
  2. Yes, it was either in context as you mentioned or in context that notch filter setup should not interfere with low pass gyro filter ?

Back to BW. Looking at my IMU batch sample of unfiltered gyro graph (if it can be trusted), width of base frequency spike is around 40Hz, although quite a lot is going on to the left of base frequency peak and it is likely that this influenced BW calculations done by FFT ?
First harmonic has a bit wider BW of around 60 Hz.
So, from batch sampling graph it looks like I may use smaller BW than calculated by FFT engine.
I was a bit concerned that such wide BW (86Hz) may encroach on my low pass gyro filter, which I have set at 40Hz as recommended for 10inch prop copters by documentation: left side of notch filter at 85Hz - 43Hz (half BW) = 42Hz - close to 40Hz of low pass filter.
Despite that graph showing filtered gyro signal suggests that 40Hz peak was not attenuated (as on both graphs is shows amplitude of around -50), I’ll probably narrow BW to 70Hz just to stay on safe side and it still should be plenty if these graphs can be trusted.


Check the Magnitude box before loading the log file to the FFT graph. The default Log scaling is not the best way to view the data IMO. It should be the other way around with a Log checkbox as the option.

3 Likes

Hi Dave,

When I look at the RATE.out(variable) in the log.

When do I need to lower my filters? And how do I know if my filters are to low, not allowing for enough signal to get through for my type of aircraft?

Maybe it’s to complex to explain like I’m asking you to now, at least to someone with my knowledge level.

The general rule is <.10 for Rate>Rout/Pout.

By feel for one. The values produced by the Initial Parameters Setup is very conservative so it’s not common to be below that. On my 7" for example I can use Rate and Gyro filters much higher (>2X) than suggested and still have relatively low noise. Start with low levels of vibration, configure the Notch Filters properly (that craft has a dynamic notch and a static notch) and a good tune is a lot easier to accomplish.
I should add that what I started at on this craft is largely due to Andy’s 7" build Blog.

1 Like

I’m working on a drone right now woth 22inch propps. It’s not by any means finnished tunong wise but has some noise tjat peaks over 0.1

The notch is in place and working very well. Xfacta helped me set it up. I think some of my noise could be d term related since it’s a bit high compared to the P term. I also have reason to beleive I should lower the D term based on flight data and feel.

But when I look at the noise. Should I look during a hover or during more aggresive manuvering. My noise is low and fine during a hover but gpes over 0.1 during more aggresive inputs.

How should I fly to determain my noise level and set filter according to that?

Thanks!

Thanks for the tip Dave, peaks look clearer now with magnitude box checked.

2 Likes