VBAT compensation for pid (PD)

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
wektorx
Posts: 8
Joined: Sat Aug 27, 2011 8:08 pm

VBAT compensation for pid (PD)

Post by wektorx »

When battery voltage is over the nominal value it decrease P and D PID for pitch, roll and yaw to 80-100%.

Add to config.h

Code: Select all

#define VBATCOMP 111 //aku voltage compesation for pid PD pitch roll. 111=11.1V for 3s, 148=14.8V for 4s etc. Remember to setup pid when aku voltage is near nominal value.


Add to MultiWii.ino in section: globals variables

Code: Select all

static uint8_t vbatcomp=100;


Add to MultiWii.ino in section: //PITCH & ROLL only dynamic PID adjustemnt, depending on throttle value...

Code: Select all

 ...  
    dynP8[axis] = (uint16_t)P8[axis]*prop1/100;
    dynD8[axis] = (uint16_t)D8[axis]*prop1/100;
   #ifdef VBATCOMP
      dynP8[axis]=(uint16_t)dynP8[axis]*vbatcomp/100;
      dynD8[axis]=(uint16_t)dynD8[axis]*vbatcomp/100;
    #endif
...


Add to MultiWii.ino in section: #if defined(VBAT)...

Code: Select all

...
  } else if ( !buzzerState && (currentTime > (buzzerTime + (2000000>>buzzerFreq))) ) {
        buzzerState = 1;
        BUZZERPIN_ON;
        buzzerTime = currentTime;
      }
    }
    #ifdef VBATCOMP
        vbatcomp=constrain((VBATCOMP*100)/(vbat),80,100);
    #endif
...


Regards

Post Reply