PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Garmin und Atmega8



Hartl
22.05.2008, 23:26
Hallo zusammen,
ich habe ein „schwerwiegendes“ Problem.
Ich möchte mit dem Atmega8, aus meinem etrex Summit von Garmin z.B. das NMEA Protokoll „$GPRMC“, die Zeit und das Datum auf einem Display
anzeigen lassen (nur für Testzwecke). Wenn ich den Atmega8 vom PC aus
mit einem GPS Simulator die Daten schicke funktioniert es wunderbar,
vom Garmin zum PC (GPS Simulator) geht auch, nur wenn ich das Garmin wieder an den Atmega8 anstecke, kommt nur Zeichensalat heraus. Als RS232 / TTL Wandler verwende ich einen MAX232.
Hat vielleicht jemand eine Lösung.
Vielen Dank im voraus.

Gerhard

theborg
23.05.2008, 00:17
Richtige bautrate ?
Richtige Spannung viele module haben nur nen 3,3V ttl da geht nen max232 nicht

Hartl
23.05.2008, 08:24
Die Schnitstelle funktioniert ja in beide Richtungen, nur kann der Atmega8 anscheinend nicht mit dem Garmin. Der RS232 / TTL Wandler ist ein Bausatz von Pollin.
$regfile = "m8def.dat" ' ATmega8L 8PU
$crystal = 3686400 ' für myAVR Board USB
$baud = 4800 ' NMEA Schnittstelle

Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2

Dim C As Byte
Dim I As Byte
Dim Stime As String * 6
Dim Sdate As String * 6
Dim Soutput As String * 8

Declare Sub Wait_for_char(byval C As String)
Declare Sub Wait_for_string(byval S As String)
Declare Function Read_string() As String

Cls
Cursor Off Noblink

Lcd "Lese $GPRMC..."
Wait 2
Cls
Config Serialin = Buffered, Size = 100 ' Konfig. der ser. Eingabe
'Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Enable Interrupts

' $GPRMC,hhmmss.ss,A,llll.ll,a,yyyyy.yy,a,x.x,x.x,dd mmyy,x.x,a*hh NMEA Protokoll orig.
' $GPRMC,140942,A,4923.3757,N,01117.6031,E,0.0,167.0 ,120408,1.4,E,A*13 NMEA Protokoll Garmin etrex Summit
'-------------------------------------------------
Do
Call Wait_for_string("$GPRMC,") ' Warte auf $GPRMC
Stime = Read_string() ' Lese UTC Zeitangabe
Soutput = Left(Stime, 2) + ":" + Mid(Stime, 3, 2) + ":" + Mid(Stime, 5, 2)
Locate 1, 1
Lcd Soutput;

For I = 1 To 7 ' Lese 7 Kommata
Call Wait_for_char(",")
Next
Sdate = Read_string()
Soutput = Left(Sdate, 2) + "." + Mid(Sdate, 3, 2) + "." + Mid(Sdate, 5, 2) ' Lese Datum
Locate 2, 1
Lcd Soutput;

Loop
End
'-------------------------------------------------
Sub Wait_for_char(ByVal C As String)
Local Cc As Byte
Do
Cc = Waitkey()
Loop Until Cc = Chr(C)
End Sub
'-------------------------------------------------
Sub Wait_for_string(byval S As String) As String
Local Ii As Byte
Local Cc As Byte

Ii = 1
M1:
Cc = Waitkey()
If Cc <> Mid(S, Ii, 1) Then
GoTo M1
Else
Incr Ii
If Ii > Len(S) Then GoTo M2
GoTo M1
End If
M2:
End Sub
'-------------------------------------------------
Function Read_string() As String
Local Cc As Byte
Local Ss As String * 7
ss = ""
Do
Cc = Waitkey()
ss = ss + Chr(Cc)
Loop Until Cc = ","
Read_string = Left(ss, 6)
End Function