Kind of vario implementation in ALT HOLD

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

Kind of vario implementation in ALT HOLD

Post by nhadrian »

Hi all,

I tried to make a simple implementation of altitude control in ALT mode.
The basic idea is that depending on the stick position, I change the value of AltHold.

Here are my changes (in Multiwii 2.0):

in multiwii.ino, define these values:

Code: Select all

static uint32_t currentTime2 = 0;
static uint32_t varioTime = 0;


then replace this part:

Code: Select all

  #if BARO
    if (baroMode) {
      if (abs(rcCommand[THROTTLE]-initialThrottleHold)>20) {
         baroMode = 0; // so that a new althold reference is defined
      }
      rcCommand[THROTTLE] = initialThrottleHold + BaroPID;
    }
  #endif


with this:

Code: Select all

  #if BARO
    currentTime2=millis();
    if (baroMode) {
      if ( ((rcCommand[THROTTLE]-initialThrottleHold)>ALT_HOLD_THR_DEADBAND) && ((currentTime2 - varioTime)>100) ) {
         //baroMode = 0; // so that a new althold reference is defined
             AltHold = AltHold + (VARIO_SCALE*(rcCommand[THROTTLE]-initialThrottleHold))/100;
             varioTime = currentTime2;
      }
      else if ( ((initialThrottleHold-rcCommand[THROTTLE])>ALT_HOLD_THR_DEADBAND) && ((currentTime2 - varioTime)>100) ) {
         //baroMode = 0; // so that a new althold reference is defined
             AltHold = AltHold - (VARIO_SCALE*(initialThrottleHold-rcCommand[THROTTLE]))/100;
             varioTime = currentTime2;
      }
      rcCommand[THROTTLE] = initialThrottleHold + BaroPID;
    }
  #endif


and finally define these in config.h:

Code: Select all

#define ALT_HOLD_THR_DEADBAND 50 //deadband around setpoint throttle value

#define VARIO_SCALE 1 //relation between vario and throttle stick


Changing the value of VARIO_SCALE will change the raising/descending speed.

CAUTION!!! I tested this code till now only with gui or in my living room since we have ..... strong wind nowasays in Hungary, so try it on your own risk!!!!! Please note that using these changes, when ALT mode is activated, you will NOT have direct relation between throttle stick and real throttle, so this code needs as good ALT_HOLD PID settings as it can be!!!

Any comments are wellcome, since I don't have much programming skills, just pure logics... :D

BR
Adrian

Lapino
Posts: 84
Joined: Tue Aug 16, 2011 10:01 am

Re: Kind of vario implementation in ALT HOLD

Post by Lapino »

That's the way I'm used to when flying an Ascending Technologies UAV in Alt-hold mode ;)
Good to know that multiwii used another approach as I don't have any experience with alt hold mode with multiwii yet :)

LuFa
Posts: 160
Joined: Fri Jan 27, 2012 7:56 pm

Re: Kind of vario implementation in ALT HOLD

Post by LuFa »

cool , i have also try do programm something like that .
But your code looks mutch cleaner :)

Post Reply