Let's Make Robots!

lsm303 on Rover 5 4wd

Hi All,

Has anyone had any success using a lsm303dlhc as a compass on a Rover 5 4wd with the motors running?

After some research, I noted that some people had them mounted on a mast so I've placed it 400mm above the motors. This has completely removed any interference from everything except the motors. Even with an XBee transmitting continuously, the headings don't vary more than 1-2 degrees with the Rover stationary (which is much better than I'd hoped for). But as soon as I fire up the motors, the readings are useless. I tried raising it to 600mm but this didn't alleviate the problem.

I only had a quick google, but mu-metal sheet doesn't seem to be easily obtainable in Australia and I'd only be guessing at the required thickness anyway.

I only fitted a compass because the optical encoders are becoming a bit unreliable of late and I use them to turn the Rover the required number of degrees. Also, one of the motors is a bit slow so the Rover slowly turns left when it's going straight ahead. I tried tweaking the PWM on that motor but it's not linear and needs to be compensated according to how fast the Rover is going. (I'll work out the maths later). I was hoping to use the compass to adjust the course on the fly.

Anyway, it's not a show stopper - I'll just stop the Rover when I want to take a reading and I'll keep using the encoders to turn and then stop and fine-tune with the lsm303. If I feel like pulling it all apart (no motivation at this stage) I'll try OddBot's suggestion and play with the encoder pot to see if I can improve the reliability.

Just thought someone might have solved this.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Most of these little compass modules have a calibration routine --the one's I have used require you to spin the compas around in a circle during this calibration. If your motors are running during this calibration (and thus, on) your compas should "calibrate around them".

Hi Chris,

The datasheet only mentions calibration in passing and mostly to point out that it shouldn't be normally necessary. However, I did calibrate it and compared it to my precision bearing Suunto. With the motors powered down, its performance comfortably exceeds my requirements. To be honest, I woudn't even mind if the bearings returned didn't match a conventional compass as long as relative bearings were correct.

If the motors were just "biasing" the device, then I could factor that into the code but with power applied (and up on a stand so the Rover isn't actually going anywhere), the bearings can vary as much as 180 degrees from one reading to the next - all over the place. So I don't believe that it's a candidate for calibration.

It's possible to reduce the gain on the device but I couldn't imagine that achieving much since it would presumably attenuate both the earth's magnetic field as well as the motors.