I had an exam yesterday, and I was asked the following question:

Why PID controller is necessary for stabilizing the inverted pendulum on a cart, why not we just use PI or PD?

Now I've seen some papers taking about using PD to stabilize the inverted pendulum, and I couldn't find any mathematical explanation, any help?


2 Answers 2


Without going into the details of the underlying equations of motion, I could argue that the D part is needed to damp out the oscillations of the pole while reaching for the (unstable) equilibrium point with no overshoots and guaranteeing at the same time sufficient dynamics.

Now, if we consider the context where the equilibrium point is reached but the cart is still accelerating, the only term capable of counteracting the inertial forces on the pole is the integral I, which indeed is the only part delivering effort when we have 0 error. Besides this, the integral is always desirable to compensate for uncertainties in the plant.

To elaborate more, I've found this quite enlighting reference on the dynamics of the cart-pole system.

Essentially, if we linearize the system we get: $$ \ddot{\theta}=\frac{g}{L}\theta+\frac{u}{ML}, $$ where $\theta$ is the angular displacement of the pole with respect to the equilibrium, $u$ is the force applied to the cart, $M$ is the mass of the cart, $L$ is the length of the pole, and $g$ the gravity acceleration.

Contrary to what I said above, for $\theta=0$ we can obtain the equilibrium $\ddot{\theta}=0$ with $u=0$, thus the integral I is not strictly required. Anyway, we ought to recap that ours is only an approximated linear model; therefore, the I term can help compensate for the unmodeled quantities.

Let's come to the PD part then.

The system is unstable because of the positive eigenvalue $+\sqrt{g/L}$. Hence, we need to find a suitable control law to stabilize it. A full state-feedback controller is proposed in the reference, which is of the form: $$ u=h_1\theta+h_2\dot{\theta}. $$ It's easy to demonstrate that for $h_1=-Mg$ and $h_2<0$, the resulting closed-loop eigenvalues are both stable $\lambda_{1,2}=0,h_2/ML$.

To conclude, $u=-Mg\theta+h_2\dot{\theta}$ is nothing but a PD. Actually, this is more properly called a state-feedback controller, but we can clearly see the contributions of the proportional and the derivative parts, although not specified in terms of the error.

Now, let's go back to the I part.

If we don't know precisely the value of the mass $M$ and also we measure $\theta$ with a certain level of accuracy, then $h_1\theta=-Mg\theta$ won't cancel out exactly the term $\left(g/L\right)\theta$ in the dynamics equation. The mismatch between the designed and the real parameters can be tackled by using the integral part I.

  • $\begingroup$ Ok, that part I understood, thanks! But can we prove the need of PID mathematically? $\endgroup$ Commented Oct 27, 2019 at 12:42
  • $\begingroup$ Tamim, I've extended the answer. $\endgroup$ Commented Oct 27, 2019 at 13:29
  • $\begingroup$ Would nonzero friction be another reason for needing I? $\endgroup$
    – SteveO
    Commented Oct 28, 2019 at 11:55
  • $\begingroup$ @SteveO, yes that's correct: static friction can be fought back using I. Also, the I term is needed when stabilizing around $\theta \neq 0$. $\endgroup$ Commented Oct 28, 2019 at 12:10
  • $\begingroup$ Thank u very much It's clearer now.... $\endgroup$ Commented Oct 28, 2019 at 20:14

I think the simple answer is that the cart-pole dynamics (linearized) are second-order (i.e. the moving parts have mass and thus inertia). In fact, it's also a non-minimum-phase system (has a zero in the right half-plane), which means it has an initial inverse response (i.e. to move the top of the pole right you have to start by moving the cart left for a bit). This requires a higher-order PID controller with a transfer function of the following form:

$$G_c(s)=\frac{K_c (T_i s + 1) (T_d s + 1)}{T_i s (T_f s + 1)}$$

This is the non-interactive form of the PID where:

  • $s$ : Laplace variable
  • $K_c$ : Controller gain
  • $T_i$ : Integrator time constant
  • $T_d$ : Derivative time constant
  • $T_f$ : Filter time constant

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.