Notifications
Clear all

Trouble with MPU 6050 Code

48 Posts
9 Users
14 Reactions
4,888 Views
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@azflyer So far I haven't found that sketch, but on a search I do see it is an error others have encountered. Sadly I see no resolution for it so far. If you can post me the links where you got whatever source code you are usig it would speed things up for me.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@azflyer Try this, it will compile but I don't know if it will work. The underlying libraries have changed so it's problematic.

//LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, 1);

LiquidCrystal_I2C lcd(i2c_addr, 16, 2);

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@azflyer I have tried several different libraries, tried examples from several other sites including instructables and none of them work. Something fundamental has changed.

I will return to this problem when I have got my own project under control if nobody else has sorted it by then. One avenue of attack you might try is to goto the web site of the folks who provided the MPU6050 and see/ask for a sample sketch from them.

Good luck.

EDIT Still try the changes I pointed out above, that may work but seems too easy.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@azflyer)
Member
Joined: 4 years ago
Posts: 12
 

@zander okay thanks


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@azflyer Try the simple change I outlined, I know it compiles and let us know how it went.

Here are the changes again, just comment // out the original line with the POSITIVE comple error and add the new line after it.

//LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);

LiquidCrystal_I2C lcd(i2c_addr, 16, 2);

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@azflyer Ok, here are the complete instructions. Quite a lot changed and one of the libraries is very non-standard. Since you are very new I have given you 'special' files to simplify the installation. The full instructions are a little daunting.

CAVEAT I don't have this setup, so have no idea if it will work but at least it compiles.

Step 1. Install the MPU6050 library using the included zip file and the standard technique of Sketch/Include Library/Add .ZIP library

Step 2. Install the I2Cdev library by the same method as step 1.

Step 3. edit the file MPU6050_6Axis_MotionApps20.h (see screen print) lines 365, 367, 369 you need to add TC to the XYZ offset vars so they look like the variable names in lines 361, 362, 363 (see 4th screen print if in doubt) I have included before and after pictures.

Step 4. Use the normal Library Manager install the library 'LiquidCrystal I2C' (see screen snap)

Step 5. Edit the file 'mpu_6050_level.ino' line 23 should be commented out, that means adding // to the beginning of the line (see screenshot) then add the following line after 23

LiquidCrystal_I2C lcd(i2c_addr, 16, 2);

It should now work.

I hope I got that all right.

 

 

Screen Shot 2022 05 24 at 14.53.22
Screen Shot 2022 05 24 at 14.37.19
Screen Shot 2022 05 24 at 14.37.46
Screen Shot 2022 05 24 at 15.00.24
Screen Shot 2022 05 24 at 15.04.58

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@azflyer I got the MPU6050 hooked up and ran both sketches. Everything worked except the LCD. As you recall the library was changed for that so I think something is missing. I will have another coffee then try a sample sketch to see if I can see what is missing.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@azflyer Here is a picture of it working. I had to make at least one other change, it's small but I am doing some file compares to make sure I haven't forgotten anything.

IMG 6902

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@azflyer Here are all the changes needed for the level sketch. My initials are on each line, a total of 4 and I think I already told you about the changes to line 23 and 24. The other two are equally simple. See attached screen grabs. Each line to be added or modified includes my marker //RCA

Screen Shot 2022 05 24 at 19.15.20
Screen Shot 2022 05 24 at 19.06.22

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@azflyer)
Member
Joined: 4 years ago
Posts: 12
 

@zander I appriciate all your efforts. I'll give it a try.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@azflyer Ok, but don't forget all the other things that need to be fixed first including downloading two files from here. Given how you have said you aren't forum savvy yet, here is a link to the first 5 steps before you can make the level fix changes work. Let me know if you need any more help than this, but I have done the exact same steps and the sketch now works.

https://forum.dronebotworkshop.com/postid/29760/

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@azflyer How is it going, were my instructions clear?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@azflyer)
Member
Joined: 4 years ago
Posts: 12
 

Yes your instructions were clear, thanks again 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@azflyer Now that you have it working, what is your next step, I assume you want to use the sample to help you build some device for one of your RC planes.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@azflyer)
Member
Joined: 4 years ago
Posts: 12
 

Thanks for all your help. I don't have any immidiate plan to use this device.  I am a big fan of Mr. Bill, so I thought I should build this circuit. Also I design, build and fly drone aka quadcopter. So This device MPU6050 would help me to learn more about flight stabilazionn in a quadcopter and such.


   
Ron and Inst-Tech reacted
ReplyQuote
Page 3 / 4