Gyro_scale is wrong for L3G4200D

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
ovaltineo
Posts: 15
Joined: Sun Apr 28, 2013 11:41 pm

Gyro_scale is wrong for L3G4200D

Post by ovaltineo »

As I said in my other post, the gyro scale is wrong for the MPU6050 and L3G4200D in Multiwii v2.2. This has been fixed somewhat in the latest dev release R1429. But, it is still wrong for the L3G4200D. In R1429, it is defined as
#if defined(L3G4200D)
#define GYRO_SCALE (20 / 70 * PI / 180.0 / 1000000.0) //l3g4200 70 LSB/(deg/s)
#endif

This is wrong because sensitivity for this gyro is 70mdps/LSB. This unit is very different from the unit used in the MPU6050 sensitivity of 16.4LSB/dps. These units are inverted and mdps is 1000 times of dps.

Moreover, why is the raw value of L3G4200D divided by 20 in Gyro_getADC, while MPU6050 and ITG3200 get divided by 4? Also, the power on default of L3G4200D is 250dps, not 2000dps. So unless we change Gyro_init, these values are wrong anyway.

To set 2000dps, add to Gyro_init:
i2c_writeReg(L3G4200D_ADDRESS ,0x23 ,0x30); // CTRL_REG4 Select 2000dps

Replace divide by 20 with divide by 4 in Gyro_getADC:
GYRO_ORIENTATION( ((rawADC[1]<<8) | rawADC[0]) >> 2,
((rawADC[3]<<8) | rawADC[2]) >> 2,
((rawADC[5]<<8) | rawADC[4]) >> 2);

Define correct gyro scale:
#define GYRO_SCALE ((4.0f * PI * 70.0f)/(1000.0f * 180.0f * 1000000.0f)) //(L3G4200D)
Last edited by ovaltineo on Tue May 07, 2013 11:31 am, edited 1 time in total.

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Gyro_scale is wrong for L3G4200D

Post by Alexinparis »

Hi,

I don't remember who included this gyro def in multiwii.
anyway, your change seems wise.

but then I don't understand the 20.0f in your last equation ? shouldn’t be 4 instead ?

ovaltineo
Posts: 15
Joined: Sun Apr 28, 2013 11:41 pm

Re: Gyro_scale is wrong for L3G4200D

Post by ovaltineo »

Yes. Cut and paste error. Fixed.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Gyro_scale is wrong for L3G4200D

Post by copterrichie »

I am using a L3G4200D and will give this a test, maybe as soon as this afternoon.

felixrising
Posts: 244
Joined: Sat Mar 23, 2013 12:34 am
Location: Australia

Re: Gyro_scale is wrong for L3G4200D

Post by felixrising »

r1435 has part of the required changes in, ie GYRO_SCALE, but not the init changes required: Gyro_getADC() and Gyro_init().... a la ovaltineo

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Gyro_scale is wrong for L3G4200D

Post by Alexinparis »

felixrising wrote:r1435 has part of the required changes in, ie GYRO_SCALE, but not the init changes required: Gyro_getADC() and Gyro_init().... a la ovaltineo


right, this time it's my fault ;) I forgot some part.
I will correct it

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Gyro_scale is wrong for L3G4200D

Post by copterrichie »

Took the Sweptback II out to the park for additional flight testing, have not flown it since the upgrade to MWC 2.2. Wanted to test the Gyro Scale factor



I would say, Kudos and Job Well done!!!

felixrising
Posts: 244
Joined: Sat Mar 23, 2013 12:34 am
Location: Australia

Re: Gyro_scale is wrong for L3G4200D

Post by felixrising »

Did you do some loops? To confirm that the scale factor is correct, doing a few loops in the same plane will show up cumulative error highlighting problems. Keeping in mind that temperature could have some effect on scale accuracy if it's not compensated for.

iamhandgun
Posts: 8
Joined: Thu May 30, 2013 7:23 am

Re: Gyro_scale is wrong for L3G4200D

Post by iamhandgun »

I'm flying the hunter vtail frame and using multiwii 2.2 and the gy-80 imu that uses l3g4200 gyro. I stumbled upon this discussion because i've been having problems getting my back motors to stop fighting on throttle and looked into the code for lpf. Doing searches on the gyro brought me here. I'm wondering if I update my code with these scale and speed definitions will it help clean things up? I'm still pretty new to all of this.

Also, I'm not exactly sure where to put this code. R1435 has the gyro scale in the def.h panel but in v2.2 the gyro scale is in the IMU panel. I assume that the init statement is still in the Sensors tab as in v2.2. Do I just add/change the code where it is in 2.2 or move to where it is in r1435? I'm confused by the gryo orientation comment as well. do i change the rawADC of 0, 2 , and 4 to 2 or was that a misstype of 20 or should this be 4? sorry again for all the newb questions.

Last question. Would it just be easier for me to revert to 2.1 and wait till the next release comes out? I'm afraid of destroying my vtail if I input this stuff incorrectly.

Thanks for any comments you may have for me.
cheers

Post Reply