'------------- GPS_MONI---------------------
'
' geliefertes Format:
'
'-> $GPGGA,072344.187,5141.6192,N,00752.0280,E,1,06,1.6,119.9,M,47.4,M,0.0,0000*7B
' $GPGLL,5141.6192,N,00752.0280,E,072344.187,A*3B
' $GPGSA,A,3,13,23,11,17,04,20,,,,,,,2.6,1.6,2.1*31
' $GPGSV,3,1,10,23,78,167,47,20,55,091,36,13,50,213,45,04,41,300,32*7D
' $GPGSV,3,2,10,17,22,237,44,31,21,042,00,11,14,157,46,01,10,049,00*77
' $GPGSV,3,3,10,25,09,173,00,02,08,314,00*7F
' $GPRMC,072344.187,A,5141.6192,N,00752.0280,E,0.04,342.98,070707,,*0B
'-> $GPVTG,342.98,T,,M,0.04,N,0.1,K*61
' $GPMSS,0,0,0.000000,200,*5A
'
'-> : nur diese Zeilen werden benötigt
'
'
'
$prog &HFF , &HEF , &HD9 , &H00 ' Fuse-Bits
' =LB =FB =FBH =FBX
$regfile = "m8def.dat"
$crystal = 12000000
$hwstack=32
$swstack=32
$framesize=32
Config Lcd = 20 * 4
Config Lcdpin = Pin , Db4 = Portc.0 , Db5 = Portc.1 , Db6 = Portc.2 , Db7 = Portc.3 , E = Portc.4 , Rs = Portc.5
'--------------für RS232--------------------
$baud = 4800
On URXC OnRXD 'Interrupt-Routine setzen
Enable URXC
Dim ser_buf(2) As String * 82 'max 2 x 82 Zeichen bei GPS
DIM s11 as String * 11
DIM zeile1 as Byte
DIM zeile2 as Byte
DIM i as Integer
DIM arr(13) as String * 11
Sreg.7 = 1 'Interrupts freigeben
'--------------Main--------------------------
Ddrb.1 = 1 'LED zum Blinken
cls
cursor off noblink
lcd "Warten auf GPS-Maus.";
locate 3 , 1
lcd "(c) DiLi-Soft";
locate 4 , 1
lcd "22.08.2007";
wait 2 'Maus-Init abwarten
print "$PSRF103,00,00,01,00*24" 'GGA einschalten ohne Checksum
print "$PSRF103,05,00,01,00*21" 'VTG einschalten ohne Checksum
print "$PSRF103,01,00,00,01*25" 'GLL abschalten
print "$PSRF103,02,00,00,01*26" 'GSA abschalten
print "$PSRF103,03,00,00,01*27" 'GSV abschalten
print "$PSRF103,04,00,00,01*20" 'RMC abschalten
print "$PSRF103,06,00,00,01*22" 'MSS abschalten
do
s11 = left(ser_buf(1) , 5)
loop until s11 = "GPGGA" or s11 = "GPVTG"
locate 2 , 1
lcd "GPS-Maus gefunden!";
wait 1
if s11 = "GPGGA" then
zeile1=1
zeile2=2
else
zeile1 = 2
zeile2=1
end IF
cls
Do
Portb.1 = 1 'LED ein
' Format: GPGGA,072344.187,5141.6192,N,00752.0280,E,1,06,1.6,119.9,M,47.4,M,0.0,0000
do
i = split(ser_buf(zeile1) , arr(1) , ",")
loop until i > 12 ' 12 + 1 sind nötig, damit der 12. !voll! gefüllt ist
arr(2) = left(arr(2) , 6) ' Zeit UTC
s11 = left(arr(2) , 2) + ":" + mid(arr(2) , 3 , 2) + ":" + mid(arr(2) , 5 , 2)
locate 1 , 1
lcd s11 ; " Sats: " ; arr(8);
if arr(7) = "1" then ' valide Daten?
locate 2 , 1
s11 = arr(3) ' Breitengrad
while len(s11) < 10
arr(3) = " " + s11 ' "s11 = " " + s11" geht nicht !!
s11 = arr(3)
wend
s11 = left(arr(3) , 3) + " " + right(arr(3) , 7) ' Grad von Minuten separieren
arr(3) = s11
lcd arr(4) ; " " ; arr(3) ; " " ; arr(10) ; " ";
locate 3 , 1
s11 = arr(5) ' Längengrad
i = 1
while mid(s11 , i , 1) = "0" ' führende Nullen kappen
mid(s11 , i , 1) = " "
incr I
wend
arr(5) = left(s11 , 3) + " " + right(s11 , 7)
lcd arr(6) ; " " ; arr(5) ; " " ; arr(12) ; " ";
else
locate 2 , 1
lcd string(20 , " ");
locate 3 , 1
lcd string(20 , " ");
end IF
' Format: GPVTG,342.98,T,,M,0.04,N,0.1,K
do
i = split(ser_buf(zeile2) , arr(1) , ",")
loop until i > 8
i = val(arr(8)); ' Geschwindigkeit
if i > 1 then ' unter 2 Km/h nix ausgeben
locate 4 , 1
i = instr(arr(8) , ".")
i = i - 1
s11 = mid(arr(8) , 1 , i) ' nur ganzzahlige Km/h
lcd s11 ; " Km/h";
i = instr(arr(2) , ".")
i = i - 1
s11 = mid(arr(2) , 1 , i) ' nur ganzzahlige Grade
lcd " Kurs: " ; s11 ; " ";
else
locate 4 , 1
lcd string(20 , " ");
end IF
Waitms 500
Portb.1 = 0 'LED aus
Waitms 500
Loop
End
'--------------RS232-INT---------------------
DIM UDR_buf As Byte
DIM ser_col As Byte
ser_col = 1 'Index auf ser_buf()
OnRXD:
UDR_buf = UDR 'Byte aus UART lesen
Select Case UDR_Buf
Case 13 :
Case 10 : Incr ser_col
If ser_col = 3 Then
ser_col = 1
End If
Case "$": ser_buf(ser_col) = ""
Case Else
If Len(ser_buf(ser_col)) < 82 Then
ser_buf(ser_col) = ser_buf(ser_col) + Chr(UDR_buf)
End If
End SELECT
Return