ArduinoGeneral

NEED HELP FOR 10 DOF Mems IMU can't initialize

userHead detama 2014-06-15 23:49:37 5895 Views9 Replies
Hello there, I need some help on the newly brought 10 DOF Mems IMU Sensor. When I was trying to run the sample code in arduino (Sample.ino), I can upload the program with no problem, but serial monitor shows arduino freeze at the line "  sixDOF.init(); //init the dfrobot and Gyro ", if I delete this line, the code runs fine and constantly display changing values with or without the sensor attached, which makes me think those values didn't come from the sensor itself. Is my sensor broken? Or is it coding problem?

on the sensor board, a red light LED is on when I connected to arduino
my arduino type is leonardo
OS: win7

here is the samlpe code I used:

//The 10 Dof sample sketch for reading the BMP085 and IMUs raw data

#include <Wire.h>
#include <FreeSixIMU.h>
#include <FIMU_ADXL345.h>
#include <FIMU_ITG3200.h>
#include <HMC5883L.h>
#include <BMP085.h>

float angles[3]; // yaw pitch roll
float heading;
BMP085 dps = BMP085();
long Temperature = 0, Pressure = 0, Altitude = 0;

// Set the FreeSixIMU object
FreeSixIMU sixDOF = FreeSixIMU();

HMC5883L compass;
// Record any errors that may occur in the compass.
int error = 0;

void setup(){

  Serial.begin(9600);
  Wire.begin();
  delay(1000);
  dps.init();
  dps.dumpCalData();
  delay(5000);
 
  delay(5);

[color=red]  Serial.print(" before sixDOF "); // I added this line myself[/color]

  sixDOF.init(); //init the dfrobot and Gyro

[color=red]  Serial.print(" after sixDOF "); // I added this line myself, program never goes here[/color]

  delay(5);
  compass = HMC5883L(); // init HMC5883
 
  error = compass.SetScale(1.3); // Set the scale of the compass.
  error = compass.SetMeasurementMode(Measurement_Continuous); // Set the measurement mode to Continuous 
  if(error != 0) // If there is an error, print it out.
    Serial.println(compass.GetErrorText(error));

}

void loop(){
  dps.getTemperature(&Temperature);
  dps.getPressure(&Pressure);
  dps.getAltitude(&Altitude);
 
  sixDOF.getEuler(angles);

  getHeading();
  PrintData();
 
  delay(300);
}

void getHeading(){
  // Retrive the raw values from the compass (not scaled).
  MagnetometerRaw raw = compass.ReadRawAxis();
  // Retrived the scaled values from the compass (scaled to the configured scale).
  MagnetometerScaled scaled = compass.ReadScaledAxis();
 
  // Values are accessed like so:
  int MilliGauss_OnThe_XAxis = scaled.XAxis;// (or YAxis, or ZAxis)

  // Calculate heading when the magnetometer is level, then correct for signs of axis.
  heading = atan2(scaled.YAxis, scaled.XAxis); 
 
  float declinationAngle = 0.0457;
  heading += declinationAngle;
 
  // Correct for when signs are reversed.
  if(heading < 0)
    heading += 2*PI;
   
  // Check for wrap due to addition of declination.
  if(heading > 2*PI)
    heading -= 2*PI;
 
  // Convert radians to degrees for readability.
  heading = heading * 180/M_PI;
}

void PrintData(){
 
  Serial.print("Eular Angle: ");
  Serial.print(angles[0]);
  Serial.print("  "); 
  Serial.print(angles[1]);
  Serial.print("  ");
  Serial.print(angles[2]);
  Serial.print("  ");
  Serial.print("Heading: ");
  Serial.print(heading);
  Serial.print("  ");
  Serial.print("Temperature: ");
  Serial.print(Temperature);
  Serial.print("C");
  Serial.print("  ");
  Serial.print("Altitude: ");
  Serial.print(Altitude);
  Serial.print("cm");
  Serial.print("  ");
  Serial.print("Pressure: ");
  Serial.print(Pressure);
  Serial.println(" Pa");
}
2014-06-23 13:53:03 detama, no problem.

Post any updates, i'd like to follow up on your project.
I'm trying this with flymaple, but doing slowly..  :P
userHeadPic Jose
2014-06-20 08:42:43 Thank you so much Jose, those informations are definitely going to help me with a big deal. I'm going to start studying them. Just like old high school again LoL.

