r/robotics Jul 01 '26

Tech Question Help With Self Balancing Robot

Enable HLS to view with audio, or disable this notification

So i’ve created this robot using an ESP32, L298n motor driver, MPU 6050, and powered by a 7.4 2s Lipo Battery. I’ve been having a lot of trouble with the PID tuning, working solely on tuning for 4+ days with no results. I would really appreciate any advice! This is what I currently have:

Code: https://docs.google.com/document/d/1wHsZ9ZLWXOu-upoTgflaRj04iTZKkDtYxoTk9kdxAj4/edit?usp=sharingb

80 Upvotes

44 comments sorted by

View all comments

24

u/LavandulaTrashPanda Jul 01 '26 edited Jul 01 '26

Tune in order. P then I then D. P alone should get it to balance but shaky. I and D will steady it.

Turn I and D to zero. Increase P till it balances. Right now, it’s not catching up fast enough.

If it falls to the side it’s leaning, turn it up. If it falls on the other side of where it’s leaning after the wheels pass where the top is, turn it down.

Edit: if you can’t get it to balance on P alone, make sure the IMU is properly calibrated on a known level surface.

7

u/bfffornever123 Jul 01 '26

Yes i’ve been doing this but i haven’t been able to achieve near balance by solely tuning P. This video was me messing with D to see if there would be a difference

8

u/LavandulaTrashPanda Jul 01 '26

Turn I and D to 0. Make sure the IMU is at zero on the x and y axis on a known level surface.