Great video as always! You must be the only guy in the world who really make true engineering with Arduino... Both in coding and physics, it's pretty cool, congrats ;)
vous n'avez pas poster des nouveaux vidéos, j'ai attendu et je vois conditionnement vos vidéos, tes calculs la façons d’expliqué pas seulement théoriquement comme a enseignement marocain , mais aussi pratiquement, avez vos des nouveaux? un contact ? virement, vous nos manquer.
Electronic stuff has partly arrived, rest is in transit from China. I have made the frame from PMMA yesterday with the lasercutter at Hafven, the maker space in Hannover. Thanks for the teaching!
Thanks again for making this. I made this robot and haven't got it working yet, but the process of going through your code has already taught me a lot of new stuff.
Hey Joop, I found that system looks smoother (especially on low speeds) when I use 'left_motor = 5000/(pid_output_left);' (same for right) instead of piece of code with '405 - (1/(pid_output_left + 9)) * 5500; ... 400-pid_output_left etc'. I was confused about 405, 9, 5500 and figured out that it is better to use pid output as frequency (which is linear function of speed!) instead of pulse length (which is non-linear). So, after that we have freq like 5..400, and calculate pulse length=(1/freq)*1000 miliseconds, and step count: pulse_length/(20 microseconds). 20 microseconds is period of interrupt. In other words, it is 5000/pid_output_left. Why it is not 50000? it should be 50000, but we need extra speed, so we just use 10x faster, 5000.
One more thing to code: The postiton of the robot must only reflect the commads from the radio control, nothing else should matter. So if the robot is moved by external force (pushed or by gravity on a slope), it should remeber the number of steps needed to stabilize and move the same exact number of steps in oposite direction. Very nice video series. Very explanatory. Kudos!
I made the code as easy as possible so others can understand it and make there own features. The code is just to get you started and motivated to explore and learn.
A fantastic set of videos on building this Balancing robot. Parts ordered. Will try and add a App control device to the code. Maybe a RC option as well.
Thank for your share, I'd like to make an auto balancing robot for educational purpose and your code is the most efficient and clear I ever seen. Congrats.
Greate Video. Building one today. One thing about diode current, motor current and diode current are not correlated as you explain because motor voltage is much lower than battery voltage...
Have you considered adding velocity feedback using the pulse count that drives the wheels as a proxy for velocity? Velocity feedback may improve stability of the robot and perhaps allow you to set velocity as a control input to the robot.
Hi, I was just wondering how to use the code you just want the bot to stand and not use a remote. say move forward from within the code. Its for a project I'm doing. I'm fine with it all except I'm not sure how to separate the controller pid code from the rest. Thanks
ik heb 1 klein vraagje. Is er een reden dat het laatste gedeelte, namelijk het stuk dat de puls uitvoert en de richting verandert, niet meer in de void loop staat?
This is great. I will totaly 3D print some kind of robot and do somthing like this. I will try to combine this with ROS. The robot will then be able to map the room and travel from point A to B. Thanks
Hello, I just completed both the balancing robot and the nun chuck. Both the robot and the remote pass the hardware test and the robot balances very well at start up. When I try the nun chuck control the robot does not respond. I know this a 2 year old project but I just discovered it and love it. I suspected it is the 2.4 gig serial transmitter so I replace them and still get no response and I am having trouble finding example programs to test them. Note I am using exactly the units specified and would really appreciate some advice on troubleshooting this last problem. Thanks in advance!
Hi Joop First of all I would like to thank you, this is brilliant, I built one. But, Can I ask if it is possible to change the 2.4ghz transceiver to a normal hobby R/C transmitter/receiver, Instead of the nunchuck and if so how ?, I am new to code and not very good Thank You
Sorry Joop, I appreciate your work and your very good explanation but the schematic here in your Part 3 - YABR-Video(3:56min) is NOT the same like the schematic in your web-site...! Here is the "FAULT"-PIN connected and at the schematic in your web-site the FAULT-PIN is NOT connected ! ...... Wich one should I use ? .......The web-site schematic don't work, connections are checked many times....current is set to 150mA....MPU-value is about 865.....-but motors do not move(NEMA17) . Now I'm not shure if I followed the "incomplet" schematic or the bigger Steppers are the reason for not working........Tomorrow I will try the Part3-Video-Schematic...........
Download the schematics from here: www.brokking.net/yabr_downloads.html The fault pin should not be connected. If you Google "DRV8825" you will find schematics that you can try.
7:02 is a bit confusing because it uses the number 8200. This number is approximately 8,192 according to mpu documents and I believe should be calibrated? or it may change the angle calculation. Took me a second to figure out that this number was coming from page 13 of mpu 6050 datasheet BTW, another awesome video!!
Hi Joop: My robot balances, but does not stay balanced. After a couple of minutes, it takes off, though I am using your code. I am wondering if I need to add velocity feedback using encoders or as I suggested in my earlier comment use the pulse count as a proxy for velocity feedback. I have tried using the pulse count as velocity feedback, but have not had any luck. I may have to spend more time fine tuning it. Your comments will be appreciated.
AMIGO VOCÊ REALMENTE É UM EXPERT NESSE ASSUNTO, ADMIRO MUITO SUA INTELIGENCIA, TE DOU OS PARABÉNS POR SEUS VÍDEOS. SÓ FICO TRITE É PELO FATO DE NÃO ENTENDER SUA LÍNGUA. QUERIA MUITO MONTAR ESSE ROBÔ. ESPERO QUE O UA-cam BOLE UMA MANEIRA DE TRADUZIR OS VÍDEOS EM ÁUDIO, SERIA FANTÁSTICO
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?
Hi Joop, thank you for that great video ,I wonder if I can use steppers with 3.75 degrees step, if yes, are there any modifications that should be applied to the code?
Good day Joop I realy like your projects, I am building the same robot that you have build but I want to run the robot with Bluetooth from my phone ,,,,,, is it possible to install HC-05 Bluetooth instead of the serial connection and do I still have to put the R1 resistor in line ore can I remove it what part of the code do I have to change or remove to replace with Bluetooth code Ad again thank you for your good projects
Thanks joop for your vidéos, great PID code, i have made one with a pro mini 8mhz drived with bluetooth /android and an other with DC motors. Great job !
Have you checked, that the main loop executes in less than 4ms (osciloscope or signal analyzer)? It's seems to be quite long and there is a lot of floating point math, which is really slow. Great project, congrats.
Hi Joop. So I ended up building the robot a little modified in terms of the structure but almost similar. I have not place the battery yet at the top (so it is not top heavy) as I am testing the robot using an external power supply. What I have noticed is while the robot balances, it seems to be running forward continuously. How can i prevent this from happening? One more thing I have noticed is that the hardware calibration value for the MPU6050 keeps changing every time I run the hardware test code. Any idea why?
Make sure it's completely still when running the calibration. And it's normal that you get slight variations when you do this. The robot can only work when it's not connected to any wires. So make sure you get a battery and place it on top. Otherwise the robot will keep moving.
Hello. Thanks a lot for you. I've done YABR about 10 days ago. It's a good balancing car!!! I used RF trans&receiver with joystick as signal sender. The Kysan_Nema17_stepper motor as a actuator. The rest is same with you. Ah, The timer interrupt is good idea! (Very sorry not to be about YABR area) I have a question about YMFC auto altitude process. I had totally understood your YMFC code. Its flying is perfect! I've got data from barometer according to its sample rate . . . about 50hz. And calculated PID value, which is 'pid_output_altitude' . I've added the value each esc_1, 2, 3, 4. esc_1 = throttle - pid_output_pitch + pid_output_roll - pid_output_yaw + pid_output_altitude; esc_2 = throttle + pid_output_pitch + pid_output_roll + pid_output_yaw + pid_output_altitude; esc_3 = throttle + pid_output_pitch - pid_output_roll - pid_output_yaw + pid_output_altitude; esc_4 = throttle - pid_output_pitch - pid_output_roll + pid_output_yaw + pid_output_altitude; Is it right process? Thanks a lot although any other trivial help!
I did it already through try and errors. Thanks. Because of your advice and hints in the video and blog, I always obtain energy. Thanks again. Nowadays I am writing RTH function with HMC5883 & GPS. It's hard to write my own code without any help. (In fact your help is only one.) When I calculate the direction of Quad, the PID control is likely also needed. Is it right?
Hi, I am following your interesting MPU6050-projects on UA-cam. I am currently building a Segway clone, using MPU6050. But I try to use the onboard Digital Motion Processor to read the filtered pitch angle directly. I am curious why people dont seem to be using the DMP-values. What are your experiences? Is there a catch maybe?
I never tried the DMP because when I was starting with the MPU-6050 the library was reversed engineered and not very stable. And more important, I like to make/write my own IMU :-)
Thanks for the video! This really helps understand how your code works. That said, I do have a minor issue. When my robot reaches max speed, suddenly the control loop seems to stop the motors and the robot falls over. This happens bot forward and backward. If I increase the max speed, it happens at a faster speed. Any idea what might be causing this?
Can anyone tell me how he got the equation for linear compensation of the stepper motor?....im using a 5.18 : 1 planetary geared nema 17...is it the same equation?
I built the robot and it balances beautifully, but I'm struggling hopelessly with the remote. I've now bought eight of the transceivers from three different suppliers in two countries and I cannot get any of them to talk to each other. The nunchuck is sending 1, 2, 4 and 8, but I might as well have a piece of damp string between the remote and the robot as the transceivers, for all the good they do. Did you have to make sure your transceivers had the same IDs or change any other settings to get them to talk to each other? Do you have any suggestions for how I might test them? Sadly, these transceivers do not feature much on the internet - everything seems to be more centred on the NRF24L01. I've downloaded the manual for the Open Smart ones, but that hasn't been any real help at all.
There is a blue led on the transceivers that will lit when they receive or transmit data. So you can send data via the serial output of the Adruino and check if the led on the other tranceiver starts to flash. I bought 4 of them and they all worked fine without any settings. Make sure you use 9600bps.
Sorry it's been so long in following your suggestion (but I've been building a copy of Ben Eater's 8 bit computer - brilliant!). However, I'm back struggling with the remote again. Yes, both the transmitter and the receiver blue LEDs flash when I operate the nunchuck, but the robot does nothing other than balance itself. The LEDs aren't very bright, but they do light up
Joop Brokking Hi Joop I have the same problem the robot stands still the remote is making connection flashes blue on robot and Nunchuck but there is no movement at all can you please advise
Hello, your explanation of your code was very good, thanks for your hard work and sharing it with us. I do have a question if the robot travels on a surface that is not level say the right wheel is elevated above the left ( not front to back level, but right to left unlevel) will the software compensate to this and keep the robot balanced? Again thanks.
Hey Joop, your work is realy the best ever. I build this bod and now it is running. But i used finlay a Bluetooth module and a handy app to control. One question i would have. Your code use the motors with 1/4 steps. If i change the motor controller to 1/16 steps, the bod is not able to be at zero. I assume it have to do with the 20ms IRQ routine? My reason to try 1/16 steps is the noise of 1/4 steps configuration. Could you give an hint on what would be necessary to change on the code, to can use the motor controller with 1/16 step configuration? Many thanks Rainer
Thanks for the great tutorial. I did build the robot and am facing some challenges. MPU is working fine. The pid_output increases and clamps at 400 all the time it never comes down even if i change the robot orientation manually. Any pointers to see what could be wrong. angle_gyro responds well. The other problem that i have is my stepper motor stops responding when the throttle variable is beyond 325 i just hear the PWM sound. Thanks in advance for any directions.
It's normal the the PID output is maximum all the time. This is because the robot is never in a 100% horizontal position and the I-gain is really high. Best way to test the PID controller is to set the I- and D-gain to 0. This way you only see the error. This might help you. If you only hear the PWM sound it means that the stepper motor cannot keep up with the signal and comes to a standstill. Make sure to set the correct stepper modes.
Great project! I love this! I'm making the balance robot using DC servo motor. I'm using data reading from DMP of MPU6050. It currently can balance itself but I feel it's not perfect and there is many thing to do with it. In of them is that when I pushed it in a direction with plenty of force it was easily fallen or it moved with max speed til falling. Could you please help me to implement the brake function for my robot. I didn't use remote control as I will be next goal after the balancing work without problem. Thanks in advance!
Wow. Really impressive implementation. Where did you get the informations about the formulars for the motor pulse calculation? I would like to comprehend why you choosed numbers like the 400.
Hi Joop! Great video and very educative! I have made an auto-balancing robot inspired in yours for a project for a class. The only differences are: -> I am using arduino Nano instead of mini pro ->My motor is not a Nema (your motor doesn't have specs, but looks like a NEMA). My stepper motors are Mitsumi M42sp-6tg from old printers wreckage. -> I have built the rest of the project just like yours, using the same pinouts in the board. My project is simpler than yours, I don't have the remote control stuff and my objective is to only get the robot balancing to stand still alone. Apparently, running your code makes my robot to keep the wheels stuck, but with no movement at all. Could you help me, please? Thank you!
Hello. Thank you for your great video. I have build my balancing robot based on your documentation. Everything works fine exept the transmission causes problems. I have used you original code in the nunchuk and in the robot. But there must be something wrong with the code. The robot only turns in one direction. Moving forward and backward command will not be received by the robot. Unfortunatly it is a litte difficult for me to debug the problem. Any Idea how I can find out where the problem comes from. BR Andreas
Hi, i changed the code in line 225 from if(!(received_byte & B00001100)) to if(received_byte & B00001100) but i replaced the also the Nunchuck version with an handy app input
Good project! 😉 What software did you used to design the the frame for the plywood? If not open source, what open source software do you advise for that type of job?
Thank you for your video. I have some question. Can I put the difference MPU-6050 alignment on my robot? I mean, your video put in a vertical line but I have to put mpu-6050 in a horizontal line.
Hi Joop. This is great tutorial. Appreciate so much! I used Arduino Mega for my robot. Can you help me what should I change in code if I still use Mega board instead of Nano?
Hey, Awesome video! I plan to make a system similar to this, but I want to mount my board Horizontally rather than vertically. All the components will be in the same orientation as your board though. Looking at the code, all I would have to change are the I2C Registers we pull data from 3F -> 3B (To pull Accel Data from X axis rather than Z) and then the Gyro Registers (which I'm not entirely sure about what I need to change from, as it makes my head spin a bit at the moment, haha). Does this sound correct to you? Thanks for the awesome videos!
Great project! I build your robot from steppermotors I had from other project and printed the frame with 3D. All other parts are as your robot. I have a problem regarding the stepper motor frequency. My stepper motor work with a max. stepper frequency of about 2kHz. If I measure the stepper motor frequency of your software it is in a max. about 5.6kHz. So motor does not rotate and robot is not working. I measured ISR tick, which is the 20microsec and also the main loop is 4millisec. I tried to find a parameter to limit the max. stepper frequency to 2kHz but couldn't solve the search . Any help from the experts, which parameter I can align. Thank's Wolfgang
Hello, i have a question. In your case, the main loop frequency its 250Hz, but in my case, im datalogging in SD Card the MPU and GPS, what means the main loop frequency isnt 250Hz, so, i can calculate the angles with my own frequency loop, right? the only thing that means, ill have a bit more error if the frequency be higher than 250Hz?
If you are using a higher refresh rate the calculations need to be optimized for this refresh rate. Make sure that you have a constant refresh rate/loop time.
Hello Joop, I'm your big fan and I'm about to buy all the components necessary to build my balancing robot and also a drone. Just as a doubt, If I want to build an overboard, do you think that this code could works? Of course, adjusting the diameter of the wheels and big battery. Also, which drone do you prefer, the octocopter or the quadcopter? Which one provides you a better performance? I really appreciate your help, thank you regards!
The code can be used to measure the angle but not for controlling a hoverboard. You have to modify the code yourself. Quad or octo depends on what you are going to do with it. If you are starting I would suggest a quadcopter. This is cheaper to fix when you crash.
Hi Joop! I love your videos, and I love the YABR especially. What an amazing design! Mine is completely built and working now (happily balancing!) but I have not yet connected the radios for remote control, because I would prefer to use a bluetooth radio or NRF24L01 radios. Have you tried these or is there a reason not to? Thanks!!!
This is amazing! As somebody who knows little about this kind of programming, do you think it could be scaled up to a robot approx. 30cm tall? I want to create a working model of the robot from my comic strip. Thanks!
Hi Joop, can you expand on the part about "logarithmic behavior of stepper motor speed vs pulse train"? I'm trying to figure out what this line means: if(pid_output_left > 0)pid_output_left = 405 - (1/(pid_output_left + 9)) * 5500; Where do the 405, the 9, and the *5500 come from? What is this equation derived from? Thanks
Ah I see, it is non-linear because you are changing the period between pulses correct? ie, your output is 1/x. If I am varying the frequency of pulses, that should already be linear right? Since varying the frequency is directly varying how many steps per second the motor is receiving?
Hi i Like all you videos. :-) But i have a quistin. I like to use BL but my BT app can only send karakter, like a "a" "b" "c" and so one, how do i convert them to bit.?? And also what do the line. if(!(received_byte & B00001100)){ //Slowly reduce the setpoint to zero if no foreward or backward command is given if(pid_setpoint > 0.5)pid_setpoint -=0.05; //If the PID setpoint is larger then 0.5 reduce the setpoint with 0.05 every loop else if(pid_setpoint < -0.5)pid_setpoint +=0.05; //If the PID setpoint is smaller then -0.5 increase the setpoint with 0.05 every loop else pid_setpoint = 0; //If the PID setpoint is smaller then 0.5 or larger then -0.5 set the setpoint to 0 } You skip this part :-)
Hello. Thank you for your great video. I have build my balancing robot based on your documentation. I use NEMA17 SX17-1005LQCEF engines - 1.8 ° (200 Steps on full rotation). Will they be good for this project?. If not, could you tell me how to make the correct code for these motors?
whats this guys profession, how can i be like him like knowing all this stuff about microprocessors and electronics; should i apply for embedded systems jobs or i dont know who does that white good companies, aerospace companies. Can anyone help?
Your Videotutorial is probably the best and most thorough I have ever seen. Keep up the great work! What I do not understand is, however, why it is important for you to keep the frequence of loop() constant. Is there any specific reason?
battery_voltage = (analogRead(0) * 1.222) + 85 if analogRead(0) = 1023 then battery_voltage = (1023 * 1.222) + 85 = 1335.106 does that mean battery voltage equals 13.35 V?
Hi Joop, Thank you very much for your effort in producing the entertaining and educating videos. I learnt a lot. After watching all three YABR videos, I realize that so long as the robot is self balancing on the pitch axis, the hardware setup procedure will take care of the normal balance position. so no code change is needed even the MPU6050 is positioned horizontally at setup (instead of vertical). Grateful if you could confirm my understanding. Thanks,
The position of the MPU-6050 is very important because the accelerometer is needed for compensating the gyro's drift. As explained in detail in this video: ua-cam.com/video/4BoIE8YQwM8/v-deo.html
ok, I mounted the MPU6050 vertically. Another question - will e the robot's weight distribution along the pitch axis affect the performance. I could imagine the power use is increased, pls share your thoughts.
Hi Joop, Completed the built, hardware test program run ok, and generated a balancing value -1319 (negative). My MPU5060 is setup vertically by attaching it to an angled stand, the pcb and other components are mounted horizontally. Wondering why a negative value?! Followed the procedure to limit DVR8825 current. After changing the balance value in the Balancing robot program and upload. Powered the robot by 12V lipo, the robot cannot balance. Try to reload the hardware test program, but this time, encountered upload error: "Verification error content not match". Research the web indicates an upload reset issue, what is your view on this?
Deal extreme is out of the stepper motors. Maybe someone could list the nema14 motors they used from Banggood or a different source like Amazon. I have everything made I'm just waiting on the motors.
You could also use these: www.dx.com/p/geeetech-3d-printer-reprap-1-8-degree-anti-slip-42yb-stepper-motor-black-370044 But please note that these are 42mm in stead of 35. So you have to modify the frame.
Great video as always! You must be the only guy in the world who really make true engineering with Arduino... Both in coding and physics, it's pretty cool, congrats ;)
vous n'avez pas poster des nouveaux vidéos, j'ai attendu et je vois conditionnement vos vidéos, tes calculs la façons d’expliqué pas seulement théoriquement comme a enseignement marocain , mais aussi pratiquement, avez vos des nouveaux? un contact ? virement, vous nos manquer.
Electronic stuff has partly arrived, rest is in transit from China. I have made the frame from PMMA yesterday with the lasercutter at Hafven, the maker space in Hannover. Thanks for the teaching!
Thanks again for making this. I made this robot and haven't got it working yet, but the process of going through your code has already taught me a lot of new stuff.
Good job, this is one of the best arduino videos I've ever seen.
Man: your channel es incredibly serious and rigorous.
MY RESPECTS !!
Hey Joop, I found that system looks smoother (especially on low speeds) when I use 'left_motor = 5000/(pid_output_left);' (same for right) instead of piece of code with '405 - (1/(pid_output_left + 9)) * 5500; ... 400-pid_output_left etc'. I was confused about 405, 9, 5500 and figured out that it is better to use pid output as frequency (which is linear function of speed!) instead of pulse length (which is non-linear). So, after that we have freq like 5..400, and calculate pulse length=(1/freq)*1000 miliseconds, and step count: pulse_length/(20 microseconds). 20 microseconds is period of interrupt. In other words, it is 5000/pid_output_left.
Why it is not 50000? it should be 50000, but we need extra speed, so we just use 10x faster, 5000.
Can you show it in program? :D
One more thing to code: The postiton of the robot must only reflect the commads from the radio control, nothing else should matter. So if the robot is moved by external force (pushed or by gravity on a slope), it should remeber the number of steps needed to stabilize and move the same exact number of steps in oposite direction.
Very nice video series. Very explanatory. Kudos!
I made the code as easy as possible so others can understand it and make there own features. The code is just to get you started and motivated to explore and learn.
You can't do that using only the hardware shown here. You would need encoders on each wheel
Really a incredible work. Will try make it. Have ordered parts. Till now all other discriptions give me less information. Great job.
Your videos are among the best, please don't stop making them.
A fantastic set of videos on building this Balancing robot. Parts ordered. Will try and add a App control device to the code. Maybe a RC option as well.
I am curious what the 400 means in the code.
Thank for your share, I'd like to make an auto balancing robot for educational purpose and your code is the most efficient and clear I ever seen. Congrats.
You're THE best at this!
It would be really interested if you could make a video about sending video from a camera with an arduino and a wifi chip or Bluetooth.
Greate Video. Building one today. One thing about diode current, motor current and diode current are not correlated as you explain because motor voltage is much lower than battery voltage...
Have you considered adding velocity feedback using the pulse count that drives the wheels as a proxy for velocity? Velocity feedback may improve stability of the robot and perhaps allow you to set velocity as a control input to the robot.
No doubt zoop you are rocking once again..
great video, unfortunately for those of us not looking to copy and paste his code , some parts specially the mathematics is left unexplained.
Hello there Mr Joob, u are more than professional, thanks so much , keep uploading, great work
Hi, I was just wondering how to use the code you just want the bot to stand and not use a remote. say move forward from within the code. Its for a project I'm doing. I'm fine with it all except I'm not sure how to separate the controller pid code from the rest. Thanks
Brilliant tutorial and your editing skills are impressive.
ik heb 1 klein vraagje. Is er een reden dat het laatste gedeelte, namelijk het stuk dat de puls uitvoert en de richting verandert, niet meer in de void loop staat?
This is great. I will totaly 3D print some kind of robot and do somthing like this. I will try to combine this with ROS. The robot will then be able to map the room and travel from point A to B. Thanks
Hello, I just completed both the balancing robot and the nun chuck. Both the robot and the remote pass the hardware test and the robot balances very well at start up. When I try the nun chuck control the robot does not respond. I know this a 2 year old project but I just discovered it and love it. I suspected it is the 2.4 gig serial transmitter so I replace them and still get no response and I am having trouble finding example programs to test them. Note I am using exactly the units specified and would really appreciate some advice on troubleshooting this last problem. Thanks in advance!
Hi Joop
First of all I would like to thank you, this is brilliant, I built one. But, Can I ask if it is possible to change the 2.4ghz transceiver to a normal hobby R/C transmitter/receiver,
Instead of the nunchuck and if so how ?, I am new to code and not very good
Thank You
Sorry Joop, I appreciate your work and your very good explanation but the schematic here in your Part 3 - YABR-Video(3:56min) is NOT the same like the schematic in your web-site...! Here is the "FAULT"-PIN connected and at the schematic in your web-site the FAULT-PIN is NOT connected ! ...... Wich one should I use ? .......The web-site schematic don't work, connections are checked many times....current is set to 150mA....MPU-value is about 865.....-but motors do not move(NEMA17) . Now I'm not shure if I followed the "incomplet" schematic or the bigger Steppers are the reason for not working........Tomorrow I will try the Part3-Video-Schematic...........
Download the schematics from here: www.brokking.net/yabr_downloads.html
The fault pin should not be connected. If you Google "DRV8825" you will find schematics that you can try.
7:02 is a bit confusing because it uses the number 8200. This number is approximately 8,192 according to mpu documents and I believe should be calibrated? or it may change the angle calculation. Took me a second to figure out that this number was coming from page 13 of mpu 6050 datasheet
BTW, another awesome video!!
Hi Joop: My robot balances, but does not stay balanced. After a couple of minutes, it takes off, though I am using your code.
I am wondering if I need to add velocity feedback using encoders or as I suggested in my earlier comment use the pulse count as a proxy for velocity feedback. I have tried using the pulse count as velocity feedback, but have not had any luck. I may have to spend more time fine tuning it. Your comments will be appreciated.
hi! I've found some parameters were not declared in the code. e.g. TWBR, TCCR2A, TCCR2B , any reason? thanks.
AMIGO VOCÊ REALMENTE É UM EXPERT NESSE ASSUNTO, ADMIRO MUITO SUA INTELIGENCIA, TE DOU OS PARABÉNS POR SEUS VÍDEOS. SÓ FICO TRITE É PELO FATO DE NÃO ENTENDER SUA LÍNGUA. QUERIA MUITO MONTAR ESSE ROBÔ.
ESPERO QUE O UA-cam BOLE UMA MANEIRA DE TRADUZIR OS VÍDEOS EM ÁUDIO, SERIA FANTÁSTICO
This is what your brain learns to do when you balance a broomstick ;) Again, an excellent video in this series.
The beauty is that the brain is indeed self learning. How cool is that ;-)
the brain is a very good programmer :D
outstanding work! you convinced me to subscribe
Very nice explanation. Thanks! I might recommend you my SoftTimer Arduino library as you can set a Task there to be run at every 4ms.
good job and interesting explanation of this part of code
Can you make the detail explaination about the step motor driver chip you used? thank for your great tutorials.
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?
Hi Joop,
thank you for that great video ,I wonder if I can use steppers with 3.75 degrees step, if yes, are there any modifications that should be applied to the code?
Hello, Can I substitute the Pro Mini in the robot for a Nano without making any software changes?
Thanks.
Yes, that should be possible.
Good day Joop I realy like your projects, I am building the same robot that you have build but I want to run the robot with Bluetooth from my phone ,,,,,, is it possible to install HC-05 Bluetooth instead of the serial connection and do I still have to put the R1 resistor in line ore can I remove it
what part of the code do I have to change or remove to replace with Bluetooth code
Ad again thank you for your good projects
Thanks joop for your vidéos, great PID code, i have made one with a pro mini 8mhz drived with bluetooth /android and an other with DC motors. Great job !
Have you checked, that the main loop executes in less than 4ms (osciloscope or signal analyzer)? It's seems to be quite long and there is a lot of floating point math, which is really slow.
Great project, congrats.
Yes, I checked it. Floats are slow but not that slow :-)
Hi Joop. So I ended up building the robot a little modified in terms of the structure but almost similar. I have not place the battery yet at the top (so it is not top heavy) as I am testing the robot using an external power supply. What I have noticed is while the robot balances, it seems to be running forward continuously. How can i prevent this from happening? One more thing I have noticed is that the hardware calibration value for the MPU6050 keeps changing every time I run the hardware test code. Any idea why?
Make sure it's completely still when running the calibration. And it's normal that you get slight variations when you do this.
The robot can only work when it's not connected to any wires. So make sure you get a battery and place it on top. Otherwise the robot will keep moving.
Hello. Thanks a lot for you. I've done YABR about 10 days ago. It's a good balancing car!!! I used RF trans&receiver with joystick as signal sender. The Kysan_Nema17_stepper motor as a actuator. The rest is same with you. Ah, The timer interrupt is good idea!
(Very sorry not to be about YABR area) I have a question about YMFC auto altitude process.
I had totally understood your YMFC code. Its flying is perfect!
I've got data from barometer according to its sample rate . . . about 50hz. And calculated PID value, which is 'pid_output_altitude' . I've added the value each esc_1, 2, 3, 4.
esc_1 = throttle - pid_output_pitch + pid_output_roll - pid_output_yaw + pid_output_altitude;
esc_2 = throttle + pid_output_pitch + pid_output_roll + pid_output_yaw + pid_output_altitude;
esc_3 = throttle + pid_output_pitch - pid_output_roll - pid_output_yaw + pid_output_altitude;
esc_4 = throttle - pid_output_pitch - pid_output_roll + pid_output_yaw + pid_output_altitude;
Is it right process? Thanks a lot although any other trivial help!
You have to fix the throttle first and then change it with the calculated PID value.
I did it already through try and errors. Thanks. Because of your advice and hints in the video and blog, I always obtain energy. Thanks again. Nowadays I am writing RTH function with HMC5883 & GPS. It's hard to write my own code without any help. (In fact your help is only one.) When I calculate the direction of Quad, the PID control is likely also needed. Is it right?
Hi, I am following your interesting MPU6050-projects on UA-cam. I am currently building a Segway clone, using MPU6050. But I try to use the onboard Digital Motion Processor to read the filtered pitch angle directly. I am curious why people dont seem to be using the DMP-values. What are your experiences? Is there a catch maybe?
I never tried the DMP because when I was starting with the MPU-6050 the library was reversed engineered and not very stable. And more important, I like to make/write my own IMU :-)
Thanks for the video! This really helps understand how your code works. That said, I do have a minor issue. When my robot reaches max speed, suddenly the control loop seems to stop the motors and the robot falls over. This happens bot forward and backward. If I increase the max speed, it happens at a faster speed. Any idea what might be causing this?
in my robot the moving forward and backward works fine...but when turning its shaking....why is that?
Dear can I use arduino nano?
Can anyone tell me how he got the equation for linear compensation of the stepper motor?....im using a 5.18 : 1 planetary geared nema 17...is it the same equation?
I built the robot and it balances beautifully, but I'm struggling hopelessly with the remote. I've now bought eight of the transceivers from three different suppliers in two countries and I cannot get any of them to talk to each other. The nunchuck is sending 1, 2, 4 and 8, but I might as well have a piece of damp string between the remote and the robot as the transceivers, for all the good they do. Did you have to make sure your transceivers had the same IDs or change any other settings to get them to talk to each other? Do you have any suggestions for how I might test them? Sadly, these transceivers do not feature much on the internet - everything seems to be more centred on the NRF24L01. I've downloaded the manual for the Open Smart ones, but that hasn't been any real help at all.
There is a blue led on the transceivers that will lit when they receive or transmit data. So you can send data via the serial output of the Adruino and check if the led on the other tranceiver starts to flash.
I bought 4 of them and they all worked fine without any settings. Make sure you use 9600bps.
Sorry it's been so long in following your suggestion (but I've been building a copy of Ben Eater's 8 bit computer - brilliant!). However, I'm back struggling with the remote again. Yes, both the transmitter and the receiver blue LEDs flash when I operate the nunchuck, but the robot does nothing other than balance itself. The LEDs aren't very bright, but they do light up
Joop Brokking
Hi Joop I have the same problem the robot stands still the remote is making connection flashes blue on robot and Nunchuck but there is no movement at all can you please advise
Hello, your explanation of your code was very good, thanks for your hard work and sharing it with us. I do have a question if the robot travels on a surface that is not level say the right wheel is elevated above the left ( not front to back level, but right to left unlevel) will the software compensate to this and keep the robot balanced? Again thanks.
No, the robot is made for flat surfaces only.
Hey Joop, your work is realy the best ever. I build this bod and now it is running. But i used finlay a Bluetooth module and a handy app to control. One question i would have. Your code use the motors with 1/4 steps. If i change the motor controller to 1/16 steps, the bod is not able to be at zero. I assume it have to do with the 20ms IRQ routine?
My reason to try 1/16 steps is the noise of 1/4 steps configuration.
Could you give an hint on what would be necessary to change on the code, to can use the motor controller with 1/16 step configuration?
Many thanks
Rainer
You cannot run this robot on 1/16. The motors will simply not produce enough speed to balance the robot.
Thanks for the great tutorial. I did build the robot and am facing some challenges. MPU is working fine. The pid_output increases and clamps at 400 all the time it never comes down even if i change the robot orientation manually. Any pointers to see what could be wrong. angle_gyro responds well. The other problem that i have is my stepper motor stops responding when the throttle variable is beyond 325 i just hear the PWM sound. Thanks in advance for any directions.
It's normal the the PID output is maximum all the time. This is because the robot is never in a 100% horizontal position and the I-gain is really high.
Best way to test the PID controller is to set the I- and D-gain to 0. This way you only see the error. This might help you.
If you only hear the PWM sound it means that the stepper motor cannot keep up with the signal and comes to a standstill. Make sure to set the correct stepper modes.
Great project! I love this! I'm making the balance robot using DC servo motor. I'm using data reading from DMP of MPU6050. It currently can balance itself but I feel it's not perfect and there is many thing to do with it. In of them is that when I pushed it in a direction with plenty of force it was easily fallen or it moved with max speed til falling. Could you please help me to implement the brake function for my robot. I didn't use remote control as I will be next goal after the balancing work without problem. Thanks in advance!
Wow. Really impressive implementation. Where did you get the informations about the formulars for the motor pulse calculation? I would like to comprehend why you choosed numbers like the 400.
It's all done by:
while (fail == 1){
think again;
try again;
if(succes)fail = 0;
}
Are you refering your answer just to the numbers or also to the formular self?
Hi Joop!
Great video and very educative!
I have made an auto-balancing robot inspired in yours for a project for a class.
The only differences are:
-> I am using arduino Nano instead of mini pro
->My motor is not a Nema (your motor doesn't have specs, but looks like a NEMA). My stepper motors are Mitsumi M42sp-6tg from old printers wreckage.
-> I have built the rest of the project just like yours, using the same pinouts in the board.
My project is simpler than yours, I don't have the remote control stuff and my objective is to only get the robot balancing to stand still alone. Apparently, running your code makes my robot to keep the wheels stuck, but with no movement at all. Could you help me, please?
Thank you!
Hi
Is possible to use arduino Nano in this project?
Thanks for very detailed video.
Hello. Thank you for your great video. I have build my balancing robot based on your documentation. Everything works fine exept the transmission causes problems. I have used you original code in the nunchuk and in the robot. But there must be something wrong with the code. The robot only turns in one direction. Moving forward and backward command will not be received by the robot. Unfortunatly it is a litte difficult for me to debug the problem. Any Idea how I can find out where the problem comes from. BR Andreas
If you move the Nunchuck, can you see the blue LED's flash on the transceivers?
Hi, i changed the code in line 225 from
if(!(received_byte & B00001100))
to
if(received_byte & B00001100)
but i replaced the also the Nunchuck version with an handy app input
Good project! 😉
What software did you used to design the the frame for the plywood? If not open source, what open source software do you advise for that type of job?
I use LibreCad for the drawings. It's free :-)
I don't get this line:
*if(pid_output > 10 || pid_output < -10)pid_error_temp += pid_output * 0.015 ;*
Thank you for your video.
I have some question. Can I put the difference MPU-6050 alignment on my robot?
I mean, your video put in a vertical line but I have to put mpu-6050 in a horizontal line.
Change/swap the axis in the code via the trail and error method.
Joop, how can i chage the axis in the code?
How to get PWM values for motors speed from your PID, to use a dc motors
Hi Joop. This is great tutorial. Appreciate so much! I used Arduino Mega for my robot. Can you help me what should I change in code if I still use Mega board instead of Nano?
can we take any Chassis measurements as our wish or we is there any ratio of mesasurements..
It's best to start with the ratios that I used so you got a working model. After that you can change anything you like and try to make it work.
Hey, Awesome video! I plan to make a system similar to this, but I want to mount my board Horizontally rather than vertically. All the components will be in the same orientation as your board though. Looking at the code, all I would have to change are the I2C Registers we pull data from 3F -> 3B (To pull Accel Data from X axis rather than Z) and then the Gyro Registers (which I'm not entirely sure about what I need to change from, as it makes my head spin a bit at the moment, haha). Does this sound correct to you? Thanks for the awesome videos!
What have you do to solve this problem??
You are the best.....
If I use A4988 is there any problem
Great project! I build your robot from steppermotors I had from other project and printed the frame with 3D. All other parts are as your robot.
I have a problem regarding the stepper motor frequency. My stepper motor work with a max. stepper frequency of about 2kHz. If I measure the stepper motor frequency of your software it is in a max. about 5.6kHz. So motor does not rotate and robot is not working. I measured ISR tick, which is the 20microsec and also the main loop is 4millisec.
I tried to find a parameter to limit the max. stepper frequency to 2kHz but couldn't solve the search . Any help from the experts, which parameter I can align.
Thank's Wolfgang
The robot won't work at 2kHz. You really need the maximum speed to make it balance correctly. If you use the same motors as I did it should work fine.
sir.... why the angle is always increase (I copied your code and follow all your step.)
Hello, i have a question. In your case, the main loop frequency its 250Hz, but in my case, im datalogging in SD Card the MPU and GPS, what means the main loop frequency isnt 250Hz, so, i can calculate the angles with my own frequency loop, right? the only thing that means, ill have a bit more error if the frequency be higher than 250Hz?
If you are using a higher refresh rate the calculations need to be optimized for this refresh rate. Make sure that you have a constant refresh rate/loop time.
Joop Brokking lowest loop frequency, increase the error
Hello Joop, I'm your big fan and I'm about to buy all the components necessary to build my balancing robot and also a drone.
Just as a doubt, If I want to build an overboard, do you think that this code could works?
Of course, adjusting the diameter of the wheels and big battery.
Also, which drone do you prefer, the octocopter or the quadcopter?
Which one provides you a better performance?
I really appreciate your help, thank you
regards!
The code can be used to measure the angle but not for controlling a hoverboard. You have to modify the code yourself.
Quad or octo depends on what you are going to do with it. If you are starting I would suggest a quadcopter. This is cheaper to fix when you crash.
Joop Brokking awesome, thank you for all you have shared. regards
Is it able to work with horizontally changed center of mass? I mean some weight moved out of axis/lipo line.
As long as you set the correct balance calibration value.
And how about dynamic calibration?
The goal is to grab some object from the floor and counterweight it with own mass by doing some tilt.
Hi Joop! I love your videos, and I love the YABR especially. What an amazing design! Mine is completely built and working now (happily balancing!) but I have not yet connected the radios for remote control, because I would prefer to use a bluetooth radio or NRF24L01 radios. Have you tried these or is there a reason not to? Thanks!!!
The modules that I used are plug and play and don't consume any microcontroller calculation power. The is why I did not use the NRF modules.
Joop Brokking thanks Joop 😊
Joop Brokking I can't believe how well the robot can balance even on loose bed covers on a mattress!
This is amazing! As somebody who knows little about this kind of programming, do you think it could be scaled up to a robot approx. 30cm tall? I want to create a working model of the robot from my comic strip. Thanks!
Yes, it will work if it is larger. You might need to tune the PID values but it should work fine.
Thanks!
Hi Joop, can you expand on the part about "logarithmic behavior of stepper motor speed vs pulse train"?
I'm trying to figure out what this line means:
if(pid_output_left > 0)pid_output_left = 405 - (1/(pid_output_left + 9)) * 5500;
Where do the 405, the 9, and the *5500 come from? What is this equation derived from? Thanks
You can find it in the Excel sheet. The equation is the result of trying to compensate the behavior of the stepper motor.
Ah I see, it is non-linear because you are changing the period between pulses correct? ie, your output is 1/x. If I am varying the frequency of pulses, that should already be linear right? Since varying the frequency is directly varying how many steps per second the motor is receiving?
Hi i Like all you videos. :-)
But i have a quistin.
I like to use BL but my BT app can only send karakter, like a "a" "b" "c" and so one, how do i convert them to bit.??
And also what do the line.
if(!(received_byte & B00001100)){ //Slowly reduce the setpoint to zero if no foreward or backward command is given
if(pid_setpoint > 0.5)pid_setpoint -=0.05; //If the PID setpoint is larger then 0.5 reduce the setpoint with 0.05 every loop
else if(pid_setpoint < -0.5)pid_setpoint +=0.05; //If the PID setpoint is smaller then -0.5 increase the setpoint with 0.05 every loop
else pid_setpoint = 0; //If the PID setpoint is smaller then 0.5 or larger then -0.5 set the setpoint to 0
}
You skip this part :-)
Hi. this was not exclaimed in the description. if(!(received_byte & B00001100)){ as the nunchuck is not sending this. Anybody...
Hello. Thank you for your great video. I have build my balancing robot based on your documentation. I use NEMA17 SX17-1005LQCEF engines - 1.8 ° (200 Steps on full rotation). Will they be good for this project?. If not, could you tell me how to make the correct code for these motors?
If you use the same stepper controllers it should work fine.
thanks for the great video! how can i change the code for a4988 driver? i already changed circuit. thanks again!
whats this guys profession, how can i be like him like knowing all this stuff about microprocessors and electronics; should i apply for embedded systems jobs or i dont know who does that white good companies, aerospace companies. Can anyone help?
Does anyone have an issue with the stepper motors? They don’t seem to have enough torque and stop and make a whirring noise!
yes same happening with my motors ( took from dot matrix printers) ... did you find the solution?
bro please help me i am facing some problems with my project can i contact you, please
Nice Woork Mr. Joop You're awsome !
How I can control this project with an Android application instead of the joystick :)
Plz help me !
Go On !!
Your Videotutorial is probably the best and most thorough I have ever seen. Keep up the great work!
What I do not understand is, however, why it is important for you to keep the frequence of loop() constant. Is there any specific reason?
Otherwise the PID controller is getting really confused. It's fixed on 4ms and will react different on a different loop time.
battery_voltage = (analogRead(0) * 1.222) + 85
if analogRead(0) = 1023 then
battery_voltage = (1023 * 1.222) + 85 = 1335.106
does that mean battery voltage equals 13.35 V?
Here we added (+85) for the diode voltage drop, where the highest voltage that will come to the analogRead will be (5V - 0.85V) = 4.15V...
Hi Joop,
Thank you very much for your effort in producing the entertaining and educating videos. I learnt a lot.
After watching all three YABR videos, I realize that so long as the robot is self balancing on the pitch axis, the hardware setup procedure will take care of the normal balance position. so no code change is needed even the MPU6050 is positioned horizontally at setup (instead of vertical). Grateful if you could confirm my understanding.
Thanks,
The position of the MPU-6050 is very important because the accelerometer is needed for compensating the gyro's drift. As explained in detail in this video: ua-cam.com/video/4BoIE8YQwM8/v-deo.html
thanks for your reply. Lucky that I have not soldered my mpu to pcb.
ok, I mounted the MPU6050 vertically. Another question - will e the robot's weight distribution along the pitch axis affect the performance. I could imagine the power use is increased, pls share your thoughts.
Hi Joop,
Completed the built, hardware test program run ok, and generated a balancing value -1319 (negative). My MPU5060 is setup vertically by attaching it to an angled stand, the pcb and other components are mounted horizontally. Wondering why a negative value?!
Followed the procedure to limit DVR8825 current.
After changing the balance value in the Balancing robot program and upload. Powered the robot by 12V lipo, the robot cannot balance. Try to reload the hardware test program, but this time, encountered upload error: "Verification error content not match".
Research the web indicates an upload reset issue, what is your view on this?
one more question, the diode becomes burning hot when 12V power is connected for a brief while. Is it normal?
great video nice
Deal extreme is out of the stepper motors. Maybe someone could list the nema14 motors they used from Banggood or a different source like Amazon.
I have everything made I'm just waiting on the motors.
You could also use these:
www.dx.com/p/geeetech-3d-printer-reprap-1-8-degree-anti-slip-42yb-stepper-motor-black-370044
But please note that these are 42mm in stead of 35. So you have to modify the frame.
I've done with Nema17 which is 42mm. And the size of frame is not important just like Joop's saying!
Back in stock !!! Ordering today
if you are making robots then my projects are just toys..Take me as a padawan
fantastic
where did you learn such complex coding?
From the datasheet of the ATmega328P.
What i learned: You should not change values if you don't know what you are doing
Thank u Joop Brokking :D
God bless you!
Cool
bro send me link for downloading code
nice!
Love you ;)
I want a baby...
Try to listen the video at 0.25 speed. LMAO!
joop please help me out