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

Files at this revision

API Documentation at this revision

Comitter:
tylerjw
Date:
Fri Dec 28 17:12:27 2012 +0000
Parent:
24:7477105103e5
Child:
26:85cdb1031eb1
Commit message:
Added watchdog, append file, and servo... NOT TESTED!!!

Changed in this revision

Servo.lib Show annotated file Show diff for this revision Revisions of this file
chan_fatfs_sd.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
watchdog.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Fri Dec 28 17:12:27 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/tylerjw/code/Servo/#1e75dcbded83
--- a/chan_fatfs_sd.lib	Mon Dec 17 23:42:34 2012 +0000
+++ b/chan_fatfs_sd.lib	Fri Dec 28 17:12:27 2012 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/tylerjw/code/chan_fatfs_sd/#f84cf96bb008
+http://mbed.org/users/tylerjw/code/chan_fatfs_sd/#1f9748c6b865
--- a/main.cpp	Mon Dec 17 23:42:34 2012 +0000
+++ b/main.cpp	Fri Dec 28 17:12:27 2012 +0000
@@ -8,6 +8,8 @@
 #include "ff.h"
 #include "BMP085.h"
 #include "nmea_parser.h"
+#include "watchdog.h"
+#include "Servo.h"
 #include "config.h"
 
 I2C i2c(p9, p10); // sda, scl
@@ -80,8 +82,10 @@
     DigitalOut log_led(LED3);
 
     f_mount(0, &fs);
-    f_open(&fp_gps, "0:gps.txt", FA_CREATE_ALWAYS | FA_WRITE);
-    f_open(&fp_sensor, "0:sensors.csv", FA_CREATE_ALWAYS | FA_WRITE);
+    f_open(&fp_gps, "0:gps.txt", FA_OPEN_EXISTING | FA_WRITE);
+    f_lseek(&fp_gps, f_size(&fp_gps));                                  // NOT TESTED!!!
+    f_open(&fp_sensor, "0:sensors.csv", FA_OPEN_EXISTING | FA_WRITE);
+    f_lseek(&fp_sensor, f_size(&fp_sensor));                            // NOT TESTED!!!
 
     while(1) {
         log_led = !log_led;
@@ -154,6 +158,18 @@
 {
     DigitalOut left_turn(LED4);
     DigitalOut right_turn(LED1);
+    
+    // servos ////////////////////////// NOT TESTED!!! ///////////////////////////
+    Servo left_s(p21);
+    Servo right_s(p22);
+
+    left_s.calibrate_max(0.0007);
+    left_s.calibrate_min(-0.0014);
+    right_s.calibrate(0.0009);
+    
+    left_s = 0.0;
+    right_s = 0.0;
+    ////////////////////////////////////////////////////////////////////////////////
 
     right_turn = 1;
     Thread::wait(400);
@@ -181,10 +197,16 @@
             continue; // don't do anything
         } else if(course_diff > 180.0 || course_diff < 0.0) {
             left_turn = 1;
+            right_s = 0.0;                                      // NOT TESTED!!!
+            left_s = 1.0;
             Thread::wait(400); // turn left
+            left_s = 0.0;
         } else {
             right_turn = 1;
+            left_s = 0.0;
+            right_s = 1.0;
             Thread::wait(400); // turn righ
+            right_s = 0.0;
         }
     }
 }
@@ -196,6 +218,13 @@
     Thread thread2(log_thread, NULL, osPriorityNormal);
     Thread thread3(sensor_thread, NULL, osPriorityNormal);
     Thread thread4(parachute_thread, NULL, osPriorityRealtime);
+    
+    Watchdog wdt; // NOT TESTED!!!
+    
+    wdt.kick(2.0);
 
-    while(true) ;
+    while(true) {
+        wdt.kick();
+        Thread::wait(500);
+    }
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/watchdog.lib	Fri Dec 28 17:12:27 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/tylerjw/code/watchdog/#daae6c64fbdf