'Define Symbols Symbol LAT=B55 'Latitude (0-90) Symbol N_S=BIT0 'North=0 & South=1 Symbol LONG=B54 'Longitude (0-180) Symbol E_W=BIT1 'East=0 & West=1 Symbol MONTH=B53 'Month (1-12) Symbol DAY=B52 'Day of Month (1-31) Symbol HOUR=B51 'Hour of Day UTC (0-23) Symbol MINUTE=B50 'Minute of Day UTC (0-59) '************************************************************************************************ 'Code to query GPS for LAT, LONG, MONTH, DAY, HOUR, MINUTE 'Store results in unused high memory to avoid corrupting low memory 'Uses an EM-411 GPS Module (www.dx.com) SERTXD("GPS Signal Acquisition: Wait 30 Sec",32,13,10) PAUSE 30000 'Using the GPRMC Sentence from GPS Module 'By default data is stored starting in B0,B1,B2, etc. 'POKE and PEEK data to avoid memory conflicts with lower memory 'Do range checks at end for basic error testing QUERY: 'Return here if the range check fails bptr=0 'Set bit pointer to zero 'Note: SERIN has 30 second timeout, and a timeout destination 'SERIN looks for text string "$GPRMC" to start memory logging SERIN[30000,END_P],C.6, T4800_8,("$GPRMC"),@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,_ @bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,_ @bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,_ @bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,_ @bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,_ @bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,_ @bptrinc,@bptrinc,@bptrinc,@bptr 'Note: ASCII Characters have been stored in memory SERTXD("1st= ",B0,B1,B2,B3,B4,B5,B6,B7,B8,B9,B10,B11,B12,B13,B14,B15,B16,B17,B18,B19,32,13,10) SERTXD("2nd= ",B20,B21,B22,B23,B24,B25,B26,B27,B28,B29,B30,B31,B32,B33,B34,B35,B36,B37,B38,B39,32,13,10) SERTXD("3rd= ",B40,B41,B42,B43,B44,B45,B46,B47,B48,B49,B50,B51,B52,B53,B54,32,13,10) 'The ASCII Value is the numeric value plus $30 (See any ASCII table) 'Convert ASCII characters to equivalent numeric values... B1=B1-$30 B1=B1*10 B2=B2-$30 B1=B1+B2 'SERTXD("HR= ",#B1,32,13,10) POKE 56, B1 '56 is first byte of upper memory 'SERTXD("MIN= ",B3,B4,32,13,10) B3=B3-$30 B3=B3*10 B4=B4-$30 B3=B3+B4 'SERTXD("MIN= ",#B3,32,13,10) POKE 57, B3 '57 is second byte of upper memory 'SERTXD("LAT= ",B14,B15,32,13,10) B14=B14-$30 B14=B14*10 B15=B15-$30 B14=B14+B15 'SERTXD("LAT= ",#B14,32,13,10) POKE 58, B14 '58 is third byte of upper memory 'SERTXD("LONG= ",B26,B27,B28,32,13,10) 'Should not exeed 180, so byte will hold value B26=B26-$30 B26=B26*100 B27=B27-$30 B27=B27*10 B26=B26+B27 B28=B28-$30 B26=B26+B28 'SERTXD("LONG= ",#B26,32,13,10) POKE 59, B26 'Uses 59 in upper memory 'GPS string does not pad heading: Must do logical branch 'IF B50=44 then a normal case with 3 digit heading IF B49=44 THEN GOTO PARSE1 'ASCII 44 is a comma, 2 digit IF B48=44 THEN GOTO PARSE2 'ASCII 44 is a comma, 1 digit 'SERTXD("DAY= ",B51,B52,32,13,10) B51=B51-$30 B51=B51*10 B52=B52-$30 B51=B51+B52 'SERTXD("DAY= ",#B51,32,13,10) POKE 61, B51 'SERTXD("MONTH= ",B53,B54,32,13,10) B53=B53-$30 B53=B53*10 B54=B54-$30 B53=B53+B54 'SERTXD("MONTH= ",#B53,32,13,10) POKE 60, B53 GOTO END_OF_PARSE PARSE1: 'Handles special case of a 2 digit heading report 'SERTXD("DAY= ",B50,B51,32,13,10) B50=B50-$30 B50=B50*10 B51=B51-$30 B50=B50+B51 'SERTXD("DAY= ",#B50,32,13,10) POKE 61, B50 'SERTXD("MONTH= ",B52,B53,32,13,10) B52=B52-$30 B52=B52*10 B53=B53-$30 B52=B52+B53 'SERTXD("MONTH= ",#B52,32,13,10) POKE 60, B52 GOTO END_OF_PARSE PARSE2: 'Handles special case of a 1 digit heading report 'SERTXD("DAY= ",B49,B50,32,13,10) B49=B49-$30 B49=B49*10 B50=B50-$30 B49=B49+B50 'SERTXD("DAY= ",#B49,32,13,10) POKE 61, B49 'SERTXD("MONTH= ",B51,B52,32,13,10) B51=B51-$30 B51=B51*10 B52=B52-$30 B51=B51+B52 'SERTXD("MONTH= ",#B51,32,13,10) POKE 60, B51 GOTO END_OF_PARSE END_OF_PARSE: 'Check if Northern or Southern Hemisphere 'N_S=0 'Northern 'E_W=1 'Western IF B24=78 THEN 'ASCII 78='N' N_S=0 'Northern ELSE N_S=1 'Southern ENDIF 'Check if East or West of prime meridian 'SERTXD("B37= ",B37,32,13,10) IF B37=87 THEN 'ASCII 87='W' E_W=1 'West ELSE E_W=0 'East ENDIF 'Do data range checks (Veracity of data) PEEK 56, HOUR IF HOUR > 23 THEN GOTO QUERY PEEK 57, MINUTE IF MINUTE > 59 THEN GOTO QUERY PEEK 58, LAT IF LAT > 90 THEN GOTO QUERY PEEK 59, LONG IF LONG > 180 THEN GOTO QUERY PEEK 60, MONTH IF MONTH > 12 THEN GOTO QUERY PEEK 61, DAY IF DAY > 31 THEN GOTO QUERY SERTXD("HOUR= ",#HOUR,32,13,10) SERTXD("MINUTE= ",#MINUTE,32,13,10) SERTXD("LAT= ",#LAT,32,13,10) SERTXD("LONG= ",#LONG,32,13,10) SERTXD("MONTH= ",#MONTH,32,13,10) SERTXD("DAY= ",#DAY,32,13,10) SERTXD("E_W= ",#E_W,32,13,10) SERTXD("N_S= ",#N_S,32,13,10) 'This is the program ending. END_P: SERTXD("PROGRAM ENDING",32,13,10) END