# Loop time for self balancing robot

I have been working on a self balancing robot and there are quite a few parameters and one of them is loop execution time (t_loop henceforth). To my understanding, the smaller t_loop, the better it is for the control algorithm. But, since the motors also need to be given sufficient time to react, we cannot make it very small. Also, making t_loop large so that motors have sufficient time to react will make the system unstable. So there has to be some optimum value. I started with 5 milliseconds and started increasing it. At 5 ms the robot is quiet jerky (but it manages to balance). Between 10 and 20 ms, the vibrations become less. The question is how to find the optimum value of t_loop or control loop execution time.

• couple of typos: the word is quite – jsotola Feb 17 '19 at 18:24
• at what loop time does it fail if you keep increasing the loop time? – jsotola Feb 17 '19 at 18:26
• Between 40 - 50 ms – Nischal Feb 17 '19 at 19:36
• A quite nice resource on this can be found here: controlguru.com/… – Ugo Pattacini Feb 17 '19 at 19:51