Accelerometers, Gyros, Magnetometers in a nutshell

by Mathieu DD | May 22, 2015 | (8) Posted in Tips

There sure are a lot of sensors packed on these controller boards. It seems like each new release touts the addition of a new one, but do you really know what each of them does? There are only so many ways (six to be exact) a craft can move, up-down (altitude), left-right (latitude), forward-back (longitude), yaw, pitch and roll, can't a few sensors just handle that?

Let's go over the various types and see how their strengths combine:

Relationship Between Position, Speed and Acceleration

Before we start, we'll need a high-level math crash course (or review). We will not get into the equations here, but skip ahead directly to the implications. I'll surely be faulted for this, but likely from people who didn't need to read this article in the first place ;)

Position, Speed and Acceleration as concepts should be fairly obvious for everyone. Obviously, they are somehow related. On a mathematical level, this somehow is through the powers of derivation and integration. Essentially, if you know one over some period of time, you can figure out the others.

Integration

If you now your speed, you can figure out how far you have travelled (position) if you know how long you travelled at that speed. In mathematics, this is called integration. One important limitation, in this example as in any integration, is that you will not know WHERE you are, just how far you have travelled, unless you know where you STARTED from. So knowing your speed is not enough to know your position. You need to know your starting position.

In a similar fashion, you can determine your speed from your acceleration, if you know your starting speed. In practice, this is much easier because we usually start at rest, with a speed of zero.

So, you can get RELATIVE POSITION from speed and RELATIVE SPEED from acceleration. To get any ABSOLUTE position or speed, you need to know your INITIAL conditions.

Derivation

If we want to work our way back, figuring out our speed from our position, it is also fairly easy. If you travelled 10 miles in 2 hours, you would know that your speed has been 5 miles per hour, on AVERAGE. This computation is called derivation. Note that you can only figure out the AVERAGE speed over that period of time. Maybe your travelled faster than 5 mph the first hour and less the second one. We don't know. You can minimize this problem by checking the position more often, like every 1 thousandth of a second. This is easy enough, but we'll see below how this can cause other problems.

So, you can get AVERAGE SPEED from position and AVERAGE ACCELERATION from speed. To get any INSTANT speed or acceleration, you need to check your position or speed, respectively, very, very often.

Noise

Unfortunately, we don't live in a perfect world and that is true of sensors as well. Every time we check a sensor, it gives us a result with some noise added or removed. Usually, noise is relatively small, and getting relatively smaller, but it is still there.

Noise is not such a big deal in integration. Noise may make the reading a little higher once and then a little less, so it tends to cancel itself out over time. This is different from bias, another issue we won't tackle here, where the reading is always skewed (biased) one way.

The problem with noise is with derivation. As we said earlier, to get something close to the INSTANT speed or acceleration, we need to check the position or speed very often. Part of the derivation computation is diving the value by the time difference. If the interval is 1 thousandth of a second, dividing by 1/1000 is the same as multiplying by 1000. We will be multiplying the noise by 1000.

The problem with derivation then is that the more we try to get an INSTANT value of speed (for example) rather than an average, the more SENSITIVE to noise we become.

Gyroscopes - For Relative Pitch, Roll and Yaw Control

Gyroscopes, commonly referred to as simply 'gyros', have long been a staple of RC flight. They measure angular (rotation) speed directly.

Gyroscopes remain ever present on most controller boards because they provide a solid starting point for the stability control of multi-copters. Actually, other sensors are added mostly to address the limitations of gyroscopes, so let's take a look at these limitations:

  • Because they measure the angular speed, we need to integrate the position. The means the position (or more accurately positions - in X, Y, Z yaw, pitch and roll) we get is only RELATIVE to an arbitrary position we don't know (initial position) and subject to drift over time.
  • Because they measure the angular speed, we need to derive the acceleration. The acceleration could be useful because the thrust of the motors affect the acceleration directly and can be used in more advanced control methods.
  • Because the measure the angular speed, they completely ignore any linear movement. This is a lesser problem on multi-copters which achieve linear motion by banking and thrusting in the inclined direction, but is a larger problems on conventional aircraft for which the propeller controls linear movement more directly.

Accelerometers - For Absolute Pitch and Roll Control

Accelerometers are useful mostly to provide an absolute positional reference for the pitch and roll of a multi-copter. This is because we can read 3 accelerometers (one for each translation axis), compute a vector of the overall acceleration and compare it to the gravitational pull of the earth which is of a known orientation (DOWN) and magnitude (9.8 m/s^2). This is usually added to provide self-levelling capability to the controllers.

Of particular interest here is that the accelerometers in this case are used to read the gravity and return an angular position directly, without integration and its associated pitfalls mentioned above. However, in order to use it as such, we need a 3-axis accelerometer in order to get a single piece of useful information.

More advanced controllers may use the acceleration values directly, including integration of the associated speed and position, in their control loops but it seems pretty rare. This way of getting information doesn't provide much benefit over the same information gathered by the gyroscopes.

Magnetometer - For Absolute Yaw Control

Magnetometers, or solid-state compasses, are used to provide an absolute positional reference for the yaw of a multi-copter. This is usually added to provide a stable heading control.

Because these sensors are usually very slow to update (relative to other sensors), they are very rarely, if ever, used to derive speed or acceleration over the yaw. Again, gyroscopes provide more than adequate information for this.

GPS - For Absolute Latitude, Longitude and Altitude Control

GPS modules use satellites to get a relatively accurate position (typically up to 1 meter) for the latitude, longitude and altitude of the multi-copter. They cannot give any information regarding the rotations (yaw, pitch, roll) which is why the other sensors are always present.

Because these sensors are usually very slow to update (relative to other sensors), they will rarely be used in the high-speed control loop of the multi-copter. See related article on the PID control.

Barometer - For Absolute Altitude Control (alternative)

Barometers, or solid-state pressure sensors, are used to provide an absolute positional reference for the altitude of a multi-copter. They are much cheaper then GPS units, but can provide similar resolution over the altitude, but will do nothing for the latitude and longitude of the craft.

COMMENTS

HilldaFlyer on May 23, 2015
Great explanation. I love learning about this stuff.
Log In to reply
micha on May 27, 2015
Awesome article! Thanks!
Log In to reply
JeffCovert on June 12, 2015
It is amazing the difference of 40 years. If you had posted this in the mid-70s, you would have been escorted to an undisclosed location. Now this is almost common knowledge. I'm amazed that I can get a full set of gyros, accelerators and a processor for under $20. When I was first learning to fly RC, you needed to be very, very rich to get a single axis gyro that would give you one axis of stability. It is so much cheaper to fly now days…
Log In to reply
JeffCovert on June 12, 2015
P.S.
You give a very good explanation for in laymen’s terms, Very informative yet short so most could or would read it…
Thanks…

Log In to reply

You need to log-in to comment on articles.


Accelerometers, Gyros, Magnetometers in a nutshell