Arduino/MPU6050 Balance Bot Part2

  Рет қаралды 111,436

jmhrvy1947

jmhrvy1947

Күн бұрын

This is the 4th in a series of clips describing various ways an Arduino can be used to setup a simple low cost smart car.
This time N20 gear motors are compared to the original "yellow" drives. Plus changes made to the Balancing code, and to the LCD display since the last video
Code & Support Docs for this project may be found at github.com/jmharvey1/Arduino-...

Пікірлер: 146
@amirhosein640
@amirhosein640 7 жыл бұрын
Thank you so much for a full description I was so glad to see your reply Thanks again
@send2murph
@send2murph 7 жыл бұрын
One of, if not the best I've seen. Nice work.
@jmhrvy1947
@jmhrvy1947 7 жыл бұрын
Thank You
@jmhrvy1947
@jmhrvy1947 7 жыл бұрын
Thank You
@christopherbousquet-jette117
@christopherbousquet-jette117 7 жыл бұрын
Hi, the place where you put your MPU6050 it's importante? Thanks you in advance!
@jaswanthsamba4776
@jaswanthsamba4776 8 жыл бұрын
how and where do I place the MPU6050 on the set??...
@mrarmymanful
@mrarmymanful 7 жыл бұрын
Hi, what is your loop update rate? Also did you have to move some weight to the top of the chassis as to not overwhelm the motors when balancing?
@jmhrvy1947
@jmhrvy1947 7 жыл бұрын
Its been a while since I worked with it. But as I remember it, I think the loop rate is something like 30ms. Initially the 16X2 display was really slowing things down. But I found a different library to manage it, and after that, the loop rate was fairly consistent, (and no longer a problem). As you can see by the layout of the car, I tried to place the car's mass ( the batteries) as high as I could, and yet at the same time, arrange things such that when it fell over, damage would be minimal. With half the batteries on one side, and the other half on the other side, no matter which way it fell, at least one battery would pop lose. Ensuring that the car would shut down almost instantly.. This saved a lot of wear and tear, especially in the early days of development. .
@chilljlt
@chilljlt 8 жыл бұрын
excellent
@AlessandroTorrisi
@AlessandroTorrisi 7 жыл бұрын
Really beautiful project, I tryied to read the code but it's very difficult for me, congratulations for your work!
@jmhrvy1947
@jmhrvy1947 7 жыл бұрын
Glad you liked the project. Understand about the code. Today I'd probably have a hard time following it. It was a learning exercise for me, so the code contains a lot commented out test lines and at the same time it could use more comment lines explaining what each section is there for
@hieppham1484
@hieppham1484 8 жыл бұрын
Thank your issue I sure my wiring is OK ( I am electronic Eng.. with many years working..) my LCD.. after i press button for start,, display indicated " Init MPU 6050...." and no change status indicate.. a can not seen position value... to day i try up code again, but not succesfull by erro as last mail to you ( :" N20BalanceBotR1.ino: In function 'void setup()': N20BalanceBotR1:210: error: 'TCCR4B' was not declared in this scope" )
@coithieugia1508
@coithieugia1508 9 жыл бұрын
thank you for share. i am setup all same project. but my robot is not blance. pls hepl me how to put MPU 6050 on robot.
@pcamara2
@pcamara2 8 жыл бұрын
Hi: Thanks for sharing your project. I've got a question...reading the code relating withd PWM setup you declare that freq. of pin 13 & 11 is about 60Hz //setup PWM frequency to ~60Hz for OutPut pins 13 & 11 then you declare the period is 2 ms TCCR4B = TCCR4B & 0b11111000 | 0x06; //Set Digital pin 13 Right Wheel PWM period @ ~2ms but T=1/F=1/60=0.0166 s that is 16ms. So do I have to use 2ms or 16ms? Thanks again for your support.
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
+Pedro Camara Good question... Use the code as is. However, the Comments above and to the side of the line in question are both obsolete compared to the code. Early on, I experimented with low PWM frequencies (which is where the refernece to 60hz came from) Then at another point, I played with 500hz signals, and finally settled on 1Khz (I think most sources quote the frequency to be ~980Hz) which is what the TCCR4B = TCCR4B & 0b11111000 | 0x06; actually yields. I apologize for the confusion, but beware, the sketch went through many iterations before it was finished. And to be sure, a sharp eye will uncover a number of other outdated comments. At the time, I saw these entries as notes to myself about what had been tried (and failed). I hope you will be able to see through most of them. But where they give you doubt, don't hesitate to ask. Thanks for your interest in the project
@pcamara2
@pcamara2 8 жыл бұрын
+jmhrvy1947 Many thanks for your quick and explanative answer. Due to the fact that I'm trying to adapt your code to arduino one, I'll need to change some lines such the one related with TCCR4B , I guess. Thanks again four your willingness
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
+Pedro Camara Your correct TCCR4B has no meaning on the UNO. So for sure, that line will either need to be dropped, or changed, to one of the other clock registers that the UNO has. The 2X16 Display, that I used in the video, pretty much dictates that pins 13 & 11 be the PWM outputs. Another display might give you a different set of choices... Again, good luck with your project
@_Piers_
@_Piers_ 9 жыл бұрын
I've been looking at the metal geared motors and wheels similar to the ones you used here, but I haven't been able to find a simple way to attach the two. You appear to have a nice little metal coupling,I don't suppose you can remember where you got it from? Thanks :)
@jmhrvy1947
@jmhrvy1947 9 жыл бұрын
+Pook365 They were an EBay purchase, and came as part of a package set, that included the motors, gear trains, wheels, couplers, and plastic motor clamps. Also they were listed under this title: 2x Smart Car Robot Self-balancing Kits Wheel+ N20 Motor+3mm Connector_KD113-2x And, at the time, sold for ~ $26 US. It seemed a little pricey, but it did guarantee me that all the bits & pieces would be compatible. FWIW The car (with the motors shown & the ~10Volt Battery supply) is still running. So for this application, they were a good solution. Hope that helps. Good Luck with your project.
@_Piers_
@_Piers_ 9 жыл бұрын
jmhrvy1947 Thanks for the reply, they're still selling those kits so I know what the missing piece looks like at least now...Will have to consider :)
@user-ih4yh9ww2u
@user-ih4yh9ww2u 3 жыл бұрын
Cool!
@divyaprakashbiswas8781
@divyaprakashbiswas8781 2 жыл бұрын
Amazing explanation! Thanks for sharing. Did you face any issues due to the backlash of the N20 geared motors? Would it be effective if I increase the height of the robot and move the center of mass to the upper section to compensate for the motor backlash?
@jmhrvy1947
@jmhrvy1947 2 жыл бұрын
good questions... One reason I selected the N20 motors/gear set, is, for the money, they appeared to have a minimal amount of "blacklash". And to your 2nd question, the higher the center of mass the easier it is to balance. Try balancing a pencil on the palm of your hand, and then do the same with a broom. (sweep end up) Again, thanks for the interest in the project.
@divyaprakashbiswas8781
@divyaprakashbiswas8781 2 жыл бұрын
@@jmhrvy1947 Thanks a lot.
@JoseFlores-ql4gt
@JoseFlores-ql4gt 7 жыл бұрын
that's an awesome proyect, are you using a gyroscopic to obtain the values of Control PID? I really liked your proyect.
@jmhrvy1947
@jmhrvy1947 7 жыл бұрын
Thanks.. It was a fun project and a real learning experience
@JoseFlores-ql4gt
@JoseFlores-ql4gt 7 жыл бұрын
jmhrvy1947 i'll try to do something like this. it is amazing. keep going, You already have a new subscriptor since now
@njfife14
@njfife14 8 жыл бұрын
Is all of the feedback being processed by the Arduino from the MPU6050 through the I2C connection, or are you using the rasberry pi to help with the actual balancing of the robot. I wasn't sure if an Arduino mega would be fast enough to balance a robot like this very well.
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
+njfife14 Good question. The Arduino (in this video, a Leonardo) does all the processing. As i remember it, typical loop times run between 10 and 30 milliseconds. At one point I had issues with the SainSmart LCD library but found, when it came to updating the 16X2 display, that the Arduino "LiquidCrystal" library was much quicker. FWIW: I used a MEGA on the full size segway clone (Pleas see: kzbin.info/www/bejne/bZjLiqKqnsZoZ68 ) and it was plenty capable of doing all the PID processing. In fact, in the fullsize unit, the PID setting were set to produce a highly over-damped output, because the rider inherently contributs to the balance process.
@njfife14
@njfife14 8 жыл бұрын
Cool, I never would have thought about the rider adding their own balance to it, thanks =)
@radumotisan
@radumotisan 9 жыл бұрын
nice!
@stevenlee1726
@stevenlee1726 7 жыл бұрын
Helo, Urgent, do your motor have encoder on it? Is it important to have the encoder? Because my motor dont have encoder on it, am i still able to do this?
@jmhrvy1947
@jmhrvy1947 7 жыл бұрын
No. This car did not use encoders. Thanks for the question.
@TutocarloCV
@TutocarloCV 7 жыл бұрын
nice
@hamzaamri2549
@hamzaamri2549 7 жыл бұрын
Great project , your video has been a great reference for my own self balancing robot but i'm having a lot of trouble with the code , i have a Leonardo and an mpu6050 with the same set of motors as you , is it possible that your code will work on my machine without removing the lcd dispaly module or the front sensor ?
@hamzaamri2549
@hamzaamri2549 7 жыл бұрын
actually i did try your code but the motors start spinning in the same direction for about 30 seconds and then only the right one keep spinning in the same direction no matter the orientation of the gyro , if you have any advises it will be much appreciated
@jmhrvy1947
@jmhrvy1947 7 жыл бұрын
I can't say for sure. But it could be that the motors are generating electrical interference (RFI) that causes the code in the Arduino (Leonardo) to crash. If you haven't already done so, put a 0.1ufd capacitor across each motor (right at motor, where the power leads attach to the motor) Also, in my car, the battery is attached to the dual H-bridge, & then I used the H-bridge's regulated 5V output to feed the Leonardo. Not having the front sensor, should not make a difference (provided that the sense code has been disabled, or the the sense input has been disabled) GL Jim
@hamzaamri2549
@hamzaamri2549 7 жыл бұрын
Thank you so much for taking some time to answer ,i did the same with the battery and the dual H-bridge to feed the Leonardo but i never considered the possibility that the problem was from the motors so i kept trying different iteration of code but i will most certainly try the capacitors hopefully it'll work ; again thank you for your time and good luck with your future projects
@jmhrvy1947
@jmhrvy1947 7 жыл бұрын
Ok... I hope the suggestion brings some improvement. And GL to you too.
@amirhosein640
@amirhosein640 7 жыл бұрын
Hello Complete robot when power is on show this in lcd: IR Dect P -60 Yaw 174 and When the robot horizontally motors on at high speed
@shaswatdharaiya8013
@shaswatdharaiya8013 7 жыл бұрын
so i tried making one of this balancing bot with an ext power supply(which has no fault). The problem with my bot is that everytime I use power more than 5V, the system jams/hangs and the tyres keeping spinning in just one direction. They dont change direction they dont stop spinning. What should i do?
@shaswatdharaiya8013
@shaswatdharaiya8013 7 жыл бұрын
And yeah im using arduino nano for this.
@jmhrvy1947
@jmhrvy1947 7 жыл бұрын
If I follow what you have there, my first suggestion would be to install two capacitors right at the power input to the Arduino (Nano). A 100 micro-farad, and a 0.1 micro-farad. (Both are important) Please let me know how that works out for you
@elsharv7456
@elsharv7456 8 жыл бұрын
we have a problem with the code ,can u provide us the code in one txt file??
@mohammadhassan9611
@mohammadhassan9611 6 жыл бұрын
where can I found the previous videos ?
@jmhrvy1947
@jmhrvy1947 6 жыл бұрын
If they didn't come up in the side panel, you can click on or search jmhrvy1947 and find there.
@fatihgungorbilsem7665
@fatihgungorbilsem7665 9 жыл бұрын
hi good job. i have uno and mega 2560 r3 , can i use this code whit uno or mega 2560 r3... i dont want use LCD shield..
@jmhrvy1947
@jmhrvy1947 9 жыл бұрын
***** The code could be adapted to run on either; However, the Mega might be the easier of the two. I say that because I used the Mega in the Segway like transporter, shown in another video, and in my mind it has a better overlap in how the pins and timers are used. But if space is a problem, then go with the UNO. I'm sure with a little thought it can get the job done. This car will run without the display, but it really comes in handy while trying to get it up and going. If you build something like it, let me know how it works out.
@MdReza-vw4yd
@MdReza-vw4yd 8 жыл бұрын
What is the name of those wellow box with motor?
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
these are very similar to the ones shown in the video www.ebay.com/itm/smart-Car-Robot-Plastic-Tire-Wheel-with-DC-3-6v-Gear-Motor-for-arduino-/400985432465?hash=item5d5c982191:g:WVMAAOSwaNBUh7Xc
@hieppham1484
@hieppham1484 8 жыл бұрын
OK today i uploaded the code to arduino ok but after i press a button for start.. count down.." Init MPU6056 steady ..". display...but 2 motor not running...( may be how to check now . Please help me
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
+Hiep Pham I am guessing it could due to one of two issues. 1. There is a wiring problem 2. The MPU is not happy with the car's position. First, let's focus on issue 2: From your description, it appears that the initialization process starts. But I can't tell if the MPU thinks the car is upright (P=0) . Watch the "P" value shown in the lower left corner of the display. If everything is assembled correctly, and with the car held at it's balance point. The P value should drift a reading of "000". The motors wont start until this reading persists for about 2 seconds. If you don't see "000" but get some other number. Go back & look at how (where) the MPU is attached to the car. For this sketch to work (without changing the code) the MPU needs to located upside down (underneath) the top of the car. If on the other hand, if you do see "P 000", and the motors don't start. Then I would look carefully at the wiring connections. Particularly those running from the Arduino to the 298 H bridge. Let me know what you find
@hieppham1484
@hieppham1484 8 жыл бұрын
i am up code OK but now LCD alway indicated " Init MPU 6050.." .. and no change pages Maybe MPU6050 can not detected position ??? I connected all components follow your diagram PDF
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
+Hiep Pham Hiep, I sent you a separate message last night describing what the problem is, when you try to adapt this project to the UNO, and recommending that the Leonardo is the preferred way to go (given the other components shown in this video) Did you find that message?
@meteozdemir2712
@meteozdemir2712 8 жыл бұрын
hello sir, i will started to this project. now im collecting the components. after i did i want to add a remote control to it. is it possible addtion to your robot? i want use bluetooth module and use android cell phone. And one question too, why are u use ir sensor i dont get it. sorry for stupid questions.
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
+Mete Özdemir Its not a stupid question ("why the IR sensor?"): For sure you don't need it to build this particular version of the 'Balance Bot'. But I already had it, and wanted to see if I could use it to make the Bot move in a given direction. (Think of it as a crude remote control command). In practice I found it useful when I wanted to run the Bot in a small space [ like on a table top]. By placing an object at the low end of the table, the bot would slowly wander toward the object until the IR sensor detected the object. When it did, the bot would back away 5 or 6 inches, and then start the process all over. To your first question ("Can this Bot be setup to operate via Remote Control), the short answer is "yes". Here is a link : kzbin.info/www/bejne/pmbHlZ2vqtNkh8U to a video clip I made later in the project. It shows the same bot (Hardware wise) being driven with a re-purposed toy IR controller. The sketch used in this later video is an adaption of the sketch used in the above video. I have not published the RC version of the sketch, because much of that sketch is focused on decoding the commands from the IR Transmitter (which are unique to the toy controller, and as such would be of little value to anyone else). There are some challenges in adapting this project to operate as an RC Bot. Code/Sketch space is one. But the other is integrating the speed and direction commands into the PID loops. The challenge is compounded by the fact that the motors in this bot are very low power. So the bot's speed vs balance band is quite narrow. If you like a challenge, then I think you will enjoy the project as you have outlined it. Let me know how it works out for you.
@hieppham1484
@hieppham1484 8 жыл бұрын
Dear Sir i can not upload code because with note :" N20BalanceBotR1.ino: In function 'void setup()': N20BalanceBotR1:210: error: 'TCCR4B' was not declared in this scope" please help me... last time i load code OK but balanbot can not activate. by " Init MPU 6050..." indicated.on LCD
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
+Hiep Pham When you compile (upload) the sketch, make sure the Leonardo board is selected in the IDE. If in fact, you are actually using an UNO type board, this sketch wont work unless you modify it first. Please confirm which board you are working with (Uno or Leonardo?)
@henkrieuwers
@henkrieuwers 8 жыл бұрын
HI jmhrvy1947, i build your car but have some problems. everything ok but when i start the motors, the program "freeze". i think it has something to do with induction from the motors(the yellow ones) to the mpu6050. do you have any suggestion?
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
Try placing a 0.1Mfd capacitor across each motor. For maximum effectiveness, solder the capacitors right to the terminals on the motor housing. I hope that helps.
@henkrieuwers
@henkrieuwers 8 жыл бұрын
I have done that but no effect.. even when i electrical separate the motors from the car and feed them from a accu and place the motors
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
At one point in the car's development I ran into the same thing. And yes it is VERY frustrating. In the version you see in this video. The batteries feed the dual bridge. It has a 5V reg & I use the that output to drive the Arduino. Then use the output of the Arduino to supply the MPU. That seemed work for me. Additionally you'll notice I have the motor controller close to the motors, while the Arduino and MPU are located at the other end of the car. Not sure how much flexibility you have with your version of this project But maybe you can adapt yours to have a similar layout GL Jim
@henkrieuwers
@henkrieuwers 8 жыл бұрын
Hi Jim, I followed your suggestions and with succes! the motorboard is now close to the motors and far away from the mpu6050 + Leonardo. now i can concentrate on pid settings., Henk
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
Good to hear you had some luck. As for tuning the PID settings, the best advice I can offer is patience. If your battery layout mirrors mine, you will quickly see that you have "instant shut on fall", which IMO helps save the motors and electronics
@ZainabAlabrahimi
@ZainabAlabrahimi 8 жыл бұрын
did u use a gyroscope sensor?
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
+Zainab Alabrahimi The MPU-6050 acts as the gyroscope sensor
@ZainabAlabrahimi
@ZainabAlabrahimi 8 жыл бұрын
+jmhrvy1947 thnx for the reply
@sharanhegde9100
@sharanhegde9100 8 жыл бұрын
What are the dimensions of the wooden structure? Also does it play a huge factor for the balancing of the bot? Please do give a list of the items you have used here, it'll be very much appreciated
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
+Sharan Hegde Thanks for the questions. The unit as shown with what I call the N20 wheel set is 9 1/2 inches (measured from the ground to the top of the display.) The dimensions are not critical. But at same time, any deviation in the car's configuration will probably mean that the PID constants used in the Arduino sketch will need some tweaking to achieve optimum stability . On the other hand, Once I had the Bot dialed-in You could place objects on the top of the Bot and it was able to maintain balance. As for a list of parts, here's a rough listing: GY-521 6 DOF MPU-6050 Module 3 Axis Accelerometer Leonardo R3 Pro ATmega32U4 Board for Arduino Compatible 1602 LCD Board Keypad Shield Blue Backlight For Arduino Duemilanove Robot 2x Smart Car Robot Self-balancing Kits Wheel+ N20 Motor+3mm Connector_KD113-2x 2x Battery case box holder for x 4AA size cells Dual H Bridge L298N DC Stepper Motor Driver Module SPST switch IR detector (optional) 8x AA NmH rechargable batteries Jumper Wire Mounting Screws 1 3M foam sanding block (cut to form bumper) double sided foam tape. 5mm plywood (Bot frame) That's pretty much it. Hope that helps.
@sharanhegde9100
@sharanhegde9100 8 жыл бұрын
+jmhrvy1947 So, In accordance with your code and diagram. I have built the Bot, all credits to you:) But, the problem I'm facing now is that the Pitch will not go to 000 at the start, it may be because of the positioning of the MPU-6050. Can I get some advice on this matter?
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
+Sharan Hegde I'm impressed :-) I can think of two things to consider: 1. The sketch you downloaded (from the github site) contains MPU initialization values that were found with my MPU placed on a level table, in a normal (MPU) component side up position. If you haven't already updated those lines ( mpu.setXGyroOffset(35); mpu.setYGyroOffset(-28); mpu.setZGyroOffset(-39); ) in the sketch, to your MPU values, you probably need to do that. 2. The other point to check, is your MPU positioned the same relative way as described in the note found on the PDF connection diagram? That note reads as follows: "The MPU is mounted component side down, withe the Y axis pointed toward the back [of the car]" Let me know if you are OK on these two points. And if you are, what pitch values are you seeing now?
@sharanhegde9100
@sharanhegde9100 8 жыл бұрын
+jmhrvy1947 I have done as you have said so and successfully bought the pitch values to 000. My mistake was exactly as you theorized. So therefore I re-calibrated the Offset values using a code I found on Google and it came out as such -1090 748 5743 27 -13 25 and for the second part, I had misunderstood the note and placed the MPU with the Y axis in front of the car, but upon reading your comment especially the "[of the car]', I came to realize my mistake. The bot doesn't balance right though, These are what I have noticed a) The Error reading is exorbitantly high between the range of 3000-6000, the case is similar with the Balance Point Reading, but this is in the range of 1000-2000 b)The Wheels don't move at the same speed, I don't know whether this is a fault in the motors or L298N (I'm considering the L298N as you also had a similar problem early on in your PART 1 video). I'm extremely sorry if I'm troubling you, but can you please advice on this matter?
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
+Sharan Hegde The situation may not be as bad as it appears. I was able to get similar results to what you are reporting (high Bpt & err readings and wheel motors running at different speeds) by holding my bot (in the air, and way off of what should be the balance point) for a minute or less. So what I would focus on first is, "do the wheels turn in the right direction to bring the car back to level, when they are first energized?" If "No" then look at reversing the motor connections. Depending on how they are currently wired, it may be that you only need to reverse one motor, or could be that both need to be changed, Let me know what you find, and we will go from there.
@slvg-xt4ck
@slvg-xt4ck 9 жыл бұрын
I have replicated your ROBY using an Arduino MINI and two motors and wheels i was having. It seems to work but it is not able to keep the balancing. Surely i have to modify PID but I don't know how also because it is the first time I am working with it. Could you suggest a way? If it is of some help the error i read on LCD at a standing position is 1500-1700, the motors are rated for 77 round/minand the weel diameter is 65mm.The second question is how to calculate the Gyro and Accel offset. Thanks
@jmhrvy1947
@jmhrvy1947 9 жыл бұрын
slvg1942 "...at a standing position is 1500-1700,..." These number sound large. That would imply that the MPU thinks its tilted between 15 to 17 degrees.. I am used to seeing only 3 digit numbers like what you see in the video. There "192" means the mpu thinks it's 1.92 degree off of horizontal. Or another way to say it is the car is leaning forward by 1.92 degrees. for a start, I would disable the motors and maybe some of the code and test how the reading change as you manually rotate the car about the wheel's axles. But assuming that the gyro has been calibrated in level postion, then the number you see on the display at startup (while holding the car at it "balance point")is the number the number (but with a decimal point before the last two digits) that you would normally load sketch variable "PitchBalancePt" with. In my case that was "2.29". As for what are good PID values. I have no easy way of telling you. The best I can offer is start by setting the "Ki" & "Kd" values to 0.0 and make sure that a positive "Kp" value causes the car's wheels to rotate in the correct direction to compensate for it falling. In my case "0.32" ended up being the number I needed for the N20 motors shown in the video. But basically you will want to find the largest value that moves your car the right way. But not so big that the car overshoots and ends up falling backwards to the direction it was originally leaning.. Next, you start increasing the "Ki" & "Kd" values, until you find the combination that works best with your car.. Have lots patience, and build the car so that it can survive many crashes ;-)
@slvg-xt4ck
@slvg-xt4ck 9 жыл бұрын
jmhrvy1947 At first thank for your help. I was checking the rotation angles and i got a little confused. You suggest to mount GY521 component down with Y axis pointed toward the back it means that the X axis is the same of wheel axis. In such a way when the car lean forward or backward is rotating around X axis it means a variation of roll not pitch or am I wrong ? I am not able so see the proper position of GY521 in your video so before making modification on hardware I will wait for your answer. I got your code from github . The following instruction //setup PWM frequency to ~60Hz for OutPut pins 13 & 11 TCCR4B = TCCR4B & 0b11111000 | 0x06; //Set Digital pin 13 Right Wheel PWM period @ ~2ms is not recognized by arduino compiler because it is setting a CPU register, I have cutted it.
@slvg-xt4ck
@slvg-xt4ck 9 жыл бұрын
jmhrvy1947 At first thank for your help. I was checking the rotation angles and i got a little confused. You suggest to mount GY521 component down with Y axis pointed toward the back it means that the X axis is the same of wheel axis. In such a way when the car lean forward or backward is rotating around X axis it means a variation of roll not pitch or am I wrong ? I am not able so see the proper position of GY521 in your video so before making modification on hardware I will wait for your answer. I got your code from github . The following instruction //setup PWM frequency to ~60Hz for OutPut pins 13 & 11 TCCR4B = TCCR4B & 0b11111000 | 0x06; //Set Digital pin 13 Right Wheel PWM period @ ~2ms is not recognized by arduino compiler because it is setting a CPU register, I have cutted it.
@jmhrvy1947
@jmhrvy1947 9 жыл бұрын
slvg1942 Yes. You are correct my GY521 is mounted so that X axis is in-line with the Wheels. And the Y axis points to the back of the car.. If yours is mounted some other way, then rather than changing the location of your MPU, it may be easier for you to change the code (by changing signs and or Array elements) that are being used to sense what is happening to the car. As for the code issue (TCCR4B = TCCR4B & 0b11111000 | 0x06; ), that is because the "Mini" has a different set of timing control registers from what is found on the Leonardo. So for your car, you are correct to comment this line out, and at this point, not worry about it. If you are using Pins 5 & 6 for PWM then I think you would be getting very similar results to what I have using pins 11 & 13 on the Leonardo. Or another option for you, could be to use 3 & 11, plus the code "TCCR2B = TCCR2B & B11111000 | B00000011;" See : arduino-info.wikispaces.com/Arduino-PWM-Frequency It sounds like you are pretty close to having all the parts in place. Let me know how it works out.
@slvg-xt4ck
@slvg-xt4ck 9 жыл бұрын
jmhrvy1947 Ok one bug is out. I was using pins 10 and 11 for PWM but they are controlled by different timer so i have modified using pins 3 and 11. AXIS. I was quite confused about axis because I was using the Eulero convention . Just to fix the point, assuming the Z axis perpendicular to the plane of GY521 PCB and a vector with origin (0,0,0) the pitch is the angle done by the vector an the plane xy or if we prefer is the bent of our car referred to the the plane of wheels and Yaw is the angle between X axis and the perspective of the vector on plane xy or if we prefer is the steering of the car. I have installed GY521 with components up instead of down, but I presume there is no difference inverting Z axis Give me some time to digest and test then i shall report if it is standing or not.
@a.sanusinazareth9213
@a.sanusinazareth9213 Жыл бұрын
I also built one using small dc motor like you n20. By the way, I use nano 168p and your code looks enough to store it, but it doesn't work. 328p can work very well. Really, I still don't understand the minimum requirements of mid-project like that.
@jmhrvy1947
@jmhrvy1947 Жыл бұрын
First & foremost, always appreciate folks taking the time to share their experiences. My guess as to why the code failed to work today, on a different MPU. 1. Parts of it were written specifically for the atmega32U4. and 2. The code , now 8 years old,. is trying to link to libraries that have, in all likely hood, been revised a number of times since then. All too often a revised library isn't backwards compatible. Rendering code that once compiled and ran fine, useless. Not complaining. Its just the way it is
@a.sanusinazareth9213
@a.sanusinazareth9213 Жыл бұрын
@@jmhrvy1947 Then I think I must learn a lot about programming and try to build my own library the best I can. Thanks soooo much for your reply.
@FrankLopezx
@FrankLopezx 9 жыл бұрын
have you used the nRF24L01+ with this setup ?
@jmhrvy1947
@jmhrvy1947 9 жыл бұрын
Frank Lopez No, I haven't. To be honest, until you asked the question, I wasn't aware of it's existence. Just did a quick look, and it certainly looks like it could be a good solution for those projects where you want/need remote monitoring/control. Especially where distances exceed that of Bluetooth. Thanks for bringing it to my attention. I may order a couple just get a better understanding of what they can do.
@FrankLopezx
@FrankLopezx 9 жыл бұрын
oh please do, they are cheap i got like 10 for like 7bucks i suggest Ebay or Banggood.com they have good rep and support. im trying to wireless have this same control over Dc motor or even stepper motors tho they is alot of videos out there no one seems to explain this the right way? and when they do its vague and no reply "sorta just showing off" no means to help others. tho i have done what you did using servos i can manage the merge of the nRF24L01+ example code with this type of sketch you have., maybe we can email each other and you can help me achive this and by thus you will see that it is something worth the buy and im only saying that cuz you are a better/exp coder as im sorta new and this datasheet for the nRF is not really to beginner friendly tho is not about the datasheet is about the arduino structure and i dont really know how to structure it well
@jmhrvy1947
@jmhrvy1947 9 жыл бұрын
Frank Lopez Ok....There's a pair headed this way. Will let you know when they arrive... You're right,, they can be had for very little money, So couldn't resist the opportunity to see what you can do with them.
@FrankLopezx
@FrankLopezx 9 жыл бұрын
jmhrvy1947 sure thing hit me up when you work something out.
@FrankLopezx
@FrankLopezx 9 жыл бұрын
jmhrvy1947 another thing i wanted to ask about those drivers you using the red board with the L298D i think it is>? is your jumper on ? or off? cuz mines i got 4 and none work without the jumper tho im feeding it 20volts and i think it says to remove IF using voltages greater then 10-12v ? and if using less then leave on so you can regulate 5v to arduino
@hieppham1484
@hieppham1484 8 жыл бұрын
Yeah i very interested yous balancebot, but i never programming before... but i can understend about electronic....my board is arduino UNO. can you help me for my balanbot running,,, give me code for it. Thank alots
@BYAZIT
@BYAZIT 9 жыл бұрын
Great work! I am doing similar project with MCU6050+ Arduino Nano v3. Can you please share your code?
@jmhrvy1947
@jmhrvy1947 9 жыл бұрын
Byazit Bostami By now you may have already found it, but not, go to: github.com/jmharvey1/Arduino-BalanceBot There it will give you a link to down load the code & a schematic of how mine wired. Your Nano should work just as well for a project like this, but the sketch was written around a Leonardo, so it will most likely need some changing before it will work with what you have there. Let me know how your project turns out.
@BYAZIT
@BYAZIT 9 жыл бұрын
As soon as I get some success...I will share with you... I am also thinking of making the BIG one :) where did you buy those motor and driver? Can you share with me? I am not annoying... Right!!!
@jmhrvy1947
@jmhrvy1947 9 жыл бұрын
Byazit Bostami "where did you buy those motor and driver?" Through EBay The Drivers are: Dual BTS7970 68A Motor Driver Drive Module H-Bridge PWM Control robot and the Motors are listed as: 24V 350W Electric Motor W/ Gear Reduction Razor Dirt Quad Scoo 24 Volt 350 Watt The BTS7970 has more than enough current handling ability, but when used with a 6 cell lipo battery (24V) you will be right at their Voltage limit, I used a pair of TVS 1.5KE15CA TRANSZORD in each motor circuit to help ensure they didn't see more voltage than the could handle... So far that has worked without failure. For motors, I originally considered "used" wheel chair motors, but because of my limited building skills and limited specs, I opted for the above. I found these had plenty of low end torque, but lacked speed. They work very well as "proof of concept" components. But if I had it to do over again, I'd probably use 500 watt motors, but without the internal gear reduction.
@DarcyWhyte
@DarcyWhyte 6 жыл бұрын
Did I understand you're not using encoders in the wheels?
@jmhrvy1947
@jmhrvy1947 6 жыл бұрын
Yes... That's correct. No encoders.
@phamdacphuoc1995
@phamdacphuoc1995 8 жыл бұрын
That's great, but why do you use both pitch and yaw ? i think it needs only one DOF to perform. And the center of gravity, is it better high or low ?
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
+phamdacphuoc1995 That's a good question. And you are correct, for balance one DOF is all that's needed. But to ensure that both wheels move together, I read the YAW of the car (Bot) as well. Otherwise using a simple common throttle signal, may cause one wheel to move, while the other might not turn at all. (i.e. one wheel is on a smooth surface, and the other is not) Hope that makes sense, and again good question
@phamdacphuoc1995
@phamdacphuoc1995 8 жыл бұрын
+jmhrvy1947 Thank you. I got your idea. And how do you think about center of gravity? since my project use the "yellow" motor same as your, and its center is high, and i don't know if that is the reason why my robot is not stable =)
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
+phamdacphuoc1995 Actually the higher the CG the better. Thats why a broom is easier to balance than a tube of the same length. As for getting better performance (balance) You probably need to keep working on the PID values. I played with mine for hours, and found that I needed different values for the Yellow wheel set than what was optimum for the N20 wheels.. Almost any physical change to the car will mean that the PID values need to be tweaked (along with the Bpt setting). In general, as long as you can control it, more power, means more stability.
@alessandr2012
@alessandr2012 6 жыл бұрын
the center of mass are too high and this condition make the control more difficult.
@jmhrvy1947
@jmhrvy1947 6 жыл бұрын
Not really... Try balancing a broom on the palm of your hand with the heavy end down
@sapankotak3777
@sapankotak3777 8 жыл бұрын
hello jmhevy1947 thanks for share this amazing project i want to learn about arduino program of that Balance robot and also mpu6050 so if you have any video or any think then pleas help me
@jmhrvy1947
@jmhrvy1947 8 жыл бұрын
Glad you enjoyed the video. As for wanting to learn more. The link to GitHub found in the introductory comments will take you to a copy of the source code (sketch) used here, as well a wiring diagram for the Bot/Car. Also if you haven't already done so, check out Part1 of this video. It talks about using the TeaPot program which is a good first sketch for working with the 6050MPU I wish you luck with this project
@escapevelocitylabs166
@escapevelocitylabs166 7 жыл бұрын
Very well done video and talk. What was the most difficult aspect of your bot? For me, it was dealing with sensor noise. I've made progress on my 6-foot tall balancing bot and just got my XBEE remote controller in there. Here's the result: kzbin.info/www/bejne/h3nFapiPdt56gMU
@jmhrvy1947
@jmhrvy1947 7 жыл бұрын
Very nice! You've raised the bar in the "how high can you go" category ;-) You asked what was the most difficult part. Thinking back on it, there were number of challenges. But solving each one was always rewarding. And once solved that problem seemed like no big deal. But from a physical point of view, the wheel drive units (used in the above video) had non-linear response (dead band, and gear backlash) and were under powered. So working out a control algorithm that responded smoothly enough to keep the bot balanced, both while still and when in motion was probably the trickiest part. And to clear its still easy crash the this bot (while using the remote controller). But that's another video ( kzbin.info/www/bejne/pmbHlZ2vqtNkh8U) Again, nice job with your project & thanks for sharing it.
@huongvpvlog3334
@huongvpvlog3334 7 жыл бұрын
C: \ Users \ MINH10 ~ 1 \ AppData \ Local \ Temp \ arduino_modified_sketch_280400 \ sketch_jul04a.ino: 2: 29: lỗi nghiêm trọng: Adafruit_Sensor.h: Không có tập tin hoặc thư mục #include ^ biên soạn chấm dứt. trạng thái thoát 1 Lỗi biên dịch cho bảng Arduino Nano.
@huongvpvlog3334
@huongvpvlog3334 7 жыл бұрын
ban xem cho minh cai loi nay
@mkschreder
@mkschreder 7 жыл бұрын
Most of the code on the internet is stupidly written so you waste hundreds of thousands of cycles just doing nothing (busy waiting). If you code against an rtos you can easily interleave the pid and the display updates. Thats the solution you are looking for.
@jmhrvy1947
@jmhrvy1947 7 жыл бұрын
Interesting comment. Wasn't aware of the library.. Next time I do something like this, I'll look in to it Thanks for sharing.
Balancing robot final year project
8:36
József Fekete
Рет қаралды 219 М.
Sigma Girl Past #funny #sigma #viral
00:20
CRAZY GREAPA
Рет қаралды 33 МЛН
Василиса наняла личного массажиста 😂 #shorts
00:22
Денис Кукояка
Рет қаралды 10 МЛН
路飞被小孩吓到了#海贼王#路飞
00:41
路飞与唐舞桐
Рет қаралды 19 МЛН
How to Balance Robot PID tutorial in under 2 minutes! #BalanceBot
1:52
Simple 3D printed mini balancing robot
3:39
Axel's DIY
Рет қаралды 63 М.
Simple Arduino Robot uses a MPU6050 to manage steering
8:02
jmhrvy1947
Рет қаралды 25 М.
Self Balancing Robot | PID Tuning
5:59
Viekash Vinoth Kumar
Рет қаралды 10 М.
making a Balancing Robot (part 2)
3:20
Kris Temmerman
Рет қаралды 108 М.
Codesys Powered Self Balancing Robot
4:30
WickedLabElectronics
Рет қаралды 247 М.
Balancing Robot with PID - Mini Robot PCB
17:29
Electronoobs
Рет қаралды 45 М.
evoBOT - a Self Balancing Robot That Can Grasp and Carry Cargo
2:09
Arduino Unboxing: Self-Balancing Robot Kit ELEGOO Tumbller
15:38
Geek Detour
Рет қаралды 98 М.
КРУТОЙ ТЕЛЕФОН
0:16
KINO KAIF
Рет қаралды 2,5 МЛН
Simple maintenance. #leddisplay #ledscreen #ledwall #ledmodule #ledinstallation
0:19
LED Screen Factory-EagerLED
Рет қаралды 24 МЛН
Опыт использования Мини ПК от TECNO
1:00
Андронет
Рет қаралды 558 М.
Собери ПК и Получи 10,000₽
1:00
build monsters
Рет қаралды 2,2 МЛН