plot accelerometer data
Dependencies: mbed LSM9DS1_Library_cal
Diff: main.cpp
- Revision:
- 3:201ee5790c15
- Parent:
- 1:9e6bd185745d
--- a/main.cpp Thu Jun 25 10:38:41 2020 +0000 +++ b/main.cpp Wed Jul 08 11:06:21 2020 +0000 @@ -20,15 +20,48 @@ if (!IMU.begin()) { pc.printf("Failed to communicate with LSM9DS1.\n"); } - + int i=0 ; while(1) { while(!IMU.accelAvailable()); IMU.readAccel(); - float acc = sqrt(IMU.calcAccel(IMU.ax)*IMU.calcAccel(IMU.ax)+IMU.calcAccel(IMU.ay)*IMU.calcAccel(IMU.ay)+IMU.calcAccel(IMU.az)*IMU.calcAccel(IMU.az)); + + while( !IMU.gyroAvailable() ) + + IMU.readGyro(); + + + //float acc = sqrt(IMU.calcAccel(IMU.ax)*IMU.calcAccel(IMU.ax)+IMU.calcAccel(IMU.ay)*IMU.calcAccel(IMU.ay)+IMU.calcAccel(IMU.az)*IMU.calcAccel(IMU.az)); + + //pc.printf("%9f",acc) ; + pc.printf("%d",i) ; - pc.printf("%9f\n",acc) ; + pc.printf(",") ; + pc.printf("%9f",IMU.calcAccel(IMU.ax)) ; + pc.printf(",") ; + pc.printf("%9f",IMU.calcAccel(IMU.ay)) ; + pc.printf(",") ; + pc.printf("%9f",IMU.calcAccel(IMU.az)) ; + pc.printf(",") ; + + + pc.printf("%9f",IMU.calcAccel(IMU.gx)) ; + pc.printf(",") ; + pc.printf("%9f",IMU.calcAccel(IMU.gy)) ; + pc.printf(",") ; + pc.printf("%9f",IMU.calcAccel(IMU.gz)) ; + pc.printf(",") ; + + + pc.printf("%9f",IMU.calcAccel(IMU.mx)) ; + pc.printf(",") ; + pc.printf("%9f",IMU.calcAccel(IMU.my)) ; + pc.printf(",") ; + pc.printf("%9f",IMU.calcAccel(IMU.mz)) ; + pc.printf("%\n\r") ; + + i++ ; wait(0.1) ;