Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of programmaACC by
Revision 4:fa71806deb67, committed 2018-04-25
- Comitter:
- NdA994
- Date:
- Wed Apr 25 11:59:37 2018 +0000
- Parent:
- 3:c9fbf54ed265
- Commit message:
- ProgrammaACC_daTestare;
Changed in this revision
--- a/MPU6050.h Fri Mar 30 16:29:45 2018 +0000
+++ b/MPU6050.h Wed Apr 25 11:59:37 2018 +0000
@@ -151,7 +151,7 @@
// Specify sensor full scale
int Gscale = GFS_250DPS;
-int Ascale = AFS_2G;
+int Ascale = AFS_4G;
//Set up I2C, (SDA,SCL)
I2C i2c(I2C_SDA, I2C_SCL);
@@ -442,7 +442,7 @@
fifo_count = ((uint16_t)data[0] << 8) | data[1];
packet_count = fifo_count/12;// How many sets of full gyro and accelerometer data for averaging
- for (ii = 0; ii < packet_count; ii++) {
+/* for (ii = 0; ii < packet_count; ii++) {
int16_t accel_temp[3] = {0, 0, 0}, gyro_temp[3] = {0, 0, 0};
readBytes(MPU6050_ADDRESS, FIFO_R_W, 12, &data[0]); // read data for averaging
accel_temp[0] = (int16_t) (((int16_t)data[0] << 8) | data[1] ) ; // Form signed 16-bit integer for each sample in FIFO
@@ -459,8 +459,8 @@
gyro_bias[1] += (int32_t) gyro_temp[1];
gyro_bias[2] += (int32_t) gyro_temp[2];
-}
- accel_bias[0] /= (int32_t) packet_count; // Normalize sums to get average count biases
+}*/
+/* accel_bias[0] /= (int32_t) packet_count; // Normalize sums to get average count biases
accel_bias[1] /= (int32_t) packet_count;
accel_bias[2] /= (int32_t) packet_count;
gyro_bias[0] /= (int32_t) packet_count;
@@ -537,7 +537,7 @@
// Output scaled accelerometer biases for manual subtraction in the main program
dest2[0] = (float)accel_bias[0]/(float)accelsensitivity;
dest2[1] = (float)accel_bias[1]/(float)accelsensitivity;
- dest2[2] = (float)accel_bias[2]/(float)accelsensitivity;
+ dest2[2] = (float)accel_bias[2]/(float)accelsensitivity;*/
}
--- a/SDFileSystem.lib Fri Mar 30 16:29:45 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://os.mbed.com/teams/Unina_corse/code/SDFileSystemFunzionante/#23af2f852b5a
--- a/header.h Fri Mar 30 16:29:45 2018 +0000
+++ b/header.h Wed Apr 25 11:59:37 2018 +0000
@@ -1,8 +1,7 @@
#include "mbed.h"
#include <time.h>
-#define BLOCCO 1000
+#define BLOCCO 10
-//SDFileSystem sd(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, "sd");
Serial pc(USBTX,USBRX,9600);
typedef struct{
--- 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());
+ }
}
}
