Loading... Please wait...
More Internet searching gave me references to several different IMU and AHRS devices, as well as individual gyroscopes. I was surprised however at how small the gyros were – again, I envisioned gyroscopes as large round objects the size of grapefruits. I noticed mention of the use of MEMS technology for the gyros.
MEMS – micro-electro-mechanical-systems – this refers to a relatively new (early 1970’s) technology allowing extremely small mechanical devices to be manufactured using technology similar to making electronic chips. Layers of material are photo etched onto a substrate and actual micro-machines are made! Rather than relying on large spinning balls, these gyros use MEMS technology to fabricate devices that are smaller than a match head.
Rotating the gyro sensor subjects its structure to the Coriolis force. You are familiar with the centrifugal force that causes objects to move away from you on an outward trajectory – the Coriolis force an associated lateral component. The Coriolis force causes a mechanical structure to vibrate inside the MEMS chip. The resulting vibration is detected by measuring the capacitance change between the mechanical structure and some fixed electrodes, i.e., mechanical fingers move together and apart as the sensor turns about its axis. The associated change in capacity between the fingers is output from the sensor via voltage that varies with the amount or rate of rotation experienced by the sensor.
MEMS Gyro Mechanical Structure MEMS “Tuning Fork”
OK, how do I go about actually using these MEMS gyros? I was not even sure where to start. I went back to SparkFun and saw that they had gyros on what they called “breakout boards”. A breakout board usually mounts the device of interest along with a voltage regulator, capacitors, resistors and the like to allow you to actually access the particular device – they are similar to the development boards for the microcontrollers I had been learning about.

