Anda di halaman 1dari 46

Use of a GPS unit & The Arduino Microcontroller for Surveying.

July 2, 2012

Abstract The experiment to which this paper concentrates on aims to use the Arduino microcontroller, a programmable 8 bit microprocessor complete with I/O components etc, and a simple GPS unit to make a basic surveying unit. In order to do this various topics are touched upon. The method of communication between the Arduino and GPS is explored in detail in as much as the type of data the position data is received in, the methods the Arduino can employ to extract this data and nally how the Arduino can use this data for distance and area calculations. The Arduino is capable of taking GPS data that comes in the form of NMEA sentences and strip the desired ASCII characters representing position coordinates from the sentence. These can then be converted to oating point numbers and used for arithmetic such as nding distances between two points of latitude and longitude. With a method of nding distances established a program or sketch to nd the area of an irregular sketch was written that successfully calculates the area and plots out the shape on a colour LCD. The error associated with this method was also established with an understanding that the percentage error decreases with increasing distance.

Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . Background . . . . . . . . . . . . . . . . . . . . . . . . . 2.1 The Arduino Microcontroller . . . . . . . . . . . . 2.2 EM-406A GPS module . . . . . . . . . . . . . . . 2.3 Phi II Shield LCD . . . . . . . . . . . . . . . . . 2.4 Sparkfuns 08600 colour LCD . . . . . . . . . . . 3 Method and Algorithms . . . . . . . . . . . . . . . . . . 3.1 Sentence Isolation . . . . . . . . . . . . . . . . . . 3.2 Determination of Distance using Latitude and Longitude . . . . . . . . . . . . . . . . . . . . . . 3.3 The Calculation of the Area of an Irregular Shape 3.4 The Integration of Sparkfuns 08600 Colour LCD 4 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1 Time and Location Display Sketch . . . . . . . . 4.2 Relative Distance Sketch . . . . . . . . . . . . . . 4.3 Irregular Area Sketch . . . . . . . . . . . . . . . . 4.4 Evaluation of Errors . . . . . . . . . . . . . . . . 5 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1 Advancements and Improvements . . . . . . . . . 5.2 Discussion of Errors . . . . . . . . . . . . . . . . 6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Appendix A: Sentence Isolation Sketch . . . . . . . . . . 2 Appendix B: Time and Location Display Sketch . . . . . 3 Appendix C: Relative Distance Sketch . . . . . . . . . . 4 Appendix D: Irregular Area Sketch . . . . . . . . . . . . 5 Appendix E: Error Estimation . . . . . . . . . . . . . . . 1 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 2 4 5 5 6 7 8 9 10 11 11 12 13 18 20 20 22 22 23 26 26 28 33 44

Introduction

This project puts to the test the adaptability of the Arduino to practical tasks, using data to create an informative output and to see how portable it can be. The task set to the Arduino in this project is to see if it can take serial data from a GPS unit and use it to rstly to display position information onto LCDs. This examines the Arduinos capability to take information from one source and manipulate it into a form that will be accepted by an output device like an LCD. Secondly to use latitude and longitude information to nd the distance travelled by the user as the crow ies. This task requires conversion of data to integers that can be used for arithmetic. Also requires the Arduino to save latitude and longitude values until such time as they are to be put to use. Thirdly this project explores if the Arduino can use this distance information to nd areas of simple and complicated shapes. This necessitates the need of a well written code and the memory in the Arduino in which to take this code and put it to use in the eld. Lastly this project questions whether all of the above components can be expressed on a colour 132 132 pixel LCD. For this a library has to be created or found that will allow the plotting of the irregular area being calculated by the Arduino. Also the toll on battery life is recorded thus making a direct impact on the units portability.

2
2.1

Background
The Arduino Microcontroller

The Arduino is a programmable 8-bit microcontroller that is capable of manipulating a series of periphery devices based on the program or with a program that uses serial data from another periphery device. For example a thermistor could be connected up to the Arduino and the Arduino in turn connected up to a small piston device. Based on the temperature values coming in from the thermistor the Arduino could open or close a window in response. Other examples of periphery devices include LEDs, LCDs and GPS units which is the device featured in this report. The Arduino is a marriage of two separate projects both aimed at making a certain specialized eld more accessible to either the public or to students. The rst of these projects is called the Wiring project aimed at making a user friendly library of commands based on C complete with a programming

(a) EM-406A GPS Unit [Spa12a]

(b) Arduino Mega 2560 [BCI+ 12f]

framework that would compile this code and upload it to your microcontroller [BHB12]. Traditional microcontrollers are programmed with C alone and as such getting the microcontroller to light a single LED was a challenge even for the intermediate programmer. The creation of a library for common microcontroller tasks was an initiative to get artists and hobbyists more interested in digital electronics by making it more accessible to non professionals. The second project named Processing had the same project idea in mind but with software literacy in the visual arts [FR12]. The purpose of Processing initially was to be a tool for teaching computer programming in the context of the visual arts but it quickly became the tool of choice for professional work in this eld also. The Arduino team took the library from Wiring and adapted it for their own line of microcontrollers. The development environment was fashioned after Processing in order to write, compile and upload the code to the Arduino boards [BCI+ 12d]. The result is the Arduino community with a series of boards and an Arduino playground full of advice and edgling ideas kept up to date by beginners and experts alike. The board used in this project is the Arduino Mega 2560, one if the larger boards it houses 54 digital input and output pins of which 14 are capable of pulse width modulation output, 16 analog inputs and 4 hardware serial ports. The board can either be powered by a USB connection or by a standard battery [BCI+ 12f, Ard12].

(a) Phi II Shield

(b) 08600 LCD [Spa12b]

2.2

EM-406A GPS module

The EM406-A GPS module distributed by Sparkfun and made by USGlobalSat is a small 30 30 mm unit that serially outputs GPS information with a quoted accuracy of 10 m 2DRMS. 2DRMS means twice the distance root mean square which quotes the accuracy of the unit in terms of circular error probability. In this case it means that the position given by the GPS will be within a circle of 10 m radius 95% of the time [Spa12a, Cor12]. It houses the SiRF StarIII chipset which is a piece of silicon capable of locking to GPS signals and passing coordinate information to the mini computer housed within the unit. The GPS signal carries with it a record of time of when it left the satellite. Its the StarIII job to use that information to nd the distance the satellite is from the unit. If in canyon like area the signals could be reected o walls thus introducing considerable error. The StarIII has a series of tricks to correct this and is the main reason for its popularity as a chip in GPS modules as it enhances the signal aquistion in urban or canopy environments [Owi06]. The module also has an embedded antenna which aids in signal aquistion as well as a LED status indicator and 6 pin cable interface enabling it to be pinned to the Arduino Mega 2560 [Spa12a]. Using this 6 pin cable the GPS can be connected serially to the Arduino in order to transmit position data to the Arduino. The data the GPS outputs comes in the form of NMEA sentences which is a data transmission protocol inherited from the National Marine Electronics Association. The NME Association use this ASCII based protocol to transmit position data to their various vessels throughout the world [DeP12]. There are 4 unique sentences characterised by the rst 6 ASCII characters 4

