Support for MPU6050

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
frank26080115
Posts: 26
Joined: Mon Jul 11, 2011 12:47 pm

Re: Support for MPU6050

Post by frank26080115 »

The FIFO structure is already well defined. Are you getting "FIFO is ready"? Is the FIFO all zeros? Does the FIFO not match what you expect? Does it seem random? Noisy? Double check your endianness?

The registers are mostly the same, I think there are some differences in the internal DMP memory (not the same as registers) between silicon revisions according to the "Motion Processing" code that InvenSense provided. I don't even know how to tell which silicon revision I have but I think you can guess based on the date of manufacturing, I'm pretty sure I'm using the latest.

By the way, the roll axis uses arctan, it goes between -180 and 180 degrees just fine. My pitch axis will only go between -60 and 60 due to the arcsine approximation error.

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Support for MPU6050

Post by timecop »

No, I'm not getting fifo data at all (actually one read gets fifo level of like 4, then nothing else after).
I'll look over it again, initialization is fine, they're all standard i2c buffer writes as you can see here
http://code.google.com/p/afrodevices/so ... _mpu6050.c
(under #ifdef MPU6050_DMP)
Unless I messed up pointers to 3d array when I got rid of dumb for loops, I'll look over it again but I think its fine.

frank26080115
Posts: 26
Joined: Mon Jul 11, 2011 12:47 pm

Re: Support for MPU6050

Post by frank26080115 »

hmm... personally I would hook the I2C bus to an analyser right now and log the traffic for a second.

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Support for MPU6050

Post by timecop »

Yea, that was my next plan. I'm so lazy... :D

didlawowo69
Posts: 38
Joined: Tue Oct 11, 2011 1:42 pm

Re: Support for MPU6050

Post by didlawowo69 »

Hi,
i have a question for MPU6050 user's.
do you think this IMU on freeIMU 0.4v is better than an allinone board like sirius from multiwiicopter.com ?

cause i'm going to buy a new IMU for my quad, and have no idea how to compare this both.

thx in advance.

amourdurisk
Posts: 31
Joined: Wed Nov 02, 2011 8:58 pm

Re: Support for MPU6050

Post by amourdurisk »

Hi didlawowo69,

I test ITG3200+bma180 and MPU6050, in my case, I find that itg3200 is less sensitive to vibration so I had better results with itg
Would require other users MPU say what they think

Matt.

amourdurisk
Posts: 31
Joined: Wed Nov 02, 2011 8:58 pm

Re: Support for MPU6050

Post by amourdurisk »

i have found someone like me who think that the LPF with MPU has no effect
Here http://www.rcgroups.com/forums/showpost.php?p=20902329&postcount=2859

someone else has the same problem?

Matt.

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Support for MPU6050

Post by timecop »

No man, it works fine for me. But I don't use DJI frames.

amourdurisk
Posts: 31
Joined: Wed Nov 02, 2011 8:58 pm

Re: Support for MPU6050

Post by amourdurisk »

which lpf do you use dongs ?

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Support for MPU6050

Post by timecop »

none, (default) of 256hz

amourdurisk
Posts: 31
Joined: Wed Nov 02, 2011 8:58 pm

Re: Support for MPU6050

Post by amourdurisk »

If you don't use it how you can know if LPF is working or not for you ?

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Support for MPU6050

Post by timecop »

OK, I poked around with DMP code again.
dmpFifoReady() always reads 0x04, 0x00 -> fifo of 1024.
So.. It's always full?...
edit: Got it.
I had a 20ms delay after init, which would immediately saturate the fifo.
since the code never reset it again, it would just stay full.
Now im getting data in dmp_received_packet, time to play with it.
edit2: i'm getting quat data at like ~20Hz.
Is that the best this thing can do? :)
edit3: all working. still at 20Hz though.
I'm turning on a led each time a successful entry into dmploop w/available data and turning it off on exit.
this takes 1.5ms on STM32/72MHz (read data + calculate), then the rest is blank of ~55ms until next cycle.

frank26080115
Posts: 26
Joined: Mon Jul 11, 2011 12:47 pm

Re: Support for MPU6050

Post by frank26080115 »

one of the settings determine the FIFO output rate, look around for "inv_set_fifo_rate" in the code comments and the settings are given in the documentation for "Embedded MotionApps Platform Functional Specification"

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Support for MPU6050

Post by timecop »

Cool, thanks :)
it's running at 200Hz now.

Image

didlawowo69
Posts: 38
Joined: Tue Oct 11, 2011 1:42 pm

Re: Support for MPU6050

Post by didlawowo69 »

any news from MPU6050 support,
could you tell me if that works correctly, because my quad don't work fine :/

fax8
Posts: 61
Joined: Mon Feb 14, 2011 5:29 pm

Re: Support for MPU6050

Post by fax8 »

working good.. you may wanna try setting some DLPF. Some frames needs it to avoid some kind of resonance problems.

didlawowo69
Posts: 38
Joined: Tue Oct 11, 2011 1:42 pm

