Generation 3 of the Harp project

Dependencies:   Servo TMP36 GZ buffered-serial1 chan_fatfs_sd nmea_parser watchdog mbed-rtos mbed

Fork of HARP2 by Tyler Weaver

Revision:
16:653df0cfe6ee
Parent:
15:ceac642f6b75
Child:
17:4927053e120f
--- a/main.cpp	Wed Dec 12 16:45:23 2012 +0000
+++ b/main.cpp	Wed Dec 12 17:16:08 2012 +0000
@@ -3,26 +3,17 @@
 #include "buffered_serial.h"
 #include "ff.h"
 #include "BMP085.h"
-#include "ITG3200.h"
 
 I2C i2c(p9, p10); // sda, scl
 BMP085 alt_sensor(i2c);
 
-I2C i2c_2(p28,p27);
-
-
-#define CELLS       3.0
-#define LIPO_EMPTY  3.4
-#define LIPO_FULL   4.2
-
-const float BAT_MUL = 4.7;
-const float BAT_FULL = (CELLS * LIPO_FULL);
-const float BAT_EMPTY = (CELLS * LIPO_EMPTY);
-const float BAT_RANGE = BAT_FULL - BAT_EMPTY;
+const float BAT_GPS_MUL = 15.51;
+const float BAT_MBED_MUL = 10.26;
 
 Serial pc(USBTX, USBRX);
 BufferedSerial gps(NC, p14);
 AnalogIn gps_battery(p20);
+AnalogIn mbed_battery(p19);
 
 typedef struct {
     char    line[80];
@@ -95,9 +86,11 @@
 void sensor_thread(const void* args)
 {
     DigitalOut sensor_led(LED2);
+    Timer t;
+    t.start();
     
     sensor_line *message = mpool_sensor_line.alloc();
-    strcpy(message->line, "GPS Battery,BMP085 Temperature,BMP085 Pressure,BMP085 Altitude(ft)\r\n");
+    strcpy(message->line, "Time(s),GPS Battery(V),mbed Battery(V),BMP085 Temperature(C),Pressure,Altitude(ft)\r\n");
     queue_sensor_line.put(message);
     
     while(true)
@@ -106,21 +99,23 @@
         sensor_led = 1;
         sensor_line *message = mpool_sensor_line.alloc();
         
+        //timestamp
+        float time = t.read();
+        
         //gps battery
-        float sample = gps_battery.read();
-        float gps_battery_voltage = sample*BAT_MUL*3.3;
+        float gps_battery_voltage = gps_battery.read()*BAT_GPS_MUL;
+        
+        //mbed battery
+        float mbed_battery_voltage = mbed_battery.read()*BAT_MBED_MUL;
         
         //BMP085
-        int bmp_temperature = alt_sensor.get_temperature();
+        float bmp_temperature = (float)alt_sensor.get_temperature() / 10.0;
         int bmp_pressure = alt_sensor.get_pressure();
         float bmp_altitude = alt_sensor.get_altitude_ft();
-        
-        // more sensors
-        
-        sprintf(message->line, "%f,%d,%d,%f\r\n", gps_battery_voltage,bmp_temperature,bmp_pressure,bmp_altitude);
+                        
+        sprintf(message->line, "%f,%f,%f,%f,%d,%f\r\n", time,gps_battery_voltage,mbed_battery_voltage,bmp_temperature,bmp_pressure,bmp_altitude);
         queue_sensor_line.put(message);
         sensor_led = 0;        
-        Thread::wait(100);
     }
 }