Digital compass or accelerometers

greetings to everybody,
i have a basic question about the device to use in a mobile robot,which will move independently and keep record of the movements,creating a map…me and my team are still in the beginning of the project,and i wonder what to use…does anyone know the difference of a 3d compass and a 3d acceleretometer/gyroscope; is it that the 2nd measures the gravity acceleration (g) so it has values only in movement whereas the compass has always o value;in my case for making the map,which device would be more appropriate;the compass will be the HMR3300.the map will be a 3d one…will i have to use a combination of the 2;;please if anyone knows smthing…
thank you.

An inertial navigation system is a really ambitious project, I’d love to see how it turns out. So, lets cover the basics, and forgive me for repeating some things I’m sure you already know:

So, a 3D compass is exactly what it sounds like. Picture a compass where the needle is free to tilt up and down as well as rotate left and right. There is a vertical component to the Earth’s magnetic field, varying depending on where you are. Standing over the north magnetic pole, a 3D compass would point straight down towards your feet! There might be compasses that output virtual needle angles, but the ones I’m familiar with output the magnitude of the magnetic field in three perpendicular directions (X,Y,Z). The compass reading won’t change as you move it around, except for when you rotate it, so a compass alone won’t give you a complete record of motion, only of orientation.

Accelerometers and Gyroscopes are operate differently, although they sometimes come in the same package, so lets talk about them separately.

Digital gyroscopes tell you the rate that they are rotating (i.e. 10 degrees per second) about an axis. A 3D gyroscope will tell you the rate at which it is rotating about three axes, but it its up to you to integrate these readings (measure them very frequently, multiply by the time since the last reading, and add them all up to find how far you’ve rotated) to find the current relative orientation of your robot.

Accelerometers, as the name implies, measure acceleration. In a horizontal plane, an accelerometer that isn’t moving, or that is moving with a constant speed will read zero. To find out how far an accelerometer has moved, you need to integrate the acceleration data twice, once to find the velocity of the accelerometer, then again to find it’s position. Keep in mind this makes the assumption that the accelerometer is initially stationary!

The big problem is that accelerometers don’t measure actual acceleration, they measure forces. Ideally these would all be inertial forces (the internal workings of the accelerometer tending to stay where they are as you try to move it around). The problem is that gravity also applies a force on the accelerometer, causing it to register a virtual downward acceleration, even when it isn’t moving. To cancel this out, you have to know which way is down. This isn’t a big problem if your robot is moving on a flat surface, but if your robot will be rotating as well as translating in three dimensions, you’ll need gyros as well. Oddly enough, a 3D accelerometer will read zero when it is in freefall, and actually accelerating towards the earth!

Accelerometers and gyroscopes are frequently paired because they compliment each other. Gyroscopes can tell you how far you’ve rotated form a starting orientation, but have no way of knowing what that starting orientation was. A stationary accelerometer will tell you which way is down, but once it starts moving you need to know its orientation to get position data from it. So, guidance systems based on accelerometers and gyroscopes generally have a stationary initialization routine. You turn the system on, but leave it still for a while. The accelerometer tells you which way is down, so you can figure out the initial orientation of the robot (with respect to it’s initial heading). This is also a good time to figure out the “steady state drift” of the gyroscope, the small, but nonzero reading that each axis will give when it’s actually not rotating, to subtract out of later readings. As your robot moves, integrating the gyro readings will tell you your robot’s new orientation (still, with respect to it’s initial heading), and double integrating the accelerometer readings, taking into account the changing orientation will tell you it’s position.

The big problem with inertial navigation is that it is prone to HUGE ERRORS. Accelerometer and gyroscope readings drift somewhat randomly over time, with changing temperatures, and for reasons you shouldn’t even worry about like the rotation of the earth. These errors are magnified by integration (and double integration) and add up over time. A 3D compass is nice to have, because although it’s not as precise (and doesn’t work well indoors) it provides an absolute orientation reference, with an error that won’t increase over time.

Anyway. I’m sure I’ve given you WAY too much information to process. As you can probably tell I’ve got a little interest in this subject my self, so please feel free to ask more questions or for clarification. Most of all good luck, and be sure to let us know how it turns out!


1 Like

thank you for your reply nexisnet.your information is very helpfull to originate our curse of action…i will let u know the progress of our project which will begin as soon as the equipments arrives.i will also take the courage of disturbing again if problems occur…till next time,enjoy !! :slight_smile:

I know this post is a bit old but I would like to know something. I am interested in experimenting with the 3-axis accelerometer board on this site as well as the single asix-gyro. However, wouldn’t you want a gyro for each axis of accelerometer axis? IE: if you have a 3-axis accelerometor, wouldn’t you want to pair it with 3 axes of gyro? If so, can the single axis gyro on this site be tripled up and mounted on different sides of a machined aluminum cube to give 3-axes? Or is it only do be used to rotate around the z-axis in a level to ground orinetation with the z-axis normal to the ground and parallel to the gravity vector?

Thanks for the info!


The gyro can be mounted in any orientation, so you can put three of them together to get three axes. Whether you want one gyro axis per accelerometer axis axis is up to your application.

- Jan

I guess I was responding to the post above in how you can use the gyro to give a tilt while moving relationship to the accelerometer in the same axis.
Although frankly every time I think about where I may want to use these devices I keep coming back to thinking that a servo motor could do the same thing as far as trying to locate something to a known position such as a scanning sensor or something. I guess you’d mainly want to use the accelerometers and gyros if you need to relate these to being “level” with respect gravity. My dream would be integrating them into an RC plane or something or having a semi-autonomous cheapie little RC helicopter but it seems like the errors associated with these types of devices may make that nearly impossible. At least at the level of sophistification(ie: affordable) of these particular sensors.

Forgive me if I have some juvenile questions. I’ve always wanted to get into the robot hobby and the main resources I have are the “Robot Builders Banaza” (the 1st edition I picked up from a 1/2 priced books a few years ago and then just got the 3rd edition the other day) and the internet. I think my ambisions are a bit ahead of my skill level at this point. :stuck_out_tongue: The main exposure I’ve had to electronics is building(aka: assembling/through-hole soldering) a fuel and ignition EFI control computer and integrating it into my car. It’s called a Megasquirt. But it has definitely rocketed my electronics knowledge ahead of what it used to be.
I like the component offerings on this site and I’m glad there is a fairly active forum to go along with it. It’s a nerd’s paradise! :smiling_imp: