Also hab das mal gemacht.
dabei ist mir aufgefallen dass die Magnetwerte sich immer nur um den Faktor 256 ändern .
![]()
Also um die Multiplikation des H_Bytes.
das bedeutet demnach, dass entweder der Magnetsensor defekt ist, was ich nicht hoffe. Oder dass hier beim auslesen ich irgendwas falsch mache.
hier nochmal der Code vom auslesen des Magnetsensor:
Code:'Variablen für Magnetfeld Sensor : Const Magnet_w_addr = &H3C '3C 1E Const Magnet_r_addr = &H3D Const Cra_reg_m = &H00 Const Crb_reg_m = &H01 Const Mr_reg_m = &H02 Const Out_x_h_m = &H03 ' Magnetfeld Const Out_x_l_m = &H04 Const Out_y_h_m = &H05 Const Out_y_l_m = &H06 Const Out_z_h_m = &H07 Const Out_z_l_m = &H08 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 ....... Sub Magnet_readsensordata() Dim Temp As Byte I2cstart I2cwbyte Magnet_w_addr I2cwbyte Out_x_h_m I2cstart I2cwbyte Magnet_r_addr 'I2cwbyte Magnet_w_addr 'I2cwbyte Mr_reg_m 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) End Sub







Zitieren

Lesezeichen