Das Modul kann mit Spannungen von 3,3 bis 5 V betrieben werden. Das bedeutet aber nicht, dass auch bei den Signalleitungen Spannungen bis 5 V zulässig sind. Die Schaltskizze des Moduls zeigt nämlich, dass die Platine zwar einen Spannungsregler für den NE0-6M aufweist, aber keine Pegelanpassungen für den Eingang RX bzw. den Ausgang TX. Das Manual des NE0-6M gibt 3,6 V als Maximalspannung an.
Standardmäßig überträgt das Modul die GPS-Daten im NMEA-Protokoll seriell (TTL) mit 9600 Baud (8 Bit, keine Parität, 1 Stoppbit). Um diese Daten zu empfangen und auszuwerten, reicht es aus, den TX-Ausgang des Moduls mit einem (hochohmigen) Eingang des Mikrocontrollers zu verbinden. Bei unserer Attiny-Platine kann man als Eingang allerdings leider nicht einfach auf den RxD-Eingang des Attiny zurückgreifen, weil dieser über einen Pull-Up-Widerstand mit 5 V verbunden ist. In dem Beitrag viewtopic.php?f=12&t=53 habe ich dargestellt, wie man dieses Pegelproblem beseitigen kann. Für erste Testversuche soll hier ein anderer Pin des Attiny benutzt werden:
Code: Alles auswählen
GY-GPS6MV2---Attiny
VCC --- +5 V
GND --- Masse
TX --- PortD.4
Beim Attiny steht nur für den RxD-Eingang eine Hardware-UART zur Verfügung. An den anderen Ports muss eine Software-UART von BASCOM herhalten; für diese stehen keine Puffer oder Interrupts zur Verfügung. Deswegen ist die Zeit zur Verarbeitung der empfangenen Bytes sehr beschränkt. So reicht die Zeit zum Senden des empfangenen Bytes an das Terminal mit dem BASCOM-Befehl printbin nicht aus. Deswegen greifen wir in unserem Programm direkt auf das UDR-Register der Hardware-UART zurück: Durch UDR = c wird der Inhalt von c in das UDR-Register gelegt und von da automatisch von der UART versendet. Während dieser Sendezeit kann die Software-UART sich wieder um den Empfang des nächsten Bytes kümmern.
Code: Alles auswählen
$regfile = "attiny2313.dat"
$crystal = 4000000
$baud = 9600
$hwstack = 32
$swstack = 10
$framesize = 40
Dim C As Byte
Ddrd = &B01100000 ' D5, D6 als Ausgang; Rest als Eingang
Portd = &B10001110 ' Beginn mit Item 0
Open "COMD.4:9600,8,n,1" For Input As #1 ' portd.4 als software-Uart
Do
C = Inkey(#1)
If C > 0 Then Udr = C ' Ausgabe über Terminal, s. u.
Loop
Close #1 ' nur pro forma
End
Code: Alles auswählen
$GPGSV,3,3,09,31,25,067,24*42
$GPGLL,5110.64055,N,00628.36138,E,122320.00,A,A*6D
$GPRMC,122321.00,A,5110.64038,N,00628.36118,E,0.251,,291213,,,A*70
$GPVTG,,T,,M,0.251,N,0.465,K,A*22
$GPGGA,122321.00,5110.64038,N,00628.36118,E,1,06,2.07,31.6,M,46.5,M,,*60
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.34*01
$GPGSV,3,1,09,01,53,139,28,04,18,303,17,11,25,152,23,12,05,350,21*7C
$GPGSV,3,2,09,13,17,200,32,17,42,275,33,20,88,344,35,23,48,189,40*78
$GPGSV,3,3,09,31,25,067,25*43
$GPGLL,5110.64038,N,00628.36118,E,122321.00,A,A*65
$GPRMC,122322.00,A,5110.64018,N,00628.36113,E,0.379,,291213,,,A*71
$GPVTG,,T$GPRMC,122325.00,A,5110.63977,N,00628.36063,E,0.065,,291213,,,A*79
$GPVTG,,T,,M,0.065,N,0.121,K,A*22
$GPGGA,122325.00,5110.63977,N,00628.36063,E,1,06,2.07,34.0,M,46.5,M,,*6F
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.34*01
$GPGSV,3,1,09,01,53,139,28,04,18,303,20,11,25,152,23,12,05,350,22*7B
$GPGSV,3,2,09,13,17,200,32,17,42,275,33,20,88,344,34,23,48,189,39*77
$GPGSV,3,3,09,31,25,067,24*42
$GPGLL,5110.63977,N,00628.36063,E,122325.00,A,A*69
$GPRMC,122326.00,A,5110.63973,N,00628.36054,E,0.101,,291213,,,A*79
$GPVTG,,T,,M,0.101,N,0.187,K,A*2D
$GPGGA,122326.00,5110.63973,N,00628.36054,E,1,06,2.07,34.4,M,46.5,M,,*68
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.35*00
$GPGSV,3,1,09,01,53,139,27,04,18,303,20,11,25,152,22,12,05,350,21*76
$GPGSV,3,2,09,13,17,200,31,17,42,275,31,20,88,344,34,23,48,189,38*77
$GPGSV,3,3,09,31,25,067,23*45
$GPGLL,5110.63973,N,00628.36054,E,122326.00,A,A*6A
$GPRMC,122327.00,A,5110.63951,N,00628.36013,E,0.192,,291213,,,A*71
$GPVTG,,T,,M,0.192,N,0.356,K,A*29
$GPGGA,122327.00,5110.63951,N,00628.36013,E,1,06,2.07,35.4,M,46.5,M,,*6B
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.35*00
$GPGSV,3,1,09,01,53,139,27,04,18,303,24,11,25,152,22,12,05,350,20*73
$GPGSV,3,2,09,13,17,200,31,17,42,275,31,20,88,344,34,23,48,189,38*77
$GPGSV,3,3,09,31,25,067,23*45
$GPGLL,5110.63951,N,00628.36013,E,122327.00,A,A*68
$GPRMC,122328.00,A,5110.63938,N,00628.35999,E,0.113,,291213,,,A*70
$GPVTG,,T,,M,0.113,N,0.209,K,A*2B
$GPGGA,122328.00,5110.63938,N,00628.35999,E,1,06,2.07,36.1,M,46.5,M,,*65
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.35*00
$GPGSV,3,1,09,01,53,139,27,04,18,303,25,11,25,152,23,12,05,350,19*79
$GPGSV,3,2,09,13,17,200,31,17,42,275,31,20,88,344,34,23,48,189,38*77
$GPGSV,3,3,09,31,25,067,23*45
$GPGLL,5110.63938,N,00628.35999,E,122328.00,A,A*60
$GPRMC,122329.00,A,5110.63922,N,00628.35973,E,0.102,,291213,,,A*7E
$GPVTG,,T,,M,0.102,N,0.190,K,A*28
$GPGGA,122329.00,5110.63922,N,00628.35973,E,1,06,2.07,37.0,M,46.5,M,,*6B
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.35*00
$GPGSV,3,1,09,01,53,139,27,04,18,303,25,11,25,152,23,12,05,350,19*79
$GPGSV,3,2,09,13,17,200,31,17,42,275,31,20,88,344,34,23,48,189,38*77
$GPGSV,3,3,09,31,25,067,24*42
$GPGLL,5110.63922,N,00628.35973,E,122329.00,A,A*6E
$GPRMC,122330.00,A,5110.63913,N,00628.35958,E,0.156,,291213,,,A*7C
$GPVTG,,T,,M,0.156,N,0.289,K,A*22
$GPGGA,122330.00,5110.63913,N,00628.35958,E,1,06,2.07,37.5,M,46.5,M,,*6D
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.35*00
$GPGSV,3,1,09,01,53,139,27,04,18,303,23,11,25,152,23,12,05,350,18*7E
$GPGSV,3,2,09,13,17,200,31,17,42,275,31,20,88,344,34,23,48,189,38*77
$GPGSV,3,3,09,31,25,067,24*42
$GPGLL,5110.63913,N,00628.35958,E,122330.00,A,A*6D
$GPRMC,122331.00,A,5110.63908,N,00628.35953,E,0.047,,291213,,,A*7D
$GPVTG,,T,,M,0.047,N,0.086,K,A*2E
$GPGGA,122331.00,5110.63908,N,00628.35953,E,1,06,2.07,37.9,M,46.5,M,,*61
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.35*00
$GPGSV,3,1,09,01,53,139,28,04,18,303,22,11,25,152,23,12,05,350,18*70
$GPGSV,3,2,09,13,17,200,32,17,42,275,29,20,88,344,34,23,48,189,38*7D
$GPGSV,3,3,09,31,25,067,24*42
$GPGLL,5110.63908,N,00628.35953,3.
$GPRMC,122332.00,A,5110.63910,N,00628.35943,E,0.177,,291213,,,A*74
$GPVTG,,T,,M,0.177,N,0.328,K,A*2B
$GPGGA,122332.00,5110.63910,N,00628.35943,E,1,06,2.07,38.1,M,46.5,M,,*6D
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.35*00
$GPGSV,3,1,0903,,,,3,,,,2,5,7G,2937027252284338837P,92,7*GL1.3,0853122,A
$GPRMC,122333.00,A,5110.63906,N,00628.35911,E,0.339,,291213,,,A*7D
$GPVTG,,T,,M,0.339,N,0.628,K,A*26
$GPGGA,122333.00,5110.63906,N,00628.35911,E,1,06,2.07,38.6,M,46.5,M,,*6B
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.35*00
$GPGSV,3,1,09,01,53,139,28,04,18,303,19,11,25,152,23,12,05,350,17*77
$GPGSV,3,2,09,13,17,200,31,17,42,275,27,20,88,344,34,23,48,189,38*70
$GPGSV,3,3,09,31,25,067,23*45
$GPGLL,5110.63906,N,00628.35911,E,122333.00,A,A*67
$GPRMC,122334.00,A,5110.63897,N,00628.35881,E,0.332,,291213,,,A*70
$GPVTG,,T,,M,0.332,N,0.615,K,A*23
$GPGGA,122334.00,5110.63897,N,00628.35881,E,1,06,2.07,39.1,M,46.5,M,,*6B
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.35*00
$GPGSV,3,1,09,01,53,139,27,04,18,303,20,11,25,152,23,12,05,350,17*72
$GPGSV,3,2,09,13,17,200,30,17,42,275,27,20,88,344,34,23,48,189,38*71
$GPGSV,3,3,09,31,25,067,24*42
$GPGLL,5110.63897,N,00628.35881,E,122334.00,A,A*61
$GPRMC,122335.00,A,5110.63892,N,00628.35861,E,0.331,,291213,,,A*79
$GPVTG,,T,,M,0.331,N,0.613,K,A*26
$GPGGA,122335.00,5110.63892,N,00628.35861,E,1,06,2.07,39.5,M,46.5,M,,*65
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.35*00
$GPGSV,3,1,09,01,53,139,27,04,18,303,22,11,25,152,23,12,05,350,17*70
$GPGSV,3,2,09,13,17,200,30,17,42,275,26,20,88,344,34,23,48,189,38*70
$GPGSV,3,3,09,31,25,067,24*42
$GPGLL,5110.63892,N,00628.35861,E,122335.00,A,A*6B
$GPRMC,122336.00,A,5110.63879,N,00628.35842,E,0.176,,291213,,,A*7F
$GPVTG,,T,,M,0.176,N,0.326,K,A*24
$GPGGA,122336.00,5110.63879,N,00628.35842,E,1,06,2.07,40.1,M,46.5,M,,*68
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.35*00
$GPGSV,3,1,09,01,53,139,27,04,18,303,23,11,25,152,22,12,05,350,18*7F
$GPGSV,3,2,09,13,17,200,31,17,42,275,26,20,88,344,34,23,48,189,38*71
$GPGSV,3,3,09,31,25,067,24*42
$GPGLL,5110.63879,N,00628.35842,E,122336.00,A,A*6C
$GPRMC,122337.00,A,5110.63869,N,00628.35821,E,0.215,,291213,,,A*7C
$GPVTG,,T,,M,0.215,N,0.398,K,A*27
$GPGGA,122337.00,5110.63869,N,00628.35821,E,1,06,2.07,40.5,M,46.5,M,,*69
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.35*00
$GPGSV,3,1,09,01,53,139,28,04,18,303,23,11,25,152,22,12,05,350,18*70
$GPGSV,3,2,09,13,17,200,31,17,42,275,26,20,88,344,35,23,48,189,38*70
$GPGSV,3,3,09,31,25,067,25*43
$GPGLL,5110.63869,N,00628.35821,E,122337.00,A,A*69
$GPRMC,122338.00,A,5110.63855,N,00628.35801,E,0.197,,291213,,,A*77
$GPVTG,,T,,M,0.197,N,0.366,K,A*2F
$GPGGA,122338.00,5110.63855,N,00628.35801,E,1,06,2.07,41.1,M,46.5,M,,*6E
$GPGSA,A,3,20,01,23,17,04,13,,,,,,,3.13,2.07,2.35*00
$GPGSV,3,1,09,01,53,139,28,04,18,303,23,11,25,152,21,12,05,350,19*72
$GPGSV,3,2,09,13,17,200,31,17,42,275,26,20,88,344,34,23,48,189,38*71
$GPGSV,3,3,09,31,25,067,25*43
$GPGLL,5110.63855,N,00628.35801,E,122338.00,A,A*6B
$GPRMC,122339.00,A,5110.63843,N,00628.35782,E,0.14