I'm planning to build a V22 like copter/plane, with high velocity and vertical takeoff, I need those raw data in order to program an auto flight system, any suggestions ;D
userHeadPic detama
2014-06-19 14:10:21 this library is using quaternion, so the posted links are just a reference.
[url=http://www.x-io.dfrobot.uk/res/doc/quaternions.pdf]http://www.x-io.dfrobot.uk/res/doc/quaternions.pdf[/url]

maybe this one help, but I haven't try ( looks good )
[url=http://www.camelsoftware.com/firetail/uploads/ce10dofahrs.zip]http://www.camelsoftware.com/firetail/uploads/ce10dofahrs.zip[/url]
userHeadPic Jose
2014-06-19 13:54:11 getRawValues() gets the raw values.
This function is in FreeSixIMU.cpp in folder libraries > FreeSixIMU

Instead of calling the euler function you can call that one. Or just call the euler function and instead print the raw values. The sample code prints the euler values.

Starlino made a a great guide, there are many more. This is a very nice starting point:
[url=http://www.starlino.com/imu_guide.html]http://www.starlino.com/imu_guide.html[/url]
[url=http://www.starlino.com/dcm_tutorial.html]http://www.starlino.com/dcm_tutorial.html[/url]

Detama, are you using Arduino for a plane or copter?
userHeadPic Jose
2014-06-19 07:31:45 Thanks Grey, I will try to study that for sure. Could you help me with one more thing? I'd like to print all the raw data from sensors directly, but I'm new to this and there's so many libraries from the sensor, could you please show me a few line of sample code to print all the raw data from sensor? Any help is deeply appreciated! userHeadPic detama
2014-06-18 15:20:53 Aha, Jose,
A simple  physics book is not enough! ;)

For the velocity, I am sorry, it can't measure the speed directly. It only could measure the acceleration.
So if you want to get the velocity value, you have to use Calculus to calculate the speed
That will be a little complex. But you could have a try.

My suggestion? An advanced mathematics book is very necessary.
The wiki page of Euler_angles is very nice.
userHeadPic Grey.CC
2014-06-18 13:20:02 [quote="detama"]
1: the introduction of this sensor said it can measure the velocity of the aircraft, but i can't find how to calculate the the velocity just based on these values, I need it because velocity is very important for auto control, without it, the air plane is just like a blind fly...
[/quote]
store a range of values and compare with old ones. if the change is bigger, the speed is bigger. that could be in simple terms a way to try.

[quote="detama"]
2: how to find the 3 axis accelerations, it is part of the 10 dimension sensor, but not in the sample code
[/quote]
The code is calculating positioning on the example. To get the raw values of the accelerometer you will need to print data from sensors directly instead of using the euler function.

[quote="detama"]
3: based on raw data from this program, what other parameters can I find out through calculations, I hope you could share it if you have them somewhere, so I don't have to study Physics again LoL
[/quote]

My suggestion? find a physics book and take it easy :P
[url=http://en.wikipedia.org/wiki/Euler_angles]http://en.wikipedia.org/wiki/Euler_angles[/url]
userHeadPic Jose
2014-06-18 08:37:35 Hello Grey, thanks for the reply

Sorry for the confusion, I'm new to this and I used A4 A5 instead of D2 D3, my bad, now I connected the sensor properly and the program is working

thank you so much

Just have a few more basic questions

1: the introduction of this sensor said it can measure the velocity of the aircraft, but i can't find how to calculate the the velocity just based on these values, I need it because velocity is very important for auto control, without it, the air plane is just like a blind fly...

2: how to find the 3 axis accelerations, it is part of the 10 dimension sensor, but not in the sample code

3: based on raw data from this program, what other parameters can I find out through calculations, I hope you could share it if you have them somewhere, so I don't have to study Physics again LoL

Once again, thanks for the help

userHeadPic detama
2014-06-17 14:13:09 Welcome detama,

This line "sixDOF.init();" will initialize the data of the sensor. if you don't add this line in the sketch, you will find the data will be changing all the time. And it is not reliably.

Hey, what is your mean of freeze at this line? Is there anything else in the Serial port?
Leonardo IIC interfaces are D2 & D3, I have tried add your red line in the code . with a long delay time (I add the delay to 5000ms), I saw these line appear in the Serial monitor prefect.
userHeadPic Grey.CC