2014-06-03 09:37 AM
Hello!
I'm trying to obtain correct data using I2C interface from magnetometer lsm303dlhc, which is included on mu stm32f3discovery board. I've configured device for continous conversion mode, 30Hz data output rate and scale 1.3 Gauss. My aim is to get simple information about placement from north (angle from north pole). To make this real i'm counting angle beetwen measured values of y and x dimension [atan2(mag_y, mag_x)]. Unfortunatelly i'm getting unexpected results - i.e. rotating 90 degrees equal 120 degrees or 60 deegress, depends on board placement (boards is lying on the table all the time). This results are repeatable, so i think that device is working with some kind of non-linear scale, which i can't determine. Weird is fact that this is board from st and imo it should work with any problems. I programmed my second board and situation is simmilar. What should i do to make this device work properly? Have anybody had this problem before?2014-09-20 12:57 AM
Plot the two axes as you rotate the device. You will see they trace out an ellipse. The centre of the ellipse is the axes offset, and the size is the axes scale. Minus the offset and divide by the scale to get a centred circle which will give you better angles. The offsets on the magnetometer are quite large - up to 1 times the earths mag field!!!