How to configure moving average for gyros - MultiWii 2.2

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
socrate78
Posts: 2
Joined: Wed Mar 13, 2013 11:14 am

How to configure moving average for gyros - MultiWii 2.2

Post by socrate78 »

In MultiWii 2.2 config.h there are changes in moving average parameters.

Code: Select all

      #define MMGYRO 10                      // (*) Active Moving Average Function for Gyros
      #define MMGYROVECTORLENGTH 15          // Length of Moving Average Vector (maximum value for tunable MMGYRO


Can someone explain what are "10" and "15"?

User avatar
dramida
Posts: 473
Joined: Mon Feb 28, 2011 12:58 pm
Location: Bucharest
Contact:

Re: How to configure moving average for gyros - MultiWii 2.2

Post by dramida »

Moving average is a average of a first-in-first-out buffer, called a vector with n number of terms. For n=2 we have (a+b)/2.

For the gyros, 15 means the average of a window of last 15 samples, in which the most distant 5 values are discarded as invalid and the rest of 10 giro samples are added together and divided by 10. (please correct me if i got this one wrong)

Practically, i don't recommend averaging gyro samples unless you are using a flying wing. It's better to use internal LPF for MPU6050 or ITG3200. For me works like a charm LPF= 20. Some use 42 instead but i had trouble in winter with this value.

And one more thing, if you want a smoother response of the gimbal servos, try setting the moving average for gimbal only, let's say for 32 samples.

User avatar
shikra
Posts: 783
Joined: Wed Mar 30, 2011 7:58 pm

Re: How to configure moving average for gyros - MultiWii 2.2

Post by shikra »

On this subject for gimbal users...

In anyone would like to help with testing of some gimbal smoothing code drop me a pm....
I just added in to a 2.2 zip last night

Looking at ways to improve on the current gimbal smoothing.
- Remove delay/lag from averaging when in fast angular changes
- Much less memory footprint. No averaging arrays used
- Anti-jitter
- Deadband introduced if needed

I am unable to test due to weather, but it looks good on the bench!
I've always found the gimbal jitter really annoying on the Multiwii. Assumption was it was down to the software PWM generation, but moving it to a hardware one showed no impromement for me for the smooth AP stuff. So finally decided to try to fix...

Post Reply