is it clear to everyone, that the following code limits the time resolution for every step to about 15ms?
MultiWii.ino
Code: Select all
static uint8_t taskOrder=0; // never call all functions in the same loop, to avoid high delay spikes
switch (taskOrder++ % 5) {
case 0:
#if MAG
Mag_getADC();
#endif
break;
case 1:
#if BARO
Baro_update();
#endif
break;
case 2:
#if BARO
getEstimatedAltitude();
#endif
break;
...
For baro it means, that you get a new value about each 75 ms. If you dont' believe, measure the time between 2 consecutive BaroAlt calculations. The BMP085 is capable of deliver 8 measurements in about 30 ms (8*oversampling), the code now calculates 4 values (4*oversampling) in 75 ms. Instead of stacking optimizations without knowing exactly the effect of any of them the basics have to be fixed..