Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 8 months ago.
l3g4200 gyroscope giving random values...
/media/uploads/jayanth32/gyroscope_readings.txt I've interfaced l3g4200d gyroscope to lpc1768 using i2c interface. But i get random values even if i keep the sensor still. And also there are inconsistent variations for even when i slowly move it. And also, am i supposed to get negative values???.. So, is there anything to rectify these problems?? please help... thanks in advance
1 Answer
8 years, 8 months ago.
In that results file, is it idle in the first and last part, and moving in the middle? Because then it is doing its job fine.
i want to what those values mean and how are they generated... i could not relate this with info given in datasheet... can u help me sir?
posted by 18 Apr 2016Have a look at for example: https://learn.sparkfun.com/tutorials/gyroscope/how-a-gyro-works. Gyros are a bit harder to debug than accelerometers for example, since they have to stays in motion to measure something.
posted by 18 Apr 2016
Negative values are normal. But you really need to give more information about what you get and which code you use.
posted by Erik - 17 Apr 2016yeah sure... here is the code i am using..
Serial pc(USBTX, USBRX); L3G4200D gyro(p9, p10);
int main() { int g[3]={0,0,0}; pc.printf("Now starting gyroscope test...\n");
Set highest bandwidth. gyro.setLpBandwidth(LPFBW_42HZ);
while (1) {
Arbitrary wait for printf clarity. wait(1); gyro.read(g); pc.printf("x=%d,y= %d,z= %d \r\n", g[0], g[1], g[2]);
}
}
posted by jayanth kumar 17 Apr 2016and the l3g4200.cpp read function is as below
void L3G4200D::read(int g[3]) { assert the MSB of the address to get the gyro to do slave-transmit subaddress updating. data[0] = L3G4200D_OUT_X_L | (1 << 7); _device.write(GYR_ADDRESS, data, 1);
Wire.requestFrom(GYR_ADDRESS, 6); while (Wire.available() < 6);
_device.read(GYR_ADDRESS, data, 6);
uint8_t xla = data[0]; uint8_t xha = data[1]; uint8_t yla = data[2]; uint8_t yha = data[3]; uint8_t zla = data[4]; uint8_t zha = data[5];
g[0] = (short) (xha << 8 | xla); g[1] = (short) (yha << 8 | yla); g[2] = (short) (zha << 8 | zla);
posted by jayanth kumar 17 Apr 2016i have attached the readings file... i want to what those values mean and how are they generated... i could not relate this with info given in datasheet... so, please help me.. thanks in advance
posted by jayanth kumar 17 Apr 2016With
posted by Erik - 17 Apr 2016<<code>> and <</code>>
you can make it better readable.