Labprocedurewriteup

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Lab Procedure/ Write Up

Inverted Pendulum Background


An inverted pendulum is a classic physics problem, yet building one is a classic controls problem.
Being unstable nonlinear system with a single input and multiple outputs makes the inverted pendulum an
interesting controls problem. Historically, it has served as a benchmark for the performance and
effectiveness of a particular control techniques. Examples of practical applications include rocket flight
control, segways, robotic arms, or a human standing upright.
While there are several variations and levels of complexity to inverted pendulum systems, we will
be dealing with a system that has only two degrees of freedom (horizontal position of the carriage and
angle of the pendulum).

Dynamics
First the dynamics of the system must be analysed. This inverted pendulum is a 2 dimensional problem,
reducing complexity and a Free Body Diagram can be drawn.
[MAKE FBD IT GOES HERE]

The cart has a weight of m_c, the weight of the pendulum shaft is m1 and the weight at the end of the
pendulum is m2. The length of the pendulum is l.

Controls
The process of writing a program to develop the digital PID control of a system is not very
complex. The basic equation for the PID controller is shown below.

K dd
PID=K pE(t )+ K i E(t )dt + E(t )
dt
Where K p , K i, Kd are the control variables for the proportional, integral, and derivative
controls respectively. E(t ) is the amount the measured value deviates from the desired
variable with respect to time.

The control system in this project uses two PID controllers to control the speed of the motor.
One of the controllers determines how the motor should react to center the pendulum in the
track, while the other determines how the motor must react to keep the pendulum upright. The
errors are calculated with the desired position and angle both being zero. This makes the error
calculation trivial since the error is simply the desired value minus the current value, so the error
will simply be the negative of the current value of either position or angle. The PID controllers
are in series, which means that they fight for control of the motor. As a result, the angle
controller has to be winning the fight most of the time or else the pendulum would stay perfectly
centered, but would not balance. However, it is also important that the position controller be
active or the pendulum will stay upright, but run off the track. In order to find the speed the
motor should be going, the position PID is subtracted from the angle PID. Although the
generalized equation for PID control systems makes sense in theory, since the error is not given
as an equation in the field the integral and derivative components must be found rather than
solved for.
From basic calculus we know that the integral of a graph is the area under the curve, and it can
be approximated by dividing the graph into a series of rectangles of set width with the
centerpoint at the top of each rectangle coinciding with the line of the graph. Each of these
rectangles are added together to find the area of the graph. The more rectangles present, the
more accurate the integral. This method was used to determine the integral of the error. The
width of the rectangles was chosen to be 5ms. Since the integral is a running summation this
value would continually increase if the value of the error was constantly positive, and the system
would go out of control. However, since the system was designed to oscillate until it reaches the
desired angle the positive and negative components of the integral will cancel out, thus keeping
the integral component of the PID controller comparable to the proportional and derivative
components.

Similarly, a derivative is the instantaneous change of one variable with respect to another
variable. This can be roughly approximated as the change of one variable divided by the change
of the second variable. In this system the first variable is either position or angle, while the
second is time. In order to be consistent the derivatives change in time is always 5ms. Since
the derivative is defined as being instantaneous, it is updated every 5ms.

The way that the error is used tells exactly how each control variable affects the control system.
The control variables are really just weights for the different forms the error takes. In the
proportional control component of the system the proportional control variable is multiplied by
the error, so this value will be larger the larger the error is. For the integral control component
the integral control variable is multiplied by the integral of the error, so when the error persists
for long periods of time the integral of the error will be large. The derivative control component
has the derivative control variable multiplying the derivative of the error, so this value will be
largest when there are sudden large changes in the position or angle. All of this means that the
proportional control component will correct for large errors, the integral control component will
correct for persisting errors, and the derivative control component will correct for sudden
changes. The control variables only control how strongly the system reacts to each of the
aforementioned errors.

PID Tuning
The main goal of this laboratory experiment is to better learn about control systems, and how to
find the control variables of control systems. Many methods have been formulated to solve the
problem of finding control variables, and the method this lab will use is called the Ziegler-Nichols
method. Since the Ziegler-Nichols method does not include the ability to find the control
variables for two PID controllers in series, only the control variables of the angle PID controller
will be found. The instructions for tuning a PID control system using the Ziegler-Nichols Method
are listed below.

1. Make sure that the program and hardware are on and ready as per the Basic
Operation section.
2. Turn off the swing up portion of the program by changing the SWING_UP
variable from 1 to 0.
3. While the pendulum is in the downward position, set Kpa to 1, Kia to 0, and Kda
to 0 and upload the program.
4. Balance the pendulum in the upright position.
5. Press the white button on the circuit, and boop the pendulum. As can be seen,
the pendulum will simply move to the side until it stops working.
6. The Ziegler-Nichols method instructs to slowly raise the value of Kpa until the
pendulum starts oscillating, so repeat steps 3 to 5 while increasing the value of Kpa until
it just starts oscillating. This value is called Ku
7. Once this point is reached, you will need to find the period of the oscillations.
8. Time the pendulum for the length of its oscillation, while counting the number of
times it oscillates. The period is the time of oscillation divided by the number of
oscillations. The period is denoted Pu.
9. The starting values of Kpa, Kia, and Kda are given by the equations below.
K pa=.6K u
K 2
K ia = pa
Pu
K da=0.125K paPu
10. These values should have the pendulum balancing at a basic level, but it can be
improved with subtle changes.

You might also like