Skip to content
July 16, 2010 / Nandha kumar

Tran-Duino Proof of Concept

Hi to all,

I have posted about my Final year MCA academic project ” Tran – Duino” in my previous posts.

I have atlast some how managed to prepare the proof of concept for my project. In my previous post, I had done upto extracting latitude and longitude values from the GPS sentences received from EM-406a GPS module and printing it in LCD Display as follows,

Then after completing this part, I started with reading GPS log file stored within SDcard in the form of Textfile. The usual GPS log file will be in the following format.

GPS LOG File

The code that I followed is from ladyada.net . The file contains GPS sentences that are received from GPS module each second. Each line is a GPS sentence starting from $ symbol and ends with * followed by two digit Hexadecimal checksum value. The Word “GPRMC” defines the datatype of NMEA sentence that is being received. GP defines that the device used is a GPS receiver module.

RMC – Recommended Minimum Type C sentence. There are more than 20 type of NMEA data sentences that is transmitted to GPS units.All of these sentences usually provide the common data that is latitude and longitude, velocity. The RMC sentence has the following fields, namely,

$GPRMC – datatype

131754.000 – Fix taken time (UTC)

A – status [ A – if active or V – if void ]

1307.3412 – latitude in Degrees, minutes and micro minutes.

N – latitude direction [ North ]

08013.3205 – longitude in Degrees, minutes and micro minutes.

E – longitude direction [ East ]

1.13 – Speed over the ground in Knots

307.60 – Track Angle

210510 – Fix taken date

*0F – checksum data

For more information regarding NMEA sentences please visit here .

I started to find a code that can able to read back the data being stored in the SDcard. First I saw through the AF_SDLog library and found functions like sdcard_read() to read the data from SD card. I also tried the card read example provided with that library. It worked successfully. I was able to read the data present in the text file completely and print it in Serial monitor.

In the GPS sentence , the only needed part for my project is the latitude and longitude. So, I started to find the way to read only those data and avoid remaining data from each sentence. But Then I identified that the data being read from card is of uint8_t data type. This datatype is similar to char datatype but not the same.

Hence, I tried all sorts of conversion from uint8_t to float , double . But I couldnot convert it as I required. Then I found a SDCard library – a modified version of AF_SDLog library, to read data from SD card. Using this library I was able to print the latitude and longitude alone from each GPS sentence and print it in serial monitor. But I was not able to process further with it (ie) converting into float or double type. I also had the problem of assigning the exact buffer size of reading the data from SDcard. I had this problem since the length of GPS sentences being logged in the sdcard is of varied length . This happens when sufficient data needed to fill each GPS sentence gets missing due to poor signal. For example, the fields like magnetic variation, date, etc will be mostly missing sometimes.

Then I found a way to type convert the latitude and longitude from uint8_t to float value. I was really happy. But a new problem arised. I was not able to integrate the new SDCard library code with the AF_SDLog library code [ even though both the libraries are almost similar ]. I was sad on how to proceed further.

I asked the help from ladyada forum and stated the problem I faced. They advised me to use the sdfatlib from http://code.google.com/p/sdfatlib/ . I tried with the SdFatRead example provided with the library. It worked fine. Again I had the problem with type conversion from uint8_t to float datatype. I integrated the float conversion from the previous code into this example code and it worked.

Data Read from SDcard

For my project’s proof of concept I need to compare two float values. But When I googled regarding this, I came to know that float comparison is not possible and was not accurate. I had no other way but to use the char datatype to compare the latitude and longitude data. So, I typecasted the uint8_t type as char . It worked fine. But another great problem I faced was that when I was reading data from SD card as char datatype, The data being read became irregular (ie) The latitude and longitude read from each GPS sentence was not exactly read. It sometimes included the next characters after the required data. hence the entire format got collapsed.

I was really fedup. I tried several ways and also seeked help from arduino forums and my friends. But I could not make it. Because of this problem the comparison part was also not working.

Actually the Idea of my project was to read the GPS data like latitude and longitude from SD card, receive GPS data from GPS receiver, compare them and if data matches, print some data in Display. But the problem is that when using char data type, I can only compare character by character since the data processing is done inside the loop. I was really confused on how to proceed further.

I was getting more nervous as my review dates were nearing. I was in great tension to show atleast the proof of concept  in my college. During that time, I thought of a way. Instead of extracting latitude and longitude from the entire 80 character sentence, I just modified the logging code so that only converted latitude and longitude can be logged into SDcard. For achieving this purpose I made use of  the write() function from sdfatlib library. This function writes the data of type character into SDcard.

Latitude and Longitude- not converted

But to my bad luck, When I prepared that code there was heavy rain in my city for 2 days and it was cloudy too. So, the GPS unit was not receiving any data. Then after 2 days, The day was bright and fine. I uploaded the code into Arduino and started logging it. Yes, The code worked fine and the data was getting logged as I required. For now one part of the task was finished.

