Pages: [1]   Go Down
Author Topic: ITG3205 Gyroscope values extremely far off  (Read 104 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have finally been able to get the readings from my ITG3205 gyroscope, have the two read bytes concatenated into a single value, and am trying to convert the readings into an angle. My problem is that, even when I ignore the calculation that finds the angle, my readings seem to be off by an order of magnitude. I used the offset given in the datasheet, specifically 14.375 LSB/deg/sec. I have randomly thrown in a couple of extra 0's to the value I'm dividing by, and that gets me closer, but.... obviously doing that won't fix my issue. I have posted the suspect function that does all of this for me, and have also attached the code.

Any input on what I might possibly be doing wrong would be greatly appreciated!
P.S. I did read some similar earlier posts, and ensured that the proper values are declared as a float.

void getGyro(){
if ((micros() - ntg) > 8000){                          //Only update every 8000 microseconds, ~125 Hz rate
  int regAddress = 0x1B;
  readFrom(gyroDev, regAddress, 8, buffGyro);
  gyroX = ((((int)buffGyro[2]) << 8) | buffGyro[3]) + g_offx;
  gyroY = ((((int)buffGyro[4]) << 8) | buffGyro[5]) + g_offy;
  gyroZ = ((((int)buffGyro[6]) << 8) | buffGyro[7]) + g_offz;
  //temp = (((int)buffGyro[0]) << 8) | buffGyro[1];
  float dt = micros() - ntg;                                              //To calculate the time since the last measurement
  gyroX = (double)(gyroX*dt)/14375000.0;                                      //Per the data sheet, sensitivity scale factor per LSB/(deg/sec)
  gyroY = (double)(gyroY*dt)/14375000.0;
  gyroZ = (double)(gyroZ*dt)/14375000.0;
  gyroAngle[0] += gyroX;
  gyroAngle[1] += gyroY;
  gyroAngle[2] += gyroZ;
  ntg = micros();
}
}

The values that go crazy when I move the sensor are gyroX/Y/Z... Thanks!

* SensorVals.ino (5.29 KB - downloaded 3 times.)
Logged

Pages: [1]   Go Up
Jump to: