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