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.


  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?

2 Answers 2


I would not call this a cascaded control loop but rather a MIMO control loop. Typically a cascaded control loop has an inner and an outer loop and the output of the outer loop is used as the setpoint for the inner loop. Here you have multiple loops, for some reason running at different update rates, but each with their own setpoint and (presumably) sensors. Therefore I would call this a MIMO control loop.

Regarding your other questions; the above configuration is not necessarily better than a single PID controller. For example, due to the possible interaction between the loops, it is typically more difficult to evaluate robust stability in practice (i.e. based on measurements). On the other hand, multiple controllers allow for more flexibility and/or might even be needed in order to be able to control all performance variables of interest. Controlling angle, speed and turn likely requires multiple sensors, hence multiple inputs and controllers are required.

You can of course nest as many loops as you want and/or deem necessary. The only real limitation is the ability/time required to analyze the resulting complex interaction.

  • $\begingroup$ First, thank you for the answer. It was very helpful to clear most of my confusion. But i am wondering if this system is a MIMO, or actually a MISO? That's because the multiple inputs are from the IMU (gyroscope and accelerometer) and from the motor (using the encoders on the motor shafts to find the speed) but it seems to me that there is only a single output which is the PWM to the motors, to control the speed and direction of the wheels? $\endgroup$
    – DryRun
    Jun 30, 2019 at 7:40
  • $\begingroup$ But maybe you're right after all... each loop outputs its own PWM values which are summed together before they're sent to the motor, so maybe it's really multiple outputs? I'm a bit confused about this. $\endgroup$
    – DryRun
    Jun 30, 2019 at 7:50
  • $\begingroup$ There's not enough information in your original question to really determine if the system is MIMO or MISO. As there are multiple motors, I assume there are also multiple PWM signals and the system is MIMO. This is however also determined by where you put the border between plant and controller. For example: if there's additional logic that distributes a single PWM signal to multiple motors, i.e. there's only a single signal going into the plant, the same system is suddenly MISO. $\endgroup$
    – user883521
    Jun 30, 2019 at 8:12

To address your second and 3rd question it's important to remember the purpose of cascading PID loops.

Lets say you want to control a ships heading, so you create a rudder position signal using a PID loop. But the rudder doesn't take a position signal, it's just got actuators that take a "force" signal. So you run those on a PID loop to match the position setpoint. And now you've got a cascaded loop.

It may be possible to combine these into one loop, but you can see that logically it wouldn't make sense, they're each separate control problems with their own loops.

Now lets go deeper. Lets say the actuators are self contained devices that take a force signal, but internally they're just a dumb cylinder and valve. So you add a PID loop to that: it takes the force signal, and adjusts the valve using PID to match the force setpoint. That's 3 cascaded loops, and you can see how this could go on and on.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.