APPENDIX G - USING abcDB WITH GPS RECEIVERS

s

ince the release of abcDB v5.0, it has been possible to retrieve data from connected GPS (Global Positioning System) receivers.

What does this mean to you as a developer?  Simple.  POWER!

Consider the possibilities.  Perhaps you need to develop an asset tracking application.  Now you can EASILY capture GPS coordinates for each asset.  

Perhaps you’re a fisherman and want to be able to find the ‘sweet spot’ again next year?  Simple!  Just take your PocketPC along with you, and when you catch the ‘big one’, just capture the precise location and save it to your abcDB database.

There are endless possible uses for GPS applications.  It’s completely up to your imagination.

COMPATIBLE DEVICES
We cannot guarantee compatibility with all GPS devices.  We do however have some basic guidelines that will hopefully help determine if your GPS will work with abcDB or not.

First of all, your device MUST meet the NMEA (National Marine Electronics Association) standard.  Your device must also work on your PocketPC’s serial port (Ports 1 – 4)

abcDB is designed to specifically look for data in two NMEA sentences:

GPRMC (Recommended minimum specific GNSS data)
            - Example
            $GPRMC,235947.000,A,4250.5589,S,14718.5084,E,0.00,89.68,211200,,*25

GPGGA (Global Positioning System Fixed Data)
            - Example
            $GPGGA,092204.999,4250.5589,S,14718.5084,E,1,04,24.4,19.7,M,,,,0000*1F

You will want to refer to your device’s documentation and ensure that you use GPSINIT to send any initialization strings that might be required to enable the output of these two sentence types.  If your GPS does not send these two sentences, abcDB will not be able to return any valid data.

The important fact is that abcDB now makes it EASY to capture your GPS data, and in a moment we’ll demonstrate how easy it really is.

First of all, you need to be aware of the basic GPS specific statements and functions that are now included in abcDB.  They are:

GPSOPEN – This statement very simply OPENS the port to your GPS device.  Please note that abcDB currently supports GPS’s that are compliant with the NMEA standard (National Marine Electronics Association). 
GPSINIT – This statement sends optional ‘initialization’ strings to your GPS.
GPSCLOSE – Closes the port to your GPS device.
GPSLAT – Returns the Latitude of your current location.
GPSLONG – Returns the Longitude of your current location.
GPSALT – Returns the your current Altitude.
GPSALTUNIT – Returns the units that your altitude is recorded in (ie. Meters)
GPSTIME – Returns the current GPS time.
GPSSPEED – Returns your current ground speed (in knots)
GPSMAXSPEED – Returns the maximum speed you’ve traveled at since your last GPSINIT.
GPSMAXALT – Returns the maximum altitude you’ve reached since your last GPSINIT
GPSOK – Returns TRUE if there is sufficient satellite data.  Otherwise returns FALSE  NOTE:  GPS devices take some time to acquire all the necessary satellites.  As a result, GPSOK may not register TRUE for several minutes depending on the type of device you have.
GPSDATE – Returns the current GPS date.

So let’s create a quick little application that will demonstrate how to put these features to use:

First of all, let’s add textboxes, labels, and buttons to our new form so that is looks similar to this.

Give your textboxes TAG values of:

Latitude
longitude
altitude
Time
Speed
MaxSpeed
MaxAlt
GPSOK
AltUnits

Once you’re done, move to the next step.

Now, in the GPS OPEN button’s macro event, enter the following code:

GPSOPEN(“4”//”4800,N,8,1”)

Note:  The “4800,N,8,1” is a fairly standard setting for many NMEA GPS units.  The first parameter tells abcDB what serial port your GPS is configured to use.  In my case the device usescommunications Port#4.

Then, in the GPS INIT button’s macro event, enter the following single line of code:
 gpsinit("$PRWIILOG,RMC,A,T,2,0"//"$PRWIILOG,GGA,A,T,2,0"//"$PRWIILOG,ZCH,V,,,")

In my case, the first two parameters tell the GPS device to automatically output data every two seconds.  The 3rd parameter turns off certain data that is unnecessary.

Note:  We could just as easily have added this GPSINIT statement to our GPS OPEN button.  There is no real need to have two separate buttons.  We are just trying to demonstrate the individual steps that occur.

Then, in your GET VALUES button, enter the following MACRO event code:

SETVALUE(~Latitude~//GPSLAT())
SETVALUE(~Longitude~//GPSLong())
SETVALUE(~Altitude~//GPSalt())
SETVALUE(~Time~//GPStime())
SETVALUE(~Speed~//GPSspeed())
SETVALUE(~MaxSpeed~//GPSmaxspeed())
SETVALUE(~MaxAlt~//GPSmaxalt())
SETVALUE(~GPSOK~//GPSok())
SETVALUE(~AltUnits~//GPSaltunit())

FINALLY, enter the following line of code in your GPS CLOSE button’s macro event:

GPSCLOSE()

Now SAVE your form and then run it.

Assuming that your GPS is compatible and you’ve used the correct settings in your GPSOPEN and GPSINIT commands, you can now test everything out.

First, tap the GPS OPEN button to execute the GPSOPEN statement and open a connection to your GPS device.

Secondly, tap the GPS INIT button to send the optional initialization strings to your device.

Then, if everything is working properly, you should be able to tap the GET VALUES button, and you’ll hopefully see something similar to this screen.

(NOTE:  Some GPS devices take several minutes to initialize.)

Of course, this simple application doesn’t do anything other than ‘display’ the GPS data.  We could just as easily have created a table, and saved this data for future reference.  We’ll leave that up to you!