Typical Breakout board
But which gyro to use? What were the criteria for gyros to build an effective tiltmeter? And, just how does one go about turning the output of a rate-of-rotation sensor into an angle? I slowly started to realize what I did not know and seriously re-considered just ordering a developed AHRS with angles already available to me - I decided I still had a long ways to go in this project.
I pushed on. I began by reading the specification sheets that were on the web store at SparkFun. SparkFun is a wonderful site for experimenters and those dabbling in electronics, and microcontrollers and sensors in particular. Each device has its own page listing the device, documentation for the device and references to other devices that you may want to use along with the primary one. There is a wealth of useful information, tutorials, and even sample projects.
It seemed that the relatively inexpensive gyros that were on breakout boards from SparkFun were analog output devices. After reading the specifications and thinking about what they might indicate for my application, e.g., their rated output scales and sensitivity to linear acceleration, I decided that I would most likely use gyros from either Invensense (the IDGnnnn series) or Analog Devices (the ADXRS6nn series), both of which had analog output. Since the BASIC Stamp microcontroller from Parallax that I had learned about in my course of study only had digital inputs, I went back to the Parallax site, researched some more and ordered a supplemental course on analog-to- digital conversion (ADC). I also started investigating just how those IMU/AHRS devices turned the output of a rate of rotation sensor into an angle.
Digital devices can be compared to a toggle switch that controls a light in your home – it is either on or off. An analog signal can be compared to a rotary dimmer controlling another light in your home – it can have an infinite number of positions between on or off. In electronics, variations of signal for a digital device are defined by incrementing or decrementing discrete numbers as opposed to the infinitely variable signals associated with analog devices.
The microprocessor embedded in a microcontroller can only directly work with digital signals. It can only distinguish between a signal that is either off, or on – a binary bit (or in binary, an 0 or a 1). If we need to have the microprocessor deal with an analog device such as the output of an analog rate-of-rotation gyro, we have to somehow convert the analog output signal into a digital signal in order for the microcontroller to be able to use it. Some microcontrollers incorporate analog inputs, i.e., they integrate and embed ADC into their digital inputs within the microcontroller chip itself. But at this point in my journey I was not familiar with anything but the BASIC Stamp series. That series of microcontrollers only has digital inputs, so, I needed to learn about ADC.
[Thanks to <tokind at gmail.com> for catching an error in the above text!]
Bias Analog sensors are usually standardized in their output. They typically output in a range of industry standard voltages of 0 to +3.3, or 0 to +5 volts. A gyro for example might output 2.5 volts when standing still and +4.5 volts when turned clockwise at a rate as fast as it was designed to detect. If you turned it counter-clockwise at that same rate, its output would be 0.5 volts. This gyro would be considered to have an output of 2.5 volts, +/- 2 volts full range. The voltage output from a gyro that is standing still will usually have a voltage greater than zero in order to keep the output voltage in both directions of rotation a positive voltage (note our example above). The value of the steady state output is called the bias voltage or the DC offset voltage.
Gyros are usually linear in nature, so if you rotated our example gyro clockwise at half its design rate, its would output +3.50 volts (4.5 volts max rate output, minus 2.5 volts offset, divided in half, equals 1 volt – adding the 2.5 volt offset back in gives you an output of 2.5 volts plus 1 volt, or 3.5 volts).
Saturation There are an infinite number of rates at which you could turn the gyro within its design parameter and a corresponding infinite number of output voltages that would be output – hence it is considered an analog device. If you exceed the rate at which the gyro was designed to operate, it will “saturate” and the output would indicate incorrectly. For example, if you had a gyro rated at 100 degrees per second, and you rotated it at 125 degrees per second, it would saturate.
Resolution Connecting the output of an analog gyro into the input of an analog-to-digital converter would give you a digital output that would correspond to the rate of output from the gyro, but it would come in discrete (digital) steps that the microcontroller could understand. ADC’s are defined by their “word” length, or the maximum number of bits they will output for each reading of the gyro – the bigger the word length, i.e., the more bits, the better the resolution of the information being converted from analog to digital.
Standard ADC resolutions are usually in a range of 8, 10, 12 or 16 bits. When the ADC chip samples an analog signal at its input, it divides the signal into a number corresponding to the chip’s word or bit structure design, then outputs that information digitally for reading by the microcontroller. An 8-bit ADC divides the input signal into 256 parts (low resolution), a 10-bit ADC is 1024 parts, 12-bit is 4096, and a 16-bit chip divides the signal into 16,384 parts (very high resolution). In other words, if you had a full range analog signal of 1 volt into an 8-bit ADC that was moving between 0 and 1 volt, the resolution would be changing in the range in steps of 0 to 256. For example, a reading of 0.5 volts would translate into a value of 128. However, that same voltage applied to a 12-bit ADC would be changing in steps of from 0 to 4096. That 0.5 volt analog signal would translate into a value of 2048 – much higher resolution, or accuracy of the data being read. The amount of resolution you need is a function of the application you are working on.
Sensitivity Gyros are also rated for their sensitivity, or the degrees per second that corresponds to a given output voltage. I was experimenting with an Invensense IDG1215 gyro. The IDG1215 is a dual axis (X and Y) gyro rated for a full-scale output of 67 degrees of rotation per second. Another version of the IDG gyro, the IDG500, is rated at 500 degrees per second. Since I do not need that amount of rotational sensing for my rocket, I used the lesser-rated sensor, which, for the same absolute value of voltage output will result in more sensitivity per volt output. That is, I would see a 1.0 volt swing for a rotation of 67 degrees, rather than a 1.0 volt swing for a 500 degree rotation. The IDG1251 would be considered more sensitive than the IDG500. This greater sensitivity would result in greater precision when used in the calculations used later on to create actual angles from the rate-of-rotation.
Invensense IDG1215 2-axis MEMS Gyro SparkFun Breakout Board
So, armed with all of the device parameters and specifications, we can get back to the actual output of an analog sensor and its relationship to the ADC and the microcontroller. I will use the example that I was working with initially. My setup included the IDG1215 gyro, a 12-bit analog-to-digital converter and the BASIC Stamp 2pe (BS2pe) microcontroller, all mounted on a Parallax BASIC Stamp development board.



