Uploaded by Joshua Planting

Inverted Pendulum Stabilization via Feedback Control

advertisement
Inverted Pendulum Stabilization via Feedback Control
ME 313 Dynamic Modeling of Engineering Systems,
Submitted: 5 December 2023, Date of Experiment: 4 December 2023
Abstract (128 words).
This report investigates the implementation of feedback control to stabilize an inverted pendulum in the vertical
orientation. Two distinct feedback controllers are implemented: one to achieve a ~50% overshoot from a 90° initial
displacement and the other focused on an ideal response to the same initial displacement. Both controllers operate on
a proportional derivative approach to feedback control and were implemented into the Arduino-controlled inverted
pendulum. The tuning process for the 50% overshoot controller involved slowly increasing the proportional gain until
the desired response was achieved and was validated by plotting and analyzing data in MATLAB. The desired
response controller attempts to optimize for minimal overshoot and rapid return to the vertical orientation. The results
of the two experiments in this project validate the use of simple mathematical models and the efficacy of filtering and
control strategies in unideal real-world systems.
sinusoidal input. The third project entailed
1. Introduction
conducting two experiments to determine the
The junior-level mechanical engineering course
system properties of the pendulum, including its
dynamic modeling of engineering systems. The
natural frequency, damping ratio, and static
course learning outcomes include modeling
gain. The experimental pendulum transient
dynamic systems with differential equations,
response was then compared with a simulated
interpreting stability and time constants of the
pendulum transient response. Moving forward to
transient response of linear state space systems,
the fourth project, the focus shifts to creating and
and implementing feedback controllers. These
implementing a digital controller for the inverted
learning outcomes were accomplished by
pendulum.
assigning the pendulum project. This report
3. Methods
explores the pendulum project's fourth and final
assignment. The focus is twofold, creating a
To implement feedback control to stabilize the
feedback controller that achieves a 50%
pendulum in the inverted orientation, existing
overshoot and another feedback controller that
code from prior projects must be modified. The
achieves an ideal response from an angle step
first step is to redefine the coordinate system so
input.
that θ = 0 when the pendulum is inverted. This is
accomplished
2. Background
by
modifying
the
existing
arctangent function in the code.
The first project involved linking the MEMS
Next, the code for the actual feedback controller
accelerometer to the Arduino and utilizing the
needs to be implemented in the existing Arduino
IMU to measure the sensor's angle and angular
code. The feedback controller for this specific
velocity in both degrees and degrees per second.
project is a proportional derivative controller.
In the subsequent project, the Arduino was
The controller outputs torque in bits based on the
connected to an H-bridge circuit to drive the DC
angle and angular speed of the pendulum that
motor-powered gearbox in response to a
1
J. Planting
Report
restores the pendulum to its vertical position.
Where 𝜃 is the angle, 𝜔
The equation governing this torque output is:
frequency, and 𝜁 is the damping ratio. Using the
is the natural
experimentally determined natural frequency
𝑢 = −𝑘 (𝜃 − 𝜃 ) − 𝑘 (𝜃̇ − 𝜃̇ )
and damping ratio the 50% overshoot response
where 𝑢 is the controller torque in bits, 𝑘 is the
can be simulated in MATLAB. This simulated
proportional gain, 𝑘 is derivative gain, 𝜃 − 𝜃
data can then be superimposed over the
is the difference between the current and desired
experimental angle vs time and motor torque vs
angles, and 𝜃̇ − 𝜃̇ is the difference between the
time plots.
current and desired angular velocities. This
3.3 Tuning a desired response controller
torque output is limited to − 255 ≤ u ≤255 to
keep within the constraints of the motor’s
The desired response of the controller is to
capabilities.
quickly bring the pendulum back to 0° from a
90° initial displacement with very little to no
3.1 Tuning a 50% overshoot controller
overshoot. This result was achieved through
For this part of the experiment, the proportional
tuning 𝑘 and 𝑘 . 𝑘 had an initial value equal
derivative controller was tuned by modifying
to the 50% overshoot experiment and 𝑘 = 0.
𝑘 until a desired result of 50% overshoot from
Both values were then adjusted in .01 increments
a 90° initial displacement. This tuning process
in either direction individually until the desired
consisted of starting with a small value of 𝑘 ≈
response was achieved. The complementary
filter from previous projects was also modified.
1 and 𝑘 = 0. 𝑘 was then incremented in steps
The c value was reduced to .9 to process data that
of .1 until the desired response of 50% or 45°
was closer to the raw sensor value. This showed
overshoot was achieved. Once the desired
great improvements in the response time of the
overshoot is achieved collect data on the
controller. The baud rate was also increased to
transient response. Export that data to MATLAB
improve the fluidity of the controller response to
the plot angle vs time and motor torque vs time.
angle input. Once the desired response is
Using the data and the plots calculate dynamic
achieved, collect data and export the data to
response properties such as natural frequency,
MATLAB
𝜔 and damping ratio, 𝜁.
and
plot
angle
(filtered
and
unfiltered) vs time on one plot and motor torque
3.2 Simulating a 50% overshoot controller
vs time on another.
The pendulum system can be described by the
4. Results
second-order differential equation:
The graphs below depict the results of the two
𝜃̈ = −2𝜁𝜔 𝜃̇ − 𝜔 𝜃
project experiments: 50% overshoot controller
and desired response controller.
2
J. Planting
Report
3
J. Planting
Report
4
J. Planting
Report
5. Discussion
achieved for this system. Graph four shows the
The results of the two experiments are shown
torque input from the controller required to
above in the results section. Through a rather
achieve such a response. Reducing the load on
tedious tuning process, an overshoot of
the Arduino further improved system response.
approximately 50% was obtained from a 90°
One way this was achieved was by eliminating
initial displacement. The proportional gain, 𝑘
prints to the console. This response cannot be
required to achieve this result was 2.72 [dim].
shown graphically or analyzed because the
The following plot depicting motor torque vs
prints to the console were how data was acquired
time showcased the controller input necessary to
and then transferred to MATLAB for plotting.
achieve
the
roughly
45°
overshoot.
6. Conclusions
Superimposing the simulated data derived from
The successful implementation of feedback
the experimental natural frequency, 𝜔 , and
damping ratio,
control for the inverted pendulum system
𝜁, it can be seen that the
demonstrated proficiency in the course learning
experimental dynamic response closely follows
outcomes, namely, dynamic systems and control
what the simulation predicts. This means that the
theory.
second-order theoretical model is capable of
capturing the system’s behavior with nontrivial
In the 50% overshoot experiment, the similarity
accuracy. However, the model’s accuracy could
showcased between the experimental and
be improved by adding terms that model
simulated dynamic response provides a strong
frictional forces and gravity.
argument for the efficacy of filtering and
proportional derivative control strategies on a
The desired response controller proved to be
system with high and varied friction and cheap
more challenging in terms of tuning. Through
components, as well as the validity of theoretical
the process of incrementally increasing and
models applicability in real-world scenarios.
decreasing both 𝑘 and 𝑘 , the desired result
was achieved with values of 2.8 and .15
The desired response experiment shows the
respectively. Tuning the complementary filter
importance of a meticulous approach to system
and adjusting the baud rate also significantly
tuning to achieve specific dynamic response
improved the response time of the system.
characteristics. It also demonstrated the need for
Attempts to further increase the “snappiness” of
additional control to account for friction and
the system response by increasing either
gravity to create a more desirable response.
increasing 𝑘 or 𝑘 caused controller output to
Acknowledgments
exceed the motor’s limits as discussed in the
References
methods section. When the limits are exceeded,
the system freezes or becomes intermittent. The
third graph depicts the optimized response
5
Download