Johan Beverini / Mbed 2 deprecated Project_5A_2

Dependencies:   mbed

Fork of MPU6050IMU by Kris Winer

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "MPU6050.h"
00003 #include <math.h>
00004 
00005 
00006 float sum = 0;
00007 uint32_t sumCount = 0;
00008 
00009    MPU6050 mpu6050;
00010    
00011    AnalogOut ANA1(A3);
00012    //AnalogOut ANA2(PA_5);
00013    
00014    Ticker ms;
00015    
00016    Timer t;
00017 
00018    Serial pc(SERIAL_TX, SERIAL_RX); // tx, rx
00019    
00020    Serial BT(PA_9, PA_10); // tx, rx
00021    
00022 
00023    
00024     float alpha, betaa, gammaa;
00025     float axx, ayy, azz;
00026     float poid[3];
00027     float a, b, c, d, e, s;
00028     int i;
00029     float matrice[3][3], resultat[3];
00030     
00031     bool first = true;
00032     
00033     bool tick_mili;
00034     
00035     float x_x_filter[3]={0,0,0}, x_y_filter[3]={0,0,0};
00036     float y_x_filter[3]={0,0,0}, y_y_filter[3]={0,0,0};
00037     float z_x_filter[3]={0,0,0}, z_y_filter[3]={0,0,0};
00038     float a_coef[3]={1.0000,   -1.5610,    0.6414};
00039     float b_coef[3]={0.0201,    0.0402,    0.0201};
00040     float x_x_filter_ph[3]={0,0,0}, x_y_filter_ph[3]={0,0,0};
00041     float y_x_filter_ph[3]={0,0,0}, y_y_filter_ph[3]={0,0,0};
00042     float z_x_filter_ph[3]={0,0,0}, z_y_filter_ph[3]={0,0,0};
00043     float a_coef_ph[3]={1.0000,   -1.9956,    0.9956};
00044     float b_coef_ph[3]={0.9978,   -1.9956,    0.9978};
00045     float gx_filtre, gy_filtre, gz_filtre;
00046     float gx_filtre2=0.0f, gy_filtre2=0.0f, gz_filtre2=0.0f;
00047     float trapeze_x = 0.0f;
00048     float trapeze_y = 0.0f;
00049     float trapeze_z = 0.0f;
00050  
00051 void mili(void){
00052     tick_mili=true;
00053 }
00054  
00055  
00056         
00057 int main()
00058 {
00059   pc.baud(9600);  
00060   BT.baud(9600); 
00061   
00062   pc.printf("hello word\n");
00063   BT.printf("connection...\n");
00064 
00065   //Set up I2C
00066   i2c.frequency(400000);  // use fast (400 kHz) I2C   
00067   
00068     alpha=0;
00069     betaa=0;
00070     gammaa=0;  
00071   
00072   ms.attach(&mili, 0.001);
00073   t.start();        
00074   
00075   //lcd.init();
00076   //lcd.setBrightness(0.05);
00077   
00078     
00079   // Read the WHO_AM_I register, this is a good test of communication
00080   uint8_t whoami = mpu6050.readByte(MPU6050_ADDRESS, WHO_AM_I_MPU6050);  // Read WHO_AM_I register for MPU-6050
00081   pc.printf("I AM 0x%x\n\r", whoami); pc.printf("I SHOULD BE 0x68\n\r");
00082   
00083   if (whoami == 0x68) // WHO_AM_I should always be 0x68
00084   {  
00085     pc.printf("MPU6050 is online...");
00086     wait(1);
00087     //lcd.clear();
00088     //lcd.printString("MPU6050 OK", 0, 0);
00089 
00090     
00091     mpu6050.MPU6050SelfTest(SelfTest); // Start by performing self test and reporting values
00092     pc.printf("x-axis self test: acceleration trim within : "); pc.printf("%f", SelfTest[0]); pc.printf("% of factory value \n\r");
00093     pc.printf("y-axis self test: acceleration trim within : "); pc.printf("%f", SelfTest[1]); pc.printf("% of factory value \n\r");
00094     pc.printf("z-axis self test: acceleration trim within : "); pc.printf("%f", SelfTest[2]); pc.printf("% of factory value \n\r");
00095     pc.printf("x-axis self test: gyration trim within : "); pc.printf("%f", SelfTest[3]); pc.printf("% of factory value \n\r");
00096     pc.printf("y-axis self test: gyration trim within : "); pc.printf("%f", SelfTest[4]); pc.printf("% of factory value \n\r");
00097     pc.printf("z-axis self test: gyration trim within : "); pc.printf("%f", SelfTest[5]); pc.printf("% of factory value \n\r");
00098     wait(1);
00099 
00100     if(SelfTest[0] < 1.0f && SelfTest[1] < 1.0f && SelfTest[2] < 1.0f && SelfTest[3] < 1.0f && SelfTest[4] < 1.0f && SelfTest[5] < 1.0f) 
00101     {
00102     mpu6050.resetMPU6050(); // Reset registers to default in preparation for device calibration
00103     mpu6050.calibrateMPU6050(gyroBias, accelBias); // Calibrate gyro and accelerometers, load biases in bias registers  
00104     mpu6050.initMPU6050(); pc.printf("MPU6050 initialized for active data mode....\n\r"); // Initialize device for active mode read of acclerometer, gyroscope, and temperature
00105 
00106     //lcd.clear();
00107     //lcd.printString("MPU6050", 0, 0);
00108     //lcd.printString("pass self test", 0, 1);
00109     //lcd.printString("initializing", 0, 2);  
00110     wait(2);
00111        }
00112     else
00113     {
00114     pc.printf("Device did not the pass self-test!\n\r");
00115  
00116        //lcd.clear();
00117        //lcd.printString("MPU6050", 0, 0);
00118        //lcd.printString("no pass", 0, 1);
00119        //lcd.printString("self test", 0, 2);      
00120       }
00121     }
00122     else
00123     {
00124     pc.printf("Could not connect to MPU6050: \n\r");
00125     pc.printf("%#x \n",  whoami);
00126  
00127     //lcd.clear();
00128     //lcd.printString("MPU6050", 0, 0);
00129     //lcd.printString("no connection", 0, 1);
00130     //lcd.printString("0x", 0, 2);  lcd.setXYAddress(20, 2); lcd.printChar(whoami);
00131  
00132     while(1) ; // Loop forever if communication doesn't happen
00133   }
00134 
00135 
00136 
00137  while(1) {
00138   
00139   if (tick_mili==true){
00140       tick_mili=false;
00141   
00142   
00143   // If data ready bit set, all data registers have new data
00144   if(mpu6050.readByte(MPU6050_ADDRESS, INT_STATUS) & 0x01) {  // check if data ready interrupt
00145     mpu6050.readAccelData(accelCount);  // Read the x/y/z adc values
00146     mpu6050.getAres();
00147     
00148     // Now we'll calculate the accleration value into actual g's
00149     ax = (float)accelCount[0]*aRes - accelBias[0];  // get actual g value, this depends on scale being set
00150     ay = (float)accelCount[1]*aRes - accelBias[1];   
00151     az = (float)accelCount[2]*aRes - accelBias[2];  
00152    
00153     mpu6050.readGyroData(gyroCount);  // Read the x/y/z adc values
00154     mpu6050.getGres();
00155  
00156     // Calculate the gyro value into actual degrees per second
00157     gx = (float)gyroCount[0]*gRes; // - gyroBias[0];  // get actual gyro value, this depends on scale being set
00158     gy = (float)gyroCount[1]*gRes; // - gyroBias[1];  
00159     gz = (float)gyroCount[2]*gRes; // - gyroBias[2];
00160  
00161 
00162     tempCount = mpu6050.readTempData();  // Read the x/y/z adc values
00163     temperature = (tempCount) / 340. + 36.53; // Temperature in degrees Centigrade
00164    }  
00165    
00166     Now = t.read_us();
00167     deltat = (float)((Now - lastUpdate)/1000000.0f) ; // set integration time by time elapsed since last filter update
00168     lastUpdate = Now;
00169     
00170     sum += deltat;
00171     sumCount++;
00172     
00173     if(lastUpdate - firstUpdate > 10000000.0f) {
00174      beta = 0.04;  // decrease filter gain after stabilized
00175      zeta = 0.015; // increasey bias drift gain after stabilized
00176     }
00177     
00178    // Pass gyro rate as rad/s
00179     //mpu6050.MadgwickQuaternionUpdate(ax, ay, az, gx*PI/180.0f, gy*PI/180.0f, gz*PI/180.0f);
00180 
00181 
00182     //gx*=PI/180.0f;
00183     //gy*=PI/180.0f;
00184     //gz*=PI/180.0f;
00185     //gx/=1000.0f;
00186     //gy/=1000.0f;
00187     //gz/=1000.0f;
00188     
00189     ////////filtre PB 100Hz / PH 1Hz
00190     //x_x_filter[6]=x_x_filter[5]; x_x_filter[5]=x_x_filter[4]; x_x_filter[4]=x_x_filter[3]; 
00191     //x_x_filter[3]=x_x_filter[2]; 
00192     x_x_filter[2]=x_x_filter[1]; x_x_filter[1]=x_x_filter[0];
00193     x_x_filter[0]=gx;
00194     //x_y_filter[6]=x_y_filter[5]; x_y_filter[5]=x_y_filter[4]; x_y_filter[4]=x_y_filter[3];
00195     //x_y_filter[3]=x_y_filter[2]; 
00196     x_y_filter[2]=x_y_filter[1]; x_y_filter[1]=x_y_filter[0];
00197     x_y_filter[0]=b_coef[0]*x_x_filter[0]+b_coef[1]*x_x_filter[1]+b_coef[2]*x_x_filter[2] //+b_coef[3]*x_x_filter[3] //+b_coef[4]*x_x_filter[4]+b_coef[5]*x_x_filter[5]+b_coef[6]*x_x_filter[6]
00198                     -(a_coef[1]*x_y_filter[1]+a_coef[2]*x_y_filter[2]); //+a_coef[3]*x_y_filter[3]); //+a_coef[4]*x_y_filter[4]+a_coef[5]*x_y_filter[5]+a_coef[6]*x_y_filter[6]);
00199     gx_filtre=x_y_filter[0];
00200     
00201     //y_x_filter[6]=y_x_filter[5]; y_x_filter[5]=y_x_filter[4]; y_x_filter[4]=y_x_filter[3];
00202     //y_x_filter[3]=y_x_filter[2]; 
00203     y_x_filter[2]=y_x_filter[1]; y_x_filter[1]=y_x_filter[0];
00204     y_x_filter[0]=gy;
00205     //y_y_filter[6]=y_y_filter[5]; y_y_filter[5]=y_y_filter[4]; y_y_filter[4]=y_y_filter[3];
00206     //y_y_filter[3]=y_y_filter[2]; 
00207     y_y_filter[2]=y_y_filter[1]; y_y_filter[1]=y_y_filter[0];
00208     y_y_filter[0]=b_coef[0]*y_x_filter[0]+b_coef[1]*y_x_filter[1]+b_coef[2]*y_x_filter[2] //+b_coef[3]*y_x_filter[3] //+b_coef[4]*y_x_filter[4]+b_coef[5]*y_x_filter[5]+b_coef[6]*y_x_filter[6]
00209                     -(a_coef[1]*y_y_filter[1]+a_coef[2]*y_y_filter[2]); //+a_coef[3]*y_y_filter[3]); //+a_coef[4]*y_y_filter[4]+a_coef[5]*y_y_filter[5]+a_coef[6]*y_y_filter[6]);
00210     gy_filtre=y_y_filter[0];
00211     
00212     //z_x_filter[6]=z_x_filter[5]; z_x_filter[5]=z_x_filter[4]; z_x_filter[4]=z_x_filter[3]; 
00213     //z_x_filter[3]=z_x_filter[2];
00214     z_x_filter[2]=z_x_filter[1]; z_x_filter[1]=z_x_filter[0];
00215     z_x_filter[0]=gz;
00216     //z_y_filter[6]=z_y_filter[5]; z_y_filter[5]=z_y_filter[4]; z_y_filter[4]=z_y_filter[3]; 
00217     //z_y_filter[3]=z_y_filter[2]; 
00218     z_y_filter[2]=z_y_filter[1]; z_y_filter[1]=z_y_filter[0];
00219     z_y_filter[0]=b_coef[0]*z_x_filter[0]+b_coef[1]*z_x_filter[1]+b_coef[2]*z_x_filter[2] //+b_coef[3]*z_x_filter[3] //+b_coef[4]*z_x_filter[4]+b_coef[5]*z_x_filter[5]+b_coef[6]*z_x_filter[6]
00220                     -(a_coef[1]*z_y_filter[1]+a_coef[2]*z_y_filter[2]); //+a_coef[3]*z_y_filter[3]); //+a_coef[4]*z_y_filter[4]+a_coef[5]*z_y_filter[5]+a_coef[6]*z_y_filter[6]);
00221     gz_filtre=z_y_filter[0];
00222     
00223      ////////filtre PB 100Hz / PH 1Hz
00224     //x_x_filter[6]=x_x_filter[5]; x_x_filter[5]=x_x_filter[4]; x_x_filter[4]=x_x_filter[3]; 
00225     //x_x_filter_ph[3]=x_x_filter_ph[2]; 
00226     x_x_filter_ph[2]=x_x_filter_ph[1]; x_x_filter_ph[1]=x_x_filter_ph[0];
00227    x_x_filter_ph[0]=gx_filtre;
00228     //x_y_filter[6]=x_y_filter[5]; x_y_filter[5]=x_y_filter[4]; x_y_filter[4]=x_y_filter[3];
00229     //x_y_filter_ph[3]=x_y_filter_ph[2]; 
00230     x_y_filter_ph[2]=x_y_filter_ph[1]; x_y_filter_ph[1]=x_y_filter_ph[0];
00231     x_y_filter_ph[0]=b_coef_ph[0]*x_x_filter_ph[0]+b_coef_ph[1]*x_x_filter_ph[1]+b_coef_ph[2]*x_x_filter_ph[2] //+b_coef_ph[3]*x_x_filter_ph[3] //+b_coef[4]*x_x_filter[4]+b_coef[5]*x_x_filter[5]+b_coef[6]*x_x_filter[6]
00232                     -(a_coef_ph[1]*x_y_filter_ph[1]+a_coef_ph[2]*x_y_filter_ph[2]); //+a_coef_ph[3]*x_y_filter_ph[3]); //+a_coef[4]*x_y_filter[4]+a_coef[5]*x_y_filter[5]+a_coef[6]*x_y_filter[6]);
00233     gx_filtre=x_y_filter_ph[0];
00234     
00235    //y_x_filter[6]=y_x_filter[5]; y_x_filter[5]=y_x_filter[4]; y_x_filter[4]=y_x_filter[3];
00236     //y_x_filter_ph[3]=y_x_filter_ph[2]; 
00237     y_x_filter_ph[2]=y_x_filter_ph[1]; y_x_filter_ph[1]=y_x_filter_ph[0];
00238     y_x_filter_ph[0]=gy_filtre;
00239     //y_y_filter[6]=y_y_filter[5]; y_y_filter[5]=y_y_filter[4]; y_y_filter[4]=y_y_filter[3];
00240     //y_y_filter_ph[3]=y_y_filter_ph[2]; 
00241     y_y_filter_ph[2]=y_y_filter_ph[1]; y_y_filter_ph[1]=y_y_filter_ph[0];
00242     y_y_filter_ph[0]=b_coef_ph[0]*y_x_filter_ph[0]+b_coef_ph[1]*y_x_filter_ph[1]+b_coef_ph[2]*y_x_filter_ph[2] //+b_coef_ph[3]*y_x_filter_ph[3] //+b_coef[4]*y_x_filter[4]+b_coef[5]*y_x_filter[5]+b_coef[6]*y_x_filter[6]
00243                     -(a_coef_ph[1]*y_y_filter_ph[1]+a_coef_ph[2]*y_y_filter_ph[2]); //+a_coef_ph[3]*y_y_filter_ph[3]); //+a_coef[4]*y_y_filter[4]+a_coef[5]*y_y_filter[5]+a_coef[6]*y_y_filter[6]);
00244     gy_filtre=y_y_filter_ph[0];
00245     
00246    //z_x_filter[6]=z_x_filter[5]; z_x_filter[5]=z_x_filter[4]; z_x_filter[4]=z_x_filter[3]; 
00247     //z_x_filter_ph[3]=z_x_filter_ph[2]; 
00248     z_x_filter_ph[2]=z_x_filter_ph[1]; z_x_filter_ph[1]=z_x_filter_ph[0];
00249     z_x_filter_ph[0]=gz_filtre;
00250     //z_y_filter[6]=z_y_filter[5]; z_y_filter[5]=z_y_filter[4]; z_y_filter[4]=z_y_filter[3]; 
00251     //z_y_filter_ph[3]=z_y_filter_ph[2]; 
00252     z_y_filter_ph[2]=z_y_filter_ph[1]; z_y_filter_ph[1]=z_y_filter_ph[0];
00253     z_y_filter_ph[0]=b_coef_ph[0]*z_x_filter_ph[0]+b_coef_ph[1]*z_x_filter_ph[1]+b_coef_ph[2]*z_x_filter_ph[2] //+b_coef_ph[3]*z_x_filter_ph[3] //+b_coef[4]*z_x_filter[4]+b_coef[5]*z_x_filter[5]+b_coef[6]*z_x_filter[6]
00254                     -(a_coef_ph[1]*z_y_filter_ph[1]+a_coef_ph[2]*z_y_filter_ph[2]); //+a_coef_ph[3]*z_y_filter_ph[3]); //+a_coef[4]*z_y_filter[4]+a_coef[5]*z_y_filter[5]+a_coef[6]*z_y_filter[6]);
00255     gz_filtre=z_y_filter_ph[0];
00256 
00257 
00258     trapeze_x=deltat*((gx_filtre+gx_filtre2)/2.0f);
00259     trapeze_y=deltat*((gy_filtre+gy_filtre2)/2.0f);
00260     trapeze_z=deltat*((gz_filtre+gz_filtre2)/2.0f);
00261     
00262     gx_filtre2=gx_filtre;
00263     gy_filtre2=gy_filtre;
00264     gz_filtre2=gz_filtre;
00265 
00266     //calcule angle
00267     alpha+=trapeze_x;
00268     betaa+=trapeze_y;
00269     gammaa+=trapeze_z;  
00270 
00271     if(alpha>=360.0f){alpha-=360.0f;}
00272     if(alpha<=-360.0f){alpha+=360.0f;}
00273     if(betaa>=360.0f){betaa-=360.0f;}
00274     if(betaa<=-360.0f){betaa+=360.0f;}
00275     if(gammaa>=360.0f){gammaa-=360.0f;}
00276     if(gammaa<=-360.0f){gammaa+=360.0f;}
00277 
00278     ANA1.write((alpha+500.0f)/1000.0f);
00279     //ANA2.write(alpha/360.0f);
00280 
00281     // Serial print and/or display at 0.5 s rate independent of data rates
00282     delt_t = t.read_ms() - count;
00283     if (delt_t > 100) { // update LCD once per half-second independent of read rate
00284 
00285     pc.printf("ax = %f", 1000*ax); 
00286     pc.printf(" ay = %f", 1000*ay); 
00287     pc.printf(" az = %f  mg\n\r", 1000*az); 
00288 
00289     pc.printf("gx = %f", gx); 
00290     pc.printf(" gy = %f", gy); 
00291     pc.printf(" gz = %f  deg/s\n\r", gz); 
00292     
00293 //    pc.printf("post filtre : gx = %f", gx_filtre2); 
00294 //    pc.printf(" gy = %f", gy_filtre2); 
00295 //    pc.printf(" gz = %f  deg/s\n\r", gz_filtre2);
00296     
00297     pc.printf(" temperature = %f  C\n\r", temperature); 
00298     
00299 //    pc.printf("q0 = %f\n\r", q[0]);
00300 //    pc.printf("q1 = %f\n\r", q[1]);
00301 //    pc.printf("q2 = %f\n\r", q[2]);
00302 //    pc.printf("q3 = %f\n\r", q[3]);      
00303     
00304     //lcd.clear();
00305     //lcd.printString("MPU6050", 0, 0);
00306     //lcd.printString("x   y   z", 0, 1);
00307     //lcd.setXYAddress(0, 2); lcd.printChar((char)(1000*ax));
00308     //lcd.setXYAddress(20, 2); lcd.printChar((char)(1000*ay));
00309     //lcd.setXYAddress(40, 2); lcd.printChar((char)(1000*az)); lcd.printString("mg", 66, 2);
00310     
00311     
00312   // Define output variables from updated quaternion---these are Tait-Bryan angles, commonly used in aircraft orientation.
00313   // In this coordinate system, the positive z-axis is down toward Earth. 
00314   // Yaw is the angle between Sensor x-axis and Earth magnetic North (or true North if corrected for local declination, looking down on the sensor positive yaw is counterclockwise.
00315   // Pitch is angle between sensor x-axis and Earth ground plane, toward the Earth is positive, up toward the sky is negative.
00316   // Roll is angle between sensor y-axis and Earth ground plane, y-axis up is positive roll.
00317   // These arise from the definition of the homogeneous rotation matrix constructed from quaternions.
00318   // Tait-Bryan angles as well as Euler angles are non-commutative; that is, the get the correct orientation the rotations must be
00319   // applied in the correct order which for this configuration is yaw, pitch, and then roll.
00320   // For more see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles which has additional links.
00321     //yaw   = atan2(2.0f * (q[1] * q[2] + q[0] * q[3]), q[0] * q[0] + q[1] * q[1] - q[2] * q[2] - q[3] * q[3]);   
00322     //pitch = -asin(2.0f * (q[1] * q[3] - q[0] * q[2]));
00323     //roll  = atan2(2.0f * (q[0] * q[1] + q[2] * q[3]), q[0] * q[0] - q[1] * q[1] - q[2] * q[2] + q[3] * q[3]);
00324     //pitch *= 180.0f / PI;
00325     //yaw   *= 180.0f / PI; 
00326     //roll  *= 180.0f / PI;
00327 
00328 //    pc.printf("Yaw, Pitch, Roll: \n\r");
00329 //    pc.printf("%f", yaw);
00330 //    pc.printf(", ");
00331 //    pc.printf("%f", pitch);
00332 //    pc.printf(", ");
00333 //    pc.printf("%f\n\r", roll);
00334 //    pc.printf("average rate = "); pc.printf("%f", (sumCount/sum)); pc.printf(" Hz\n\r");
00335 
00336      //pc.printf("Yaw, Pitch, Roll: %f %f %f\n\r", yaw, pitch, roll);
00337      //pc.printf("average rate = %f\n\r", (float) sumCount/sum);
00338      
00339      //BT.printf("Yaw, Pitch, Roll: %f %f %f\n\r", yaw, pitch, roll);
00340      //BT.printf("average rate = %f\n\r", (float) sumCount/sum); 
00341      
00342     //alpha=yaw;
00343     //betaa=pitch;
00344     //gammaa=roll;
00345 
00346     pc.printf("delta = %f\n\r", (float) deltat);
00347 //    pc.printf("alpha, beta, gamma: %f %f %f\n\r", alpha, betaa, gammaa);
00348     
00349     axx=ax;
00350     ayy=ay;
00351     azz=az;
00352     
00353 ////////////////////////////////////////////////////////Matrice d'Euler();
00354     c = cos(alpha*PI/180.0f); s = sin(alpha*PI/180.0f);
00355     a = cos(betaa*PI/180.0f); b = sin(betaa*PI/180.0f);
00356     d = cos(gammaa*PI/180.0f); e = sin(gammaa*PI/180.0f);
00357 
00358     matrice[0][0] = e*a - e*c*b;
00359     matrice[0][1] = (-d)*b - e*c*a;
00360     matrice[0][2] = e*s;
00361     matrice[1][0] = e*a + d*c*b;
00362     matrice[1][1] = (-e)*b + d*c*a;
00363     matrice[1][2] = (-d)*s;
00364     matrice[2][0] = s*b;
00365     matrice[2][1] = s*a;
00366     matrice[2][2] = c;
00367 
00368    for(i=0; i<3; i++)
00369    {
00370         float temp = 0;
00371         temp = axx * matrice[i][0] + ayy * matrice[i][1] + azz * matrice[i][2];
00372         resultat[i] = temp;
00373    }
00374 //////////////////////////////////////////////////////////
00375     
00376 //    if (first==true){
00377 //     poid[0]=resultat[0];
00378 //     poid[1]=resultat[1];
00379 //     poid[2]=resultat[2];
00380 //     first=false;
00381 //    } else {
00382 //     resultat[0]-=poid[0];
00383 //     resultat[1]-=poid[1];
00384 //     resultat[2]-=poid[2];
00385 //    }
00386     
00387 //     pc.printf("acceleration sans Euler : %f ; %f ; %f\n\r", axx, ayy, azz);
00388 //     pc.printf("acceleration avec Euler : %f ; %f ; %f\n\r", resultat[0], resultat[1], resultat[2]);
00389      BT.printf("acceleration sans Euler : %f ; %f ; %f\n\r", axx, ayy, azz);
00390      BT.printf("acceleration avec Euler : %f ; %f ; %f\n\r", resultat[0], resultat[1], resultat[2]);
00391      
00392  
00393     myled= !myled;
00394     count = t.read_ms(); 
00395     sum = 0;
00396     sumCount = 0; 
00397 }
00398 }
00399     if (BT.readable()) {
00400         char c = BT.getc();
00401         if(c == 'a') {
00402             BT.printf("\nOK\n");
00403         }
00404     }
00405 }
00406  
00407  }
00408 
00409 
00410