GPS16X-HVS GPS Receiver
14
CRBasic Example 8-1. Reading the GPS Using the GPS() Instruction
'Program the GPS16-HVS to use 38.4 kbaud, no parity, 8 data bits, and 1 stop bit
PipeLineMode
Const
LOCAL_TIME_OFFSET = -6
'Local time offset relative to UTC time
Dim
nmea_sentence(2)
As
String
* 100
Public
gps_data(15)
Alias
gps_data(1) = latitude_a
'Degrees latitude (+ = North; - = South)
Alias
gps_data(2) = latitude_b
'Minutes latitude
Alias
gps_data(3) = longitude_a
'Degress longitude (+ = East; - = West)
Alias
gps_data(4) = longitude_b
'Minutes longitude
Alias
gps_data(5) = speed
'Speed
Alias
gps_data(6) = course
'Course over ground
Alias
gps_data(7) = magnetic_variation
'Magnetic variation from true north (+ =
'East; - = West)
Alias
gps_data(8) = fix_quality
'GPS fix quality: 0 = invalid, 1 = GPS, 2 =
'differential GPS, 6 = estimated
Alias
gps_data(9) = nmbr_satellites
'Number of satellites used for fix
Alias
gps_data(10) = altitude
'Antenna altitude
Alias
gps_data(11) = pps
'usec into sec of system clock when PPS
'rising edge occurs, typically 990,000 once
'synced
Alias
gps_data(12) = dt_since_gprmc
'Time since last GPRMC string, normally less
'than 1 second
Alias
gps_data(13) = gps_ready
'Counts from 0 to 10, 10 = ready
Alias
gps_data(14) = max_clock_change
'Maximum value the clock was changed in msec
Alias
gps_data(15) = nmbr_clock_change
'Number of times the clock was changed
'Define Units to be used in data file header
Units
latitude_a = degrees
Units
latitude_b = minutes
Units
longitude_a = degrees
Units
longitude_b = minutes
Units
speed = knots
Units
course = degrees
Units
magnetic_variation = unitless
Units
fix_quality = unitless
Units
nmbr_satellites = unitless
Units
altitude = m
Units
pps = ms
Units
dt_since_gprmc = s
Units
gps_ready = unitless
Units
max_clock_change = ms
Units
nmbr_clock_change = samples
BeginProg
'Use SetStatus prior to scan if baud rate needs to be changed for device
Scan
(1,Sec,0,0)
GPS
(latitude_a,Com4,LOCAL_TIME_OFFSET*3600,100,nmea_sentence(1))
NextScan
EndProg
9. Troubleshooting
Testing and evaluation of serial communications is best done by reducing the
whole system to small manageable systems. Usually some portions of the
whole system are working. The first steps involve finding what is working.
During this process, you may find parts of the system that are not working or
mistakes that can be easily corrected. Fix each subsystem before testing others.