Re: Support for MPU6050

Post by didlawowo69 »

could you explain how to setup DLPF ?

Arf
Posts: 22
Joined: Tue May 22, 2012 10:48 pm

Re: Support for MPU6050

Post by Arf »

didlawowo69 wrote:could you explain how to setup DLPF ?


There are some MPU-6050 LPF defines for the gyro in config.h perhaps that what he means?


Specifically:

//#define MPU6050_LPF_256HZ // This is the default setting, no need to uncomment, just for reference
//#define MPU6050_LPF_188HZ
//#define MPU6050_LPF_98HZ
//#define MPU6050_LPF_42HZ
//#define MPU6050_LPF_20HZ
//#define MPU6050_LPF_10HZ // Use this only in extreme cases, rather change motors and/or props

didlawowo69
Posts: 38
Joined: Tue Oct 11, 2011 1:42 pm

Re: Support for MPU6050

Post by didlawowo69 »

thx for this answer
could you tell me whiche config.h do you use for MPU > I2C address

fax8
Posts: 61
Joined: Mon Feb 14, 2011 5:29 pm

Re: Support for MPU6050

Post by fax8 »

didlawowo69 wrote:could you tell me whiche config.h do you use for MPU > I2C address


Please clearify your question.

didlawowo69
Posts: 38
Joined: Tue Oct 11, 2011 1:42 pm

Re: Support for MPU6050

Post by didlawowo69 »

could you write on the forum your config for MPU
it's seems the I2C address in the multiwii code is not correct.

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

Re: Support for MPU6050

Post by EOSBandi »

Hi Guys,
I remember that there were some discussion about the incorrect acc scaling. It seems that finally it turned out that some revisions of the chip has half the sensitivity that described in the datasheet. Here is a small code to check chip revision and set the acc scaling factor correctly.

Code: Select all

void ACC_init () {

#define MPU6000ES_REV_C4          0x14 
#define MPU6000ES_REV_C5          0x15    
#define MPU6000ES_REV_D6          0x16   
#define MPU6000ES_REV_D7          0x17   
#define MPU6000ES_REV_D8          0x18       
#define MPU6000_REV_C4          0x54   
#define MPU6000_REV_C5          0x55      
#define MPU6000_REV_D6          0x56       
#define MPU6000_REV_D7          0x57   
#define MPU6000_REV_D8          0x58   
#define MPU6000_REV_D9          0x59   
#define MPUREG_PRODUCT_ID          0x0C   // Product ID Register 
#define MPUREG_ACCEL_CONFIG                                0x1C 

uint8_t _product_id = i2c_readReg(MPU6050_ADDRESS,MPUREG_PRODUCT_ID); // read the product ID rev c has 1/2 the sensitivity of rev d
          if ((_product_id == MPU6000ES_REV_C4) || (_product_id == MPU6000ES_REV_C5) ||
      (_product_id == MPU6000_REV_C4)   || (_product_id == MPU6000_REV_C5)){
      // Accel scale 8g (4096 LSB/g)
      // Rev C has different scaling than rev D
      i2c_writeReg(MPU6050_ADDRESS,MPUREG_ACCEL_CONFIG,1<<3);
   } else {
      // Accel scale 8g (4096 LSB/g)
      i2c_writeReg(MPU6050_ADDRESS,MPUREG_ACCEL_CONFIG,2<<3);
   } 
  acc_1G = 512;

Katch
Posts: 280
Joined: Thu Aug 04, 2011 1:44 pm

Re: Support for MPU6050

Post by Katch »

if you look very closely at the mpu6050 chip if it has the initial ES at the end then it's an engineering sample with the different acc scaling.

User avatar
EOSBandi
Posts: 802
Joined: Sun Jun 19, 2011 11:32 am
Location: Budapest, Hungary
Contact:

Re: Support for MPU6050

Post by EOSBandi »

Katch wrote:if you look very closely at the mpu6050 chip if it has the initial ES at the end then it's an engineering sample with the different acc scaling.

It's not an ES issue, but a difference between revC and revD

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Support for MPU6050

Post by timecop »

Looks like that code was lifted from diyclones code, and i don't think it covers MPU6050... at least in product IDs...
Like mine are product_id 0x28... Any way to find a list of all the stuff properly?

didlawowo69
Posts: 38
Joined: Tue Oct 11, 2011 1:42 pm

Re: Support for MPU6050

Post by didlawowo69 »

how to identify which version of MPU i have ?

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Support for MPU6050

Post by timecop »

didlawowo69 wrote:how to identify which version of MPU i have ?


Load the program, breakpoint on i2cread of product ID, then examine the variable? oh.. never mind I forgot this is obsolete 8bit hardware.

Maybe Serial.Print() it or something.

didlawowo69
Posts: 38
Joined: Tue Oct 11, 2011 1:42 pm

Re: Support for MPU6050

Post by didlawowo69 »

on my MPU it's write MPU6150ES.

what can i do whit that ? :(

jmellipse
Posts: 3
Joined: Wed Jun 27, 2012 12:32 pm

Re: Support for MPU6050

Post by jmellipse »

I just got my mpu6050 from flyduino.net. I using MultiWii 20120522. I noticed that the gyro x and y is mixed up, the acc x and y are fine. This is with the stock ACC_ORIENTATION and GYRO_ORIENTATION.
It seems that I can change these and would be able to fly. But is feels strange that they are mixed even tough the are on the same chip. Any idea ?

jmellipse
Posts: 3
Joined: Wed Jun 27, 2012 12:32 pm

Re: Support for MPU6050

Post by jmellipse »

Never mind, I just learned that this is known and already changed in 20120622 if you select the FLYDUINO board. Thanks

Sebbi
Posts: 478
Joined: Sun Jul 08, 2012 1:08 am
Location: Germany
Contact:

Re: Support for MPU6050

Post by Sebbi »

Hi,

has anybody tried to run the dmp code for this IMU on an Arduino Pro Mini (328P) yet? If so, did you switch to constant time intervals or just poll the fifo fast enough? Is it faster/more accurate than the default MultiWii code? Faster = one still needs to convert the quaternions into euler angles for the rest of the code to work, right? Or has somebody invented algorithms which stay in "magic quaternion land" all the time? ;-)

User avatar
mgros
Posts: 90
Joined: Thu Jan 20, 2011 12:32 am

Re: Support for MPU6050

Post by mgros »

What about this news?
http://www.diydrones.com/profiles/blogs/invensense-releases-licence-to-allow-use-of-the-mpu-6000-dmp-proc
Invensense releases licence to allow use of the MPU-6000 DMP processor

Can we use DMP in multiwii?

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

Re: Support for MPU6050

Post by copterrichie »

This is good news, the DMP should be able to handle some angular calculations I am told. :)

