LusoRobótica - Robótica em Português
Sistemas específicos => Arduino / AVR => Tópico iniciado por: kast em 06 de Julho de 2009, 01:40
-
Oi pessoal
Tenho andado a programar bascom para o arduino e tem funcionado.
No entanto não consigo fazer o bascom comunicar com o módulo gps que tenho aqui ... alguém ajuda...
Tirei o código de outro site e alterei-o um pouco ... alguém me diz porque n
ao funciona ?
'--------------------------------------------------------------
' GPS PARSE NEMA MESSAGE RMC
' Douglas Burkett
' 9 January 2002
'--------------------------------------------------------------
$crystal = 16000000
$baud = 9600
Dim Sync_char As Byte , Tmdt As String * 7 , Tmp As String * 3 , Sentence_hdr As String * 6
Dim A As Byte , Hh As Integer , Mm As Integer , Ss As Integer
Dim Xx As Word
Cls
Sync: 'use $ as sync character, it starts every NMEA sentence
Hh = -1
Mm = -1
Ss = -1
'Loops until a start of sentence character is received.
Open "comd.0:9600,8,N,1" For Input As #1
Open "comd.1:9600,8,N,1" For Output As #2
Do
Set Portb.5
Print #2 , " Not Parsing ...." 'message available
Sync_char = Inkey(#1) 'check serial port
Print #2 , Sync_char 'message available
If Sync_char = "$" Then
Print #2 , "Parsing ...." 'message available
Goto Msg_parse
End If
Reset Portb.5
Loop 'Forever
Msg_parse:
Inputbin Sentence_hdr 'get five characters, weird because the sixth character triggers the action and is lost
'which in this case is okay because it is the comma separator, odd.
If Sentence_hdr <> "GPRMC" Then Goto Sync 'Is it the right sentence?
Inputbin Tmdt
Tmp = Left(tmdt , 2)
Hh = Val(tmp)
If Hh < 0 Or A > 24 Then Goto Invalid_time
Tmp = Mid(tmdt , 3 , 2)
Mm = Val(tmp)
If Mm < 0 Or Mm > 59 Then Goto Invalid_time
Tmp = Mid(tmdt , 5 , 2)
Ss = Val(tmp)
If Ss < 0 Or Ss > 59 Then Goto Invalid_time
Print #2 , "Time " ; Hh ; ":" ; Mm ; ":" ; Ss
Goto Sync
Invalid_time:
Wait 3 'pause to read
Goto Sync
Close #1
Close #2
End
-
Qual modelo do modulo gps???
-
O Modelo do gps é EM-410.
Já experimentei com o software do arduino e consigo que ele me dê a informação correcta que vem do gps, incluindo a localização.
Agora só falta mesmo saber o que é que se passa com o bascom.
Se alguém conseguir arranjar ou explicar-me, um programita em bascom para que o arduino comunique nos pins 6 e 7 (input e output) respectivamente.
kast
-
Me envia o código do arduino e tentarei mudar para o bascom.
mauortega@terra.com.br
-
Desculpe a demora estava viajando.
Teste este código
Até +++
'--------------------------------------------------------------
' GPS PARSE NEMA MESSAGE RMC
' Douglas Burkett
' 9 January 2002
'--------------------------------------------------------------
$crystal = 16000000
$baud = 9600
Dim Sync_char As Byte , Tmdt As String * 7 , Tmp As String * 3 , Sentence_hdr As String * 6
Dim A As Byte , Hh As Integer , Mm As Integer , Ss As Integer
Dim Xx As Word
Cls
Sync: 'use $ as sync character, it starts every NMEA sentence
Hh = -1
Mm = -1
Ss = -1
'Loops until a start of sentence character is received.
Do
Set Portb.5
Print " Not Parsing ...." 'message available
Sync_char = Inkey() 'check serial port
Print Sync_char 'message available
If Sync_char = "$" Then
Print "Parsing ...." 'message available
Goto Msg_parse
End If
Reset Portb.5
Loop 'Forever
Msg_parse:
Inputbin Sentence_hdr 'get five characters, weird because the sixth character triggers the action and is lost
'which in this case is okay because it is the comma separator, odd.
If Sentence_hdr <> "GPRMC" Then Goto Sync 'Is it the right sentence?
Inputbin Tmdt
Tmp = Left(tmdt , 2)
Hh = Val(tmp)
If Hh < 0 Or A > 24 Then Goto Invalid_time
Tmp = Mid(tmdt , 3 , 2)
Mm = Val(tmp)
If Mm < 0 Or Mm > 59 Then Goto Invalid_time
Tmp = Mid(tmdt , 5 , 2)
Ss = Val(tmp)
If Ss < 0 Or Ss > 59 Then Goto Invalid_time
Print "Time " ; Hh ; ":" ; Mm ; ":" ; Ss
Goto Sync
Invalid_time:
Wait 3 'pause to read
Goto Sync
End
-
mauortega
Neste momento já consigo escrever qq coisa para o serial. No entanto não consigo que o arduino leia outros pins.
O problema é que se o ponho a ler um pin que não seja o pin 0 (portD.0) ou escrever que não seja o pin 1 (portD.1).
O meu problema agora é este ... mas está a melhorar :D
Já alguma vez tentaste ligar outro pin que não o 0 ou o 1 ?
Kast