BMP085を入れました

Dependencies:   BMP085_2 SDFileSystem mbed

Committer:
yattu0914
Date:
Wed Jul 31 10:59:58 2013 +0000
Revision:
5:9cfdae50349e
Parent:
4:5872b6ac17e5
Child:
6:3cc5c120fbe3
???SD????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yattu0914 0:2c21bfd10524 1 #include "mbed.h"
yattu0914 4:5872b6ac17e5 2 #include "SDFileSystem.h"
yattu0914 5:9cfdae50349e 3 #include "BMP085.h"
yattu0914 1:6dc59f48b649 4
yattu0914 4:5872b6ac17e5 5 SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
yattu0914 0:2c21bfd10524 6 Serial xbee(p13,p14); // tx, rx
yattu0914 1:6dc59f48b649 7 /*Timeout dater;*/
yattu0914 4:5872b6ac17e5 8 //LocalFileSystem local("local");
yattu0914 3:37b076ff27a9 9 Timer timer;
yattu0914 0:2c21bfd10524 10
yattu0914 0:2c21bfd10524 11 AnalogIn temp_in(p20);
yattu0914 0:2c21bfd10524 12 AnalogIn acc_x(p17);
yattu0914 0:2c21bfd10524 13 AnalogIn acc_y(p18);
yattu0914 0:2c21bfd10524 14 AnalogIn acc_z(p19);
yattu0914 0:2c21bfd10524 15 AnalogIn v_out(p16);
yattu0914 0:2c21bfd10524 16 AnalogIn light_in(p15);
yattu0914 4:5872b6ac17e5 17 BMP085 bmp085(p28, p27);
yattu0914 4:5872b6ac17e5 18
yattu0914 4:5872b6ac17e5 19
yattu0914 0:2c21bfd10524 20
yattu0914 0:2c21bfd10524 21 int main() {
yattu0914 0:2c21bfd10524 22
yattu0914 0:2c21bfd10524 23 float r_temp, temp;
yattu0914 5:9cfdae50349e 24 float vo,ax,ay,az, light,P,t;
yattu0914 1:6dc59f48b649 25
yattu0914 5:9cfdae50349e 26 FILE* fp = NULL;
yattu0914 5:9cfdae50349e 27 fp = fopen("/sd/CanSat.txt", "a");
yattu0914 1:6dc59f48b649 28 unsigned count = 0;
yattu0914 4:5872b6ac17e5 29
yattu0914 4:5872b6ac17e5 30 //time_t epoch = 0;
yattu0914 0:2c21bfd10524 31
yattu0914 4:5872b6ac17e5 32 //fprintf(fp, "E %d \r", epoch);
yattu0914 3:37b076ff27a9 33 timer.start();
yattu0914 4:5872b6ac17e5 34
yattu0914 2:e093c70066d0 35 while(1){
yattu0914 3:37b076ff27a9 36 //epoch = time(NULL);
yattu0914 3:37b076ff27a9 37 float seconds = timer.read();
yattu0914 2:e093c70066d0 38 temp = temp_in;
yattu0914 2:e093c70066d0 39 vo = v_out/10*33;
yattu0914 2:e093c70066d0 40 ax = acc_x/10;
yattu0914 2:e093c70066d0 41 ay = acc_y/10;
yattu0914 2:e093c70066d0 42 az = acc_z/10;
yattu0914 2:e093c70066d0 43 light = light_in/10*33;
yattu0914 2:e093c70066d0 44 r_temp = temp_in * 3.3 * 100 ;
yattu0914 4:5872b6ac17e5 45 bmp085.update();
yattu0914 4:5872b6ac17e5 46 P = bmp085.get_pressure();
yattu0914 4:5872b6ac17e5 47 t = bmp085.get_temperature();
yattu0914 4:5872b6ac17e5 48
yattu0914 4:5872b6ac17e5 49 if (fp != NULL) {
yattu0914 4:5872b6ac17e5 50 fprintf(fp, "S %f ", seconds);
yattu0914 4:5872b6ac17e5 51 fprintf(fp, "T %5.2f ",r_temp);
yattu0914 4:5872b6ac17e5 52 fprintf(fp, "H %5.2f ",(vo*8-6)/25);
yattu0914 4:5872b6ac17e5 53 fprintf(fp, "X %5.2f ",(ax*33-1.65)/0.66);
yattu0914 4:5872b6ac17e5 54 fprintf(fp, "Y %5.2f ",(ay*33-1.65)/0.66);
yattu0914 4:5872b6ac17e5 55 fprintf(fp, "Z %5.2f ",(az*33-1.65)/0.66);
yattu0914 4:5872b6ac17e5 56 fprintf(fp, "L %5.2f ",light);
yattu0914 4:5872b6ac17e5 57 fprintf(fp, "P %6.2f ", P);
yattu0914 4:5872b6ac17e5 58 fprintf(fp, "t %6.2f ", t);
yattu0914 5:9cfdae50349e 59 fprintf(fp,"\n\r");
yattu0914 4:5872b6ac17e5 60 }//if
yattu0914 1:6dc59f48b649 61
yattu0914 5:9cfdae50349e 62 if (count % 10 == 0) {
yattu0914 3:37b076ff27a9 63 xbee.printf("S %f ", seconds);
yattu0914 2:e093c70066d0 64 xbee.printf("T %5.2f ",r_temp);
yattu0914 2:e093c70066d0 65 xbee.printf("H %5.2f ",((vo*8-6)/25));
yattu0914 2:e093c70066d0 66 xbee.printf("X %5.2f ",(ax*33-1.65)/0.66);
yattu0914 2:e093c70066d0 67 xbee.printf("Y %5.2f ",(ay*33-1.65)/0.66);
yattu0914 2:e093c70066d0 68 xbee.printf("Z %5.2f ",(az*33-1.65)/0.66);
yattu0914 2:e093c70066d0 69 xbee.printf("L %5.2f",light);
yattu0914 4:5872b6ac17e5 70 xbee.printf("P %6.2f ", P);
yattu0914 4:5872b6ac17e5 71 xbee.printf("t %6.2f ", t);
yattu0914 2:e093c70066d0 72 xbee.printf("\n\r");
yattu0914 2:e093c70066d0 73 }//if
yattu0914 1:6dc59f48b649 74
yattu0914 2:e093c70066d0 75 ++count;
yattu0914 5:9cfdae50349e 76 wait(0.1);
yattu0914 2:e093c70066d0 77 }//while
yattu0914 5:9cfdae50349e 78 fclose(fp);
yattu0914 1:6dc59f48b649 79 }