Greetings! I have a IDG-500 gyro breakout board and a 5dof IMU with another IDG-500. I’m not very knowledgable on the subject of MEMS gyroscopic sensors and I was wondering if anyone could help me with the strange behavior I’ve been noticing. First of all the “Zero rate output” specified in the datasheet is dubious, the “real” zero rate value is different every time I turn the thing on! :shock: I did write a bit of code to find the zero rate output for the current session, but occasionally the value will change AGAIN in the middle of things! Could you help a n00b?
Sooo…exactly what values ARE you getting?
Sounds about par for the course with these MEMs devices.
Ok, here’s the code I am using. (It’s for a Maple board so it’s just a little different than arduino)
float zeroX1;
float zeroY1;
float zeroX2;
float zeroY2;
int xout;
int yout;
float xaccout;
float yaccout;
float zaccout;
float trackX;
float trackY;
float trackaccXZ;
float trackaccYZ;
unsigned int time;
void setup()
{
pinMode(10, INPUT_ANALOG); //x
pinMode(11, INPUT_ANALOG); //y
pinMode(13, OUTPUT); //LED
pinMode(15, INPUT_ANALOG); //accx
pinMode(16, INPUT_ANALOG); //accy
pinMode(17, INPUT_ANALOG); //accz
pinMode(18, INPUT_ANALOG); //x
pinMode(19, INPUT_ANALOG); //y
calibrate();
}
void loop()
{
//I am using both the gyro on the IMU and the gyro breakout. (which are identical modules) This code calculates and averages the two values.
xout = ((analogRead(10) * 3.3 / 4095 - zeroX1) / 0.002 - (analogRead(18) * 3.3 / 4095 - zeroX2) / 0.002) / 2;
yout = ((analogRead(11) * 3.3 / 4095 - zeroY1) / 0.002 - (analogRead(19) * 3.3 / 4095 - zeroY2) / 0.002) / 2;
trackX += (xout * 0.01);
trackY += (yout * 0.01);
SerialUSB.println(trackX);
SerialUSB.println(trackY);
/*
xaccout = (analogRead(15) * 3.3 / 4095 - 1.635) * 3.01; //All this commented stuff is for the accelerometer only
yaccout = (analogRead(16) * 3.3 / 4095 - 1.615) * 3.01;
zaccout = (analogRead(17) * 3.3 / 4095 - 1.655) * 3.01;
trackaccYZ = atan(zaccout / yaccout) * (180 / PI);
trackaccXZ = atan(zaccout / xaccout) * (180 / PI);
SerialUSB.println(trackaccXZ);
SerialUSB.println(trackaccYZ);
*/
delay(10);
}
void calibrate()
{
zeroX1 = (analogRead(10) * 3.3 / 4095); //This is to find the zero value for the moment
zeroY1 = (analogRead(11) * 3.3 / 4095);
zeroX2 = (analogRead(18) * 3.3 / 4095);
zeroY2 = (analogRead(19) * 3.3 / 4095);
}/code]
The calibration usually works. But occasionally the "zero value" will change directly after the readings start! I have seen values anywhere from -20 to 200 º/s values when the unit is just sitting on my desk.
4rdu1n0:
The calibration usually works. But occasionally the “zero value” will change directly after the readings start! I have seen values anywhere from -20 to 200 º/s values when the unit is just sitting on my desk.
Hmmmm, both of those values look to be too large. The 200 º/s is almost 50% of full scale. Am I correct in thinking your calibrate routine only uses a single reading ? I think you want to take a number of independant readings and average them. This shouldn’t be the reason behind an error like you’ve seen but it’s good practice anyway.
Also why do you subtract the gyro outputs to average them ?
xout = ((analogRead(10) * 3.3 / 4095 - zeroX1) / 0.002 - (analogRead(18) * 3.3 / 4095 - zeroX2) / 0.002) / 2;
yout = ((analogRead(11) * 3.3 / 4095 - zeroY1) / 0.002 - (analogRead(19) * 3.3 / 4095 - zeroY2) / 0.002) / 2;
Is there a sign inversion someplace that makes the subtraction really an addition ?
Thanks! I’ll try the multiple readings. The gyros are opposite each other, so yes, one of them is inverted.