in the sentence; $GPRMC, $GPGGA, $GPGSA and $GPGSV. They all carry specic set of information such as time, latitude, longitude, satellite status and several more. The sentence used in this project is the $GPGGA line as it contains all the information required [DeP12].

2.3

Phi II Shield LCD

The Phi II Shield is a simple 20 4 LCD that ts virtually every Arduino model [Liu11a]. The LiquidCrystal library is used to program information onto the LCD which is a default library of the Arduino software package [BCI+ 12e]. This allows the user to display text anywhere on the LCD whether it be ASCII or serial information from a peripheral device such as temperature values from a thermistor. The location of text has to be stated explicitly as there is overow problems with this LCD, for example text going o the edge of the rst row will appear coming backwards on the third row. However this LCD is still the most popular choice among Arduino users. For a more comprehensive set of commands for this LCD there is also a downloadable library that allows the creation of menus onto the Shield as well as scrolling options and button control [Liu11b]. It is this LCD that is used mostly for this project for its easily programmable and doesnt drain as much power as the 08600.

2.4

Sparkfuns 08600 colour LCD

The 08600 is a 132 132 pixel colour LCD and is a knocko model of the LCDs found in Nokia 6100 mobile phones. It has 12 pinouts, 10 of which have to have 3.3V input, 1 pin for the backlight that needs to draw a sucient amount of power for the voltage booster to produce 7V required for the backlight and a pin for ground [Spa12b, Owe10]. One particular issue with this LCD is the ambiguity of the graphics controller it has, whether it be a Philips or an Epson [Lyn12]. The documentation contains all the information necessary to build a library to program the LCD however the syntax is dierent for both Philips and Epson. Since building a library for this is a big undertaking and time was limited, a pre built library online had to be used.

Figure 1: Algorithm for compiling sentences and displaying information

Method and Algorithms

For the main aim of the project only the Arduino and the GPS were necessary and as such were the only components, along with the Phi II shield, that were used for the majority of the project duration. The Sparkfun 08600 was left as an optional add-on at the end as to get it operational in any practical sense required an external library which at the moment is still in development. To begin the project a solid foundation of understanding had to be established in terms of getting the GPS to converse with the Arduino and to get the Arduino to extract relevant substrings of information to be put to use in various possible scenarios. The Arduino and the GPS are connected serially through serial port 3 which comprise of pin 15 (RX) and pin 14 (TX) [Cor12], there are two pins grounded to the same Arduino pin in addition to the 5V power and the 1 pulse per second wired to a +5V pin and pin 16 respectively. With the baud rate set to 4800 bps in setup the NMEA sentences can be displayed on a computer monitor using the USB serial connection of the Arduino and the computer. With this an understanding of the NMEA sentences is achieved and a sketch to extract information such as latitude and longitude can begin to be realised. The 08600 LCD requires a voltage of 3.3V for the serial peripheral in6

Figure 2: Algorithm for nding the distance travelled using Lat and Long information terface pins [Spa12b] used for communicating with peripheral devices so a voltage divider is used utilising three resistors to convert 5V from the Arduino pins to 3V for the 08600. These pins are connected to the J1 line of pins on the Arduino Mega in order to avoid bus contention that would occur should they be wired to the digital pins 0-13 line to which the Phi II shield is connected. The 08600 also requires 7V for the backlight. There is a voltage booster tted into the 08600 itself so a 5V or a 3.3V Arduino pin can supply the power, the current drawn from 3.3V being 324mA and from a 5V the power drawn is 120mA [Spa12b, Owe10]. The 5V pin is used to supply power to the backlight and a 3.3V pin for the rest (for a schematic representation, refer to the Appendices). Wiring the board to ground a default blue colour appears on the LCD indicating its ready for use.

3.1

Sentence Isolation

An algorithm to isolate the NMEA sentence $GPGGA and extract information is featured in gure 1. The rst hurdle of this project was the NMEA sentence isolation. Since the Arduino receives one ASCII symbol at a time from the GPS a method of compiling had to be decided upon. In order to be able to extract relevant chunks of information, all of the information has to be stored in a data array of some kind and kept in memory until such time 7

that its needed for data extraction. For this problem, the String Object function in the Arduino reference library [BCI+ 12e] was looked into as well as research into traditional C character arrays and the various ways in which they can be manipulated. For any data to be extracted they have to have a String or an array waiting for them to be placed into thereby indicating multiple array variables are needed. Once extracted they are still ASCII characters which can be displayed on the Phi II to give time, latitude and longitude as well as how many satellites the module has locked on to. Once completed this sketch becomes an integral external function for all future sketches concerning the GPS module. The rst step required for any work to be carried out using the module is compiling the sentences, grabbing the right sentence and nally the information, most important being the satellite information which keeps the user informed of the relative reliability of the incoming information based on how many satellites are in view.

3.2

Determination of Distance using Latitude and Longitude

As mentioned before, the previous algorithm is the base for the algorithm discussed in this section. The owchart is featured in gure 2. There are two main reasons for considering this algorithm. The rst is to put the relative accuracy of the GPS to the test by getting the Arduino, using the data from the GPS, to nd a xed known distance repeatedly and use the data for statistical analysis. The second is to be able to calculate distance for future sketches such as the irregular area sketch. For this sketch to work it needs to follow the following logic. The amount of satellites that the module is locked onto has to be known in order to monitor the number for accuracy considerations. For distance calculations an approximation is made with respect to the spherical coordinates that latitude and longitude are derived from. Since the distances under consideration here are very small, the curvature of the Earth doesnt really impact on the calculations thus for this project cartesian coordinates are used based on the understanding that the error associated with this assumption is negligibly small. With this assumption in place the distance can be determined using Pythagoras theorem providing the latitude and longitude are converted from degree minutes to meters. The conversion factors for latitude and longitude can be determined in ones locality from an ordnance survey map. A map of east Galway region was used for this purpose [oI98] and were found to be,

