cancel
Showing results for 
Search instead for 
Did you mean: 

LSM303D // Compass X,Y & Z's MSB locked

Posted on March 26, 2015 at 14:53

Hey there,

I recently installed a new LSM303D (accelerometer + compass) on my board and I am having some issues with it. I can read the data from the accelerometer fine, but the ones from the compass seem ''locked'', I read a total of 3 pairs of MSB-LSB, of which only the LSB change over time. Here is an exemple of reading (LSB on the left):

Mag X:
-125
-1
Y:
-93
-1
Z:
-22
-1
Mag X:
-115
-1
Y:
-101
-1
Z:
-26
-1
Mag X:
-119
-1
Y:
-78
-1
Z:
-34
-1

The LSBs change erratically regardless of the orientation of the sensor. Here is the config I'm using:

ST_CTRL_REG
1
, 
0
x
67
ST_CTRL_REG
5
, 
0
x
60
ST_CTRL_REG
6
, 
0
x
00
ST_CTRL_REG
7
, 
0
x
80

I am using SPI. I don't really get how I am not getting the values right. Any help or lead would help me a lot :) Thanks !
2 REPLIES 2
ferrarofcf
Associate II
Posted on April 08, 2015 at 14:25

 do you read these?

//MAGNETIC OUTPUT REGISTER

#define LSM303D_OUT_X_L_M 0x08

#define LSM303D_OUT_X_H_M 0x09

#define LSM303D_OUT_Y_L_M 0x0A

#define LSM303D_OUT_Y_H_M 0x0B

#define LSM303D_OUT_Z_L_M 0x0C

#define LSM303D_OUT_Z_H_M 0x0D

Edmunds Sprudzs
Associate
Posted on February 02, 2017 at 00:24

Hey all,

I'm using I2C and I have the same problem as described in OPs post stuck MSBs on all three magnetometer axes. Most of the time they show 255 and sometimes 0, but nothing in between. Since I'm rotating the device well over 360 degrees, this cannot be correct.

I have also lost continuous mode. i.e. whatever MD bits I set in CFG_REG_A_M, I have to write to the register in the end of every read to have something to read next time.

I was not very kind to the sensor when soldering on the prototyping board, so I could have damaged it, but I would need to understand if I'm not barking up the wrong tree here.

Thank you all for your inputs,

Edmunds