Hallo
Ich habe das RN-Mega 128 Funkboard von Robotikhardware. Daran habe ich ein Beschleunigungsensor angeschlossen.
http://www.lipoly.de/index.php?main_...9695dd5a56ac11
Ich den SCL / SDA Anschluss des Sensors an die des Controller und an den VDD Anschluss des Sensors habe ich 2,5 V dran und an den GND -.
Mein Code ist folgender:
Der gibt aber als Wert immer nur 0 aus. Woran liegt das?Code:Declare Function Rn_beschleunigung() As Word ' ---------------RN-Mega128Funk übliche ------------------ $regfile = "m128def.dat" ' Bei Mega 128 " $framesize = 32 $swstack = 32 $hwstack = 32 $crystal = 16000000 $baud = 19200 $baud1 = 9600 Config Scl = Portd.0 Config Sda = Portd.1 Config Ping.0 = Output Lcdpower Alias Portg.0 Config Pine.2 = Output Rdy_hostempfangsbereit Alias Porte.2 Config Pine.5 = Input Bsy_funkmodulsendebereit Alias Porte.5 Open "com2:" For Binary As #2 Sound Portg.2 , 400 , 450 Sound Portg.2 , 400 , 250 Sound Portg.2 , 400 , 450 ' --------------------------------------------------- Dim Beschleunigung As Word Dim V As Byte Wait 3 I2cinit Print "RN-Mega128Funk Testprogramm " V = 1 Do Beschleunigung = Rn_beschleunigung() Print "Wert x: " ; Beschleunigung V = V + 3 Wait 1 Loop End Function Rn_beschleunigung() As Word Local Lob As Byte Local Hib As Byte Local be_slaveid As Byte Local be_slaveid_read As Byte be_slaveid = &H1D 'Register auswählen I2cstart I2cwbyte be_slaveid I2cwbyte 2 I2cstop I2cstart I2cwbyte be_slaveid_read I2crbyte Hib , Ack I2crbyte Lob , Nack I2cstop Rn_beschleunigung = Makeint(lob , Hib) End Function
Vielen Dank für die Hilfe im Vorraus![/url]







Zitieren

Lesezeichen