Figure 3: Finding the area of an irregular shape

1 = 1860 m for Latitude, 1 = 1110 m for Longitude. For this calculation two points have to be recorded and either saved in memory or in the EEPROM. This is controlled by two buttons on the Phi II shield. One button gives the signal for the recording of the initial latitude and longitude point and the other records the second while immediately after going o to calculate the distance using the conversion factors and Pythagoras.

3.3

The Calculation of the Area of an Irregular Shape

This algorithm is a simple concept for nding the area of an irregular shape but dicult to implement as a sketch. An example test area is illustrated in gure 3. The algorithm for nding the area of an irregular shape is as follows. The point with the smallest value of latitude is considered a base point that the other points can project down to. This is done so that the shape can be divided into rectangles and triangles, shapes of which the area is easily calculated. To nd the area of the full shape, all the rectangles and triangles from the longitude to the minimum longitude are added together and the 9

rectangles and triangles from minimum longitude back around to maximum longitude are added together separately. The dierence between these two allocated areas should give out the area of the irregular shape. For the Arduino to be able to carry out this algorithm, the sketch will have to meet a few key requirements. The algorithm requires the max and min of both latitude and longitude so an external function is needed to determine them. The sketch should have a way to organise the points so as to start from the maximum longitude and end back at the same maximum longitude. The sketch also needs to be a general sketch that should work for a regular triangle right up to an irregular shape like the one in gure 3. This means that the sketch has to written in a non specic fashion so as to apply to the widest range of shapes as possible. Thus the main body of this sketch will be an external function that nds the distances for the sides of the rectangles and triangles, the amount of which depends on the amount of points taken and the amount of points between the maximum and minimum of both latitude and longitude. In using the amount of points to govern how the rest of the code operates ensures that it should behave appropriately for the shape being considered, the maximum and minimum also serve to characterize the shape reinforcing the logic that is followed by using the points as markers for how many distances to calculate. Once the distances are calculated the areas have to be determined. This can be done with the number of input points just like the distances. With this point logic in place the area of relatively any shape can be characterised.

3.4

The Integration of Sparkfuns 08600 Colour LCD

The inclusion of the 08600 was questionable for most of the project as an Arduino library or any interface library for the module is yet to be fully realised. There are several libraries online that are half complete and only work for specic types of knocko LCDs [For10]. The main problem being faced with this as mentioned in the background section is the telling whether you have a Philips graphics controller or an Epson [Lyn12]. This is important to know as the two are treated dierently code wise in other words the language being sent to it needs to be its native language or else it wont do anything. The 08600 according to Sparkfun has an Epson controller as they are a clone of older Sparkfun versions however they often refer to Philips controllers in various example codes which has left the issue somewhat confusing [Lyn12]. The only way to include this in the project is to explore the various forums concerning the LCD and work through their workings and see if the same results appear on the LCD here. This requires an untold amount of time 10

Figure 4: NMEA sentences which is the reason it is left as the last order of business. If a library is found then the 08600 can be used to draw the area under consideration to give the user an idea of the shape the Arduino is dealing with thus enabling assurance that the Arduino is considering the correct shape.

Results

This section consists of the nal working sketches of the algorithms described above. The key syntax elements that help overcome problems that were mentioned previously are described in full and they can be viewed in the code in the appendices where the full sketches are located. Also explored is the evolution of the algorithms in order to move around or accommodate problems faced in the coding process or indeed problems faced in the running of the code that forced the algorithm to be revised.

4.1

Time and Location Display Sketch

The sketch for time and location display works exactly how the algorithm displayed in gure 1 portrays. Reading incoming data serves to recognise the instance on a $ sign which indicates the beginning of a sentence. Once received the code jumps to an external function and into a while loop where the incoming characters are added to a string object up until the ASCII character for carriage return is received. Upon reading carriage return there is a lter in the form of an if loop to test if the sentence is $GPGGA, if not the string object containing the tested sentence is emptied and built again until such time when the sentence is $GPGGA in which case its let through with the full sentence intact [DeP12]. To show the time, latitude and longitude the appropriate sections of the sentence have to be plucked out. For time it is characters from 8-14, for latitude its characters 19-30 and for longitude its 31-43. The latitude and longitude will only be displayed however if the character at position 44 of the sentence is 1 indicating that there are satellites present. If the value is 0 then there are no satellites and no latitude and longitude information thus none shall be displayed. 11

The task of taking the snippets of information out falls on the functions of the string object in the Arduino library [BCI+ 12e]. The function string.substring(from,to) [BCI+ 12b] enables the creation of a second string from the main sentence string that contains the desired information. It is because of this very useful functionality that the string object was chosen instead of the more rudimentary character array. Upon completion of this sketch it was then used to record a series of 100 values for latitude and longitude which are recorded to the EEPROM in order to test the absolute accuracy of the module as a function of how many satellites the module has locked onto, the results of which are discussed in evaluation of errors. This sketch is an important step as it lays the basis for extraction of necessary pieces of information and how to put them to use. However if any arithmetic is to be carried out using the latitude or longitude then they must be changed from ASCII characters to integers or oating point numbers. This issue is the main focus of the next sketch.

4.2

Relative Distance Sketch

This sketch also followed from the algorithm without any problems. In terms of sentence building and selection this sketch handles these in the same way as the time and location sketch. A method of converting ASCII characters to integers was required for this sketch which came from using ordinary character arrays and a standard C library function called atoi which stands for ASCII to integer [Mar01]. There exists a sister function of this called itoa which is integer to ASCII however for the purposes here only atoi is used. In order to convert the string of ASCII numbers representing latitude and longitude, they have to be loaded into a regular character array as atoi is a C function and as such wont work with the string function which is a complicated C structure in and of itself. Coincidently there is a string object function that takes a string variable and places it into an empty character string called string.toCharArray(empty char array, num of chars), [BCI+ 12c] yet another reason string objects were used in this project. With the values o loaded into their individual character strings, atoi can be then used to convert the ASCII numbers. With the latitude and longitude converted to integers they need to be converted to meters which is done by multiplying them both by their individual conversion numbers stated in method and algorithms. With these in place Pythagoras is used to get the distance travelled between two points of latitude and longitude. Using this sketch a series of values were recorded onto the EEPROM of 12

