The Razor IMU incorporates three-axis Gyros, Acceleros and Magnetometers. It has an on-board Atmega328 microcontroller (Arduino compatible). Programmes have been developped so that it can be used has an AHRS (Attitude and Heading Reference System).
It is a low-cost solution (95 euros on Sparkfun) and with small dimensions. And it is open-source.
Here is a step-by-step tutorial on how to use it under Linux (ubuntu). The steps under Windows are essentially the same.
STEP 1 : Try the default programme of the IMU.
Connect the USB-UART module to the IMU (Rx1 to Tx2, Tx1 to Rx2, 3.3V and GND). Put the switch of the converter on the 3.3V position and plug it in a USB port.
Then open a terminal and type the following commands:
sudo apt-get install ckermit (Install the ckermit software)
kermit -l /dev/ttyUSB0 (run it on the /dev/ttyUSB0 serial port)
set flow-control none (setup the serial communication)
set carrier-watch off
set speed 38400 (Baudrate)
connect (Connection to the serial port)
Push the Reset button on the IMU board, and, magically, a menu should appear on your terminal.
STEP 2 : Programming the board with Arduino
Now that our board is working correctly, we want to change the default programme. The first step is to download and install the Arduino software.
I noticed that the bootloader required to use the board with Arduino is not programmed when you buy the board. So that is the first thing to do.
For that, we need some tools for the AVR programmation:
sudo apt-get install gcc-avr avr-libc avrdude
Then we need an AVR programmer. I used a “Bus Pirate”, but any other should work.
Connect the programmer on the ICSP header (the 6 pins on the side of the board). Here is a schematics of the connections.
Go to the folder “arduino/hardware/arduino/bootloaders/atmega”, open a terminal at this place and type the following line to program the bootloader:
avrdude -c buspirate -P /dev/ttyUSB0 -p ATMEGA328P -U flash:w:ATmegaBOOT_168_atmega328_pro_8MHz.hex
You are now able to use Arduino with the board.
STEP 3 : Try the AHRS code
Download the sources on the SVN by typing this line:
svn checkout http://sf9domahrs.googlecode.com/svn/trunk/ sf9domahrs-read-only
Copy the sources into the Arduino “Sketch folder”, open the project and program the board.
Install Python to be able to run the demo script:
sudo apt-get install python python-visual
Download the “.py” script here, edit it and change the serial port (/dev/ttyUSB0 for example) and the baudrate (38400).
Connect the IMU to the computer with the USB-UART converter, and type python IMU_Razor9DOF.py in a terminal to run the script.