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.

I currently have 3 compasses (MAG3110, HMC5883L and a GY-26) on my Rover 5. The HMC5883L is mounted about 15cm above the Rover with some nylon spacers. The MAG3110 and GY-26 are mounted on the acryl base I have on the Rover. I don't have any problems with interference of the motors. I have hooked up a scope to the various power lines on my Rover and it's pretty clean. I do have lots of capacitors (big electolytic and some ceramics) on the various pcb's (power distribution board, small servo board). Can you show us some pics of your Rover? Which motor controller are you using? 

Thanks bajdi,

Using a Spider and Dagu 4 ch controller. I've had my 'scope hooked up plenty of times but (come to think of it) never with the motors actually running. So that's worth a try.

I was planning to connect the probes to the lsm303 leads to see if they were picking up any inductive ripple so I'll definitely make the effort.

Good to hear that your compasses are working fine. I'll persist with my analysis in that case.