# The Inverted Pendulum

One of the classic control problems is the inverted pendulum. In this series of videos, we get you started on modeling and simulating the problem.

#### Summary

- Nonlinear Equations of Motion
- Simulink Model First (Messy) Attempt
- Simulink Model Second (Cleaner) Attempt with Simple Pendulum
- More About that “Embedded Matlab Function”
- Clean Simulink Model of the Inverted Pendulum

#### Nonlinear Equations of Motion

The first thing we do is derive the nonlinear equations of motion. Although the Lagrange formulation is more elegant, this video uses the conceptually simpler Newtonian formulation that anyone who has successfully completed an engineering dynamics should be able to understand.

#### Simulink Model – First Attempt

Now that we have equations of motion we can construct a Simulink model. In the video below I show you how to do it with the basic Simulink building blocks. It gets a little messy.

#### Simulink Model – Second (cleaner) Attempt with a Simple Pendulum

First I want to show you you how to create a custom Simulink block in a simulation. We’ll get it to work on the simple pendulum with a fixed base.

#### More About that “Embedded Matlab Function”

In the video above, I used the “Embedded Matlab Function” block to construct my model. Newer versions of Matlab do not have a block by this name. Instead, it’s simply called “Matlab Function.” However, in order to use it, you’re going to need to have a compiler. The video below explains this, and it explains what to do if you do not have a compiler or don’t want to use one.”

#### Clean Simulink Model of the Inverted Pendulum

Next, we’ll apply this technique to construct a Simulink model of the full inverted pendulum with a base that moves horizontally.