possible a bug in the baro algorithm ?

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
User avatar
JayBee
Posts: 12
Joined: Tue Mar 13, 2012 9:33 pm
Location: Bremerhaven (Germany)

possible a bug in the baro algorithm ?

Post by JayBee »

Inside the imu.ccp at line 336 you can find the following code:

alt.EstAlt = (alt.EstAlt * 6 + BaroAlt ) >> 3; // additional LPF to reduce baro noise (faster by 30 µs)

In my opinion there's a bug.
The sum of the old and the new values should be equal with the divider.
But the sum is 7, the divider is 8.
So over the time alt.EstAlt will become the half of BaroAlt.

JayBee

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: possible a bug in the baro algorithm ?

Post by Alexinparis »

Hi,

Please look at r1628 change. not trivial to follow, but a little faster to do this way

Code: Select all

    baroGroundTemperatureScale = ((int32_t)baroTemperature + 27315) * (2 * 29.271267f); // 2 *  is included here => no need for * 2  on BaroAlt in additional LPF

User avatar
JayBee
Posts: 12
Joined: Tue Mar 13, 2012 9:33 pm
Location: Bremerhaven (Germany)

Re: possible a bug in the baro algorithm ?

Post by JayBee »

Hello Alex,

that make sense.
Thank you for the fast reply.


JayBee

Post Reply