Sebbi
Posts: 478
Joined: Sun Jul 08, 2012 1:08 am
Location: Germany
Contact:

Re: Support for MPU6050

Post by Sebbi »

Most of the documentation is still missing ... but it's a start ;-)

tuylipden
Posts: 1
Joined: Fri Aug 10, 2012 11:06 am

Re: Support for MPU6050

Post by tuylipden »

I tried to measure the angle of accel. I configured AFS_SEL=2 (Full scale =+/-8G )

Code: Select all

signed int ACCEL_XOUT_L = 0;
signed int ACCEL_XOUT_H = 0;
signed int ACCEL_YOUT_L = 0;
signed int ACCEL_YOUT_H = 0;
signed int ACCEL_ZOUT_L = 0;
signed int ACCEL_ZOUT_H = 0;

ACCEL_XOUT = ((ACCEL_XOUT_H<<8)|ACCEL_XOUT_L);
ACCEL_YOUT = ((ACCEL_YOUT_H<<8)|ACCEL_YOUT_L);
ACCEL_ZOUT = ((ACCEL_ZOUT_H<<8)|ACCEL_ZOUT_L);

ACCEL_X = (float)ACCEL_XOUT/4096;
ACCEL_Y = (float)ACCEL_YOUT/4096;
ACCEL_Z = (float)ACCEL_ZOUT/4096;

Then, I changed the value to the real angle

Code: Select all

R=sqrt(pow(ACCEL_X,2)+pow(ACCEL_Y,2)+pow(ACCEL_Z,2));
ACCEL_XANGLE= 57.295*acos(ACCEL_X/R);
ACCEL_YANGLE= 57.295*acos(ACCEL_Y/R);

But, the result is a huge difference compared with the true angle. I don't know where the mistakes. Plz help me !!! Thanks so much !

Sebbi
Posts: 478
Joined: Sun Jul 08, 2012 1:08 am
Location: Germany
Contact:

Re: Support for MPU6050

Post by Sebbi »

Angles are usually calculated using atan2:

Code: Select all

ACCEL_XANGLE = 57.295 * atan2(ACCEL_X, sqrt(ACCEL_Y*ACCEL_Y + ACCEL_Z*ACCEL_Z));
ACCEL_YANGLE = 57.295 * atan2(ACCEL_Y, sqrt(ACCEL_X*ACCEL_X + ACCEL_Z*ACCEL_Z));


For small angles this also works (MultiWii does it as an optimization???):

Code: Select all

ACCEL_XANGLE = 57.295 * atan2(ACCEL_X, ACCEL_Z);
ACCEL_YANGLE = 57.295 * atan2(ACCEL_Y, ACCEL_Z);

aurisnow
Posts: 2
Joined: Fri Mar 22, 2013 5:37 am

Re: Support for MPU6050

Post by aurisnow »

I am trying to get my new quad all tuned and as soon as I hooked it all I can't get a signal from my roll stick. Any ideas how to troubleshoot this
I was flying this board with the same transmitter no problem, just got a new receiver.


http://www.youtube.com/edit?video_id=6AjiWInQ_mc&ns=1[

thanks!!

Post Reply