ground temp compensation - wtf baro values

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
jaames74
Posts: 22
Joined: Tue Jun 12, 2012 5:56 pm

ground temp compensation - wtf baro values

Post by jaames74 »

Hello,
a few days ago, i decided to setup my brand new witespy Ez3.0 Black, with external compass.

Board works OK with multiwii 2.2 as you can see in the picture below:
(minimal config.h, only with board specific declarations)

witespy_blck_mwc22_ms5611.jpg


When i upload MW2.3, baro does not work any more, Alt value
remains to zero. See picture below
(also using minimal config.h, only with board specific declarations)

witespy_blck_mwc23_ms5611.jpg


Using the latest public devr1648, baro behavior is even stranger:
Alt value alternates continuously between 30000, - 30000!!

witespy_blck_mwcr1648_ms5611.jpg


i 've managed to figure out that the problem lies in r1570 (baro Alt based on ground temp compensation + mirror tweak):.
r1569 works perfectly, r1570+ does not!

is this a problem of my board or a MW2.3 bug??
any help would be much appreciated you guys!

carlonb
Posts: 210
Joined: Sun Apr 03, 2011 6:29 pm

Re: ground temp compensation - wtf baro values

Post by carlonb »

Hi jaames74,
Just yesterday flying with my FPV stuffs I had an issue more or less like yours.
My installed code was MWii 2.3 Dev1648.
I started fly with a regular altitude indication on my gogles, but after few seconds I had a strange 14850mt!! and some time 30000...after -14000....
I then investigate in MWii code repository and seems the bug is solved with the dev n. 1649.
I've already mod my installed code and I will test it again on next Week end.
Look here http://www.multiwii.com/forum/viewtopic.php?f=8&t=4534
and here http://code.google.com/p/multiwii/source/detail?r=1649

Cheers
Carlo

jaames74
Posts: 22
Joined: Tue Jun 12, 2012 5:56 pm

Re: ground temp compensation - wtf baro values

Post by jaames74 »

Hello carlonb thanks for your answer!

I managed to figure out where exactly is the problem (seems crazy).
I have made a mistake in my previous post, i wrote that the problem begins with r1570 instead of r1572.
So this thread's title is misleading because the problem has nothing to do with temp compensation.

Well, in r1572 (little baro IMU tweak - IMU.cpp) Alex uses logx - logy in BaroAlt calculation instead of
log(x/y) in previous versions. I am not a coder, so i cannot understand the optimization here, but
i can understand that it is exactly the same, as we all know that log(x/y)=log x - logy.

BUT HERE BECOMES the problem for me. If i alter IMU.cpp in this way:

Code: Select all

if(calibratingB > 0) {
    logBaroGroundPressureSum = baroPressureSum;
    baroGroundTemperatureScale = ((int32_t)baroTemperature + 27315) * (2 * 29.271267f); // 2 *  is included here => no need for * 2  on BaroAlt in additional LPF
    calibratingB--;
  }

  // baroGroundPressureSum is not supposed to be 0 here
  // see: https://code.google.com/p/ardupilot-mega/source/browse/libraries/AP_Baro/AP_Baro.cpp
  BaroAlt = log( (logBaroGroundPressureSum / baroPressureSum) ) * baroGroundTemperatureScale;


my board works perfectly even with the latest dev r1665!!
See the picture!

witespy_blck_mwcr1665_no_IMUtweak.jpg


if i use native IMU.cpp:

Code: Select all

if(calibratingB > 0) {
    logBaroGroundPressureSum = log(baroPressureSum);
    baroGroundTemperatureScale = ((int32_t)baroTemperature + 27315) * (2 * 29.271267f); // 2 *  is included here => no need for * 2  on BaroAlt in additional LPF
    calibratingB--;
  }

  // baroGroundPressureSum is not supposed to be 0 here
  // see: https://code.google.com/p/ardupilot-mega/source/browse/libraries/AP_Baro/AP_Baro.cpp
  BaroAlt = ( logBaroGroundPressureSum - log(baroPressureSum) ) * baroGroundTemperatureScale;


i get this:

witespy_blck_mwcr1665_IMUtweak.jpg


does anyone know WTF is going on here? :shock:

As i was searching in the internet i found on rcgroups another person with exactly the same problem but he gets no answer:

http://www.rcgroups.com/forums/showpost.php?p=27574647&postcount=3219

carlonb
Posts: 210
Joined: Sun Apr 03, 2011 6:29 pm

Re: ground temp compensation - wtf baro values

Post by carlonb »

Hi jaames74,
Ok, my issue seems not the same of yours, I never seen that kind of issue shown in GUI, anyway I want also try to get back with the mod you suggested, use of the old log(x/y), in order to verify it next week end.
Cheers
Carlo

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

Re: ground temp compensation - wtf baro values

Post by Alexinparis »

Very strange.
I've never reproduced it, and I have no explanation.
As you said, it should be equivalent.

the reason to do log x - logy. instead of log(x/y) is to remove a costly / float operation as we know log x is constant once calibrated.

Post Reply