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.
A normal game engine at the desktop PC runs with around 40 frames per second. This is equal to 1000/40=25msec of waiting time after a tick. Fasten up the system brings no advantage but it will only increase the CPU consumption. Different from the framerate the motor control has to be executed. A motor needs some time to speed up and stop, especially in embedded systems. What is used in robotics operating systems like VXworks is a concept called realtime control. This means, that the operating systems provides threads. A thread is dropped from the main program and runs in the background until the task is done.
For example, the motor needs 1 second to stop. This means, the task in which the stop signal is send to the motor has a length of 1 second. The motor stop task is activated at timeframe 1000 and runs until the timeframe 1040 (1 second * 40 fps = 40 ticks). .During that time the main program doesn't stop but it runs also. The concept of threading is used at desktop PCs heavenly for creating GUI applications but it is useful for controlling robots as well.