
Zitat von
Che Guevara
Warum bekommst du jetzt andere Werte? Was hast du den geändert? Wie oft liest du denn den Sensor aus?
Hast du mal versucht, die Error-Variable nach der I2C-Kommunikation auszugeben? Vielleicht läuft da was schief?
Gruß
Chris
ich hab das shiften weggelassen und somit komm ich jetzt auf andere werte ^^
braucht man ja bei deiner methode nicht mehr, wenn ichs richtig verstanden habe.
aber mir ist noch nen Fehler aufgefallen. Hatte die falsche Hex Adresse zum auslesen angegeben
. jetzt kommen Werte an.
Jetzt wäre nur die Frage soll ich das nach deiner Methode ohne Shiften, mit den Hilfsvariablen Imx_tmp(1) usw. machen, oder mit meiner shift methode wie unten zu sehen.
Meine Shift Methode hab ich hier irgendwo im Forum gefunden, da hatte jemand nur den Beschleunigungssensor ausgelesen und das dann so gelöst. weis aber jetzt nicht was besser bzw. richtig ist...
Code:
Dim Abmagdata(6) As Byte
Dim Imx As Integer At Abmagdata(1) Overlay
Dim Imy As Integer At Abmagdata(3) Overlay
Dim Imz As Integer At Abmagdata(5) Overlay
...
I2crbyte Abmagdata(1) , Ack
I2crbyte Abmagdata(2) , Ack
I2crbyte Abmagdata(3) , Ack
I2crbyte Abmagdata(4) , Ack
I2crbyte Abmagdata(5) , Ack
I2crbyte Abmagdata(6) , Nack
I2cstop
Imx = Abmagdata(1)
Shift Imx , Left , 8 , Signed
Imx = Imx + Abmagdata(2)
Imy = Abmagdata(3)
Shift Imy , Left , 8 , Signed
Imy = Imy + Abmagdata(4)
Imz = Abmagdata(5)
Shift Imz , Left , 8 , Signed
Imz = Imz + Abmagdata(6)
- - - Aktualisiert - - -
Was mir auch noch aufgefallen ist, ist dass die Werte weit außerhalb der maximal Ausgabewerte des Sensors liegen (Laut Datenblatt: -2048 bis 2047)
Messdaten ohne Bewegung des Sensors:
Iax: 0 Iay: -12033 Iaz: 24769
Imx: 25088 Imy: -1793 Imz: 31745
Iax: 4096 Iay: 0 Iaz: 28865
Imx: 25600 Imy: -1793 Imz: 32513
Iax: 0 Iay: -20225 Iaz: -16191
Imx: 23552 Imy: -3073 Imz: -32511
Iax: 0 Iay: 0 Iaz: -28479
Imx: 23552 Imy: -2305 Imz: 32001
Iax: 0 Iay: 0 Iaz: -28479
Imx: 22272 Imy: -1537 Imz: -32511
Lesezeichen