the same distance to see how consistent the values were to the specications of the datasheet, the results of which are discussed in the evaluation of errors section.

4.3

Irregular Area Sketch

Data Input and Organisation As discussed in the methods section, this algorithm is based on point logic that is dierent coding structures are required for points in between maximum and minimum values of latitude and longitude. Also an element of organisation for the inputted points has to be met for this logic to work as there has to be a starting and end point that is the same regardless of the shape, in this case the maximum longitude. As a result of the codes necessity to have the points in an clockwise order the points have to be taken clockwise from the starting position otherwise organising the points in the right order for this algorithm would become very cumbersome. In order to have up to a hundred points or greater then arrays can be used. This does introduce a cap on how many points can be taken for evaluation as the size of the array has to be dened, but this number can be changed in the sketch if need be. To many points may be computationally intensive for the eight bit unit however. To keep track of points and values in the arrays the array index is used. The index is a number indicating the location of a value in an array. In this way the index of the maxima and minima can be saved as global variables and can be used to refer to these points where necessary throughout the code. In this way the maxima and minima values can stay in the arrays without disrupting the organisation of the points in the array. The aquistion of points in this sketch is controlled by a button on the Phi II shield. Upon the detection of a falling edge on the pin the button is wired to, the code jumps to an external function called Position() that records the latitude and longitude, converts them to integers and adds them to their own individual arrays. It does this jump thanks to the interrupt function from the Arduino library [BCI+ 12a]. The interrupt waits for a falling or rising edge on a digital pin and upon detection jumps to an external function of choice. This Position() function nds the maximum longitude index of the input array and saves it as a global variable. With the push of a second button this index value is used in the organisation function to reorganize the points by putting the maximum longitude in index zero and lling the array up from there. If the maximum longitude was in the middle of the 13

input array then all the points before it will be at the end after the last value of the input array in the organised array, thereby shifting the points before the maximum longitude and moving them to the end. The organise function also records the index value for the maximum and minimum values for latitude and longitude that are now in the organised array. The index value for maximum longitude will always be zero in the organised array. Distances for Area Calculation of Triangles and Rectangles Following the organisation function is the function to nd the distances required to nd the area of the rectangles and triangles of the shape dictated by the organised points called tri() in the code. This is where using the index values of arrays is put to its greatest use. The index locations are manipulated in order to move around the shape point by point. This is done to get distances required for area calculations which all takes place inside of for loops controlled by index logic. The for loop for points from max longitude to the max latitude for example runs until the control integer of the for loop equals the index number of the maximum latitude. The same logic is used for the other two sections of the shape namely the points between and including the maximum latitude and the minimum longitude and the points from minimum longitude to the minimum latitude. The last quadrant is characterised by a for loop also but only to the last point of the latitude and longitude arrays. The distance for the triangle and rectangle for the last array point to the maximum longitude, which is the rst point in the array, is calculated by a snippet of code directly after the last for loop that ends upon the event at which the control integer of the for loop equals array index number of the last point in the array. Inside of the for loop is the code that nds all the distances of the side of the rectangles and triangles of the shape. The way in which it goes about doing this is featured in gures 5 and 6. Figure 5 features the path the code takes around the shape for the segment of maximum longitude to maximum latitude and also the segment of minimum longitude to minimum latitude. The pattern is slightly dierent for the other two sectors shown in gure 6. This dierence is to account for the change in direction of the path the code has to take, one pattern having to get the distance of the triangle base and then the perpendicular height like in the maximum longitude to maximum latitude segment, the other pattern then having to get the perpendicular height rst and then the base like the maximum latitude to minimum longitude segment. Likewise for the rectangle distance calculations the distance from a rectangle point to minimum latitude is calculated before the triangle distances in the rst and third segment but does the opposite for the other 14

Figure 5: Algorithm for nding the distance travelled using Lat and Long information 15

16 Figure 6: Algorithm for nding the distance travelled using Lat and Long information

(a) 08600 displaying a computed area

(b) The computed area as seen on the Phi II

two segments. This is a direct result of the direction change around the shape. As seen in both of these owcharts the index of each array is used to drive the path forward around the shape while also controlling the duration of the for loop. Calculation of the Area Once the program completes nding all the distances around the shapes perimeter, the distances are gathered for all the triangles into a triangle distance array which will always have twice the amount of points in its array for example if the shape has 7 points the triangle distance array will have 12 distance values, the same applies for the rectangles who have their own individual array. The next step is calculating the individual areas of the triangles and rectangles using the distances contained in their own distance arrays. It falls to another for loop for this task. The for loop needs to terminate when it reached the last distance calculated before the minimum latitude so as to add together all the top areas. The index of this last distance is always twice the minimum longitude index so the for loop will operate for index values less than twice the minimum longitude index. A second for loop is used to calculate and add together all the bottom areas which terminates before the index reaches twice the latitude arrays nal point. A nal snippet of code is at the end of the two for loops for the area of the shapes between the array end point and the maximum longitude. Subtracting the bottom area from the top area yields the area of the shape which is rounded o to the 17

nearest meter since it cant be quoted with decimal points due to the 10 meter accuracy consideration [Cor12]. The Use of Sparkfuns 08600 The inclusion of this componant was dependant on whether or not a suitable library could be found to write and draw rudimentary shapes onto the 08600 since there was no time in which to write one from scratch. A library was found on the Sparkfun site for the 08600 in a comment by username TCWORLD [Spa12b]. This library was written by this user to cater for both Philips and Epson graphics controllers. Upon trying the library with the test example provided the 08600 responded positively. This library enables writing ASCII to the 08600 as well as coloured boxes with user controlled foreground and background colour. Other shapes catered for are circles and straight lines. This library was utilised to display the shape the Arduino calculates with a small compass in the corner to give a sense of direction to the displayed shape. With the calculated area displayed at the bottom of the screen the 08600 makes an eective display device using a very rudimentary library. The code for this can be found in Appendix D in a function called nokia().

4.4

Evaluation of Errors

