
Filter for 9250
Fork of MPU9250 by
Diff: main.cpp
- Revision:
- 5:c7d9f3353b7c
- Parent:
- 4:337af8bbd44e
--- a/main.cpp Sun Jul 09 13:01:22 2017 +0000 +++ b/main.cpp Sun Jul 09 14:20:09 2017 +0000 @@ -37,7 +37,7 @@ void Read_MPU9250() { - + myled= !myled; // If intPin goes high, all data registers have new data if(mpu9250.readByte(MPU9250_ADDRESS, INT_STATUS) & 0x01) { // On interrupt, check if data ready interrupt @@ -45,12 +45,12 @@ // Now we'll calculate the accleration value into actual g's ax = (float)accelCount[0]*aRes - accelBias[0]; // get actual g value, this depends on scale being set - printf("ax=%f\n\r",ax); - printf ("accelcount=%x\n\r",accelCount[0]); - printf ("accelcount int=%i\n\r",accelCount[0]); - printf ("acc X_H=%x\n\r",reg8_bit[X_H]); - printf ("acc decimel X_L=%d\n\r",reg8_bit[X_L]); - printf ("acc X_L=%x\n\r",reg8_bit[X_L]); + // printf("ax=%f\n\r",ax); + // printf ("accelcount=%x\n\r",accelCount[0]); + // printf ("accelcount int=%i\n\r",accelCount[0]); + //printf ("acc X_H=%x\n\r",reg8_bit[X_H]); + // printf ("acc decimel X_L=%d\n\r",reg8_bit[X_L]); + // printf ("acc X_L=%x\n\r",reg8_bit[X_L]); /* ay = (float)accelCount[1]*aRes - accelBias[1]; az = (float)accelCount[2]*aRes - accelBias[2]; */ @@ -141,6 +141,7 @@ //if(Mscale == 1) pc.printf("Magnetometer resolution = 16 bits\n\r"); //if(Mmode == 2) pc.printf("Magnetometer ODR = 8 Hz\n\r"); //if(Mmode == 6) pc.printf("Magnetometer ODR = 100 Hz\n\r"); + // MPU9250SelfTest(); wait(2); } else { pc.printf("Could not connect to MPU9250: \n\r"); @@ -160,21 +161,14 @@ magbias[0] = +470.; // User environmental x-axis correction in milliGauss, should be automatically calculated magbias[1] = +120.; // User environmental x-axis correction in milliGauss magbias[2] = +125.; // User environmental x-axis correction in milliGauss -//every_10ms.attach(&Read_MPU9250,3);//0.001 + wait(2); +every_10ms.attach(&Read_MPU9250, 10);//0.001 while(1) { - Read_MPU9250(); + // Read_MPU9250(); -/* - Now = t.read_us(); - deltat = (float)((Now - lastUpdate)/1000000.0f) ; // set integration time by time elapsed since last filter update - lastUpdate = Now; - sum += deltat; - sumCount++; - - */ /*******************************memory write and read***************************************/ write_EN_Flash(); @@ -214,9 +208,6 @@ /***********************************************************************************************************/ // while(1); - // count = t.read_ms(); - // sum = 0; - // sumCount = 0; wait(1); // } }