Altitude normalization

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
nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Altitude normalization

Post by nhadrian »

Hi guys,

I made these changes basically for sonar develpoment but could be interresting for anybody.
So my idea was to normalize the baro altitude value, with a compensation.
Now my code sets up baro alt to zero on every arming, to reduce temperature-drift. So when armed, baroalt became zero, and baroalt values will be measured from ground level. So that will be comperable to sonaralt values!

Here are my changes:

in multiwii.ino, define these values:

Code: Select all

static int32_t  BaroAlt0;
static int32_t  BaroOff = 0;
static uint8_t  BaroSet = 0;


then add this inside void loop (I added this after defined spektrum, but don't know where would be the best...):

Code: Select all

  #if BARO
  if (armed == 1) {
    if (BaroSet == 0) {
      BaroOff = BaroAlt0;
      BaroSet = 1;
      }
     }
  else {BaroSet = 0;}
  #endif


and finally, modify the MS5611 code to this:

Code: Select all

...
      BaroAlt0 = (1.0f - pow(pressure/101325.0f, 0.190295f)) * 4433000.0f; //centimeter
      BaroAlt = BaroAlt0 - BaroOff;
...


or BMP085 code to this:

Code: Select all

...
      BaroAlt0 = (1.0f - pow(pressure/101325.0f, 0.190295f)) * 4433000.0f; //centimeter
      BaroAlt = BaroAlt0 - BaroOff;
...


Now, alt value will be measured from ground level when flying....
Please note that these canges will not effect altitude hold algorithm. At least they don't should!!! I tested this code in three flights with alt hold enabled, worked great!!!

Here is a sample log about a short take-off in my livingroom:
Image

BR
Adrian

Magnetron
Posts: 124
Joined: Tue Jul 05, 2011 4:32 pm

Re: Altitude normalization

Post by Magnetron »

Very good idea!

User avatar
howardhb
Posts: 189
Joined: Tue Oct 11, 2011 7:10 pm
Location: Port Elizabeth, South Africa

Re: Altitude normalization

Post by howardhb »

Good idea Indeed! (Real pilots do this before take-off!)

I've tested MultiWii_2_0_preversion2, with your changes. (BMP085)
Works fine!

Thanks!

nhadrian
Posts: 421
Joined: Tue Oct 25, 2011 9:25 am

Re: Altitude normalization

Post by nhadrian »

I just had an idea that with this normalized altitude, min and max height could be established.
I mean that, for example, if function is enabled and min, max height parameters are set, around min/max alt hold would be turned on, and between them normal throttle would be applied.
This could prevent orientation loss because of too much height or accidentally crashes especially for beginners, because min and max limits couldn't be crossed. (For that, alt. hold should be activated 0,5-1 m before limits, and released when 1-1,5 m away from limits).
Maybe this is not so hard to program, unfortunatelly I don't have enough time for that... :(

Sorry for my english, it's early morning..... :D

ariekraakjr
Posts: 2
Joined: Fri Mar 30, 2012 7:49 am

Re: Altitude normalization

Post by ariekraakjr »

Nice, gonna try it out tomorrow.

jessestr
Posts: 86
Joined: Tue Dec 27, 2011 8:49 pm

Re: Altitude normalization

Post by jessestr »

Good idea.. Will use it on my mS5611

Post Reply