This example combines all the above. This program will check the antenna for fault. The checks battery backup, RTC and almanac. The results are displayed on the LCD of the Lab board.
Next tracking status is monitered until enough fixes are avalable. Again the number of satalites in veiw is displayed on the LCD.
The Atom is now ready to read in the Long Navigation message and parase the data. Once the data is parased it is displayed to the LCD. The fist slide contains Lat and Long. The second slide has altitude, horizontal speed and vertical speed. The last slide contains the heading and satalites in veiw.
Code:
Long_Nav var byte(57)
GPS_status var byte(15)
char var byte
index var byte
feildwidth var byte
workval var long
GPS_Time var long
LatDeg var byte
LatMin var long
LongDeg var byte
LongMin var long
Altitude1 var long
Altitude2 var byte
HorSpeed var byte
VerSpeed var byte
Heading1 var byte
Heading2 var byte
SV var byte
LatNS var byte
LongEW var byte
Initilize_Hardware:
lcdinit P0P1P2, outb
Gps_Initilization:
serout p11, i9600, [">QST<"] 'Send command to gps to quiry version
serin p10, i9600, [str GPS_status15] 'Read in and store responce in Version
serout S_OUT, i9600, [str GPS_status15,13] 'Send version out hardware serial port
Antenna_Fault:
if GPS_status(6) = "0" then
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "Antenna Good"]
elseif GPS_status(6) = "2"
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "Ant. Open Fault"]
goto Gps_Initilization
elseif GPS_status(6) = "6"
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "Ant. Short Fault"]
goto Gps_Initilization
endif
pause 1000
Check_Batt_Backup:
if GPS_status(7) = "1" then
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "Battery Failed"]
else
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "No Problems"]
endif
pause 1000
Check_RTC_Almanac:
if GPS_status(11) = "0" then
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "No Problems"]
elseif GPS_status(11) = "2"
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "No RTC"]
elseif GPS_status(11) = "8"
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "No Almanac"]
elseif GPS_status(11) = "A"
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "No RTC & Almanac"]
endif
pause 1000
Tracking:
if GPS_status(5) = "0" then
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "Doing Fixes"]
goto GPS_Lock
elseif GPS_status(5) = "1"
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "No GPS Time"]
elseif GPS_status(5) = "3"
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "PDOP to High"]
elseif GPS_status(5) = "8"
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "No Satalites"]
elseif GPS_status(5) = "9"
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "1 Satalite"]
elseif GPS_status(5) = "A"
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "2 Satalites"]
elseif GPS_status(5) = "B"
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "3 Satalites"]
elseif GPS_status(5) = "C"
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "Unusable"]
endif
serout p11, i9600, [">QST<"] 'Send command to gps to quiry version
serin p10, i9600, [str GPS_status15] 'Read in and store responce in Version
pause 1000
goto Tracking
GPS_Lock:
serout S_OUT, i9600, ["Start Logging LN Message", 13]
gosub Get_Long_Nav
gosub Parase_Gps
gosub Convert_Sign
gosub Lcd_Display
pause 2000
goto GPS_Lock
end
Get_Long_Nav:
serout p11, i9600, [">QLN<"] 'Send command to gps to quiry version
serin p10, i9600, [str Long_Nav57] 'Read in and store responce in Version
serout S_OUT, i9600, [str Long_Nav57,13] 'Send version out hardware serial port
return
Parase_GPS:
index = 4
feildwidth = 5
gosub String_to_Value
GPS_Time = workval
index = 13
feildwidth = 2
gosub String_to_Value
LatDeg = workval
index = 15
feildwidth = 7
gosub String_to_Value
LatMin = workval
index = 23
feildwidth = 3
gosub String_to_Value
LongDeg = workval
index = 26
feildwidth = 7
gosub String_to_Value
LongMin = workval
index = 34
feildwidth = 6
gosub String_to_Value
Altitude1 = workval
index = 40
feildwidth = 2
gosub String_to_Value
Altitude2 = workval
index = 42
feildwidth = 3
gosub String_to_Value
HorSpeed = workval
index = 47
feildwidth = 3
gosub String_to_Value
VerSpeed = workval
index = 51
feildwidth = 3
gosub String_to_Value
Heading1 = workval
index = 54
feildwidth = 1
gosub String_to_Value
Heading2 = workval
index = 55
feildwidth = 2
gosub String_to_Value
SV = workval
return
String_to_Value:
workval = 0
if feildwidth = 0 or feildwidth > 7 then String_to_Value_Done
Get_Feild_Digit:
char = Long_Nav(index)
workval = workval + (char - "0")
feildwidth = feildwidth - 1
if feildwidth = 0 then String_to_Value_Done
workval = workval * 10
index = index + 1
goto Get_Feild_Digit
String_to_Value_Done:
return
Convert_Sign:
LatNS = "N"
if Long_Nav(12) = "+" then Convert_Long_Sign
LatNS = "S"
Convert_Long_Sign:
LongEW = "E"
if Long_Nav(22) = "+" then Convert_Done
LongEW = "W"
Convert_Done:
return
Lcd_Display:
lcdinit P0P1P2, outb
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "Lat.", LatNS, dec LatDeg, ".", dec LatMin]
lcdwrite P0P1P2, outb, [$180 | $40, "Lon.", LongEW, dec LongDeg, ".", dec LongMin]
Pause 2000
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "Alt.", Long_Nav(33), dec Altitude1, ".", dec Altitude2]
lcdwrite P0P1P2, outb, [$180 | $40, "Hor.", dec HorSpeed, " Ver.", Long_Nav(46), dec VerSpeed]
Pause 2000
lcdwrite P0P1P2, outb, [$133, $132, $128, $101, $102, $10C, "Heading...", dec Heading1, ".", dec Heading2]
lcdwrite P0P1P2, outb, [$180 | $40, "SV...", dec SV]
return