Modeling and Simulation of a Inverted Pendulum
April 2025
Introduction
My fifth major course at USNA was EW306H (Honors Advanced Control Engineering). We learned how to design state-space control systems and state estimators in both simulation and physical systems.
The final project for this course was to develop a simulation for a state variable feedback (SVF) controller of an inverted pendulum on a cart.

Demo Video
Design Documentation
The inverted pendulum is a classic control problem. The goal of the project was to design a state variable feedback (SVF) controller to stabilize the pendulum in the upright position. The system consists of a cart that can move left and right, and a pendulum that can swing up and down. The cart is controlled by applying a force to it, which affects both the position of the cart and the angle of the pendulum.
Nonlinear Model
The first step in the design process was to derive the equations of motion for the system. Using Newton’s Laws of Motion one obtains two coupled, nonlinear, second-order ODEs:
Where is the position of the cart, is the angle of the pendulum, is the force applied to the cart, is the mass of the pendulum, is the mass of the cart, is the length of the pendulum, and is the acceleration due to gravity. Solving these equations for and gives the more explicit state-space form:
The following nonlinear Simulink model can thus be formed:
Linear Model
The next step was to linearize the system about the equilibrium point. The equilibrium point is defined as the point where the pendulum is upright and the cart is at rest. This point is given by: .
The linear perturbation equation (LPE) is given by:
Where is the state vector, is the system matrix, is the input matrix, and is the input force applied to the cart. The state vector is defined as:
The system matrix and input matrix are given by:
The system matrix describes the dynamics of the system, while the input matrix describes how the input affects the system.
The parameters used in the simulation are as follows:
Parameter | Description | Value |
---|---|---|
Mass of the pendulum | ||
Mass of the cart | ||
Length of the pendulum | ||
Acceleration due to gravity |
Controller Requirements
The goal is to move the cart from its initial position at to a reference destination and, at the same time, balance the pendulum about its upward position at . Specifically,
- The cart must be within of its final position in two seconds
- The cart must not overshoot its final position by more than
- The cart must travel to and settle at the reference destination
LPE Parameters
The controllability of the model can be tested by taking the controllability matrix of a 4x4 state-space model:
The rank of the controllability matrix must be equal to the number of states in the system. The rank of the controllability matrix is 4, which means that the system is controllable.
The output of interest is the position of the cart, which is given by:
Original Transfer Function
The resulting original transfer function (ORTF) of the LPE is:
Where the resulting pole-zero map is:

The system has two poles at the origin and two conjugate poles at . The system is unstable because the pole, , is on the right half-plane.
Desired Characteristic Polynomial
Given a settling time, , of 2 seconds and a percent overshoot, , of , the following damping ratio and natural frequency can be calculated:
The first two poles of the desired characteristic polynomial (DCP) can be calculated:
The third pole was selected at to cancel out the zero, , in the ORTF. However, the 2nd observed zero, , is positive and selecting a pole to the right of the origin would result in instability. Thus, the final pole was selected at the natural frequency, , which strikes a balance between both low gains and an effective speed of response.
With the selected desired poles:
The following DCP can be formed:
SVF Gains and Calibration:
The SVF gains can be calculated using Ackermann's formula:
Where is the controllability matrix and is the desired characteristic polynomial evaluated at the system matrix . The resulting gains are:
The gains were then calibrated using the following equation:
Where is the calibration gain. The resulting calibration gain is:
This value guarantees that the reference input aligns with the calculated gains, ensuring proper input calibration for the linearized plant model.
Block Diagram
Incorporating the SVF controller around the nonlinear dynamics model results in the following Simulink block diagram:
Closed Loop Transfer Function
The resulting closed loop transfer function (CLTF) of the SVF controller and plant model is as follows:
Where the resulting pole-zero map is:

The system now matches the desired characteristic polynomial and is stable.
Simulation Results
The control design successfully meets all specified requirements as illustrated in plots below. The cart achieves the desired settling time of , maintains an overshoot of less than , and settles accurately at the reference position of .
Upon examining the transient response of the cart position, an unusual behavior is observed immediately after the start: the cart initially moves backward. This is likely due to the pendulum arm needing to lean forward first in order to maintain balance while enabling the cart to move forward.
Regarding the control force, , which is measured in newtons, the initial force reaches . While this slightly exceeds the bound, it is not considered to be significantly problematic for the system's operation.
Finally, the LPE remains valid throughout the simulation, as the angular position, , of the pendulum stays close to the operating point of . The maximum deviation observed is only , confirming that the angular displacement remains small during the entire motion.


