Pages: [1]   Go Down
Author Topic: LSM303 compass problem!  (Read 1264 times)
0 Members and 1 Guest are viewing this topic.
Sweden
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!
I've just bought the LSM303 https://www.sparkfun.com/products/10888.
It should have been an easy process to calibrate the compass with the library https://github.com/pololu/LSM303, but certainly not for me.
When I use the "calibrate" sketch included in the library, which reads the max/min value from the compass, I'm just getting minimal changes in the values,if any at all, even tough I rotate every axis:
Code:
M min X: -8 Y: -4096 Z: -256 M max X: 16 Y: 3 Z: 3
and this happens after a while if I do nothing at all:
Code:
M min X: -255 Y: -4096 Z: -256 M max X: 16 Y: 4 Z: 255
So instead I've been trying the "serial" sketch, which just reads the raw data from the compass.
From that data, I've noticed  that the values from the accelerometer do change, while the values from the magnetic sensor pretty much stand still, just like the calibration-values:
Code:
A X: 786 Y: 483 Z: 447 M X: -2 Y: -4096 Z: -1
A X: 775 Y: 477 Z: 431 M X: -2 Y: -4096 Z: 0
A X: 772 Y: 480 Z: 437 M X: -2 Y: -4096 Z: -3
A X: 764 Y: 469 Z: 439 M X: -2 Y: -4096 Z: -1

What have gone wrong here? Could the magnetic-sensor on the compass have been damaged or something?

All help and suggestions is appreciated!

// Andreas

Edit:
The compass was shipped together with a vacuum pump and a liquid pump, who both cause pretty decent magnetic fields with values over 1000 microTesla (measured with phone).
Could this have damaged the magnetic sensor on the compass?..
« Last Edit: August 03, 2013, 07:16:55 am by Jellycow » Logged

Sweden
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've tried Adafruit's library now as well, and it's not working either..
Please help!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The -4096 value means "overflow" on the LSM303. You can try changing some of the settings on your compass to see what the problem may be.

Code:
 
//Set the magnetic gain
    // HEX  = BIN          RANGE    GAIN X/Y/Z        GAIN Z
    //                               DLH (DLM/DLHC)    DLH (DLM/DLHC)
    // 0x20 = 0b00100000   ±1.3     1055 (1100)        950 (980) (default)
    // 0x40 = 0b01000000   ±1.9      795  (855)        710 (760)
    // 0x60 = 0b01100000   ±2.5      635  (670)        570 (600)
    // 0x80 = 0b10000000   ±4.0      430  (450)        385 (400)
    // 0xA0 = 0b10100000   ±4.7      375  (400)        335 (355)
    // 0xC0 = 0b11000000   ±5.6      320  (330)        285 (295)
    // 0xE0 = 0b11100000   ±8.1      230  (230)        205 (205)
compass.writeMagReg(0x01,0x20);
Logged

Pages: [1]   Go Up
Jump to: