Diron
28.02.2008, 02:12
Hab mir einen Kompasssensor für meinen mega2560 bestellt und ihn angeschlossen...auch richtig. Aber beim Programmbeispiel (angepasst an den 2560) liefert er mir keine Ausgabe ausser dem Print in dem Beispiel "RN-Control CMPS03 Kompass Testprogramm
CMPS03 Kompass Firmware Version:". Verzweifel langsam dran... 4 kabel und en paar zeilen code....aber keine Antwort *schnief*
ich poste mal den Code:
Declare Function Rn_cmps_himmelsrichtung() As Word
Declare Function Rn_cmps_firmware() As Byte
' ---------- Das RN-Control übliche --------------
$prog , 255 , &B11011001 , 'Quarz an / Teiler aus / Jtag aus
$regfile = "m2560def.dat"
$hwstack = 82
$framesize = 68
$swstack = 68
$crystal = 16000000 'Quarzfrequenz
$baud = 9600
Config Scl = Portd.0 'Ports fuer I2C-Bus
Config Sda = Portd.1
Config Pine.5 = Input
Usb Alias Pine.5 'Ist 1 wenn USB angeschlossen
Config Com4 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Open "com4:" For Binary As #4 'USB Buchse
' ------------------------------------------------
Dim Himmelsrichtung As Word
Dim Grad As Single
Dim V As Byte
Wait 3 'Warte 3 Sekunde
I2cinit
Print #4 , "RN-Control CMPS03 Kompass Testprogramm "
Print #4 , "CMPS03 Kompass Firmware Version:" ; Rn_cmps_firmware()
V = 1
Do
Himmelsrichtung = Rn_cmps_himmelsrichtung()
Print #4 , "Himmelsrichtung in 0,1 Grad Schritten: " ; Himmelsrichtung
Grad = Himmelsrichtung / 10
Print #4 , "Himmelsrichtung genau in Grad: " ; Grad
V = V + 3
Wait 1
Loop
End
Function Rn_cmps_himmelsrichtung() As Word
Local Lob As Byte
Local Hib As Byte
Local Cmps_slaveid As Byte
Local Cmps_slaveid_read As Byte
Cmps_slaveid = &HC0
Cmps_slaveid_read = Cmps_slaveid + 1 'Register auswählen
I2cstart
I2cwbyte Cmps_slaveid
I2cwbyte 2
I2cstop
I2cstart
I2cwbyte Cmps_slaveid_read
I2crbyte Hib , Ack
I2crbyte Lob , Nack
I2cstop
Rn_cmps_himmelsrichtung = Makeint(lob , Hib)
End Function
Function Rn_cmps_firmware() As Byte
Local Firmware As Byte
Local Cmps_slaveid As Byte
Local Cmps_slaveid_read As Byte
Cmps_slaveid = &HC0
Cmps_slaveid_read = Cmps_slaveid + 1
I2cstart
I2cwbyte Cmps_slaveid
I2cwbyte 0 'Leseregister festlegen
I2cstop
I2cstart
I2cwbyte Cmps_slaveid_read
I2crbyte Firmware , Nack
I2cstop
Rn_cmps_firmware = Firmware
End Function
---
Jemand en Tipp? Kann ich das Ding andersweitig auf seine Funktion testen? Habt ihr das einfach angeschlossen und es ging?
CMPS03 Kompass Firmware Version:". Verzweifel langsam dran... 4 kabel und en paar zeilen code....aber keine Antwort *schnief*
ich poste mal den Code:
Declare Function Rn_cmps_himmelsrichtung() As Word
Declare Function Rn_cmps_firmware() As Byte
' ---------- Das RN-Control übliche --------------
$prog , 255 , &B11011001 , 'Quarz an / Teiler aus / Jtag aus
$regfile = "m2560def.dat"
$hwstack = 82
$framesize = 68
$swstack = 68
$crystal = 16000000 'Quarzfrequenz
$baud = 9600
Config Scl = Portd.0 'Ports fuer I2C-Bus
Config Sda = Portd.1
Config Pine.5 = Input
Usb Alias Pine.5 'Ist 1 wenn USB angeschlossen
Config Com4 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Open "com4:" For Binary As #4 'USB Buchse
' ------------------------------------------------
Dim Himmelsrichtung As Word
Dim Grad As Single
Dim V As Byte
Wait 3 'Warte 3 Sekunde
I2cinit
Print #4 , "RN-Control CMPS03 Kompass Testprogramm "
Print #4 , "CMPS03 Kompass Firmware Version:" ; Rn_cmps_firmware()
V = 1
Do
Himmelsrichtung = Rn_cmps_himmelsrichtung()
Print #4 , "Himmelsrichtung in 0,1 Grad Schritten: " ; Himmelsrichtung
Grad = Himmelsrichtung / 10
Print #4 , "Himmelsrichtung genau in Grad: " ; Grad
V = V + 3
Wait 1
Loop
End
Function Rn_cmps_himmelsrichtung() As Word
Local Lob As Byte
Local Hib As Byte
Local Cmps_slaveid As Byte
Local Cmps_slaveid_read As Byte
Cmps_slaveid = &HC0
Cmps_slaveid_read = Cmps_slaveid + 1 'Register auswählen
I2cstart
I2cwbyte Cmps_slaveid
I2cwbyte 2
I2cstop
I2cstart
I2cwbyte Cmps_slaveid_read
I2crbyte Hib , Ack
I2crbyte Lob , Nack
I2cstop
Rn_cmps_himmelsrichtung = Makeint(lob , Hib)
End Function
Function Rn_cmps_firmware() As Byte
Local Firmware As Byte
Local Cmps_slaveid As Byte
Local Cmps_slaveid_read As Byte
Cmps_slaveid = &HC0
Cmps_slaveid_read = Cmps_slaveid + 1
I2cstart
I2cwbyte Cmps_slaveid
I2cwbyte 0 'Leseregister festlegen
I2cstop
I2cstart
I2cwbyte Cmps_slaveid_read
I2crbyte Firmware , Nack
I2cstop
Rn_cmps_firmware = Firmware
End Function
---
Jemand en Tipp? Kann ich das Ding andersweitig auf seine Funktion testen? Habt ihr das einfach angeschlossen und es ging?