The datasheet of the EM-406A gives a gure for the accuracy of the GPS unit to be within a circle of radius 10 m of ones true position 95% of the time [Cor12]. If the unit is connected to the European Geostationary Navigation Overlay Service (the European equivalent to WAAS) this circle can be corrected to a 5 m radius of ones true position 95% of the time [Cor12, Age12]. Figure 7 shows a series of histograms examining the absolute accuracy of the GPS unit as you stand in one position for a period of time. The last two histograms display the relative accuracy of the Arduino and the GPS unit of a distance of 20 m. The histogram for the absolute accuracy with 3 or 4 satellites form a Gaussian shape of reasonable spread in values with a standard deviation of 53 m. This standard deviation decreases the more satellites are obtained with the deviation in the 7/8 graph being 1.5 m. Because of this the areas calculated with the Arduino along with relative distance measurements were only carried out while connected to 7 or 8 satellites. It is rare to connect to more than 8, perhaps on a sunny day up to 10 can be found. With the relative distance sketch, measurements a length of 20 m were calculated by the Arduino 15 times making the histogram present in gure 18

(a) Absolute position with 3/4 satellites

(b) Absolute position with 6/7 satellites

(c) Absolute position with 7/8 satellites

(d) Position measurement of twenty meters

(e) Position measurement of twenty meters with averaging of the Lat and Long

Figure 7: Accuracy Histograms

19

7(d). The mean of these results is 17 m with a standard deviation of 2.4 m. The histogram featured in gure 7(e) shows a similar relative distance histogram with the dierence that before making the distance calculation the incoming latitudes and longitudes were averaged over ve measurements. The resulting mean of 21 m is closer to the expected value of 20 m and has the same standard deviation of 2.5 m.

5
5.1

Discussion
Advancements and Improvements

In terms of how capable the Arduino is in extracting information from the NMEA sentences it performs quite well, the only restriction is the second delay between $GPGGA refreshing itself with new data. A way to speed this up is taking information from the other sentence with latitude and longitude information, the $GPRMC sentence [DeP12]. Extracting information from this sentence also would double the latitude and longitude information being received per second eectively halving the time it takes to average position readings. The use of the full latitude and longitude coordinates should be catered for as for this project only the decimal minutes were used as the rest of the coordinate doesnt change on the college campus. Additional strings and conversion of degrees into minutes is required so it wouldnt be to dicult to incorporate into the code. The GPS unit used in this project is capable of connecting to the dierential signal correction service known as the European Geostationary Navigation Overlay Service (EGNOS) [Age12] which can double the accuracy of the unit from 10 meters 2DRMS to 5 meters 2DRMS [Cor12]. To enable this feature a string of command syntax has to be sent to the GPS using a method unknown to me and for this reason the option wasnt explored due to time constraints. The code for the calculation of the area of an irregular shape is one that can be built on. The code is only works if two specics are met namely the points of the shape have to be taken clockwise and also the fact that if there are two points that share the maximum longitude value but dierent latitude the code wont know which point to put into the array as index zero. This is a big aw as the code depends on the maximum longitude the most for the organisation of the input points so that there is a good starting point for the distance calculations. For this reason consideration should be thought in using a new method entirely to nd the area using perhaps the Monte Carlo method of integration. 20

The library that is used for the 08600 is limited to drawing squares, lines and circles as well as writing text and using colours [Spa12b]. Its a strange library in the sense that when it draws a square that the user programmed to appear it slowly draws it across the screen. It does the same thing when the 08600 refreshes, slowly colouring the screen a default colour and only drawing the programmed shapes after this has nished covering the screen. To improve this either this library has to be modied or a new more comprehensive one found or written from scratch. Since the library caters for both Epson and Philips, the Philips code could be removed from the library since the 08600 has an Epson controller. The source code for the library itself should be revised to see what could be causing the slow refresh rate of the 08600. Alternatively a new library could be written using the 08600 data manual [Lyn12] which contains the commands and colour codes associated with the controller and the wealth of information contained in the Sparkfun comments and Arduino playground forum. If the development of this project were to be taken further, thought could be put into perhaps bringing the height above sea level into play in terms of surveying. The method of nding the area of this 3 dimensional model would obviously have to be revised, the Monte Carlo method being a good place to start. The modeling of this shape couldnt be done on the 08600 but the values can be easily saved for analysis on a more powerful machine. The accuracy of the height above sea level is much worse than the longitude and latitude necessitating the need for connection to EGNOS [DeP12, Age12]. Another side project would be to use the 08600 and the GPS to make a digital compass. The basic concept is to display a makeshift compass with North, South, East and West and all thats in between with a compass needle in the middle indicating which way is North and which is South. The relative diculty of doing this with the GPS is most likely pretty high but it would be a good exercise with the 08600, even a simpler derivative of this concept would be worth doing for the experience in operating the 08600. It would require a revised or new version of the 08600 library as it needs to refresh the screen much faster than it does by default. To make the 08600 more portable in the sense that it doesnt consume as much power while on battery, a method of turning the backlight o after a set amount of time would save a lot of power being consumed. The backlight which is wired to a 5V pin on the Arduino consumes 120mA of power [Spa12b]. If it could be used only when the user wants to use the LCD this would save battery life considerably, just like in a mobile phone.

21

5.2

Discussion of Errors

The error associated with the area from Appendix E is as follows, A = 2L0 L It follows from this that the percentage error is, 2L A = A0 L0 For an rectangular area of 2020 m the error in the area calculation using the Arduino and the GPS unit would be, A = 2(20)(2.4) = 96m The error in the length used here is the standard deviation of the relative distance measurements, the histogram of which is featured in gure 7(d). The percentage error of this rectangular area comes out to be, A 2(2.4) = = 0.24 = 24% A0 20 For an area of 100 100 m, using the same standard deviation the error associated with this area would be, A = 2(100)(2.4) = 480m with a percentage error of, A 2(2.4) = 0.048 = 4.8% = A0 100 From this simple analysis it can be estimated that the error of the area calculated will stay constant the bigger the area but the percentage error will decrease with larger areas.

Conclusion

This project has shown the adaptability the Arduino has as a microcontroller. Not only is it a useful tool for hobbyists and artists but can be used in practical applications with great results. Its clear that the Arduino is procient at taking serial data and outputting it in a variety of dierent means, whether it be LEDs or LCDs enabling the user to use the Arduino 22

for portable eld work as the output of the Arduinos task can be displayed on an LCD. Data from the GPS is taken by the Arduino, stripped of its relevant information and displayed as seen in the time and display sketch while also converting latitude and longitude into meters and using them for relative distance. This shows the ease at which the Arduino can take data and carry out a variety of dierent tasks and have them carried out in a very small amount of time. The practical use of the Arduino is proven in the irregular area sketch which takes all the components explored before and culminating them into one very useful and portable sketch. The code is capable of nding the area of areas approximately 100 100 with a percentage error of 4.8%. This surprisingly accurate result reects on the capability of the Arduino and on the workings of the simple GPS unit for nding distances and its competency in using correction techniques as the college can be a somewhat urban environment. Even through the fact that this project can be taken further especially with the 08600, it highlights the versatility of the Arduino and many of its periphery devices.

