using 9 Degrees of Freedom - Razor IMU - AHRS

What video?

I have used the 9DOF IMU connected to an arduino. First I flashed the IMU with the AHRS code from Google Code Archive - Long-term storage for Google Code Project Hosting. Then I just connected the tx and rx of the imu to the rx and tx pins of the arduino. Also connect the grounds together. I powered the imu on my breadboard with a separate regulated 3.3V supply. Then you can just read the imu serial data using the following code:

void setup()
char thisChar;
{ 
  Serial.begin(57600);
}

void loop()
{
  while (Serial.available() > 0) {
   
    thisChar=Serial.read(); 
   
  //do something with this value from the 9DOF imu
   
  }
}

Hope this helps.

@pashford...

I tried to do the same thing as you suggested...but no result.
Here is what i did, Please correct me if i am wrong:

1). I have 9DOF Razor IMU with ATMega168 on it...something similar to 9 Degrees of Freedom - Razor IMU - 16MHz (Sale) - SEN-09510 - SparkFun Electronics

2). First of all i connected it with PC using FTDI breakout board (i.e. FTDI Basic Breakout - 3.3V - DEV-08772 - SparkFun Electronics) through USB miniCable. then i programmed on it DCM_AHRS code as given on the link provided by you or more specifically:

http://code.google.com/p/sf9domahrs/downloads/detail?name=SF9DOF_AHRS_1_1.zip&can=2&q=

3). Then i connected the Rx and Tx of IMU with Tx and Rx of Arduino Duemilanove (ATMEGA168) and power (3.3v) and ground from arduino.

4). Finally i burned the small code posted by you on arduino to read serial data and print it in arduino Serial Monitor but i didn't get anything.

I have already tested the IMU by connecting it to PC through FTDI_USB breakout board and watching its output in X-CTU. It is working perfectly well as seen in X-CTU. There is one difference that its baud rate is 38400. I tried to change the baud rate in your code snippet but it didn't work either.

If you have any idea why its not working, please let me know.

Thanks a lot!

Mo,

I have recently acquired the same board. You won't see any output with the suggested code.

The first problem is that the code doesn't print() any information. I'm sure it's working fine but you, like I, want to see the numbers and know everything is working right.

Unfortunately Serial can only be used on a single serial connection at a time. The IMU - Arduino connection is one, but the PC - Arduino connection takes precendent. (citation needed)

I'm trying NewSoftSerial but so far no luck. I have not tried connecting directly to the IMU to see what data I get. I need to get an USB-FTDI plug so I can try it.

If you have solved this challenge, please update!

Thanks,
Dan

@pashford,

Can yo please guide me on how you interfaced the IMU to Arduino....i tried your code to read data but i got nothing.....thought the IMU is working with the arduino?

Thanks!

I have the razor with the 328 chip and an arduino with a similar 328.

  • I connect the PC to the arduino with the USB.
  • I connect arduino RESET to arduino GND.
  • I connect arduino 3.3V to razor 3.3V
  • I connect arduino GND to razor GND
  • I connect arduino TX1 to razor TX0
  • I connect arduino RX0 to razor RX1
  • I open the serial window in arduino at 38400 baud.
  • I reset the razor.
  • Text appears, and I follow the on-screen instructions.

Notes:

  • I should have a diode/resistor combo between the 5V arduino TX0 and the 3.3V razor RX1 (don't want to fry the razor)
  • I do not yet understand the RAW output.
  • I don't know where to get the test firmware. (sparkfun product page?)
  • I'm thinking about trying the http://code.google.com/p/sf9domahrs/ code. Anyone know if it's any good?

Unfortunately Serial can only be used on a single serial connection at a time. The IMU - Arduino connection is one, but the PC - Arduino connection takes precendent. (citation needed)

Have you tried connecting your gizmo to the standard tx/rx pins on the arduino, then monitoring the arduino/gizmo traffic using the arduino IDE serial monitor?

@aggrav8d...

cool...you solved my big problem....thanks.

Regarding your raw output question...as far as i can understand it the first three values correspond to the accelerometer readings X, Y, Z and the other 3 correpond to gyro readings X, Y, Z...the last ones are for magnetometer...

I think we can use these values directly for stabilization purposes...i dont understand why you need the firmware from google?

When you say readings, what do they mean, exactly? I don't know what the values represent.

I mean if you choose one of the 4 options by selecting 1or 2 or 3 or 4 by printing it on serial port then 1 corresponds to accelerometer readings i.e. what is the value of x-axis acceleration of board, y -axis acceleration of board and its z axis acceleration...in rest the z axis is either -260 or 260 depending on whether its face up or down....it correspond to acceleration due to gravity "g = 9.8m/sec" actually....

similarly if you print 2 then the IMU will give you Magnetometer data....if 3 it will give gyro i.e. gyro average position (i am not sure about it but its something like this)...if you tilt board in one direction its value increases in other direction its value decreases...its true for all 3 axis..

printing 4 will give you all this data together...so that you can code it easily getting all data you need at one place...its first three readings corresponds to x,y,x axis acceleration. next 3 readins corresponds to gyro and last three to the magnetomer....

let me know if you got it or not?

I got it. I just wanted to confirm that the magnetometer and gyro data were yaw/pitch/roll. I didn't know that gravity was affecting the accelerometers. Interesting.

i can say that for gyro but in fact i don't know how magnetometer is helpful in determining yaw/pitch/roll...if you figure out or get some useful link do let me know...

i will keep you posted....rather let me know your email ID as well so that we can communicate otherwise...

good luck

post it here for the other 9DOF users who are frustrated with the documentation.

Something is weird here...actually the data is not read by the arduino.....rather arduino is only used as a bridge here.....write no code in Arduino....even then the data is received.....

I read on Arduino that grounding the reset, reset micro-controller..

and we are here keeping it Gnd that is we are just bypassing micro-controller that is not desired.

That's not wierd at all. My goal is to get to the sensor, learn what it is doing, then write code to talk to it. When I have it working I can use Serial to talk to it while the PC is disconnected.

Your goals may not be the same as mine :slight_smile:

No....actually thats exactly what i want...but if you remove the reset to gnd connection then you didn't receive anything....i am trying too..let me know if you are able to analyze raw data from micro-controller....

What I understand is that if you don't have the PC connection you still get the data. However, the RX/TX pins have to be swapped. I try to remember that they have to be backwards when using the arduino as poor man's FTDI.

I also got it but if i write 4 on the IMU the data is received but it stops after a minute or two....after that i have to reset Arduino and IMU to get new data....

I can't understand why is that happening...try to see and confirm by toggling an led that are you receiving data continuously?

Can I interpret raw data in anyway to control my Helicopter? I started with yaw control, First i detect the change in Gyro reading about Z-axis (Vertical axis), then i see that the magnetometer readings increase or decrease from what those were initially. So that i can turn the helicopter in the other direction to maintain its position. But the problem is that sometimes the magnetometer increases when heli turns right and some time when it turns left!

So i can't find out whether to turn left or right to reach the initial state.

I dont think that we can use accelerometer for yaw control as it immediately returns to its original position after increasing or decreasing.

Any insight on how these three devices (Gyro, Accelerometer and magnetometer) work side by side.

thanks!

Please help!

Accelerometer will always try to return to 0 when there is no movement. Remember it is reporting acceleration, not velocity or position. that's why if you leave it flat on a table the AZ is a big number - it is accelerating downward because of gravity.

I don't have any insights on the gyro and magno other than I was told they give yaw, pitch, and roll. turning those three numbers into a vector should be fuuuuun.