HMC5883L Magnetometer

Hi,

 

I know i'm in a minority here, but I've purchased a HMC5883L Magnetometer from DIY Drones and I've been programming a DSPic to read the values through I2C. I have the device in continuous mode, however each time I loop around to re-read the values, the values/ seems to shift up a register. I.e.

I read everything correctly the first time round, the second read though XH value is displaying XL value and the third time round the XH is now reading the YH value etc etc.

 

Has anyone got any ideas, I'm assuming I am missing something in my code?

You need to be a member of diydrones to add comments!

Join diydrones

Replies are closed for this discussion.

Replies

  • Developer
    I guess your code was originally meant for the 4843 in which the read pointer would wrap around after 9 reads.
    To minimize the communication between the master and this device, the address pointer updated   automatically without master intervention. This automatic address pointer update has two additional features. First when address 12 or higher is accessed the pointer updates to address 00 and secondly when address 09 is reached, the pointer rolls back to address 03. Logically, the address pointer operation functions as shown below.
    If (address pointer = 09) then address pointer = 03
    Else if   (address pointer >= 12) then address pointer = 0
    Else (address pointer)   = (address pointer) + 1
    but for the 4883 the read pointer would wrap around after 8 reads.
    To minimize the communication between   the master and this device, the address pointer updated automatically without   master intervention. This automatic address pointer update has two additional   features. First when address 12 or higher is accessed the pointer updates to   address 00 and secondly when address 08 is reached, the pointer rolls back to address   03. Logically, the address pointer operation functions as shown below.
     
    If (address   pointer = 08) then address pointer   = 03
    Else if (address pointer >= 12) then address pointer =   0
    Else (address pointer) = (address pointer) +   1
This reply was deleted.

Activity

Jose Araujo liked Jose Araujo's profile
Aug 29
spencer harvey liked spencer harvey's profile
Jul 9
More…