David Spillman / Mbed 2 deprecated GPSNavigationNew

Dependencies:   GPS2 L3GD20 LSM303DLHC2 PID mbed SDFileSystem

Fork of GPSNavigation by David Spillman

Committer:
Spilly
Date:
Mon Apr 27 16:49:48 2015 +0000
Revision:
8:c77ab7615b21
Child:
12:273479524c71
BoatProject

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Spilly 8:c77ab7615b21 1 /*************************************************************************************************************************************************************/
Spilly 8:c77ab7615b21 2 // Created by: Ryan Spillman
Spilly 8:c77ab7615b21 3 //
Spilly 8:c77ab7615b21 4 // Last updated 4/9/2015
Spilly 8:c77ab7615b21 5 //
Spilly 8:c77ab7615b21 6 // Contains functions for controlling trolling motor relays
Spilly 8:c77ab7615b21 7 /*************************************************************************************************************************************************************/
Spilly 8:c77ab7615b21 8 DigitalOut direction(D5);
Spilly 8:c77ab7615b21 9 DigitalOut enable(D4);
Spilly 8:c77ab7615b21 10
Spilly 8:c77ab7615b21 11 /*************************************************************************************************************************************************************/
Spilly 8:c77ab7615b21 12 // Relay Trolling Motor Control
Spilly 8:c77ab7615b21 13 /*************************************************************************************************************************************************************/
Spilly 8:c77ab7615b21 14
Spilly 8:c77ab7615b21 15 int prevState = 0;
Spilly 8:c77ab7615b21 16
Spilly 8:c77ab7615b21 17 void goForward()
Spilly 8:c77ab7615b21 18 {
Spilly 8:c77ab7615b21 19
Spilly 8:c77ab7615b21 20 //Are we changing states?
Spilly 8:c77ab7615b21 21 if(prevState == 2)
Spilly 8:c77ab7615b21 22 {
Spilly 8:c77ab7615b21 23 //Short to ground will occur if parallel H-Bridge Relays are not synchronous when changing states
Spilly 8:c77ab7615b21 24 //turn off Run/Stop relay first to prevent short
Spilly 8:c77ab7615b21 25 enable = 0;
Spilly 8:c77ab7615b21 26 wait(0.5);
Spilly 8:c77ab7615b21 27 enable = 1;
Spilly 8:c77ab7615b21 28 prevState = 1;
Spilly 8:c77ab7615b21 29 }
Spilly 8:c77ab7615b21 30 else
Spilly 8:c77ab7615b21 31 {
Spilly 8:c77ab7615b21 32 enable = 1;
Spilly 8:c77ab7615b21 33 direction = 0;
Spilly 8:c77ab7615b21 34 }
Spilly 8:c77ab7615b21 35 }
Spilly 8:c77ab7615b21 36
Spilly 8:c77ab7615b21 37 void goBackward()
Spilly 8:c77ab7615b21 38 {
Spilly 8:c77ab7615b21 39 //Are we changing states?
Spilly 8:c77ab7615b21 40 if(prevState == 1)
Spilly 8:c77ab7615b21 41 {
Spilly 8:c77ab7615b21 42 //Short to ground will occur if parallel H-Bridge Relays are not synchronous when changing states
Spilly 8:c77ab7615b21 43 //turn off Run/Stop relay first to prevent short
Spilly 8:c77ab7615b21 44 enable = 0;
Spilly 8:c77ab7615b21 45 wait(0.5);
Spilly 8:c77ab7615b21 46 enable = 1;
Spilly 8:c77ab7615b21 47 prevState = 2;
Spilly 8:c77ab7615b21 48 }
Spilly 8:c77ab7615b21 49 else
Spilly 8:c77ab7615b21 50 {
Spilly 8:c77ab7615b21 51 enable = 1;
Spilly 8:c77ab7615b21 52 direction = 1;
Spilly 8:c77ab7615b21 53 }
Spilly 8:c77ab7615b21 54 }
Spilly 8:c77ab7615b21 55
Spilly 8:c77ab7615b21 56 void goStop()
Spilly 8:c77ab7615b21 57 {
Spilly 8:c77ab7615b21 58 enable = 0;
Spilly 8:c77ab7615b21 59 }