Another Arduino project - Your Arduino Balancing Robot (YABR) - Part 2 - explaining the code
HTML-код
- Опубликовано: 4 июн 2017
- In this video I explain the setup part of the main balancing robot program.
The Excel sheet, the MPU-6050 datasheet and MPU-6050 registermap that I used in this video can be downloaded here:
www.brokking.net/yabr_download...
A detailed built tutorial, drawings for the frame and electrical schematics can also be downloaded from my website:
www.brokking.net/yabr_main.html
If you have any questions please check the Q&A page first:
www.brokking.net/yabr_qanda.html
Arduino Balancing Robot Part 1
• Another Arduino projec...
Arduino Balancing Robot Part 3
• Arduino project - Your... - Наука
Excellent series. Well prepared, well scripted, explained at just the right speed, in the right order, without distractions or repetitions. Also, complex enough to be interesting. Great work, Joop; I'd say you deserve more subscribers!
Really very good explanation! I like this detailed, in-depth style involving the datasheet. Thanks for this!
Thank you so much Joop for making this video! I have been searching and searching for weeks to try and understand HOW THE HELL DO THOSE DAMN BALANCERS WORK.... AT LAST...you've made a video a normal human can watch and understand.
I have been watching and thinking WOW, what an organized mind and such a well thought out, on-track, clear and concise delivery of some very complicated information.
Who cares about the hardware...that's the easy part...it's the software that nobody seems to want to share. Thank you!
Thank you for such a great effort.
Any comments you receive that are not 100% positive and supportive...ignore them completely...you did GREAT work here my friend!!!!
I have built YABR and it is working great ! It's wonderful ! Thank you so much Mr. Joop !!
Mehr als nur interessant, zumal der eigene "Hirnschmalz" mal wieder dazu angeregt wird mitzudenken.
Auch wenn ich nicht vorhabe, einen solchen Roboter zu bauen, war alleine deinen Erklärungen und den Zusammenhängen der einzelnen Faktoren nachzuverfolgen.
Danke dir Joop !
15.06.´24
iam officially ur subscriber after i hear ur first 5 minutes in this video. Thanks for sharing us such an amazing project with very detail explanation
Your vids are awesome! Incredibly interesting! Until now I had only watched them with interest, but I might finally buy some parts and follow along.
Brilliant! Thanks for sharing your code following with a such detailed explanation!
loved it it was completely thorough. i made a 16 min video last 3 hours but i understand ever line. Thank You.
Hello, thanks for the video. I have a question: at the beginning you said wheel travels 0.2 mm per pulse but on excel sheet you wrote there 16.02(cm) x 1000(1/second)pulse. 16.02 cm was the distance traveled by the wheel after 800 pulse. it does not change behavior of the graphs, just a constant but did i miss something here?
Great video, waiting anxiously for the next one. Tks
As always, excellent job!
love your videos and all projects ..big fan. For my own learning how did you define the controller limit to 400?
Thank you very much. Isn't it berrer to calculate 512 times and use ring shift, instead of 500, and could remove division which is hard procedure for mcu?
I would like to know why you used the values for the excel sheet to make the logarithmic function linear.
Thank u so much, very Well explained, perfect Mr Joob
Thanks. Great explanation - two thumbs up.
Thanks for grate video and code. learning loads, on my setup, if I Serial.print (angle_gyro); Idont seam to get the gyro angel if anything it is the angle divided by 10. this is true when Start is 1.
any thoughts?
Cheers
Rob
awesome serie of videos, just one question i didn't find on the FAQ, If I want to use a cnc shield which has a slightly different pinout for X and Y where else besides the basic function should I tweak in order to make it work, since I mapped accordingly but seems wasnt enough, Thanks, in advance.
Hi Joop, at 2:24 u speak of 4ms and a frequency of 250Hz. How did you calculate the 4ms and what does it really mean?
Thank you for your perfect job. project 28byj-48 or DC motor ?
Great project and great video - very open and easy to follow, thanks. How easy would you feel it is for a beginner to port this to MicroPython on a Pi Pico?
The whole idea of this project is great. Though, what i wanted to accomplish was to understand the whole PID output and how it works. My goal is to programme this robot on my own. These 3 videos are not enough and contain many lacks and not precised information. I bet, almost nobody understand your excel sheet since it isn't described at all. Here comes my X hour of trying to understand what exactly the PID output means, how these undescribed values work and how to adjust them in my case. Wish me luck!
In 1:56, the travel distance in cm/s should be 20 cm/s right? 1 pulse = 0.45 degree = 0.2mm. With Period of 1 millisecond to complete 1 pulse, 1 second = 1000 pulse. 0.2mm*1000 = 20cm? Correct me if i am wrong
Nice educational video. Thanks for detailed explanation.
Is it not possible to use the reciprocal value again to get a straight line? (in excel)
Hello,
Thanks again for your videos :)
In the video, you are making lots of calculation depending on the frequency of the chipset of Arduino (seems to). Does it make any difference if I use an Arduino Nano (because the frequency seems not to be the same) ?
Cheers,
Does it matter if i put the imu in other orientation as yours in my robot, or i must to change the registers in the code ? Mine is using Y axis as setpoint, Thanks.
Hi i am trying to make something like this myself, but i have hit some of a snag. How do you manege to remote control it as done in the prevous video. As from what i understand, the only thing that keeps the robot from falling when center of gravity is off is the acceleration.
as always, very nice video. thank you :D
HI
you did something between 3.00 and 3.30.
some mathemagical slight of hand
to get from a bent line to a straight one
I am thinking you could make yet another video on just this little bit....
Awesome video
Many thanks
Hi the accelrometer Callibration value is the balance value from hardware test right?
Great explanation thanks
Is the wheel diameter plays any role in code
Tried with 75mm wheel and slowly robot moving forward without external input
I haven't looked closely at his code, but I suspect that the target balance point is a tiny bit off causing robot to lean slightly off balance. I'm thinking that this would cause it to continually move as it keeps correcting for the slight I'm balance.
even i have the same problem..used 70mm wheels and the robot slowly moves forward without external input..did u manage to solve the problem..if yes could u plz tell me how.plz do reply..thanks in advance:)
@@mikebrown7366 Tried with 70mm wheel and slowly robot moving forward without external input.did u manage to solve the problem..if yes could u plz tell me how.plz do reply..thanks in advance:)
I really like this project and am in the process of building it myself, it's very fun!
Thank you for taking the time to explain the code, I understand some of it, but with all such videos I'm left foundering after a few real tech points. I just keep watching them and hope to pick up a little knowledge from each lesson until I learn.
Can you please explain in simple terms what registers are and how they work?
Check this video about registers that I made earlier: ruclips.net/video/8aMsJWpXyE8/видео.html
Hi, may i know what we do if i change position the mpu6050 board, like a vertical position ? many thank you
Finally awesome
Unfortunately, I have a lot to learn before I can make use of your projects, I can only dream of making my own arduino robots, however your videos are perfect, and I'm a huge fan. If I could ask a question, it would be, can you recommend learning materials such as books or graded projects that would help me go from blinking an led to familiarity with drones? Do you have a professional education?? What did it entail?
Good video and everything should work if someone builds the exact replica of yours. I'm using 145mm wheels , with robot standing about 1-1/2 meters high. Is there ANY compensation I have to do for the bigger wheels? I duplicated your Excel spreadsheet with my numbers, but when you did the compensation, the distance travelled column disappeared.
I've been struggling to get this to work on an Arduino Micro. I think the issue lies with using the TIMER2 interrupt. Is there a way to modify your code so the Micro can execute it?
Hello i am trying to build my gimbal with stm 32 i have motors and frame but i need controller i am going to buy arduino stm 32 and mpu6050 any suggestions ?
I have a question. Registers 0x43 and 0x44 are the x axis values of the gyro. You refer to them as a YAW but the x axis is the ROLL component. So do you mean ROLL? Also in code line 91 your comment is wrong as 0x43 is not the "WHO AM I" register. Thank you
amazing... great explanation :)... jsut one request... can you make the next video before friday ? :D
I'm going to a hackaton event and want to build a self balancing robot... would be great if I understood the main loop beter before I start there on friday :D
Thank you very much for you explanations , i still confused about how magically you obtained values 405, 9, 5500 to compensate logarithmic speed increase in 3:30 ?
Joop Brokking: "The 405, 5500, 9 are values to counteract the non linear behavior. It's not calculated via some interesting method. I just puzzled with Excel until I got a straight line.
Same with the PID values. I't just a matter of experience I think."
sir i have stepper motor 17Pm-k103-19V can i use it but it doesnt sense 20us pulse what to do for it plz help me
Welcome, first of all I would like to congratulate you for your mega project. A piece of good work. But I have a question about the values used 405,5500,9 where did you get these values or how did you calculate them? I compared these two tables, what are they on the second film and how do I understand the first one of these two values in the second table? I've analyzed this table what is in Exel and I don't understand the value of those values that I wrote above and how did you calculate the values in columns 2 and 3? And how did you calculate the PID values for P, D and I? He lets them help in advance.
The 405, 5500, 9 are values to counteract the non linear behavior. It's not calculated via some interesting method. I just puzzled with Excel until I got a straight line.
Same with the PID values. I't just a matter of experience I think.
My wheel have a 61mm diameter. Where change to compensate it?!
Thanks
Thank you for your perfect job. i cant get a movement using nunchuck, blue blinking on nunchuck and on robot is there when i move the jog. i have used a nano for both, do i have to change the programs? Pls send your email adrss, many thanks
Hello Joop,
I like your video, I have one question: If I use wheels with diameter of 65 mm I need to modify something in the programm?
Thank you
You might get away by only changing the PID values.
very explained video. he has done what i have thought of. do you agree
Can you please give a hint about the method you used to compensate the non linear behaviour? I mean how did you calculate the values 405,5500,9?
I really need to know i have been trying hard to figure it out but no luck...thank you.!
Joop Brokking: "The 405, 5500, 9 are values to counteract the non linear behavior. It's not calculated via some interesting method. I just puzzled with Excel until I got a straight line.
Same with the PID values. I't just a matter of experience I think."
Can somebody help me. I'm using an Arduino Uno with a CNC shield and already changed the according pins and set the enable pin High.
But my steppers are screaming as soon as I connect power to the stepper drivers. Could it be something with the timing?
Any help is really much appreciated.
outstanding videos
Great video series
Kindly explain the source of the 9, 5500 and 405 values that you use in your calculations to come up with a linear system that can be controlled using a PID.
+Joop Brokking
@@rogerodipo3499 Joop Brokking: "The 405, 5500, 9 are values to counteract the non linear behavior. It's not calculated via some interesting method. I just puzzled with Excel until I got a straight line.
Same with the PID values. I't just a matter of experience I think."
Hi Joop,
Thank you for your excellent video.
Have bought the parts to compile my Self Balancing Bot. In addition to controlling via Wii control, would like to add IR sensor for added automation. My design will entail the MPU6050 being position horizontally (instead of vertical). Would like to know is there other area to watch out, apart from axis change for balancing.
Thank you in advance.
If you want to change the orientation of the MPU-6050 you need to change the specific axis of the MPU-6050. Maybe even the orientation.
thanks a lot
Hello, I'm from Brazil and I'm taking a swing following your site! Already finished mounting, I tested all the components on the board and they are all working, but when I load the program that you make available on the site it runs only one side! Do you know why this happens?
Double check your wiring and make sure that all the components work.
hola amigo el Balancing Robot (YABR) como hago para controlarlo con androy
Can you please help me with the code ? I am a starter and I've been looking all over the internet and still I don't have an answer..I can't understand the code and the PID part.
Joop, great video. I've been trying to build one of these for a long time based off the b-robot project with little success. Your code and design was much simpler to follow.
Could you explain more how you came up with 5500, 405 and other values for the linearization? I'm still trying to understand that.
Also, any suggestions for how to do this with a remote that isn't continuously sending commands? I've made an app that sends serial commands but the robot accelerates until it faceplants instead of reaching stable forward motion.
I found the values by playing around with Excel. This is a great tool to get something like this done.
The remote is only sending when the robot needs to move. After that every 100ms a new byte is sent. This must be possible when using an app.
I'm sure that's possible in an app. I just didn't want to have a background thread that had to send the same message over and over again. I'm still trying to figure out why my robot continues to accelerate when going forward instead of reaching a stable speed. Would that require adding another pid loop to control the target speed (as opposed to the target angle)?
As for the excel spreadsheet, I've downloaded yours and tried to understand it. What do the different columns and series represent? Thanks again!
Try to lower the max_target_speed setpoint to get a more stable speed. Slight increase and decrease in speed can be caused by slightly angled surfaces. Not every floor is 100% level.
@@Joop_Brokkingsir ,i know this is a little late to ask u..buut i have used 70mm wheels for my robot and it balances..only problem is it drifts and moves forward without any external input..do u have any solutions as to why this is happeneing..a reply will really help.thanks in advance:)
Hi
First thank you for a fantastic well-written project.
I'm working on a clone of your project.
However, just have a question: Does the wheel size influence the Arduino code? If so, what should be changed?
Because I have chosen Nema 17 stepmotor, and could use a little more clearance under this.
Thanks in advance
You can make the wheel a little taller to match the 45mm size stepper motors. Tuning the PID settings should be sufficient to get it to work.
hi Joop
I will try it out.
Thank you for your time
Have you found a way to change the size of the wheels in your code?
You can adjust your PID variables under "// Various settings" (pid_p_gain, pid_i_gain and pid_d_gain) - the good Joop Brokking has answered this a few times already. Good luck with your project.
Hello, thanks for the video. I have a question, I'have stepper motor step angle 0.9, how to change in the sketch , thank's
Set the stepper controller to half step and you can run the same program without modifications.
Great video and awesome balancing robot you made there sir, I made this robot too. I just had some confusion in the hardware test. After I uploaded the hardware test program, everytime I load the serial monitor, it displays different balancing values for each time I reset the pro-mini. Seems like, it constantly changes its balance setpoint. You have any idea as to why sir?
After I downloaded the balancing robot program and run it, I leans more on forward motions and often moves in imbalanced manner, then dropped.
Make sure you have reliable and soldered connections. The balance point can change a little but not more than +/- 150.
Thank you for your prompt reply. I will carefully scrutinize my soldering job. In the meantime, I'm playing around the balance values with different figures and let the robot run on its own and see how it behaves.
Good day sir, my yabr is balancing now, you're right. I checked my connections and the power supply's amperage and it solved the problem. One problem arose, but maybe because of the cheap, low-quality locally made stepper motor I purchased. It is power hungry and I was forced to supply it with higher current that resulted in the stepper motors and the motor drivers getting hot. By the way I using A4988 drivers. I shorted all three microstepping jumpers and the motors and drivers didn't get too hot, although still getting warm.
Sir, in your schematic, you connected the reset and sleep to the +5v rail. Why did you do so? Is there a specific purpose?
Thank you sir.
myonline He did it to make sure the MCU doesn't reset or goes into sleepmode
How did you get those magic number? Can you suggest some resource to understand that transformation.
It's based on trial-and-error. No reference to anything.
Cool
very cool
Not claiming to bee an expert on programming, but the two variables "throttle_left_motor", "throttle_right_motor" which is set from main loop and read from the timer interrupt should probably be declared as volatile.
Love your work though, very informative and precise at good technical level. Keep it up, and i'am also starting to build my own version of this. I ran in to the "volatile" problem when testing out the timer interrupt routine part yesterday....
I made a video about the volatile 'problem' that you can watch here: ruclips.net/video/o3dcmo-hbQw/видео.html
I tested the code with the original Arduino IDE and it worked. Only if you set the optimizer you probably need to set them to volatile.
Maybee you dont have the problem because your main loop is doing a lot og other stuff too. My Main loop did nothing but some simple increment and decrement off the throttle_left_motor variable. I have no idea about the state of my compiler optimize setting. It is just at default, I never changed it. I will watch that video later today. Maybee I will learn something... 😎
Will this code work using an Arduino Mega 2560?
I set up a robot like this one using an arduino mega 2560 but my stepper motors just get stuck.
The curve looks more hyperbolic than logarithmic to me.
No doubt of it. The linearization is very simple.
can you build 3D scanner
2:04 Linear Line... Don't get me wrong, the video and the explanation is amazing, but that made me laugh a LOT.
Nice video, very well explained. Will have any video explaining the PID ? Thanks
I made this video about PID controllers: ruclips.net/video/JBvnB0279-Q/видео.html
Wow! Thanks. I just have discovered your channel so i didn't had the time to look around for the videos. I will definitely take a look.
how do you set the pid values
Superb video series - thanks. A tiny gripe from a pedant: it's "ARD-WEEN-O" - not "ARD-DREEN-O".
Well, it's a clone so it really isn't a Arduino ;-)
Hahahaha. Excellent.
Can you ad Subtitle? Thank you very much!
I am doing this project but there is a problem I am getting a negative value in calibration and also in gyro x ,please help with it as soon as possible thank you
There is nothing wrong with negative numbers during calibration. You can use them without problems.
bro please help me i am facing some problems with my project can i contact you, please
I wanted to buy tht stepper motor...but it's not available in tht site which u hv mentioned...can u plz give me some other sites! I hv tried searching in many othr site but non of thm hv it!! everything is out of stock 😭
You could also use this one but you need to modify the frame because this one is 4.23mm.
www.dx.com/p/geeetech-3d-printer-reprap-1-8-degree-anti-slip-42yb-stepper-motor-black-370044
Joop Brokking thank you so much brother!
Hello, first of all: very nice video! But i have some questions :)
Im not going to read all the code, but if i understand correctly, you let the PID control the pulsetime ?
Wouldn't it have been easier to let the PID control the motor speed, and then calculate pulsetime from this ?
That's way easier than linearisation methods in my opinion.
I also fail to see the logarithmic part of the function y=1/x ?
Not trying to be a dick tho, your robot balances, which eventually is what matters!
As explained in the video: pulse time equals speed. So it does not matter what you calculate, you always need to compensate for the non linear behavior.
@@Joop_Brokking Hi Joop!
Very nice work and very educative presentation thanks a lot!
I came to the same conclusion as Lennert S. If I ask the PID to calculate the speed like in round per seconds, I can calculate the pulsetime from the PID output and there is nothing to compensate. Am I missing something ?
Anyway thanks a lot for the work it is very instructive !
Hi Joop, your projects are awesome and I'm trying to make my own one of these! But I cannot get hold of the 2.4 wireless modules needed! Any chance you could adapt the code to use a RC receiver input?! I can't find anybody with the knowledge on how to do this...
Lewis
Sorry, the code is as it is. If you want to modify it you need to do it yourself. The transceivers are still available at dx.com.
What is the average cost in total?
In 3 min of film you use excel. In cell 2 you give the pulse frequency. What kind of mathematical formula do you use? How do you calculate and explain what are the numbers 405, 9 and 5500. 3 cell from which pattern you use? Could you explain it all to me? Thank you and I look forward to a fair answer
And explain to me where you got the diameter of the wheel in the code. Or is it in excel? I find that many people who use your solution would like to know how you did calculations in excel. And do not write that it was fun.
You can download the Excel sheet here: www.brokking.net/yabr_downloads.html
You did not answer the question. You provided a link to the file to which I asked the question. Are you able to answer your questions?
Joop Brokking Hi! As the wheel diameter changes do the constants 405,9,5500 change with the change in the diameter of the wheels? Also I'm trying to make your awesome robot with bigger steppers and a tb6560 driver ( because I have high current draw nema23's) will they require a different pulse frequency?
Joop Brokking: "The 405, 5500, 9 are values to counteract the non linear behavior. It's not calculated via some interesting method. I just puzzled with Excel until I got a straight line.
Same with the PID values. I't just a matter of experience I think."
hello! thank you for the video. please I don't no while to download code
Is it working without the nunchuck????
Please reply
yes it works
wt is the running time!! like in minutes?? plz can u sayyy!! plzzzzz
The current consumption is 400mA. The battery is 2200mAh. Total time should be around 4 hours or so.
dear sir,
were I can download the code for this robot
www.brokking.net/yabr_main.html
1:56 should be 0.2mm*B1, it will be mm/sec, not cm
Nice work! I would like to download the source code YABR.zip but it seems that the link doesnt work. Is there a way to get it?
My sever is down at the moment. I hope to get it up and running next week.
Thank You :)
please help me with code ..i need code for this robot.
www.brokking.net/yabr_main.html
I am first viewer
Owsome
ehhhh
Hi Joop, at 2:24 u speak of 4ms and a frequency of 250Hz. How did you calculate the 4ms and what does it really mean?