da testare

Dependencies:   mbed

Fork of programmaACC by Unina_corse

Revision:
4:fa71806deb67
Parent:
3:c9fbf54ed265
diff -r c9fbf54ed265 -r fa71806deb67 main.cpp
--- a/main.cpp	Fri Mar 30 16:29:45 2018 +0000
+++ b/main.cpp	Wed Apr 25 11:59:37 2018 +0000
@@ -3,17 +3,13 @@
 #include <time.h>
 #include "MPU6050.h"
 
-int main()
-{
+int main(){
     i2c.frequency(400000);
     MPU6050 mpu6050;
     uint8_t whoami = mpu6050.readByte(MPU6050_ADDRESS, WHO_AM_I_MPU6050);  // Read WHO_AM_I register for MPU-6050
-    //pc.printf("I AM 0x%x\n\r", whoami); pc.printf("I SHOULD BE 0x68\n\r");
   
-    if (whoami == 0x68) // WHO_AM_I should always be 0x68
-    {  
-    //pc.printf("MPU6050 is online...");
-    //wait(1);
+    if (whoami == 0x68){  
+
      
         mpu6050.MPU6050SelfTest(SelfTest); // Start by performing self test and reporting values
     
@@ -45,14 +41,10 @@
     }
     
    while (true) {
-     // Read the WHO_AM_I register, this is a good test of communication
+    // Read the WHO_AM_I register, this is a good test of communication
     srand(time(NULL));
     int i;
     static const int off_set_a=400;
-    //time_t rawtime;
-    //struct tm* timeinfo;
-    //Timer temp3;
-    //temp3.start();
     for(i = 0; i < BLOCCO; i++){
        
         // If data ready bit set, all data registers have new data
@@ -60,25 +52,23 @@
                 mpu6050.readAccelData(accelCount);  // Read the x/y/z adc values
                 mpu6050.getAres();
     
-            // Now we'll calculate the accleration value into actual g's
-                vettore[i].x = (float)accelCount[0]*aRes - accelBias[0];  // get actual g value, this depends on scale being set
-                vettore[i].y = (float)accelCount[1]*aRes - accelBias[1];   
-                vettore[i].z = (float)accelCount[2]*aRes - accelBias[2];  
+                //Now we'll calculate the accleration value into actual g's
+                vettore[i].x = (float)accelCount[0]*aRes;  // get actual g value, this depends on scale being set
+                vettore[i].y = (float)accelCount[1]*aRes;   
+                vettore[i].z = (float)accelCount[2]*aRes;  
             
                 mpu6050.readGyroData(gyroCount);  // Read the x/y/z adc values
                 mpu6050.getGres();
  
-            // Calculate the gyro value into actual degrees per second
-                vettore[i].xx = (float)gyroCount[0]*gRes; // - gyroBias[0];  // get actual gyro value, this depends on scale being set
-                vettore[i].yy = (float)gyroCount[1]*gRes; // - gyroBias[1];  
-                vettore[i].zz = (float)gyroCount[2]*gRes; // - gyroBias[2];  
+                //Calculate the gyro value into actual degrees per second
+                vettore[i].xx = (float)gyroCount[0]*gRes;  // get actual gyro value, this depends on scale being set
+                vettore[i].yy = (float)gyroCount[1]*gRes;  
+                vettore[i].zz = (float)gyroCount[2]*gRes;  
                              
             }  
    
             pc.printf("%03.0f %03.0f %03.0f %03.0f %03.0f %03.0f\n\r",100*vettore[i].x+off_set_a,100*vettore[i].y+off_set_a,100*vettore[i].z+off_set_a,100*vettore[i].xx+off_set_a,100*vettore[i].yy+off_set_a,100*vettore[i].zz+off_set_a);
          
-        } 
-        //temp3.stop();
-        //pc.printf("Tempo impiegato per l'acquisizione di 1000 elementi: %f\n\r",temp3.read());     
+        }      
     }
 }