23

Bibliography
[Age12] [Ard12] European Space Agency. What is EGNOS. http://www.esa. int/esaNA/egnos.html, 2012. Arduino. Arduino MEGA 2560. http://docs-europe. electrocomponents.com/webdocs/0e8b/0900766b80e8ba22. pdf, 2012.

[BCI+ 12a] Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis. Arduino - attachinterrupt(interrupt, function, mode). http://arduino.cc/en/Reference/AttachInterrupt, 2012. [BCI+ 12b] Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis. Arduino - string - substring(). http: //arduino.cc/en/Reference/StringSubstring, 2012. [BCI+ 12c] Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis. Arduino - string - toCharArray(). http:// arduino.cc/en/Reference/StringToCharArray, 2012. [BCI+ 12d] Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis. Arduino Homepage. http://arduino.cc/, 2012. [BCI+ 12e] Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis. Arduino Libraries. http://arduino.cc/en/ Reference/Libraries, 2012. [BCI+ 12f] Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis. Arduino Mega 2560. http://arduino.cc/en/ Main/ArduinoBoardMega2560, 2012. [BHB12] Hernando Barragn, Brett Hagman, and Alexander Brevig. a Wiring - about. http://wiring.org.co/about.html, 2012. 24

[Cor12]

Globalsat Tech Corp. Product User Manual GPS Receiver Engine Board. http://www.sparkfun.com/datasheets/GPS/EM-406A_ User_Manual.PDF, 2012. Dale DePriest. NMEA Data. http://www.gpsinformation. org/dale/nmea.htm, 2012. Arduino Forum. Nokia 6100 LCD Display - Arduino Playground. http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl? num=1237036119/all, 2010. Ben Fry and Casey Reas. Processing - about. processing.org/about/, 2012. http://

[DeP12] [For10]

[FR12] [Liu11a]

John Liu. Phi 2 Documention. http://liudr.files. wordpress.com/2011/02/phi-2-documentation-04022011. pdf, 2011. John Liu. Phi prompt Text-bsed User Interface for Arduino. http://phi-prompt-user-interface-library.googlecode. com/files/Phi_prompt%20documentation%2020110523.pdf, 2011. James P. Lynch. Nokia 6100 LCD Display Driver. http://www.sparkfun.com/tutorial/Nokia%206100%20LCD% 20Display%20Driver.pdf, 2012. Michale Margolis. Arduino Cookbook. OReilly, 1005 Gravenstein Highway North, Sebastopol, CA 95472, 2001. Ordnance Survey of Ireland. Discovery Series 46 Sraith Eolais Gaillimh, 1998. Ryan Owens. Nokia - Breakout - v13. http://www.sparkfun. com/datasheets/LCD/Nokia-Breakout-v13.pdf, 2010. Rich Owings. SiRFstarIII - Why Its a Big Deal. http://www. sparkfun.com/products/465, 2006. Sparkfun. 20 Channel EM-406A SiRF III Receiver with Antenna. http://www.sparkfun.com/products/465, 2012. Sparkfun. Colour LCD - Breakout Board. sparkfun.com/products/8600, 2012. 25 http://www.

[Liu11b]

[Lyn12]

[Mar01] [oI98] [Owe10] [Owi06] [Spa12a] [Spa12b]

Appendix A: Sentence Isolation Sketch

void setup(){ Serial3.begin(4800); Serial.begin(9600); }

void loop(){ if(Serial3.available()>0){ Serial.print(char(Serial3.read())); }

Appendix B: Time and Location Display Sketch

#include <LiquidCrystal.h> #define #define #define #define #define #define LCD_RS LCD_EN LCD_D4 LCD_D5 LCD_D6 LCD_D7 8 9 7 6 2 3

int gps = 0; String SenIn = ""; char conver[5]; char conver2[5]; char conver3[5]; LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7); void setup(){ 26

Serial3.begin(4800); Serial.begin(9600); lcd.begin(20, 4); }

void loop(){ nmea_Decode(); show_Time(); show_Position(); SenIn=""; } void nmea_Decode(){ gps = Serial3.read(); while(gps!=13){ if(Serial3.available()>0){ char gps = Serial3.read(); SenIn = SenIn+gps; if(gps==13){ if(SenIn.charAt(5)==G){ break; } SenIn=""; } } } } void show_Time(){ lcd.home(); lcd.print(SenIn.substring(8,10)); lcd.setCursor(2,0); lcd.write(:); lcd.setCursor(3,0); 27

lcd.print(SenIn.substring(10,12)); lcd.setCursor(5,0); lcd.write(:); lcd.setCursor(6,0); lcd.print(SenIn.substring(12,14)); } void show_Position(){ if(SenIn.charAt(44)==1){ lcd.setCursor(0,1); lcd.print(SenIn.substring(19,30)); lcd.setCursor(0,2); lcd.print(SenIn.substring(31,43)); lcd.setCursor(14,0); lcd.print(SenIn.substring(46,48)); } }

Appendix C: Relative Distance Sketch

#include <LiquidCrystal.h> #include <EEPROM.h> #define #define #define #define #define #define LCD_RS LCD_EN LCD_D4 LCD_D5 LCD_D6 LCD_D7 8 9 7 6 2 3

volatile int state = LOW; volatile int state_2 = LOW; String String String String SenIn = ""; Lat1 = ""; Lat2 = ""; Long1 = ""; 28

String Long2 = ""; String pile = ""; char char char char char float float float float float float float float float float float float conver1[5]; conver2[5]; conver3[5]; conver4[5]; conver5[5]; Lat_one = 0; Lat_two = 0; Long_one = 0; Long_two = 0; Lat_dif = 0; Long_dif = 0; fin1 = 0; fin2 = 0; dist = 0; pile1 = 0; pile2 = 0; ave = 0;

