cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 and Gyro ITG3200

ngohoainguyen
Associate II
Posted on March 22, 2015 at 06:00

Dear all,

I am doing a project with the quadcopter. At this time, I can read the data of accelerometer ADXL345 exactly but the gyro sensor ITG3 I use I2C to communicate the sensors, and the results of ITG3200 changes over the time even it does not move. This is how I initialize the sensor, with the sampling rate is 100Hz.

writeDevice(0xD0,0x15,0x09);//sample rate divider

 writeDevice(0xD0,0x16,0x1B);//DLPF, Full scale

and this is how I read the data

data1 = RI2C(0x1D);
data2 = RI2C(0x1E);
data = (data2<<8)|data1;
Gx = data/375/100;

(Gx means the rotation around the x-axis, roll) And the result is fluctuated a lot. Could you have some ideas about this problem ? Thank you so much. My Skype ID is ngohoainguyen, you can contact to me if necessary.
2 REPLIES 2
raptorhal2
Lead
Posted on March 22, 2015 at 15:59

I believe you swapped the high and low bytes. Try this:

data = (data1<<8) | data2;

Cheers, Hal

ngohoainguyen
Associate II
Posted on March 24, 2015 at 03:55

Thank Baird Hal. It's my mistake.