This example shows a continuous and discrete inverted pendulum using Python and
QFIRE Studio
.The inverted pendulum is a classical model in control and automation engineering. This plant describes the behavior of a helicopter gliding.A classical inverted pendulum is represented by Figure 1.

Figure 1 - A car with a inverted pendulum on top
As can be seen, there are three letters in Figure 1 meaning variables of the system. Where:
These variables are used in the following equations that define the model behavior.
In this case,
The Equation 1 and 2 can be converted to state space form.
It is possible to use Python to execute the calculation for this model after defines the parameters. In this example, it will be used
Running this code, the following system is returned:
This system can be represented in block diagram as Figure 2 and 3 show. In the figures, the states will be represented by

Figure 2 - Matrix A

Figure 3 - Matrix B
This diagram was design for simulation in the Real World Workspace. Aiming to simulate it using a
QFIRE CTR-101
, the system was discretized using the following code:As result of the code, the following discrete state space system was calculated.
This system represented in block diagram is shown in Figure 4 and 5.

Figure 4 - Matrix Phi

Figure 5 - Matrix Gamma
About MWF
MWF is a traditional Brazilian company that provides a wide range of electronic and mechatronic products for industry sectors such as automotive, agricultural machinery and aerospace.
Contact Us
Rua Doutor Siqueira, 139 / Sala 804 Campos dos Goytacazes - RJ, Brasil
contact@mwf-technologies.com
© 2018-2026 MWF. All rights reserved.