This tutorial is about Serial Communications using Visual Basic with Trimble's LassenLP GPS reciever. This GPS reciever can be intefaced and controlled via a computer using a serial cable. The GPs system provides nearly accurate information on the position (i.e latitude, longtitute , Altitude) or Velocity of an object on earth. This messsage on the computer can be extracted from the Lassen LP system using Windows Hyperterminal. Using Hyperterminal is not an easy way to understand the message as it has to be extracted and converted for a ordinary person to be able to understand. This tutorial provides an visual basic code to serially extract the data, convert it appropriately and display it on an screen
Advantages of Using Lassen LP GPS Module
The LassenLP is a miniature, low- powered, high performance GPS receiver module. It uses only 3.3 volts. Because of its miniature size and low power operations, it can be embedded into many portable devices such as the palm, laptop computers, handheld radios, cell phones, automobile navigation systems and space navigation systems. . Because of its micro-sized board, the system integrator can easily fit GPS functionality into portable products. Lassen LP GPS module allows portable device developers to balance operational frequency and power consumption for a particualar application.
Motivation and Audience
Gps systems are an important aspect of life today. Today they are incorporated in any mobile equipment right from an cell phone to an automobile to a ship or also an Aeroplane. GPS systems aids in Naigation by providing the position (i.e latitude, longtitute , Altitude) or Velocity of an object.
This tutorial explains an visual basic code to interface serially with an LAssenLP GPS reciever and extract positional and velocity information from it. IT doesnot discuss about the GPS theory or the protocols used.
The rest of the tutorial is presented as follows:
Using HyperTerminal with an GPS Reciever
HyperTerminal is an program on an windows machine used to display information that is recieved on the serial port of an computer. The Lassen LP is connected to the serial port of a computer with communication setting being 4800 baud 8bit , 1 stop bit and no flow control. The information from the gps system is updated every few seconds and is as displayed in the hyper terminal window.
Understand and Simplify the GPS Code
A sample positon and velocity information from the GPS receiver is shown below. The ">" informs the beginning of the message and "<" indicates the end of the message. The letter RPV tells us that it is an response from the GPS reciever about position/velocity.
>RPV07559+4026178-0748913800000012;*76<
This is an Position/ Velocity information from the GPS receiver. IT could be dissected as follows. The DataString similiar to above
AAAAABBBCCCCCDDDDEEEEEFFFGGGHI
AAAAA This indicates the GPS time of the Day and it is in secs
BBB,CCCCC This indicates the Latitude in Degrees
DDDD,EEEEE This indicates the Longtitude in Degrees
FFF This indicates the velocity of the speed if the reciever is moving
GGG This indicates the direction in degrees.
HThis indicates the source of data
I This indicats the Age of Data whether it is Current or archieved
Visual Basic Source Code and a Brief Explanation
Here is a code with an easy to understand front end GUI as shown in the pic. The code can be downloaded LassenLP.zip rather then cutting and pasting from here.
The GUI is like this
The source code is as follows
In the above program, as seen from the GUI, We would first open the com port. Then we would query the data from the Lassen LP reciever by sending the command ">QPV<". This is done when we hit the GET DATA button. Once the data is got from the reciever it is stored in an string and needed information such as time,postion, velocity is extracted as shown in the program.Code (Text):
Private Sub cmdClose_Click() MSComm1.PortOpen = False End Sub Private Sub cmdQuery_Click() MSComm1.Output = ">QPV<" 'to query the position" Dim mystring mystring = MSComm1.Input ' From this string we need to get the needed data Dim time time = Mid(mystring, 5, 5) txttime.Text = time Dim Latitude Latitude = Mid(mystring, 11, 8) txtLatitude.Text = Latitude Dim Longtitude Longtitude = Mid(mystring, 20, 9) txtLongtitude.Text = Longtitude Dim Velocity Velocity = Mid(mystring, 30, 3) txtVelocity.Text = Velocity Dim heading heading = Mid(mystring, 34, 3) txtheading.Text = heading End Sub Private Sub cmdStart_Click() MSComm1.PortOpen = True End Sub
The above program showed us how to capture position/velocity information, similiarly we can get information on altitude as well. Also in the above program, we would collect data only when we needed, i.e by clicking on the GET DATA button. We could also automate the process whereby the data would kee[ updating itself every 3 seconds or so.A whole lot can be done with this GPs system. This is just a part of it.
Final Words
We have presented here a tutorial on how to program using visual basic to interface a GPS system to a computer using Serial Port. With this basics in mind, now we can now implement GPS systems for Navigational purposes.
References and Links
Current Information on GPS
Trimbles Website Manufacturer of the LAssen LP GPS
A very good online tutorial on GPS
Connecting GPS to PC using Visual Basic 1.0
Connecting GPS to PC using Visual Basic through serial port.