# GYRO raw to deg/s conversion - code snippet needed

Can anyone help with a code snippet for converting the raw gyro values from a MPU6050 and/or an L3G4200D into degrees/second please?

Cheers you will save my aching brain which has fallen into a pit of unresponsiveness from trying to untangle the info in the spec sheets.

A

At the most sensitive setting there are 131 counts for each degree per second.

Take the raw number, subtract the Zero Rate Offset (the value you get when not rotating) and divide the answer by 131 to get degrees per second.

For other choices of sensitivity, look up the "LSB's per degree per second" value in the datasheet.

Okay, I see 131 in the MPU6050 datasheet in LSB/(ยบ/s) units for 250 d/s.

Does that also apply to the L3G4200D? I see a different number for 250 d/s, that is 8.75 but in mdps/digit units in that datasheet.

acboother:
Does that also apply to the L3G4200D? I see a different number for 250 d/s, that is 8.75 but in mdps/digit units in that datasheet.

'mdps' would be milli-degrees-per-second

0.00875 degrees-per-second-per-LSB is 114.285714285714 LSB's-per-degree-per-second.

To get DPS from the raw number you subtract the Zero Rate Offset (the value you get when not rotating), multiply the answer by 8.75 to get milli-DPS and divide by 1000 to get DPS (or multiply by 8750 to get micro-DPS and divide by 1,000,000 to get DPS).

I've done the offset calibrations and applied new conversion factors (114.2857142857143 actually if its just a reciprocal).

This brings the readings close to one another but...

I was expecting the gyro values to be pretty stable (and the accelerometer values to be 'jittery') but the gyro, especially the L3G4200D is all over the place, significantly more than the MPU6050 when both are at rest. I have them both on the same breadboard and read one immediately after the other before doing any debug printing.

Getting an offset figure for the L3G is almost impossible. I do 100 loops and calculate the min, max and average values for x, y and z raw ouput. Then I print the results and start looping again etc. The MPU is pretty stable but the L3G... I can't see how this will be useful for noting small angular rotations when it i being swamped by what seems like noise.

They are closer in output when rotating but its very difficult (impossible) to get steady rotations at home... so its not very scientific.

I am suspicious of the sensor now. May be I'm cynical after my NRF24 wireless sensor tests where back to back tests with 4 sensors from one supplier were done with 5 sensors from another. One set were 5-10 times slower at sending/receiving messages than the other and failed more frequently altogether... superficially they looked the same but closer inspection showed minor visible quality issues. Cheap knock offs springs to mind. No one would know unless the comparison testing was done.