Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Servo TMP36 GZ chan_fatfs_sd buffered-serial1 nmea_parser watchdog mbed-rtos mbed
Revision 16:653df0cfe6ee, committed 2012-12-12
- Comitter:
- tylerjw
- Date:
- Wed Dec 12 17:16:08 2012 +0000
- Parent:
- 15:ceac642f6b75
- Child:
- 17:4927053e120f
- Commit message:
- batteries, bmp085 logging;
Changed in this revision
| ITG3200.lib | Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/ITG3200.lib Wed Dec 12 16:45:23 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/tylerjw/code/ITG3200/#e61fe4b74daa
--- 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);
}
}