David Spillman / Mbed 2 deprecated GPSNavigationNew

Dependencies:   GPS2 L3GD20 LSM303DLHC2 PID mbed SDFileSystem

Fork of GPSNavigation by David Spillman

Revision:
8:c77ab7615b21
Child:
12:273479524c71
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TrollingMotor.h	Mon Apr 27 16:49:48 2015 +0000
@@ -0,0 +1,59 @@
+/*************************************************************************************************************************************************************/
+//  Created by: Ryan Spillman
+//
+//  Last updated 4/9/2015
+//
+//  Contains functions for controlling trolling motor relays
+/*************************************************************************************************************************************************************/
+DigitalOut direction(D5);
+DigitalOut enable(D4);
+
+/*************************************************************************************************************************************************************/
+//                                                      Relay Trolling Motor Control
+/*************************************************************************************************************************************************************/
+
+int prevState = 0;
+
+void goForward()
+{
+    
+    //Are we changing states?
+    if(prevState == 2)
+    {
+        //Short to ground will occur if parallel H-Bridge Relays are not synchronous when changing states
+        //turn off Run/Stop relay first to prevent short
+        enable = 0;
+        wait(0.5);
+        enable = 1;
+        prevState = 1;
+    }
+    else
+    {
+        enable = 1;
+        direction = 0;
+    }
+}
+
+void goBackward()
+{
+    //Are we changing states?
+    if(prevState == 1)
+    {
+        //Short to ground will occur if parallel H-Bridge Relays are not synchronous when changing states
+        //turn off Run/Stop relay first to prevent short
+        enable = 0;
+        wait(0.5);
+        enable = 1;
+        prevState = 2;
+    }
+    else
+    {
+        enable = 1;
+        direction = 1;
+    }
+}
+
+void goStop()
+{
+    enable = 0;
+}
\ No newline at end of file