Steering Assist
Transcript of Steering Assist
-
7/30/2019 Steering Assist
1/7
Steering Assist for an
Agricultural Sprayer
MAE 4733
Mechatronics
Dec 12, 2012
-
7/30/2019 Steering Assist
2/7
Summary
GPS systems are used heavily in the agricultural industry. These systems are heavily integrated
in to many aspects such as tractor guidance, yield mapping, and tracking livestock. These
systems allow for very precise farming techniques saving farmers money while increasing
production. In this project I am looking into designing a basic GPS tractor guidance system
which is not integrated into a tractor, but a stand-alone system making it affordable and easy to
use.
Introduction
I set out to design a system to aid an agricultural sprayer driver. This system is to use a GPS to
record the path of the sprayer, and then calculate a line a specific distance away, the width of the
sprayer. This new calculated line will then be used to guide the driver along the path. This
systems main goal is prevent over spraying and under spraying which can be costly mistakes.
The output will be to a LCD that tells the driver in which direction to steer to drive along the
line. The system needs to be stand alone, easy to use, but also have enough capabilities to attract
buyers.
Equipment
PIC 18F#####
LCD Screen #######
GPS Receiver, Garmin GPS18LVC
Discussion
The project was divided into three main parts; receiving and parsing GPS data, using data to
calculate a new path, guiding the driving along new path.
Receiving and Parsing GPS Data
The GPS receiver sends data to PIC via RS232. Many different formats of GPS data are
sent to the PIC, they are sent in what are called sentences. Each sentence begins with a
dollar sign, $, then followed by prefix for the labeling what information is in the
-
7/30/2019 Steering Assist
3/7
sentence. This project used the $GPRMC sentence, this line holds latitude and
longitude along with some other information that was not used in the current program. In
order to parse out the data I used if statements to look for $GPRMC, since the data is
received one character at a time, If statements determined once I was in the $GPRMC
sentence line by finding the dollar sign and the following letters followed by each other.
Once the line was found the program reads each character in the sentence but only stores
the latitude and longitude. These are stored separately as in character arrays, and then
ended with a null statement making them strings. The using a function, atof, converting
the strings to floats. These floats then can be used for calculations.
Using Data to Calculate a New Path
Before a new path can be calculated a line first must be established. An array is built up
of longitude and latitude data points collected from the GPS points. Only every fifth data
point from the GPS is stored in the array. This frequency may be needed to adjust with
further testing depending on how accurate the system needs to be, or how long the
average line is due to limited memory for long array. Once the driver is finished with
making a path the driver switches the system into non-driving mode, done my rotating
the potentiometer fully clockwise. Once this is done the system will stop recording data
points and calculate a new path, then wait for the driver to go back in to driving mode by
turning the potentiometer fully counter clock wise. Once back in driving mode the
system will begin collecting data in the same fashion as above. The system will also
guide the driver along the calculated path at the same time which will be discussed in the
next section.
The calculation of the new line is done using three points at a time to calculate one point
for the new line. This is done in a for loop and will calculate a new line but the new line
will have two less points as the driven path due to how the line is calculated. Thecalculation is done by finding the angle between the first and middle point, then finding
the angle between the middle point and the third point. These two angle are then added
and divided by two. This calculated angle is then used to find a point perpendicular to
the path a specified distance away.
-
7/30/2019 Steering Assist
4/7
1 and 2 are found using an atan2 function in the code, which accounts for the x and y
component to give a full 0 to 2 output. So then 3 = (1+ 2)/2. Then,
()
()
Some examples of lines and calculated lines are shown below to show that the calculation
works for not only straight lines but also curved lines, which was one of the goals of the
project. The input is data is on the left and the output data is on the right.
-
7/30/2019 Steering Assist
5/7
Driving Along Calculated Path
Once a line had been calculated, the driver needed an output to be given direction on
which way to steer to remain on the desired path. For this the direction the driver is
headed is needed. Also, the direction the point on the line which the driver needs to steer
-
7/30/2019 Steering Assist
6/7
towards is need. This point must be also found. First in order to calculate the direction
the driver is headed, two points are needed. The last two points that have been received
from the GPS are stored in a temporary array independent of the array which logs the
path of the system. These two points are used to calculate the direction the system is
headed. Then the angle between the last point received from the GPS and a point on the
calculated line, this calculation is done until a point in from of the driver is found when
the angle is between -90 degrees and 90 degrees. Once this point is found steering
adjustments can be output to the user. Zero degrees is no steering change and the left or
right depending on if the angle is less than or greater than zero degrees. Below is a
graphical representation of this explanation.
1 and 2 are found using an atan2 function in the code. 3= 12, which is the
steering output. In this example above 1 is greater than 2, so 3 would greater than
zero and the driver would need to turn towards the right.
The System with Parts Working Together
The complete code is at the end of the report with comments.
This section will consist of an overview of the flow of the program and how the parts
work together.
-
7/30/2019 Steering Assist
7/7
The program begins by reading in the longitude and latitude from the GPS and storing in
in an array, temp_x[1] and temp_y[1]. Then a counter which count the number of temp
data points is incremented, in order for the program to know if two data points have been
stored to the temporary array so that steering calculations can be made, two points are
needed for these calculations. Then another counter, data_counter is incremented, this
counter is used to store every fifth data point received from the GPS receiver. After this a
ADC conversion is done to look at the potentiometer to determine if the system is in
Drive Mode or Calculation Mode. If in Calculation Mode then the program will calculate
a new line if at least 3 points are available, as described in the Using Data to Calculate a
New Path section above. The program will then set all the path array variables back to
zero. It will also reset counters that need to be set back to zero, such as the number of
points the driven path array. After this the program will wait to exit this mode until the
driver goes back in to Drive Mode. When the system is in Drive Mode the program
stores every fifth point and steers the driver along the path using method above.
Conclusion
The system worked