Sparkfun's 9 Degrees of Freedom - Razor IMU

SKU: SEN-10736

Initial report by Jen Shannon, 10, April, 2012

Introduction

Sparkfun's 9 Degrees of Freedom (Razor IMU) is essentially a breakout board for a small microcontroller and three separate MEMS sensors: a 3-axis accelerometer, a 3-axis gyroscope, and a 3-axis magnetic sensor. While the Razor's microcontroller ships with sample firmware that demos the output of the three sensors, the full power of the Razor is realized by uploading firmware that utilize the device as a realtime 3D orientation sensor. The Razor's onboard microcontroller can be programmed directly by an AVR programmer or by a computer-serial connection via a pre-programmed Arduino bootloader.

Orientation

The center of the airplane in the graphic below is aligned with three perpendicular axes: X,Y,Z. It is important to note that the labeling of these axes can vary, depending on whether a right-handed or left-handed orientation is used. The image below uses a right-handed orientation, which corresponds with the coordinate system used in the sample firmware listed in the code section below. (In a left-handed system, the X and the Z axes are swapped. While the Sparkfun Razor is labeled with a left-handed system, it is the software that is loaded on the microcontroller that determines the handedness of the Razor.)

The three axes in the graphic above are attached to the plane and are helpful when describing its orientation.

  • The X-axis, or roll-axis, is parallel to the plane's body and extends, in the positive direction, from the center of the plane out through its nose. Roll is a conventional name used for a rotation around this axis.
  • The Y-axis, or pitch-axis, is parallel to the plane's wings and extends, in the positive direction, from the center of the plane out through what would be the right side to a passenger facing forward on the plane, perpendicular to the X-axis. A rotation around this axis is often called pitch.
  • The Z-axis, or yaw-axis, is perpendicular to both the wings and the body of the plane and extends in the positive direction, from the center of the plane out through the bottom of the plane perpendicular to the X and Y axes.

Individually, the three different sensors on the Sparkfun board have limitations that prevent accurate orientation sensing. Collectively, these limitations are transcended. It is the computational algorithm (code) loaded on the Sparkfun's microcontroller that enables the Razor to "fuse" the output of the three sensors onboard. In general, the accuracy of an IMU is determined by both the robustness of the hardware and the strength of the computational algorithm used to convert the raw output of the sensors into these orientation angles.

Sensor Fusion: 3 Sensors and a brain

3-axis Accelerometer: Analog Devices' ADXL345

The ADXL345 measures acceleration due to gravity and linear motion along 3-axes. The diagram below roughly depicts the inner workings of the device.

The mass, labeled m, is attached to a spring (the label k is a constant that is associated with the "springiness" of the spring) which is fixed to the accelerometer (which can be thought of as a closed box). The circuitry in the lower right corner is also fixed to the accelerometer. If the accelerometer was shaken from left to right, the springiness of the spring would allow the mass to move separately from the fixed parts of the accelerometer, leading to a change in the width of the gap between the mass and the circuitry, labeled c (for capacitance). This is similar to the change in width between a dashboard and a passenger when a car travelling at constant velocity undergoes a change in velocity caused by a slam on the breaks. The variation of this width is caused by the change in velocity (acceleration) of the system and, in the case of the accelerometer, leads to a change in the capacitance of the circuit.

If the image above were flipped 90 degrees clockwise so that the acceleration arrow coincided with gravity, the mass m can be thought of as an object dangling on a spring. Even though the mass appears at rest, there exists a constant downward acceleration associated with gravity that pulls on the spring and leads to a decrease in width of the capacitance gap. This is why an accelerometer at rest reads a constant non-zero value (due to gravity) and an accelerometer in freefall reads zero. This makes accelerometers useful for measuring tilt, as gravity is constantly accelerating downward. However, because an accelerometer is unable to differentiate between acceleration due to gravity and the acceleration caused by other motion, the usefulness of this measurement is limited. This is where a gyroscope, which is able to measure the angular rate of velocity, comes in handy.

3-axis Gyroscope: Invensense's ITG-3200

Measures angular rate of velocity around 3-axes. The image below depicts how a gyroscope is able to measure rotational rate.

