Sensors.pde bug using WM+ orientation in dev20110714

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
johnnyquad
Posts: 6
Joined: Sun Feb 27, 2011 2:58 pm

Sensors.pde bug using WM+ orientation in dev20110714

Post by johnnyquad »

As posted on RCGROUPS http://www.rcgroups.com/forums/showpost.php?p=18926065&postcount=17293
there is a bug in sensors.pde which will only manifest itself if you have oriented your wm+ away from stock position and changed the orientation XYZ at the top of sensors.pde

Code: Select all

#if !defined(ACC_ORIENTATION) 
  #define ACC_ORIENTATION(X, Y, Z)  {accADC[ROLL]  = Y; accADC[PITCH]  = -X; accADC[YAW]  = Z;}
#endif
#if !defined(GYRO_ORIENTATION)
  #define GYRO_ORIENTATION(X, Y, Z) {gyroADC[ROLL] = Y ; gyroADC[PITCH] = -X; gyroADC[YAW] = Z;}
#endif
#if !defined(MAG_ORIENTATION)
  #define MAG_ORIENTATION(X, Y, Z)  {magADC[ROLL]  = -Y; magADC[PITCH]  = X; magADC[YAW]  = Z;}
#endif

if you move them away from stock then you must change the code in sensors.pde starting at line ~848 from

Code: Select all

 GYRO_Common();
    GYRO_ORIENTATION(   (rawADC[3]&0x01)     ? gyroADC[ROLL]/5  : gyroADC[ROLL] ,   //the ratio 1/5 is not exactly the IDG600 or ISZ650 specification
                        (rawADC[4]&0x02)>>1  ? gyroADC[PITCH]/5 : gyroADC[PITCH] ,  //we detect here the slow of fast mode WMP gyros values (see wiibrew for more details)
                        (rawADC[3]&0x02)>>1  ? gyroADC[YAW]/5   : gyroADC[YAW]   ); // this step must be done after zero compensation   
    return 1;


to

Code: Select all

    GYRO_Common();
                        gyroADC[ROLL] = (rawADC[3]&0x01)     ? gyroADC[ROLL]/5  : gyroADC[ROLL];
                        gyroADC[PITCH] = (rawADC[4]&0x02)>>1  ? gyroADC[PITCH]/5 : gyroADC[PITCH];
                        gyroADC[YAW] = (rawADC[3]&0x02)>>1  ? gyroADC[YAW]/5   : gyroADC[YAW];                       
    return 1;


@Alex
I know Alex you replied in rcgroups but this needs to be fixed as most people won't see the bug unless they have changed their default sensor orientation and they are using a wm+.
I've stuck this here on the multiwii forum just to remind you (and me) and its much easier to find rather than looking through the HUGE rcgroup thread for nuggets of info.
j

Post Reply