Crude navigation

Dependencies:   GPS2 L3GD20 LSM303DLHC2 PID mbed SDFileSystem

Fork of GPSNavigation by David Spillman

Committer:
Spilly
Date:
Sat May 09 22:29:01 2015 +0000
Revision:
17:ba45eaae96b3
Parent:
14:fd20b7ac8de8
Fix for SD card GPS waypoints

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 L298n H-bridge which controls the linear actuator
Spilly 8:c77ab7615b21 7 /*************************************************************************************************************************************************************/
Spilly 8:c77ab7615b21 8
Spilly 8:c77ab7615b21 9 #define Actuator_h
Spilly 8:c77ab7615b21 10
Spilly 8:c77ab7615b21 11 //L298n connections
Spilly 14:fd20b7ac8de8 12 //mbed classes (mbed folder)
Spilly 8:c77ab7615b21 13 DigitalOut pinI1(D7);
Spilly 8:c77ab7615b21 14 DigitalOut pinI2(PTC12); //D8
Spilly 8:c77ab7615b21 15 PwmOut ENA(D6);
Spilly 14:fd20b7ac8de8 16
Spilly 8:c77ab7615b21 17 /*************************************************************************************************************************************************************/
Spilly 8:c77ab7615b21 18 // L298n (H-Bridge) Functions
Spilly 8:c77ab7615b21 19 /*************************************************************************************************************************************************************/
Spilly 8:c77ab7615b21 20
Spilly 8:c77ab7615b21 21 void turnStop(float valueOne, float valueTwo)
Spilly 8:c77ab7615b21 22 {
Spilly 8:c77ab7615b21 23 pinI1 = 0;
Spilly 8:c77ab7615b21 24 pinI2 = 0;
Spilly 8:c77ab7615b21 25 ENA = valueOne;
Spilly 8:c77ab7615b21 26 }
Spilly 8:c77ab7615b21 27
Spilly 8:c77ab7615b21 28 void turnLeft(float valueOne, float valueTwo)
Spilly 8:c77ab7615b21 29 {
Spilly 8:c77ab7615b21 30 pinI1 = 0;
Spilly 8:c77ab7615b21 31 pinI2 = 1;
Spilly 8:c77ab7615b21 32 ENA = valueOne;
Spilly 8:c77ab7615b21 33 }
Spilly 8:c77ab7615b21 34
Spilly 8:c77ab7615b21 35 void turnRight(float valueOne, float valueTwo)
Spilly 8:c77ab7615b21 36 {
Spilly 8:c77ab7615b21 37 pinI1 = 1;
Spilly 8:c77ab7615b21 38 pinI2 = 0;
Spilly 8:c77ab7615b21 39 ENA = valueOne;
Spilly 8:c77ab7615b21 40 }
Spilly 8:c77ab7615b21 41
Spilly 12:273479524c71 42 //calculate an equal distance from acuator center point that the acutator can physically move to without hitting limit switch
Spilly 8:c77ab7615b21 43 float calcEnds(float center, float max, float min)
Spilly 8:c77ab7615b21 44 {
Spilly 8:c77ab7615b21 45 float upperRange = max - center;
Spilly 8:c77ab7615b21 46 float lowerRange = center - min;
Spilly 8:c77ab7615b21 47 if(upperRange < lowerRange)
Spilly 8:c77ab7615b21 48 {
Spilly 8:c77ab7615b21 49 return upperRange;
Spilly 8:c77ab7615b21 50 }
Spilly 8:c77ab7615b21 51 else
Spilly 8:c77ab7615b21 52 {
Spilly 8:c77ab7615b21 53 return lowerRange;
Spilly 8:c77ab7615b21 54 }
Spilly 8:c77ab7615b21 55 }