Code:
'Programm für GPS_Modul HI-204S******************
'kann an jeden anderen GPS Empfaenger angepaßt werden.
'Getestet auf Atmega16/32 und Atmega168
$regfile = "m16def.dat"
$crystal = 10000000
$baud = 4800
$hwstack = 32 'hardware stack
$swstack = 8 'software stack
$framesize = 44 'frame space
Dim K As String * 10
Dim S As String * 72
Dim N_grad As String * 2
Dim E_grad As String * 3
Dim N_min As String * 2
Dim N_ablage As String * 3
Dim E_min As String * 2
Dim Nord As String * 2
Dim Ost As String * 3
Dim Nord_rest As String * 7
Dim Ost_rest As String * 7
Dim E_ablage As String * 3
Dim N As String * 1
Dim O As String * 1
Dim Av As String * 1
Dim N_sec As Single
Dim E_sec As Single
Dim Runden As Single
Dim Ablage As Integer
Dim Ergebnis As Single
Const T = 1000
Const Time = 60
'Fuer Atmega168
'Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0
'Fuer Atmega16/32
Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E = Porta.3 , Rs = Porta.2
Config Lcd = 40 * 2
Cls
Cursor Off
On Urxc Onrxd
Enable Urxc
Enable Interrupts
Main:
Goto Main
Onrxd:
'S = "$GPRMC,104549.04,A,2447.2038,N,12100.4990,E,016.0,221.0,250304,003.3;W;A"
S = S + Chr(udr)
If Len(s) = 72 Then
S = Mid(s , 2 , 71)
End If
K = Mid(s , 1 , 6)
'******Position In Grad und Minuten******Auslesen**
Nord = Mid(s , 21 , 2)
Ost = Mid(s , 33 , 3)
Nord_rest = Mid(s , 23 , 7)
Ost_rest = Mid(s , 36 , 7)
'**************Ende Position Auslesen***********************
'---------------------------------------------------------------
'****Daten Auslesen und in Grad Minuten u.Sec. umrechnen********
'Daten** Nord-Süd** Grad**Minuten**Auslesen******
N_grad = Mid(s , 21 , 2)
N_min = Mid(s , 23 , 2)
N_ablage = Mid(s , 26 , 3)
N = Mid(s , 31 , 1)
'***********Status A oder V***Auslesen********
Av = Mid(s , 19 , 1)
'**************************************
'******** OST**West**Auslesen***************
E_grad = Mid(s , 33 , 3)
E_min = Mid(s , 36 , 2 )
E_ablage = Mid(s , 39 , 3)
O = Mid(s , 44 , 1)
'****************Rechnen umwandeln in Secunde***********************
' drei Stellen hinter dem Punkt in Sec umrechnen
' geteilt durch tausend Mal 60 = SEKUNDEN!
'Fuer Top50 Karten WSG84*********************************************
'********Umrechnen Nord Sued In Sec**************************
Ablage = Val(n_ablage)
Ergebnis = Ablage / T
Runden = Ergebnis * Time
N_sec = Round(runden)
'***************************************
Ablage = Val(e_ablage)
Ergebnis = Ablage / T
Runden = Ergebnis * Time
E_sec = Round(runden)
'*****************Ende Rechnen**************************************
'*******Auf Display ausgeben****************************************
If K = "$GPRMC" Then
Upperline
Lcd "" ; Ost ; Chr(223) ; Ost_rest ; Chr(39) ; O ; " " ; Nord ; Chr(223) ; Nord_rest ; Chr(39) ; N ; " " ; "STATUS=" ; Av
Lowerline
'Lcd E_grad ; " " ; E_min ; " " ; E_sec ; " " ; O ; " " ; N_grad ; " " ; N_min ; " " ; N_sec ; " " ; N
Lcd E_grad ; Chr(223) ; E_min ; Chr(39) ; " " ; E_sec ; Chr(34) ; " " ; O ; " " ; N_grad ; Chr(223) ; N_min ; Chr(39) ; " " ; N_sec ; Chr(34) ; " " ; N
End If
Return
Lesezeichen