int addr = 12; int gps = 0; LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7); void setup(){ pinMode(18, pinMode(19, pinMode(A0, pinMode(A1, INPUT); INPUT); INPUT); INPUT);

digitalWrite(A0, HIGH); digitalWrite(A1, HIGH); attachInterrupt(5, flag, RISING); // port 18 attachInterrupt(4, flag_2, RISING); // port 19 lcd.begin(20, 4); 29

Serial3.begin(4800); } void loop(){ nmea_Decode(); if(state==0){ lcd.setCursor(0,1); lcd.print("Received"); averageLat(); Lat_one=ave; averageLong(); Long_one=ave; lcd.setCursor(0,2); lcd.print("Done!"); delay(2000); lcd.clear(); state=!state; } if(state_2==0){ lcd.setCursor(0,1); lcd.print("Received"); averageLat(); Lat_two=ave; averageLong(); Long_two=ave; compute(); state_2=!state_2; }

SenIn=""; } void nmea_Decode(){

30

gps = Serial3.read(); while(gps!=13){ if(Serial3.available()>0){ char gps = Serial3.read(); SenIn = SenIn+gps; if(gps==13){ if(SenIn.charAt(5)==G){ lcd.home(); lcd.print(SenIn.substring(46,48)); break; } SenIn=""; } } } } void averageLat(){ pile2 = 0; ave=0; for(int i=0; i<5; i++){ SenIn = ""; nmea_Decode(); pile = SenIn.substring(24,28); pile.toCharArray(conver5, 5); pile1 = atoi(conver5); pile2 = pile2 + pile1; } ave = pile2/5; } void averageLong(){ pile2 = 0; ave=0; 31

for(int i=0; i<5; i++){ SenIn = ""; nmea_Decode(); pile = SenIn.substring(37,41); pile.toCharArray(conver2, 5); pile1 = atoi(conver2); pile2 = pile2 + pile1; } ave = pile2/5; } void compute(){ Lat_dif = (Lat_one-Lat_two)/10000; Long_dif = (Long_one-Long_two)/10000; fin1 = Lat_dif*1860; fin2 = Long_dif*1110; dist = sqrt((fin1*fin1) + (fin2*fin2)); lcd.setCursor(5,0); lcd.print(dist); dist = dist*1000; EEPROM.write(addr,dist); addr++; dist = dist/256; EEPROM.write(addr,dist); addr++; lcd.setCursor(0,2); lcd.print("Done!"); delay(3000); lcd.clear(); } 32

void flag(){ state = !state; } void flag_2(){ state_2 = !state_2; }

Appendix D: Irregular Area Sketch

#include <gLCD.h> #include <LiquidCrystal.h> #include <EEPROM.h> #define LCD_RS 8 #define LCD_EN 9 #define LCD_D4 7 #define LCD_D5 6 #define LCD_D6 2 #define LCD_D7 3 const char RST = 53; const char CS = 47; const char Clk = 49; const char Dat = 51; volatile int state = LOW; volatile int state_2 = LOW; String SenIn = "", Lat = "", Long = ""; char conver1[5], conver2[5], conver3[5], conver4[5], conver5[5]; float float float float position_lat[100], position_long[100]; lat_points[100], long_points[100]; dist_tri[100], dist_rec[100]; Lat_num = 0, Long_num = 0; 33

