'The following program displays GPS coordinates on an LCD screen as received by 'the accompanying transmitter via DTMF tones. gosub init 'initialise the LCD setint %00000100,%00000100 gosub WriteToLCD EEPROM 0,("GPS Tracker Version 2.0.1 Waiting forvalid dataCorrupt DataReceivedReceivingposition fix spaceforknowndatahere Searching for satellitesSpeedLocationLon .Lat SE") 'store 'welcomeMessage: 'displays "GPS tracker version 2.0.1" on startup just after prev coords . 'let b1 = 1 'gosub wrins 'for b3 = 0 to 11 'read b3, b1 'gosub wrchr 'next b3 'let b1 = 192 'gosub wrins 'for b3 = 11 to 24 'read b3, b1 'gosub wrchr 'next b3 'let b1 = 12 'gosub wrins 'pause 2000 'WaitForValidFix: 'Display "waiting for valid data" on screen 'let b1 = 1 'gosub wrins 'for b3 = 26 to 36 'read b3, b1 'gosub wrchr 'next b3 'let b1 = 192 'gosub wrins 'for b3 = 37 to 46 'read b3, b1 'gosub wrchr 'next b3 'pause 2000 main: gosub displayReceivingPosFix gosub storeLatitudeIntoROM 'stores latitude coordinates into scratchpad of EEPROM for later use gosub storeLongitudeIntoROM gosub storeAltitudeIntoROM gosub checkData 'checks data and writes to lcd goto main storeLatitudeIntoROM: gosub checkDTMF if b1 <> 10 then storeLatitudeIntoROM 'wait till star is received notifying start of download pause 220 for b10 = 0 to 8 gosub checkDTMF write b10,b1 pause 230 next return 'return to main storeLongitudeIntoROM: 'stores longitude as well as height data into ROM gosub checkDTMF if b1 <> 11 then storeLongitudeIntoROM 'wait till HASH is received notifying start of download pause 220 for b10 = 9 to 25 gosub checkDTMF write b10,b1 pause 230 next return 'return to main checkData: ' check to see if data is corrupt- checks to see if the position of numbers is OK by searching for * and #. There should be no such entry. for b1 = 0 to 20 read b1,b2 if b2 = 10 or b2 = 11 then invalidData next high 0 'beep when valid data is received pause 50 low 0 DataOK: 'after checking the validity of the data, the data is copied to a separate memory location so that 'it can be referenced on the next powerup cycle, and so that known valid data is not overwritten by bad data. for b1 = 0 to 20 read b1,b2 pause 10 b3 = b1 + 207 write b3,b2 pause 10 next WriteToLCD: 'now that data is known to be OK, write it to the LCD screen read 207,b4 pause 10 'add valid latitude data to variables read 208,b5 pause 10 read 209,b6 pause 10 read 210,b7 pause 10 read 211,b8 pause 10 read 212,b9 pause 10 read 213,b10 pause 10 read 214,b11 pause 10 read 215,b12 pause 10 gosub writelatitude read 216,b4 pause 10 read 217,b5 pause 10 read 218,b6 pause 10 read 219,b7 pause 10 read 220,b8 pause 10 read 221,b9 pause 10 read 222,b10 pause 10 read 223,b11 pause 10 read 224,b12 pause 10 gosub writelongitude wait 10 return invalidData: 'writes "data corrupt" to LCD when found corrupt. let b1 = 1 gosub wrins for b3 = 47 to 53 read b3, b1 gosub wrchr next b3 let b1 = 192 gosub wrins for b3 = 54 to 58 read b3, b1 gosub wrchr next b3 wait 3 goto main checkDTMF: if pin1 = 0 and pin0 = 0 and pin6 = 0 and pin7 = 0 then checkDTMF if pin1 = 0 and pin0 = 0 and pin6 = 0 and pin7 = 1 then one if pin1 = 0 and pin0 = 0 and pin6 = 1 and pin7 = 0 then two if pin1 = 0 and pin0 = 0 and pin6 = 1 and pin7 = 1 then three if pin1 = 0 and pin0 = 1 and pin6 = 0 and pin7 = 0 then four if pin1 = 0 and pin0 = 1 and pin6 = 0 and pin7 = 1 then five if pin1 = 0 and pin0 = 1 and pin6 = 1 and pin7 = 0 then six if pin1 = 0 and pin0 = 1 and pin6 = 1 and pin7 = 1 then seven if pin1 = 1 and pin0 = 0 and pin6 = 0 and pin7 = 0 then eight if pin1 = 1 and pin0 = 0 and pin6 = 0 and pin7 = 1 then nine if pin1 = 1 and pin0 = 0 and pin6 = 1 and pin7 = 0 then zero if pin1 = 1 and pin0 = 0 and pin6 = 1 and pin7 = 1 then star if pin1 = 1 and pin0 = 1 and pin6 = 0 and pin7 = 0 then hash nothingReceived: b1 = 13 'N = nothing received return one: b1 = 49 return two: b1 = 50 return three: b1 = 51 return four: b1 = 52 return five: b1 = 53 return six: b1 = 54 return seven: b1 = 55 return eight: b1 = 56 return nine: b1 = 57 return zero: b1 = 48 return star: b1 = 10 return hash: b1 = 11 return init: let pins = 0 ‘ Clear all output lines let b4 = 0 ‘ Reset variable b3 pause 200 ‘ Wait 200 ms for LCD to reset. let pins = 48 ‘ Set to 8-bit operation. pulsout 3,1 ‘ Send data by pulsing ‘enable’ pause 10 ‘ Wait 10 ms pulsout 3,1 ‘ Send data again pulsout 3,1 ‘ Send data again let pins = 32 ‘ Set to 4-bit operation. pulsout 3,1 ‘ Send data. pulsout 3,1 ‘ Send data again. let pins = 128 ‘ Set to two line operation pulsout 3,1 ‘ Send data. let b1 = 14 ‘ Screen on, cursor on instruction gosub wrins ‘ Write instruction to LCD return wrchr: let pins = b1 & 240 ‘ Mask the high nibble of b1 into b2. high 2 ‘ Make sure RS is high pulsout 3,1 ‘ Pulse the enable pin to send data. let b2 = b1 * 16 ‘ Put low nibble of b1 into b2. let pins = b2 & 240 ‘ Mask the high nibble of b2 high 2 ‘ Make sure RS is high pulsout 3,1 ‘ Pulse enable pin to send data return wrins: let pins = b1 & 240 ‘ Mask the high nibble of b1 into b2. pulsout 3,1 ‘ Pulse the enable pin to send data. let b2 = b1 * 16 ‘ Put low nibble of b1 into b2. let pins = b2 & 240 ‘ Mask the high nibble of b2 pulsout 3,1 ‘ Pulse enable pin to send data. high 2 ‘ Back to character mode return displayReceivingPosFix: let b1 = 1 'display "receiving position fix" on LCD gosub wrins for b3 = 67 to 75 read b3, b1 gosub wrchr next let b1 = 192 gosub wrins for b3 = 76 to 87 read b3, b1 gosub wrchr next b3 wait 3 return 'to follow is the direct connection mode for GPS connected to LCD directly. See interrupt.**************************** main2: gosub CheckSatFix 'gosub 3 deep if b0 = "1" then validfix gosub searching 'gosub 3 deep return validfix: b1 = 1 gosub wrins 'reset LCD gosub GetLatitude 'display latitude and longitude gosub writelatitude gosub GetLongitude gosub writelongitude pause 2000 'wait 2 seconds b1 = 1 gosub wrins 'clear screen and then write speed in knots 'gosub GetSpeed 'gosub writeSpeed 'pause 2000 return 'to interrupt GetLongitude: ' use b0 to skip over decimal point serin 2,N4800,("$GPGGA,"),b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b4,b5,b6,b7,b8,b0,b9,b10,b11,b12 return GetLatitude: ' use b0 to skip over decimal point serin 2,N4800,("$GPGGA,"),b0,b0,b0,b0,b0,b0,b0,b5,b6,b7,b8,b0,b9,b10,b11,b12 return GetSpeed: serin 2,N4800,("GPRMC,"),b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b6,b7,b8,b9,b10,b11,b12,b13 pause 1000 return writelatitude: let b1 = 128 'move to start of top row LCD gosub wrins for b3 = 158 to 161 'write "Lat" on LCD on top row read b3, b1 gosub wrchr next b3 read 161,b1 'put another space to blank out 0 character gosub wrchr 'let b1 = 133 'move to next char and write value of b5 which is the first digit 'gosub wrins let b1 = b5 gosub wrchr 'let b1 = 134 'move to next char and so on.... 'gosub wrins let b1 = b6 gosub wrchr 'let b1 = 135 'space 'gosub wrins read 156,b1 gosub wrchr 'let b1 = 136 'gosub wrins let b1 = b7 gosub wrchr 'let b1 = 137 'gosub wrins let b1 = b8 gosub wrchr 'let b1 = 138 'decimal point 'gosub wrins read 157,b1 gosub wrchr 'let b1 = 139 'gosub wrins let b1 = b9 gosub wrchr 'let b1 = 140 'gosub wrins let b1 = b10 gosub wrchr 'let b1 = 141 'gosub wrins let b1 = b11 gosub wrchr 'let b1 = 142 'gosub wrins let b1 = b12 gosub wrchr 'let b1 = 143 'gosub wrins read 162,b1 gosub wrchr let b1 = 12 gosub wrins return writelongitude: b1 = 192 'move to bottom row gosub wrins for b3 = 153 to 156 'write "Lon" on LCD on bottom row read b3, b1 pause 10 gosub wrchr next b3 'let b1 = 196 'move to next char 'gosub wrins let b1 = b4 gosub wrchr 'let b1 = 197 'move to next char 'gosub wrins let b1 = b5 gosub wrchr 'let b1 = 198 'move to next char and so on.. 'gosub wrins let b1 = b6 gosub wrchr 'let b1 = 199 'space 'gosub wrins read 156,b1 pause 10 gosub wrchr 'let b1 = 200 'gosub wrins let b1 = b7 gosub wrchr 'let b1 = 201 'gosub wrins let b1 = b8 gosub wrchr 'let b1 = 202 'gosub wrins read 157,b1 pause 10 gosub wrchr 'let b1 = 203 'gosub wrins let b1 = b9 gosub wrchr 'let b1 = 204 'gosub wrins let b1 = b10 gosub wrchr 'let b1 = 205 'gosub wrins let b1 = b11 gosub wrchr 'let b1 = 206 'gosub wrins let b1 = b12 gosub wrchr 'let b1 = 207 'always South 'gosub wrins read 163,b1 pause 10 gosub wrchr let b1 = 12 gosub wrins wait 20 return writeSpeed: let b1 = 128 'move to start of top row LCD gosub wrins for b3 = 140 to 144 'write "Speed" on LCD on top row read b3, b1 gosub wrchr next b3 let b1 = 134 'move to next char gosub wrins let b1 = b7 gosub wrchr let b1 = 135 'add full stop (should be full stop if data is correct from GPS) gosub wrins let b1 = b8 gosub wrchr let b1 = 136 'move to next char and so on.... gosub wrins let b1 = b9 gosub wrchr let b1 = 137 gosub wrins let b1 = b11 gosub wrchr return CheckSatFix: serin 2,N4800,("$GPGGA,"),b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0 return Searching: 'Displays the words "Searching for satellites" on LCD let b1 = 1 'reset screen gosub wrins 'send reset command to LCD for b3 = 116 to 129 ' setup for...next loop (" Searching" positions 1 to 14 on LCD) read b3, b1 ' read letter from EEPROM into variable b1 gosub wrchr ' send character to LCD next b3 ' next loop let b1 = 192 ' set b1 to .start of second line. position gosub wrins ' send instruction to LCD for b3 = 130 to 139 ' setup for...next loop (for satellites.-positions 5 to 19) read b3, b1 ' read letter from EEPROM memory into variable b1 gosub wrchr ' send character to LCD next b3 ' next loop pause 1000 return 'to main2 interrupt: 'gosub 1 deep gosub main2 'gosub 2 deep setint %00000100,%00000100 return