Gyro ADC Microcontroller
If the IDG1215 gyro were standing still, i.e., no rotation, its output would be +1.35 volts, since its bias or DC offset is just that. If though we constantly rotated the gyro clockwise at its maximum rate of 67 degrees per second, the output would be a constant +2.35 volts – the DC offset of +1.35 volts and +1.0 volts, which it adds when rotating at its maximum specified rate. At a constant rate clockwise of half that rate, i.e., 33.5 degrees per second, the output would be +1.85 volts (+1.35 V plus +0.5 V); at half that rate, the output would be +1.60 volts (+1.35 V plus 0.25 V), and so on. If we rotated the gyro counter-clockwise at a constant maximum specified rate of 67 degrees per second, the output would be 0.35 volts (+1.35 V plus -1.0 V), half that rate counter-clockwise would output +0.85 volts (+1.35 V plus -.0.5 V), and half that rate would produce an output of +1.10 volts (+1.35 V plus -.0.25 V). The output is said to be linear. So, the overall output range of our gyro would be a minimum of +.35 volts and a maximum of +2.350 volts (1.35 V DC offset, +/- 1.0 V full range rotation).
Considering that the incremental output of the gyro at its maximum rating of 67 degrees per second is 1.0 volts (2.35 V minus the DC offset of 1.35 V), the gyro is said to have a sensitivity of 15 mV/degree/sec or 15 mV/d/s (i.e., the 1 volt full-range output ÷ 67 degrees/second, or 1000 mV ÷ 67 degrees/sec = 15 mV/degree/second = 15 mV/d/s, or, 0.015 V/d/s).
Reference voltage. ADC’s have what is called a reference voltage. The reference voltage is the minimum and maximum voltage that will be presented at the input of the ADC. Typical reference voltages are 0-5 volts and 0 to 3.3 volts. In our example, we will assume the reference voltage for our 12-bit ADC is 0-5 volts. If you remember from the foregoing, a 12-bit ADC divides an input signal into 4096 parts, a 0 input signal would output 0, and 5 volts would output 4096 from the ADC. A 2.5 volt signal (half the reference voltage) would output 2056 (half the maximum output of 4096). As you can see, the ADC output is linear also in regards to the input. The microcontroller’s input therefore sees a linear output from the ADC that represents a range of 0 to 4096 as the input to the ADC ranges from 0 to 5.0 volts, or 0 to 5000 mV.
If you divide the 5000 mV by the 4096 ADU (analog-to-digital unit), you will see that each increment of the ADC output, or ADU, is equal to 1.22 mV, or, 0.00122 V – this is called the conversion factor.
In the case of the IDG gyro, whose range is 0.35 volts to 2.35 volts, the ADU output range of a 12-bit ADC will be approximately 287 to 1926 ADU (0.35 volts / 1.22 mV = 287 and 2.35 volts / 1.22 mV = 1926). We have converted the analog output of the gyro into a digital format that the microcontroller can handle. The microcontroller is able to accept these digital signals. Once read by the microcontroller, we can store the gyro sensor data and use it in the microcontroller’s programming.
Now that we can sense and store gyro output, we need the microcontroller to convert that rotational rate information into an angle. This is done by “integrating” the rotational rate information over time. To illustrate, let’s say that the gyro is in a body that is at rest (no rotation), then it instantly starts to rotate at a rate of 1 degree per second for 10 seconds and then instantly stops rotating. The body would have changed its orientation by 10 degrees. We determined this by measuring the rotation at a certain rate over periods of time – we took samples. We then integrated these samples into an angle by simply adding the samples together. The microcontroller is very capable of such repetitive measurements and calculations.
Sample rate. As stated above, the integration of an angular rate gyro is straightforward. We measure the output of the gyro at regular intervals, or sample periods. The samples have to be in a sufficient quantity, or at a rapid enough rate, to give you the resolution or accuracy you want. Typical rates are on the order of 20 to 200 samples per second, or 20 to 200 “Hertz” (Hz), again, dependent upon how precise you need to be relative to the sensitivity of the gyro.
Rate integration. So, armed with all of the above, I was able to determine the formula I needed to use in order to convert angular rate into angles. The derived angle is simply the aggregation of the samples:
Angle_new = Angle_existing +
Angle_incremental
[simply adding the amount of angle captured by the new sample onto the existing angle]
Or, using our specific setup of the IDG1215 gyro and the 12-bit ADC:
Angle_new = Angle_old +
((IDG_gyro_reading_in_ADU – gyro_DC_offset_in_ADU) * ADU_to_mV conversion ÷ gyro_sensitivity_in_mV/d/s * sample_rate_in_Hz)
So, for my example let’s say that we are integrating the Invensense IDG-1215 gyro at a sample rate of 100 Hz, that the existing integrated angle is currently at 10 degrees, and we take a gyro sample that reads 1230 ADU (which is equal to a rotation rate of +33.5 degrees per second). The formula would be:
Angle_new = Angle_existing + Angle_incremental
Angle_new = 10 degrees + ((1230 ADU – 820 ADU) * 0.00122 V/ADU ÷ 0.015 V/d/s * 100 Hz)
= 10 degrees + (410 ADU * 0.00122 V/ADU ÷ 0.015 V/d/s * 0.01 seconds)
= 10 degrees + 0.333 degrees
Angle_new = 10.333 degrees
So, after much time and study, I had finally determined what I needed to do to build a tilt meter. I had my gyros, I had a microcontroller, I had a way to input the gyro data into the microcontroller, and I had learned enough programming along the way in Basic that I figured I could actually do this! I figured I could develop a gyro-based tilt meter similar to the accelerometer-based one I had first assembled months ago.
To be continued in Part 4...