David Spillman / Mbed 2 deprecated GPSNavigationNew

Dependencies:   GPS2 L3GD20 LSM303DLHC2 PID mbed SDFileSystem

Fork of GPSNavigation by David Spillman

Committer:
Spilly
Date:
Wed Apr 29 18:10:05 2015 +0000
Revision:
13:17f04a55c6e2
Parent:
12:273479524c71
Child:
14:fd20b7ac8de8
Updated comments

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 13:17f04a55c6e2 4 // Last updated 4/29/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 //Are we changing states?
Spilly 8:c77ab7615b21 20 if(prevState == 2)
Spilly 8:c77ab7615b21 21 {
Spilly 8:c77ab7615b21 22 //Short to ground will occur if parallel H-Bridge Relays are not synchronous when changing states
Spilly 8:c77ab7615b21 23 //turn off Run/Stop relay first to prevent short
Spilly 8:c77ab7615b21 24 enable = 0;
Spilly 8:c77ab7615b21 25 wait(0.5);
Spilly 8:c77ab7615b21 26 enable = 1;
Spilly 8:c77ab7615b21 27 prevState = 1;
Spilly 8:c77ab7615b21 28 }
Spilly 8:c77ab7615b21 29 else
Spilly 8:c77ab7615b21 30 {
Spilly 8:c77ab7615b21 31 enable = 1;
Spilly 8:c77ab7615b21 32 direction = 0;
Spilly 8:c77ab7615b21 33 }
Spilly 8:c77ab7615b21 34 }
Spilly 8:c77ab7615b21 35
Spilly 8:c77ab7615b21 36 void goBackward()
Spilly 8:c77ab7615b21 37 {
Spilly 8:c77ab7615b21 38 //Are we changing states?
Spilly 8:c77ab7615b21 39 if(prevState == 1)
Spilly 8:c77ab7615b21 40 {
Spilly 8:c77ab7615b21 41 //Short to ground will occur if parallel H-Bridge Relays are not synchronous when changing states
Spilly 8:c77ab7615b21 42 //turn off Run/Stop relay first to prevent short
Spilly 8:c77ab7615b21 43 enable = 0;
Spilly 8:c77ab7615b21 44 wait(0.5);
Spilly 8:c77ab7615b21 45 enable = 1;
Spilly 8:c77ab7615b21 46 prevState = 2;
Spilly 8:c77ab7615b21 47 }
Spilly 8:c77ab7615b21 48 else
Spilly 8:c77ab7615b21 49 {
Spilly 8:c77ab7615b21 50 enable = 1;
Spilly 8:c77ab7615b21 51 direction = 1;
Spilly 8:c77ab7615b21 52 }
Spilly 8:c77ab7615b21 53 }
Spilly 8:c77ab7615b21 54
Spilly 8:c77ab7615b21 55 void goStop()
Spilly 8:c77ab7615b21 56 {
Spilly 8:c77ab7615b21 57 enable = 0;
Spilly 8:c77ab7615b21 58 }