A gyroscope measures coriolis acceleration, which is the result of a psuedo-force that is both perpendicular to the axis of rotation and the centrifugal force (another psuedo force) that pushes radially outward from a rotating body. (These forces are often referred to as fictitious or psuedo, because they're technically not forces.) However fictitious these forces might be, they seem quite real when "felt" as a passenger on a rotating a carousel. As a carousel spins with increasing angular velocity, there is a noticeable outward push, the centrifugal force. Similarly, if you were to throw a ball from a rotating carousel to someone rotating with you on the opposite side of the carousel, you would need to take the rotation of the carousel into account. Otherwise, the ball will follow the trajectory path dictated by the laws of physics as viewed by a stationary viewer on the ground. In your reference frame, the rotating carousel, the tendency of the ball to violate your rotating world would appear to be the result of a force, the coriolis force, which is proportional to the rate of rotation of the carousel. The gyroscope essentially measures this acceleration and outputs the rate of rotation.

Gyroscopes are unaffected by gravity and complement an accelerometer well for use in calculating orientation. However, like an accelerometer, they measure the rate of change of velocity, which is the change of position with respect to time. As such, calculations are prone to bias error and drift that propagate through successive iterations.

3-axis Magnetometer: Honeywell's HMC5883L

Measures magnetic field strength along 3-axes. Unlike an accelerometer and a gyroscope, which measure rates of change, a magnetic sensor can give an instantaneous direct measure of orientation in reference to magnetic north (absolute yaw). However, the sensor is vulnerable to other magnetic interference. Any electronic device or ferrous material can throw off the compasses' orientation. As such, filtering algorithms are often used to cypher out disturbances and fluctuations.

Onboard Microcontroller

Atmel's ATmega328

This is the brain of the sensor board. It can be programmed via the Arduino IDE, through a serial interface, or directly through and ARM controller. The Arduino interface makes uploading code quite simple.

Sources

Sparkfun sells all of the necessary parts to power, program, and transmit data wirelessly from the Razor. However, the FTDI friend from Adafruit, an FTDI cable (make sure that it transmits data at 3.3V, not 5V), the USB Bub II (as long as you modify it for 3.3V data i/o with the included shunt), and other options will work, too. The prices below are from Sparkfun as of 4/10/2012:

For the most simple, bare bones, wired Razor, you will need at least an FTDI to usb connection to power the board and receive data (this setup allows for changing the code via the Arduino interface).

Razor for $124.95 http://www.sparkfun.com/products/10736

FTDI Basic Breakout - 3.3 V (sku: DEV-09873) $14.95 http://www.sparkfun.com/products/9873,

6-Foot mini-B cable http://www.sparkfun.com/products/598 $3.95.

For wireless transmission, there are a variety of options. I experienced less latency with the XBee Series 1 than with the Bluetooth Mate Gold. Make sure that you remove the battery before plugging the FTDI connection to your computer (and the other way around). Adafruit also sells an X-Bee adaptor.

Polymer Lithium Ion Battery -400mAh $7.95 (pick a battery based on your needs) http://www.sparkfun.com/products/10718

USB LiPoly Charger-Single Cell (USB mini) $14.95 http://www.sparkfun.com/products/10161

Bluetooth Mate Gold $64.95 http://www.sparkfun.com/products/9358

2*XBee Explorer Regulated $9.95 http://www.sparkfun.com/products/9132

2*XBee Series 1 $22.95 http://www.sparkfun.com/products/8665

Applications

  • Space shuttles
  • satellites
  • GPS devices
  • Guided missiles
  • Sports technology
  • AntiLock brakes
  • Animation applications
  • Segway
  • Dead Reckoning
  • Interface control
  • Tap gesture recognition
  • Gaming
  • Step recognition
  • Image Stabilization
  • Drop detection
  • Portable Medical Devices

Projects: Ball of Dub http://arduino.cc/blog/2011/11/01/ball-of-dub-keeps-audio-in-your-hands/

Quadcopter http://code.google.com/p/adelaide-quadcopter/

Autonomous "armed" robot using a paintball gun http://youtu.be/beC2H9nR1Ko

The SoundScape Renderer (Spatial Audio Reprodution) http://www.tu-berlin.de/?id=ssr

measure earth's rotation http://iopscience.iop.org/0957-0233/23/2/025005;jsessionid=0788141D7EF9DFB093982B523F3848C9.c3

Electrical Characteristics

Razor Datasheet (model #10736

As the microcontroller processes the output of the three onboard sensors, the output of the board is dependent upon the firmware loaded onto the microcontroller.

3.5-16 VDC input

Board Layout & Pin Descriptions

  • FTDI - Standard 6-pin FTDI interface used for serial connection to a computer.
  • AVR - AVR programmer interface used to directly program the ATmega328 microcontroller.
  • ACC - 3-axis accelerometer
  • JST Connector - Battery connection, regulated down to 3.3V.
  • Power - Alternate power connection, regulated down to 3.3V (useful when using a battery without a JST connector or for connecting to a charger/battery breakout board).
  • GYRO - 3-axis gyroscope
  • ATMEL - ATmega328 microcontroller
  • MAG - 3-axis magnetic sensor

Microcontroller Connections

The Razor's ATmega328 microcontroller can be programmed by the Arduino IDE. To program the Razor via the Arduino IDE, connect the FTDI interface to the serial port of your computer (see the sources section for connectivity options). In the Arduino IDE under the "Tools" drop down menu, select "Arduino Pro or Pro Mini (3.3V, 8mhz) w/ATmega328".

Additional parts needed to use it

At the very minimum, the Razor needs power and a way to transmit data. A serial to USB connection will provide both and add the ability to upload different firmware to the board. Sparkfun does not ship the razor with pin heads.

Code Sample

Code sample coming soon.

The Quality and Usability Lab of Technische Universitšt Berlin offers very robust and open source AHRS tracking firmware for the Razor along with a fantastic tutorial. Through the firmware, you can calibrate all three sensors and chose from multiple data options to be sent through the serial interface. The code is clean, well organized, and easy to follow (and hence, augment to your own use). The authors also keep the firmware updated to the latest Razor release, while offering options within the code for previous models. They also created a pretty cool 3D sound renderer (Soundscape) that can be used with the Razor.

https://dev.qu.tu-berlin.de/projects/sf-razor-9dof-ahrs

Typical Behavior

Application Notes

Wireless connectivity info coming soon.