MPU 6050 Data are not constant - Netduino Plus 2 (and Netduino Plus 1) - Netduino Forums
   
Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

MPU 6050 Data are not constant


  • Please log in to reply
20 replies to this topic

#1 Heroduino

Heroduino

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationGermany

Posted 24 December 2012 - 04:00 AM

Hallo,

for several days now I try to program with my Netduino plus to read values from the sensor MPU 6050.

So, i don't have any idea, it doesn`t work, what can i do? I have tried many configurations, without success.

Here is a result at the Moment, if I start to read:

Initialisiere den Beschleunigungs- und Gyrosensor MPU-6050
-----------------------------------------------------------------------
Status: OK
Status: OK
Status: OK
Status: OK
Verbindung testen:
Status: Error
-----------------------------------------------------------------------
Acceleration: X: 162 Y:43647 Z:64764 Gyro: X: 53751 Y: 30329 Z: 57686
Acceleration: X: 0 Y:65403 Z:31771 Gyro: X: 61390 Y: 65385 Z: 1442
Acceleration: X: 28752 Y:46264 Z:0 Gyro: X: 0 Y: 0 Z: 0
Acceleration: X: 0 Y:0 Z:0 Gyro: X: 0 Y: 0 Z: 0
Acceleration: X: 0 Y:0 Z:0 Gyro: X: 0 Y: 0 Z: 0
Acceleration: X: 1281 Y:59647 Z:31809 Gyro: X: 254 Y: 29182 Z: 61951
...


The Connections to the sensor, i have already tested.
So I hope anyone can help me :o


Heroduino

PS: Sorry for my bad English. <_<

#2 Heroduino

Heroduino

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationGermany

Posted 15 March 2013 - 11:36 AM

Hello,

 

i have found the problem and I have fixed.

For interest, I post my solution.

 

http://dl.dropbox.co...nsorEnglish.zip

 

 

Heroduino



#3 Vinh

Vinh

    New Member

  • Members
  • Pip
  • 7 posts

Posted 07 April 2013 - 08:54 PM

Hello,

 

According to specifications, all measurements output of the MPU6050 are in the form 16-bit 2’s complement value (Int16).

 

Int16 values range from -32768 to 32767.

 

The results you shown have values outside that range.

 

I run your codes and get the same result but I don't know C# enough to fix it.

 

Let me know if you find a solution.

 

Regards

 

Vinh



#4 Vinh

Vinh

    New Member

  • Members
  • Pip
  • 7 posts

Posted 09 April 2013 - 10:47 PM

Hi Heroduino,

 

I found a solution to the problem. Here is:

 

  while (true)   {   // Blink LED   led.Write(!led.Read());   Thread.Sleep(1); // Sleep 1 milisecond   led.Write(!led.Read());   // read sensor state   data = sensor.GetSensorData(); // set a string with the values from sensor   string str =   "aX: " + (Int16)data.Acceleration_X + "t; " +   "aY: " + (Int16)data.Acceleration_Y + "t; " +   "aZ: " + (Int16)data.Acceleration_Z + "t; " +   "gX: " + (Int16)data.Gyroscope_X + "t; " +   "gY: " + (Int16)data.Gyroscope_Y + "t; " +   "gZ: " + (Int16)data.Gyroscope_Z + "t; " +   "T: " + (Byte)((Int16)data.Temperature / 340 + 36.53);     // Debug Output   Debug.Print(str);   Thread.Sleep(500); // Sleep .5 second   }



#5 Kamal Kumar Raj

Kamal Kumar Raj

    New Member

  • Members
  • Pip
  • 3 posts

Posted 19 May 2013 - 06:15 AM

Hello Guys,

 

I am to totally new to this Hardware electronics world. I am doing a project on Movement tracking machine. I have ordered the MPU 6050 8pin 3-axis accelerometer and 3 axis gyro scope. I have seen seen the code of Herduino but i am not getting how to include the MPU 6050 library to the code and execute it. I also don't know the connection with the netduino i have.

 

Please help me as soon as possible because i have submit this project in two weeks from now.

 

Thanks,



#6 Heroduino

Heroduino

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationGermany

Posted 24 May 2013 - 08:30 AM

Hello Kamal Kumar Raj,

 

you don't tell the fail, if you run bei exampple code.

 

Well, you Need only my example solution. Not a extra library.

 

You Connect the Netduino to MPU6050

 

+5V Pin => VCC

Analog Pin4  => SDA

Analog Pin5  => SCL

GND Pin => GND

 

So need you more help, write a message again ;)