Lat1 = 0, Lat2 = 0, Long1 = 0, Long2 = 0; Lat_one = 0, Lat_two = 0, Lat_three = 0; Long_one = 0, Long_two = 0, Long_three = 0; Lat_dif = 0; Long_dif = 0; fin1 = 0; fin2 = 0; dist = 0; area_tri_top = 0, area_tri_bottom = 0, area_rec_top = 0, area_rec_bottom = 0, area_top = 0, area_bottom = 0, area = 0; float max_Lat = -10000, max_Long = -10000; float min_Lat = 10000, min_Long = 10000; float max_Long_organ = -10000; int int int int int lat_index = 0, long_index = 0, array_end = 0; org = 0; addr = 12; control = 0, control2 = 0, control3 = 0, num = 0; min_Lat_index = 0, min_Long_index = 0, max_Lat_index = 0, max_Long_index = 0; int max_Long_organ_index = 0; int gps = 0; gLCD graphic(RST,CS,Clk,Dat); LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7); void setup(){ pinMode(18, pinMode(19, pinMode(A0, pinMode(A1, INPUT); INPUT); INPUT); INPUT);

float float float float float float float float float

digitalWrite(A0, HIGH); digitalWrite(A1, HIGH); attachInterrupt(5, flag, RISING); // port 18 attachInterrupt(4, flag_2, RISING); // port 19 //graphic.Init(0,2,0); lcd.begin(20, 4); 34

Serial3.begin(4800); Serial.begin(9600); } void loop(){ nmea_Decode(); if(state==0){ lcd.setCursor(4,0); lcd.print("Received"); Position(); } if(state_2==0){ //nokia(); lcd.setCursor(0,1); lcd.print("Received"); organise(); tri(); Area(); }

SenIn=""; }

void flag(){ state = !state; }

void flag_2(){ state_2 = !state_2; }

35

void nmea_Decode(){ gps = Serial3.read(); while(gps!=13){ if(Serial3.available()>0){ char gps = Serial3.read(); SenIn = SenIn+gps; if(gps==13){ if(SenIn.charAt(5)==G){ lcd.home(); lcd.print(SenIn.substring(46,48)); break; } SenIn=""; } } } }

void Position(){ Lat = SenIn.substring(24,28); Lat.toCharArray(conver1, 5); Lat_num = atoi(conver1); Long = SenIn.substring(37,41); Long.toCharArray(conver2, 5); Long_num = atoi(conver2); position_lat[control]=Lat_num; position_long[control]=Long_num; control++; if(Long_num>max_Long_organ){ max_Long_organ_index = control-1; } 36

save(); lcd.setCursor(13,0); lcd.print("Done"); delay(2000); lcd.clear(); state = !state; } void save(){ EEPROM.write(addr,Lat_num); addr++; Lat_num = Lat_num/256; EEPROM.write(addr,Lat_num); addr++; EEPROM.write(addr,Long_num); addr++; Long_num = Long_num/256; EEPROM.write(addr,Long_num); addr++; } void organise(){ for(org=max_Long_organ_index; org<100; org++){ if(org==control){ org = 0; } if(position_long[org]==max_Long){ break; } long_points[num]=position_long[org]; lat_points[num]=position_lat[org];

37

if(long_points[num]<min_Long){ min_Long=long_points[num]; min_Long_index = num; } if(long_points[org]>max_Long){ max_Long=long_points[num]; max_Long_index = num; } if(lat_points[num]>max_Lat){ max_Lat=lat_points[num]; max_Lat_index = num; } if(lat_points[num]<min_Lat){ min_Lat=lat_points[num]; min_Lat_index = num; } num++; } } void tri(){ for(int index=0; index<max_Lat_index; index++){ Lat1=lat_points[lat_index]; Lat2=min_Lat; Long1=long_points[long_index]; Long2=long_points[long_index]; distance(); dist_rec[control3]=dist; control3++; Lat1=lat_points[lat_index]; Lat2=lat_points[lat_index]; Long1=long_points[long_index]; long_index++; Long2=long_points[long_index]; 38

distance(); dist_tri[control2]=dist; control2++; dist_rec[control3]=dist; control3++; Lat1=lat_points[lat_index]; lat_index++; Lat2=lat_points[lat_index]; Long1=long_points[long_index]; Long2=long_points[long_index]; distance(); dist_tri[control2]=dist; control2++; } long_index = max_Lat_index; lat_index = max_Lat_index; for(int index=max_Lat_index; index<min_Lat_index; index++){ Lat1=lat_points[lat_index]; lat_index++; Lat2=lat_points[lat_index]; Long1=long_points[long_index]; Long2=long_points[long_index]; distance(); dist_tri[control2]=dist; control2++; Lat1=lat_points[lat_index]; Lat2=lat_points[lat_index]; Long1=long_points[long_index]; long_index++; Long2=long_points[long_index]; distance(); dist_tri[control2]=dist; control2++; dist_rec[control3]=dist; control3++; 39

Lat1=lat_points[lat_index]; Lat2=min_Lat; Long1=long_points[long_index]; Long2=long_points[long_index]; distance(); dist_rec[control3]=dist; control3++; } long_index = min_Lat_index; lat_index = min_Lat_index; for(int index=min_Lat_index; index<control-1; index++){ Lat1=lat_points[lat_index]; Lat2=min_Lat; Long1=long_points[long_index]; Long2=long_points[long_index]; distance(); dist_rec[control3]=dist; control3++; Lat1=lat_points[lat_index]; Lat2=lat_points[lat_index]; Long1=long_points[long_index]; long_index++; Long2=long_points[long_index]; distance(); dist_tri[control2]=dist; control2++; dist_rec[control3]=dist; control3++;

Lat1=lat_points[lat_index]; lat_index++; Lat2=lat_points[lat_index]; Long1=long_points[long_index]; 40

Long2=long_points[long_index]; distance(); dist_tri[control2]=dist; control2++; } Lat1=lat_points[control-1]; Lat2=min_Lat; Long1=long_points[control-1]; Long2=long_points[control-1]; distance(); dist_rec[control3]=dist; control3++; Lat1=lat_points[control-1]; Lat2=lat_points[control-1]; Long1=long_points[control-1]; Long2=long_points[max_Long_index]; distance(); dist_tri[control2]=dist; control2++; dist_rec[control3]=dist; control3++; Lat1=lat_points[control-1]; Lat2=lat_points[max_Long_index]; Long1=long_points[max_Long_index]; Long2=long_points[max_Long_index]; distance(); dist_tri[control2]=dist; control2++; } void distance(){ dist=0; Lat_dif = (Lat1-Lat2); Long_dif = (Long1-Long2);

41

fin1 = (Lat_dif*1860)/10000; fin2 = (Long_dif*1110)/10000; dist = sqrt((fin1*fin1) + (fin2*fin2)); Lat1 = 0; Lat2 = 0; Long1 = 0; Long2 = 0;

void Area(){ array_end = control-1; for(int i=0; i<(min_Long_index+min_Long_index); i=i+2){ float tri = (dist_tri[i]*0.5)*dist_tri[i+1]; float rec = dist_rec[i]*dist_rec[i+1]; area_tri_top = area_tri_top+tri; area_rec_top = area_rec_top+rec; } for(int i=(min_Long_index+min_Long_index); i<(array_end+array_end); i=i+2){ float tri_2 = (dist_tri[i]*0.5)*dist_tri[i+1]; float rec_2 = dist_rec[i]*dist_rec[i+1]; area_tri_bottom = area_tri_bottom+tri_2; area_rec_bottom = area_rec_bottom+rec_2; } float tri_3 = (dist_tri[array_end+array_end]*0.5)* dist_tri[array_end+(array_end+1)]; float rec_3 = dist_rec[array_end+array_end]*dist_rec[array_end+(array_end+1)]; area_tri_bottom = area_tri_bottom+tri_3; area_rec_bottom = area_rec_bottom+rec_3; area_top = area_tri_top+area_rec_top; area_bottom = area_tri_bottom+area_rec_bottom;

42

area = area_top - area_bottom; lcd.setCursor(14,1); lcd.print("Done"); lcd.setCursor(0,3); lcd.print(area); EEPROM.write(addr,area); addr++; area = area/256; EEPROM.write(addr,area); addr++; state_2=!state_2; } void nokia(){ graphic.SetBackColour(15,15,15); graphic.SetForeColour(0,0,0); graphic.Box(0,0,130,130,4); graphic.Print("N",100,90,0); graphic.Print("E",115,105,0); graphic.Print("W",85,105,0); graphic.Print("S",100,120,0); graphic.Print("Area: ",1,120,0); graphic.Print(dtostrf(area,4,2,s),31,120,0); for(int i=0; i<control-1; i++){ int X1=abs(round((position_long[i]-max_Long))/10); int X2=abs(round((position_long[i+1]-max_Long)/10)); int Y1=abs(round((position_lat[i]-max_Lat)/10)); int Y2=abs(round((position_lat[i+1]-max_Lat)/10)); graphic.Line(X1+10,Y1+10,X2+10,Y2+10,1); } int X3=abs(round((position_long[control-1]-max_Long)/10)); 43

int X4=abs(round((position_long[0]-max_Long)/10)); int Y3=abs(round((position_lat[control-1]-max_Lat)/10)); int Y4=abs(round((position_lat[0]-max_Lat)/10)); graphic.Line(X3+10,Y3+10,X4+10,Y4+10,1); }

Appendix E: Error Estimation


L = L0 L L = L0 1 L L0 L L0
2

The error in length when calculated using the relative distance sketch is,

A = L2 = L2 1 0

Where A is the area. Using the approximation 1 area equation becomes, A A0 2L0 L Thus A = 2L0 L

L L0

1 2 L the L0

44

Anda mungkin juga menyukai