2017年3月,伊豆大島共同打上実験 CORE_缶ロケチーム電装

Dependencies:   MPU6050 MS5607 mbed SDFileSystem

Files at this revision

API Documentation at this revision

Comitter:
mikawataru
Date:
Sat Feb 18 17:02:59 2017 +0000
Parent:
0:10a9c9c5ce83
Child:
2:b6eb08d059cc
Commit message:
SD??20Hz

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Sat Feb 18 17:02:59 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/mbed/code/SDFileSystem/#8db0d3b02cec
--- a/main.cpp	Sun Feb 12 06:58:29 2017 +0000
+++ b/main.cpp	Sat Feb 18 17:02:59 2017 +0000
@@ -1,39 +1,58 @@
 #include "mbed.h"
 #include "MS5607I2C.h"
 #include "MPU6050.h"
+#include "SDFileSystem.h"
 
-#define RATE 10
+#define RATE 20
 
 MS5607I2C ms5607(p9, p10, false);
 MPU6050 mpu(p9,p10);
 DigitalIn sw(p21);
 DigitalOut myled(LED1);
 Serial pc(USBTX, USBRX);
+SDFileSystem sd(p11, p12, p13, p14, "sd");
 
+Timer timer;
 Ticker loop_measure;
 
 int8_t cnt = 0;
-float altitude[RATE],pressure[RATE],temperature[RATE];
-float acc[RATE][3],gyro[RATE][3];
+bool mode = 0;
+float pressure[2][RATE],temperature[2][RATE];
+float acc[2][RATE][3],gyro[2][RATE][3];
+float t[2][RATE];
+FILE *fp;
+
 void _Launch(){
    myled = 1;
 }
 void _measure(){
-   altitude[cnt] = ms5607.getAltitude();
-   pressure[cnt] = ms5607.getPressure();
-   temperature[cnt] = ms5607.getTemperature();
-   mpu.getAccelero(&acc[cnt][0]);
-   mpu.getGyro(&gyro[cnt][0]);
+   t[mode][cnt] = timer.read();
+   pressure[mode][cnt] = ms5607.getPressure();
+   temperature[mode][cnt] = ms5607.getTemperature();
+   mpu.getAccelero(&acc[mode][cnt][0]);
+   mpu.getGyro(&gyro[mode][cnt][0]);
 //   pc.printf("%f,%f,%f\t",pressure[cnt],temperature[cnt], altitude[cnt]);
 //   pc.printf("%f,%f,%f,%f,%f,%f\r\n",acc[cnt][0],acc[cnt][1],acc[cnt][2],gyro[cnt][0],gyro[cnt][1],gyro[cnt][2]);
+   fprintf(fp, "%f,%f,%f,%f,%f,%f,%f,%f,%f\r\n",
+               t[mode][cnt],pressure[mode][cnt],temperature[mode][cnt],acc[mode][cnt][0],
+               acc[mode][cnt][1],acc[mode][cnt][2],gyro[mode][cnt][0],gyro[mode][cnt][1],gyro[mode][cnt][2]
+            );
    cnt++;
-   if(cnt==10)cnt = 0;
+   if(cnt==RATE){
+      fclose(fp);
+      fp = fopen("/sd/sdtest.txt", "a");
+      mode =! mode;
+      cnt = 0;
+    }
 }
 
 int main() {
+   timer.start();
+   fp = fopen("/sd/sdtest.txt", "w");
+   fprintf(fp, "pressure,temperature,ax,ay,az,gx,gy,gz\r\n");
    myled = 0;
-   loop_measure.attach(&_measure,0.1);
+   loop_measure.attach(&_measure,1.0/RATE);
    while(1){
-        if(sw==0)_Launch(); 
+        if(sw==0)_Launch();
    }
 }