Why not use a compass instead of an accel/gyro for a balancing robot?

There is a lot of work done on balancing robots with gyros and accelerators. They do explain the need of using it and getting roll/pitch/yaw angles (one angle only needed for basic balancing robots). I never found anything explaining why not omitting these calculations and directly use a compass in the rotation axis of interest.

Naturally, I would think of applying PID to the angle given by the compass. So why not?

If your robot will not be getting too close to other objects that contain ferrous metals or magnets, it would work. Otherwise, those objects will adversely affect the compass output.

a compass only works in the horizontal plane, so it would be of no use at all.

Mark

holmes4:
a compass only works in the horizontal plane, so it would be of no use at all.

Mark

You obviously have not played much with the 3 axis compasses available today. I use one from Adafruit.

holmes4:
a compass only works in the horizontal plane, so it would be of no use at all.

That's not quite true, but it's not quite the reason either. A 3D compass reading (which is what the available chips provide) has a declination angle as well, but if the robot is balancing perpendicular to that angle, it is of no use.

A 3D compass reading (which is what the available chips provide) has a declination angle as well, but if the robot is balancing perpendicular to that angle, it is of no use.

That is not what my 3 axis magnetometer shows. It seems to be useful in all axis, just not near iron/steel or magnets.

SurferTim:
That is not what my 3 axis magnetometer shows. It seems to be useful in all axis, just not near iron/steel or magnets.

I suggest you have a sit and think about what this has to do with a balancing robot.

Paul__B:
I suggest you have a sit and think about what this has to do with a balancing robot.

I've been "sitting and thinking" about this for weeks now. I'm about to do some experimenting with an airborne drone, and the 3D accelerometer included with the 10DOF seems to have the same accuracy as hanging your dog tags from the compass in a huey while flying IFR. It means only that the aircraft will be in trim when you crash.

My options are down to using the magnetometer or tracking the gyro rate of rotation.

does your robot contain

  • any iron or steel components?
  • any electric current loops which might make a magnetic field, say while powering a motor?

f you have time, try looking up 'Doodlebug V1 guidance system'. Those things did contain things which don't like magnets.

SurferTim:
... the same accuracy as hanging your dog tags from the compass in a huey while flying IFR. It means only that the aircraft will be in trim when you crash.

]:smiley:

I would suggest that you google compass errors to understand why this would not work. Things you should know about: magnetic dip, magnetic variation, turning error, oscillation errors, and my personal favorites, acceleration and deceleration errors.

Here's a brief overview:
https://missions.capnhq.gov/ops/DOT/school/L23CockpitFam/magneticcompass.cfm

Most of those errors are caused by the mounting of the magnetic compass and the reliance on "down" to determine direction. "Down" changes due to (edit add: inertial and) centripetal force exerted on the aircraft during acceleration, deceleration, and coordinated turns. Gyro compasses are not affected by these changes.

The 3 axis magnetometer seems to overcome most of those, except dip and deviation.

I am not saying the magnetometer is the most efficient way of determining attitude. I still believe that the accelerometer is best for determining upright and which way is "down", even though "down" may not truly be down.

A gyro is not the same thing as a magnetic compass. Just saying.