Latitude and Longitude [ converted

So, The next task was to write the comparison code. Already I had the problem that since the latitude was converted character by character inside a loop, the task was getting difficult. I tried storing the latitude and longitude into a string and compare it. But I was not successful with it. I also searched a lot in net. Also seeked help from my friends. But No use.

Then one fine day, I reached in google as “GPS Tracking Arduino” and found few links. In one of the links, I found a project where a guy has done a project to track his college bus using the bus website and also update its status in Twitter. http://randomhacksofboredom.blogspot.com/2010/04/most-useful-mess-of-wires-gps-bus.html . It was really an interesting project. But This link only gave me a great idea to solve the second part of the Task. In that blog I found the following link http://www.arduino.cc/en/Tutorial/TextString . This link introduced a new data type called Text String that can be used with Arduino. This datatype is similar to String datatype and the library also got many builtin functions that works same as many string functions like concatenation, replacing string, substring, string equality, etc.

Then I Immediately installed that library and started testing the example codes. Then I modified the code and tried with comparison of latitude and longitude with a single string using this TextString datatype. Yes, The comparison worked. Then I created a Array of Strings for storing both latitude and longitude and stored some sample data in it.I also created a array of names that is to be displayed when the latitude and longitude comparison was successful.

I tested the modified code by keeping the GPS near my window. I initially for testing the code, I made the output to be seen in Serialmonitor. After sometime of intialisation the names was getting printed. I was really happy. When I moved the GPS away from the window, some other name from that array got printed. likewise, I checked with the six sample values and all got printed.

So, For now The code works. But I have not checked the same when GPS is in movement. So, Inorder to check that I thought of making use of the sample route that I logged in my area. The sample test route when viewed as output from gpsvisualizer.com was as follows

Sample Route

The website http://www.gpsvisualizer.com/ has several facilities. We can create .gpx files, generate route map by uploading the GPS log file to the website. There are more facilities. I prefer this site to check the log files using the routemap outputted from this site. I travelled with the GPS device powered by Battery, in the above route in my bike. Then I uploaded the Log file that was generated in the SDcard into this site and got the above output.

But till now, I was not able to read back data from SDcard. So, I planned to store the stopnames and their corresponding latitude and longitude in the code itself and proceed further. Hence, I had to do a lot of manual work to make the markings. I made use of the Log file of the sample route , checked each line of log in googlemaps and identified the needed locations where stopnames are to be displayed. This part took a long time since there were nearly 494 lines of GPS log in that file.

After Identifying the needed locations and their lat lon values, I stored them in the code in the form of Array of Strings. I prepared about 17 locations in the sample route. This time I connected the LCD display with the battery powered GPS unit and travelled along the same route again in my Bike.

Components Integrated into a Unit

Since I was using the exact latitude and longitude of each location, I got the data printed on the display after crossing that location. I was really excited to see the names getting displayed. Around 10 location names got displayed. Some data was not displayed due to cloudiness. I kept the entire unit powered by 9V battery inside a Box and was travelling with it in my bicycle. The funny part was that everyone on the way were gazing at me very strangily thinking like ” what that guy was seeing inside the box?” .

So, Now The proof of concept for my project is working. To show demo to my college during review, I thought of logging data around the circular block of my college and display data about the department name we are currently entering into.

I am studying in Saveetha Engineering College located at Thandalam, Chennai. So, to get the log file of the circular block, I took the unit to my college, then reached the top floor of that block and reached one end of circular block and started with the logging. I slowly walked with the GPS unit to the other end of circular block. Due to some weak signal, The data was logged into four textfiles inside the Sdcard. I merged those files into a single file and uploaded into gpsvisualizer site. I got the following output map.

GPS log over the circular block of my college

I was really shocked to see such a terrible log map. Then I decided to check all the four log files separately and create a new log file with the needed data. I created a new log file named GPS0607.TXT [ combination of two log files GPSLOG06.TXT and GPSLOG07.TXT out of the four log files ] and uploaded it into GPSvisualizer. The output was :

Data Log around the Circular Block

This is the circular(?) block of my college. You can see four joints connecting the inner circle and outer one. Those joints are four departments namely MBA [ leftmost], IT , MCA and CSE [ rightmost] . So, the code will have to say that which department I am entering now when I walk with the device. But with the above irregular data, I cannot generate a data set which can provide information required. I was really confused on how to proceed further. Inbetween I was also in urgency to prepare for my final review. So, I prepared the slides needed for it.

Then I took the logfile that was generated around my college from the sdcard , checked each latitude and longitude set in Googlemaps and created a new file with only few needed data. All these were only my guess work and were approximate only. I also collected the common non-redundant latitude and longitude from this file and made combinations with each latitude and longitude and checked it again in Googlemaps. This process helped in refining the data and locate the needed spots in the circular block of my college.

The output of the new data file is as follows,

13.0261,80.0171
13.0261,80.0170
13.0261,80.0169
13.0261,80.0168
13.0260,80.0169
13.0259,80.0168
13.0259,80.0167
13.0259,80.0166
13.0261,80.0165
13.0259,80.0163
13.0259,80.0162
13.0260,80.0161
13.0262,80.0160
13.0263,80.0159
13.0264,80.0159

Final Data Log Around the circular block

Now, I have got the sufficient data needed. Then I included these set of data into the code and also included the text to be displayed on the LCD display. On the day of review I tested the code for Demo. It worked successfully. I showed the output in the Serial monitor using my friend’s laptop to the External examiner since the LCD display dint work unfortunately at that time.

The Serial monitor output was as follows,

Department being Displayed

Another Department Name Displayed

And Atlast I presented my project to my External Reviewer and successfully showed the demo too. I am really thankful to all the persons who had helped me and encouraged me. I mainly thank my internal guide and external guide for giving their support and encouragement through out the project.

Actually the task I have done is very simpler one and without the GPS logger code from SDfatlib library, I could not achieved it. Moreover its the power of FOSS that drove me to do this project. Thanks a lot for each and everyone.

Regards

N.Nandhakumar

Advertisements

2 Comments

Leave a Comment
  1. Mauricio / Jan 16 2011 7:17 am

    Wooow! that’s an amazing project, congratulations! and you not only explain how did you do it, you tell us the whole experience too. You make me remember my first projects with Arduino. I’m wondering if you can share your code, in the next days i will start working in a similar project and i dont have any clue about GPS working with Arduino.
    Good luck and congrats again!

Trackbacks

  1. I completed My MCA Successfully « Walkingwithtux's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: