David Spillman / Mbed 2 deprecated GPSNavigationNew

Dependencies:   GPS2 L3GD20 LSM303DLHC2 PID mbed SDFileSystem

Fork of GPSNavigation by David Spillman

TrollingMotor.h

Committer:
Spilly
Date:
2015-04-27
Revision:
8:c77ab7615b21
Child:
12:273479524c71

File content as of revision 8:c77ab7615b21:

/*************************************************************************************************************************************************************/
//  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;
}