PID control loops


I'm working on a balancing robot. I'm familiar with the simple PID control loop:


But i can't understand this PID control loop.

I have been struggling to wrap my mind around this and i have the following questions:

  1. Is this actually a cascade control loop? The programming states that the angle control PD loop is executed every 5ms, the speed control PI loop is executed every 40ms and the steering PD loop every 20ms. From my understanding, based on the loop/function execution timing, the innermost loop is the angle control loop, then the steering loop and the outermost loop is the speed control loop. Correct?

  2. Why is this complex control loop better than a classic control loop with P, I and D in one single controller?

  3. How many control loops can be nested within each other? I have only seen one inner loop and one outer loop. Is it possible to have 2 inner loops and one outer loop? Or 3 loops, each nested within the other?


As I understand the diagram, a couple of independent settings have to be handled by the 3 independent(?) PI/PD controllers. The outputs of all controllers are distributed to the wheel motors, so that the desired speed and angle affect both motors in the same way, while the desired turn correction is added to one and subtracted from the other motor. Dunno how the exact computation cycles and output mix is achieved, that's not specified in the diagram. If you have the related code, use it as it is.