Or look on my Blogpost and use Google Translate ;)

http://meineweltinme...m-netduino.html

 

 

Heroduino



#7 Kamal Kumar Raj

Kamal Kumar Raj

    New Member

  • Members
  • Pip
  • 3 posts

Posted 24 May 2013 - 04:54 PM

i have connected as you have said but when i am opening your solution in my visual studio, it is written project file is not available.



#8 Kamal Kumar Raj

Kamal Kumar Raj

    New Member

  • Members
  • Pip
  • 3 posts

Posted 24 May 2013 - 05:01 PM

these errors i am getting with your solution.

C:UsersKAMALDocumentsVisual Studio 2010ProjectsExampleAccelGyroSensorExampleGyroSensorExampleAccelGyroSensor.csproj : error  : Unable to read the project file 'ExampleAccelGyroSensor.csproj'. 
C:UsersKAMALDocumentsVisual Studio 2010ProjectsExampleAccelGyroSensorExampleGyroSensorExampleAccelGyroSensor.csproj(32,3): The imported project "C:Program FilesMSBuildMicrosoft.NET Micro Frameworkv4.2CSharp.Targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.


#9 Shadi

Shadi

    Member

  • Members
  • PipPip
  • 12 posts

Posted 30 May 2013 - 09:08 AM

#1 Many of the breakout boards already include pull-up resistors, so you don't need any. This could be the cause of mysterious data errors.

 

#2 the values are signed coming from the MPU6050, so you need to change from uint to short.

 

#3 The MPU6050 has a data ready interrupt pin you need to monitor and then use I2C read.

ipDataReady = new InterruptPort(pinDataReady, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeHigh);ipDataReady.OnInterrupt += new NativeEventHandler(ipDataReady_OnInterrupt);...public void SetDataReady(bool enabled){	var trans = new I2CDevice.I2CTransaction[] {		I2CDevice.CreateWriteTransaction(new byte[] { 0x38, enabled ? (byte)0x01 : (byte)0x0 }) // data ready interrupt	};	lock (lockI2C)	{ 		int r = i2cMPU9150.Execute(trans, 100);	}}

Attached Files



#10 Heroduino

Heroduino

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationGermany

Posted 12 June 2013 - 07:20 PM

Hello Shadi,

 

sorry I see your message at now. But, I am not sure what your are try to descripte.

 

Well, you used the "InterruptPort" Class for what. The Sensor MPU6050 can only read by I²C.

 

 

And so I wonder me, I have not see the message from Vinh.

 

Hello Vinh,

 

why you convert to string and cast the value to int16? The value need a uint, or use a int or int32. So then it functions ;)

 

 

 

Heroduino



#11 Shadi

Shadi

    Member

  • Members
  • PipPip
  • 12 posts

Posted 19 June 2013 - 12:45 AM

Heroduino,

  Pin 12 of the MPU6050 is an Interrupt pin. The MPU6050 will signal when data is ready.

Writing values to 0x38 will control when this interrupt is signaled. The MPU6050 reference sheet contains more information on bitflags in this register.



#12 alex.c.schultz

alex.c.schultz

    New Member

  • Members
  • Pip
  • 5 posts

Posted 01 July 2013 - 01:54 AM

I'm trying to get this to work and all I'm getting is:

 
Status: Fail by sending or receive.
Status: Fail by sending or receive.
aX: 15104 ; aY: 0 ; aZ: 0 ; gX: 0 ; gY: 0 ; gZ: 0 ; T: 36
 
I have my netduino plus 2 set up according to heroduino's description, but no luck.
 
I'm using the MPU 6050 GY-521 breakout board.
 
Any help would be greatly appreciated!


#13 Heroduino

Heroduino

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationGermany

Posted 01 July 2013 - 11:03 AM

Hello alex,

 

comes the failur, after the initialisation? Well, that is a failur by a loose connection or bad contact.

 

Have you try it on a Breadboard? I have my sensor now soldered.

So, important is the initialisation sequenz in my example code must execute.

 

 

Heroduino



#14 alex.c.schultz

alex.c.schultz

    New Member

  • Members
  • Pip
  • 5 posts

Posted 01 July 2013 - 04:49 PM

Thanks for the reply!

 

Yes, I have it soldered and I am using it on a breadboard. The green led power light comes on so I know there is power.

I am using the solution provided by heroduino. I assume the initialization you're talking about is done through the constructor? I shouldn't have to do anything else beside running your code right? 

 

If it is a bad board or a bad connection, I don't suppose there is a quick way to diagnose that is there? Short of pulling up the schematics and a testing the components with a multimeter?



#15 Heroduino

Heroduino

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationGermany

Posted 01 July 2013 - 06:08 PM

Hallo Alex,

 

I think the voltage is alright. :)

 

