Go Down

### Topic: Problem with IDG500 (Read 1 time)previous topic - next topic

#### wolkanb

##### May 17, 2012, 09:11 pmLast Edit: May 17, 2012, 09:17 pm by wolkanb Reason: 1
Hello;

I am using Sparkfun 5 DOF IMU (http://www.sparkfun.com/products/9268) to sense orientation of a body.

I am having some problems with reading the rotation through IDG500. I have calculated the angular velocity through the following formula:

Here gyroADC is the value I read from the analog pin, gyroOffset is the value I measure when there is no rotation. I calculated the Sensitivity as (3.3)/(1023*0.002). Here the value 0.002 taken from the datasheet, since it says the sensitivity of the gyro is equal to 2 mV/deg/sec.

Afterwards I multiplied the loop time with angular velocity to find the angle of the rotation. However when I rotate the device for 90 degrees insted of 80-90 degrees I only calculate a rotation around 20-30 degrees according to the output. So can you tell me what am I doing wrong?

Here is my code:

Quote

#include <math.h>
#define senAcc 0.33
#define Vref 3.3
#define senGyr 0.002
//#define accZ 2
//#define accY 1
//#define accX 0
//#define gyroX 3
//#define gyroY 4
int sensorval[5];
float accelZ,accelX,accelY,gyrX,gyrY;
float sum=0;
float gyroXangle=0;
float gyroXrate;
float SensitivityAcc= Vref/(senAcc*1023.0f);
float SensitivityGyro= Vref/(senGyr*1023.0f);
unsigned long timer=0;
unsigned long dtime=0;
int ZeroX=503;
int ZeroY=502;
int ZeroZ=619;
int ZeroXX=420;
int ZeroYY=424;

void setup(){
Serial.begin(115200);
analogReference(EXTERNAL);
timer=millis();
}

void loop(){
for(int i=0;i<5;i++){
for(int k=0;k<100;k++){
sum += sensorval;
}
sensorval = sum/100;
sum=0;
}
accelX=(sensorval[0]-ZeroX)*SensitivityAcc;
accelY=(sensorval[1]-ZeroY)*SensitivityAcc;
accelZ=((sensorval[2]-ZeroZ)*SensitivityAcc)+1;

gyrX=(sensorval[3]-ZeroXX)*SensitivityGyro;
gyrY=(sensorval[4]-ZeroYY)*SensitivityGyro;

gyroXrate = gyrX*dtime/1000.0f;

gyroXangle +=gyroXrate;

Serial.print(gyroXangle);
Serial.print(",");
Serial.print(gyroXrate);

Serial.print(",");
Serial.print(dtime);
Serial.println();

dtime = millis()-timer;
timer = millis();
}

"

Additionally I plugged 3.3 V output to Aref pin to make the analog Input pins work under 3.3 V.

Here is the output I get for a rotation of 90 degrees on X axis:

0.00,0.00,0
0.00,0.00,64
0.00,0.00,66
0.00,0.00,65
0.00,0.00,66
0.10,0.10,65
0.21,0.10,65
0.31,0.10,65
0.31,0.00,66
0.31,0.00,65
0.42,0.11,66
0.53,0.10,65
0.63,0.11,66
0.84,0.21,65
1.26,0.42,65
1.79,0.52,65
3.70,1.92,66
4.55,0.85,66
5.50,0.94,65
6.99,1.49,66
9.67,2.68,64
11.69,2.02,66
13.79,2.10,65
15.28,1.49,66
17.38,2.10,65
19.61,2.24,66
21.68,2.06,64
23.81,2.13,66
25.06,1.26,65
26.24,1.17,66
27.70,1.47,65
30.15,2.45,66
32.71,2.55,66
33.75,1.05,65
34.59,0.84,65
34.91,0.31,65
34.91,0.00,66
35.01,0.10,65
35.01,0.00,66
35.12,0.10,65
35.22,0.11,66
35.33,0.10,64
35.54,0.21,66
35.65,0.10,65
35.75,0.11,66
36.07,0.31,65
36.28,0.21,66
36.38,0.10,65
36.28,-0.10,65
36.28,0.00,66
35.86,-0.42,65
36.82,0.96,66
37.13,0.31,64
36.70,-0.43,66
36.81,0.10,65
35.85,-0.96,66
34.59,-1.26,65
32.70,-1.89,65
32.70,0.00,65
32.81,0.11,66
32.81,0.00,65
33.45,0.64,66
34.29,0.84,65
33.33,-0.96,66
33.54,0.21,66
33.96,0.42,65
34.49,0.52,65
35.01,0.52,65
35.54,0.53,66
35.96,0.42,65
36.17,0.21,66
36.28,0.10,65
36.39,0.11,66
36.28,-0.10,64
36.28,0.00,66
36.28,0.00,65
36.28,0.00,66
36.18,-0.10,65
36.18,0.00,65
36.18,0.00,66
36.18,0.00,65
36.18,0.00,66
36.18,0.00,65
36.07,-0.11,66
36.07,0.00,64
36.07,0.00,66
36.07,0.00,65
36.07,0.00,66
36.07,0.00,65
36.07,0.00,66
36.07,0.00,65
36.07,0.00,65
36.07,0.00,65
36.07,0.00,66
36.07,0.00,66

#### wolkanb

#1
##### May 18, 2012, 02:22 pm
I guess I found the solution the ADC can't measure all signals coming out from the gyro. The gyro has 2 mV/deg/sec sensitivity but the lowest signal Arduino can measure is 3.22 mV (3.3 V/1024). I guess thats why it gives wrong output need to test on 4.5 output and see if it works.

#### MarkT

#2
##### May 21, 2012, 02:22 am
Quote

Here gyroADC is the value I read from the analog pin, gyroOffset is the value I measure when there is no rotation. I calculated the Sensitivity as (3.3)/(1023*0.002). Here the value 0.002 taken from the datasheet, since it says the sensitivity of the gyro is equal to 2 mV/deg/sec.

No, that's wrong - try

Sensitivity =  (1024.0 / 3.3) * 0.002

Personally I'd invert the sense of Sensitivity, use (3.3 / 1024)/0.002, and multiply by it in the loop.

If you want to be really clear, try

degs_per_sec_per_volt = 1.0 / 0.002
volts_per_ADC_step = 3.3 / 1024
AV = (gyroADC - gyroOffset) * volts_per_ADC_step * degs_per_sec_per_volt
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### davidvg

#3
##### Jun 11, 2012, 09:33 am
I´m having the same problem with IDG-500 (standalone, not IMU), using the 110º/s scale (9.1 mV/º/s), and getting about 35º when rotating 90º.
It happens with both low and hign angular speed, so I think it is not depending on the measure being under the minimum voltage value detected by the ADC. I mean, if you rotate 90º in 1s, the voltage is (using the 110º/s scale) about 820mV (180mV with the 500º/s scale).
Everything else works fine. I have measured angular speeds, and the calculations are right (expected values for angular speed are shown via serial monitor).
Time between measures (for integrating angular speed) are right too.
I will try to implement a level shifter to set the zero point somewhere in the middle of the ADC range, and work with differential voltages between gyro output and reference.

#### davidvg

#4
##### Jul 01, 2012, 04:03 pm
I finally found the solution: connecting AZ pin to ground makes everything work.

#### MarkT

#5
##### Jul 02, 2012, 12:22 am

I finally found the solution: connecting AZ pin to ground makes everything work.

Ah, nasty.  The AZ pin is supposed to be pulsed high for between 2us and 1500us after powering up (or when calibrating at any point the gyro is stationary) to tare the output.  If not used it should be kept low.  The Sparkfun breakout wiring diagram is plain wrong (they would have done much better to connect it to GND on the breakout, taring can be done digitally).

The IDG-500 chip has an internal pull-up on this pin rather than a more sensible pull-down.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### davidvg

#6
##### Jul 02, 2012, 08:13 am
I have found no information about how AZ pin works, so thank you.
I will modify my code as soon as I have a moment and include your suggestion in the calibration function.

#### MarkT

#7
##### Jul 02, 2012, 02:24 pm

I have found no information about how AZ pin works, so thank you.
I will modify my code as soon as I have a moment and include your suggestion in the calibration function.

google "IDG-500 datasheet pdf"
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### davidvg

#8
##### Jul 02, 2012, 02:41 pm

google "IDG-500 datasheet pdf"

I read the datasheet one month ago. I just didn't found that step necessary as it is explained as an improvement of the measure and not as a necessary step to make it work, that's what I mean when I say I found no info on how it works. I guess I misunderstood it.

Go Up

Please enter a valid email to subscribe