Yes, the constructor had the right initialization. So, I think you don't need to change it.

If you want to check the transmission, you will need an oscilloscope.

You can try an other clockrate. At normal setting, I used 100kHz. which can change to 400kHz.

 

Show all inits with status "OK"? If yes, that is a sign for "everything is ok". ;)

If you still have trouble, perhaps you may have a bad connection with SDA and SDO.

 

Sorry for my poor English, non-native speaker.

 

Heroduino



#16 alex.c.schultz

alex.c.schultz

    New Member

  • Members
  • Pip
  • 5 posts

Posted 02 July 2013 - 03:41 AM

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]Heroduino[/color]

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]Thanks for all your help, I finally figured it out. I was using analog pins 4 and 5 for the clock and data lines. The Netduino Plus 2 has a SD and an SC line. I used those and all of a sudden the device started working![/color]



#17 MoonWalker

MoonWalker

    Member

  • Members
  • PipPip
  • 10 posts

Posted 05 July 2013 - 08:09 AM

Hi Guys,

 

how you can use the MPU6050?

Do netduino have micros() which is necessary to realize the dT (elapsed time) to calculate the Gyro angle and filtering?

am i maybe missing something there?

 

Thx

Attila



#18 Heroduino

Heroduino

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationGermany

Posted 05 July 2013 - 04:19 PM

Hello MoonWalker (Attila),

 

the elapsed time it is not necessary for filtering. For example you can progamming a attitude indicator with complemtary filtering without elapsed time. :)

 

What are you planing to do with this elapsed time?

 

 

 

Heroduino



#19 MoonWalker

MoonWalker

    Member

  • Members
  • PipPip
  • 10 posts

Posted 08 July 2013 - 06:57 AM

Hello Heroduino,

 

thank you for your reply. This only works if you utilize the DMP of that MPU6050. If you read raw data you need the dT.

My question was based on my hardware config where i was not able to utilize the DMP data from the sensor but had to work

with raw data.

 

Grüsse

Attila



#20 Heroduino

Heroduino

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationGermany

Posted 08 July 2013 - 04:47 PM

Herllo Attila,

 

sorry, but I have not understand the DMP completely. The Sensor have many options to configurate and I have here presented a tiny example code for the sensor.

 

If you want use the raw data from the sensor, deaktivate some setting in the initialisation. To Comment out the Gyro_Config (0x1B) and the Accel_Config (0x1C).

 

On the page 5 is a description what the DMP going to do. ;)

http://www.invensens...M-MPU-6000A.pdf

 

 

 

Heroduino






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.