Professional Documents
Culture Documents
1 Overview
2 Motivation and Audience
3 Parts List and Sources
4 Construction
5 Modeling
6 Measure System Parameter
7 Design a Full State Feedback Controller
8 Programming
9 DOWNLOAD
10 Final Words
11 Special Thanks
12 Contact
13 Bug
1 Overview
Figure 1
VIDEO 1: overview
( YouTube , )
Figure 1 and VIDEO 1 depict an inverted pendulum driven by a pneumatic air
cylinder. The big picture problem is maintaining the pendulum in its upright position.
Solving this is important because an "inverted pendulum" is a classical model of
control theories--robot arms or humanoid robots are often modeled as multi-link
pendulums. This tutorial shows you how to build a pneumatic inverted pendulum, and
takes approximately a few days to finish.
VENDOR
PART
PRICE PER
UNIT
QTY
controller
Arduino
$30
digital-analog
converter
National
Semiconductor
DAC0808
< $5
operational amplifier
National
Semiconductor
LM324
< $5
resistance
5.1 K Ohm
< $0.1
capacitor
0.1 uF
< $0.1
$78
> $200
$650
$5
rotational encoder
US digital
linear encoder
proportional valve
FESTO
MPYE-5-1/8-HF-010-B
FESTO
air cylinder
GRAINGER
GRAINGER
part #: 6W164
$3
bracket, pivot
GRAINGER
part #: 6W163
$3
GRAINGER
part #: 4X132
$38
polyurethane tube
GRAINGER
part #: 4HL92
connector
GRAINGER
part #: 4HN10
$4
carrier
igus
$30
Some little parts such as screws and nuts are not listed...
4 Construction
Mechanical structure
Compressed air comes from air compressor and goes in the proportional valve.
Coming out from the proportional valve, there are two branches of air flow (one is
compressor air, the other one is exhausted air) which connect to the air cylinder
(pneumatic actuator). The pPneumatic actuator connects to a cart (the aluminum box)
where the pendulum is attached, and underneath the cart lies the carrier, which guides
the cart along moves in a straight line. The rotational encoder is inside the cart, and its
shaft is fastened throught out the cart. The pPendulum is attached to the shaft and is
able to rotate 360 degrees. At the back side of the cart, attached a linear encoder is
attached. For more detail please refer to VIDEO 1.
carrier
Control circuit board
Arduino is used as the data acquisition board and control unit. Signals from the linear
encoder and rotational encoder are acquired into the Arduino, and then then Arduino
calculates an output voltage is calculated, which will then control the proportional
valve through a digital-analog converter and operational amplifier. The circuit
schematic diagram is shown belowas below:
Note that the "black green red yellow" in the linear encoder diagram are just merely
the color of wires., Yyou might have differnent ones, but after watching VIDEO 2, it
should be clear on how to use a linear encoder--the connection and programming are
similar to rotational encoder. The opamp depicted is used as an inverter and should be
connected to the +12 and -12 power rails. As noted above, if using separate power
supplies, they must share a common ground.
Arduino
Visit arduino.cc to learn more.
Rotational encoder
The rotational encoder used in this project is S1-1250-250-I-N-D (more detail
available in TABLE 1).
This encoder has 1250 counts per 360 degree (2*pi). Therefore, we have:
1250/(2*pi)360 = angle_count/alphfa
Which gives us:
Alternatively, a moving average can be utilized, in which an array of the last x average
values are stored, and the average (or weighted average) of them is taken. This is
more computationally heavy, but may filter out some of the noise.
How to read an encoder:?
When you rotate the encoder's shaft, there will be signals from Channels A and B.
Channels A and B are square waves with the same amplitudte and frequency, but they
have offset by a 90 degrees phase difference. Note that when rotating in a different
direction, at the rising edge of channel A, channel B signal will be different--say, if
rotating clockwise results a low valve of channel B at the rising edge of channel A;
then when rotating counterclockwise, at the rising edge of channel A, channel B will
give a high valve.
Linear encoder
Inside the black box of the linear encoder, there is a rotational encoder. The black box
travelles along a track. Therefore, linear encoder and rotational encoder are the same
thing--there are also channel A and B in linear encoder, and their signals are the same
as rotational encoder. The stroke of air cylinder is 0.1512m, and the linear encoder
results 2993 counts travelling that distance. So, we have:
2993/0.1512 = pos_count/x_c
Which gives us:
x_c = 0.0000505*pos_count (unit: meter)
And we could estimate cart velocity using
mathematical modeling please refer to Modeling.) This video shows how to measure
these states, and how to control the proportional valve:
VIDEO 2: measure states, digital analog converter, and proportional valve
( YouTube , )
5 Modeling
We use Lagrange's method to model the system.
Ignoringe the translational kinetic energy of the air cylinder, the total kinetic energy
is:
Lagrange's equation
The Lagrangian is:
In this model, we ignore the force that the pendulum acts on the cart, and we ignore
the friction on the cart, and the ignore friction on the shaft of the rotational encoder.
So, the Lagrange's equations are:
Also, from the datasheet of the proportional valve, one could learn that the
relationship between input voltage and output pressure is:
Here "-" in "-Pmax" indicates different output ports, it doesn't mean a negative value
(for more detail, please refer to VIDEO 2). So, we have
We will have the state space representation of the pneumatic inverted pendulum:
Therefore,
Use Taylor's approximation to linearize the system at the following equilibrium point
Where
Note that
I used software "Wolfram Mathematica 8" to solve the above equations., Tthe
Mathematica file is available in DOWNLOAD section near the end of this webpage.
The input voltage is:
Note that in hardware, for aesthetic reasons, port 2 of the proportional valve is
connected to the head port of the air cylinder, and port 4 to the base port; respectively.
But according to our mathematical model, these connections should be revisereversed.
So, I made a software change and --flipped the control input. Since the proportional
valve is originally controlled by 0-10V, the flipped input will be:
So, this is the input voltage for the proportional valve. The Arduino should output the
control signal to the DAC circuit to generate this voltage for the proportional valve.
(Refer to Digital-analog converter and operational amplifier section)
8 Programming
To program the Arduino, we need to use Arduino programming software.
Note: that the programming codes had been refined after the day that videos were
shot. So, some parts of the code shown in videos are different. However, the method
or idea of writing the program is consistent as shown in videos.
Attention: it's important to open the code correctly. For example, if you are using
Arduino 0022 (the programming software) Click "File"-->"Open", then choose
"inverted_pendulum_v3.pde". And you should see that three .pde files will open
automatically.
9 DOWNLOAD
Download 1: Arduino code
Description: Arduino code for this project.
10 Final Words
This tutorial's objective was to show how to build a pneumatic inverted pendulum
from mechanical, electronic to proagramming part. Once the concepts were conveyed
the reader could do it themselves. This article try its best to present every details,
however, reader might not have the same tools, same mechanical parts, or same circuit
components, and the vendor link provided in TABLE 1 might be out of date. Therefore,
reader might not be able to follow every step. But after reading this article, reader
should gain enough knowledge to debug their own problems.
11 Special Thanks
Special thanks for Dr. Paul Y. Oh.
12 Contact
Mr. Jiyue He: post.orange@[at]hotmail.com
13 Bug
In section 4 Construction -> Rotational encoder, unit is wrong: following SI Systems of
Units, alfa should be in unit radian:
1250/(2*pi) = angle_count/alfa -> alfa = 0.00503*angle_count (unit: radian)
I found this bug months after I finished this project, the mechanical structures has
already been disassembled, so, I could not implement this correction to the actual
inverted pendulum. As you see in VIDEO 1, the inverted pendulum worked fine even
with this bug, that's the beauty of feedback control: has great tolerance with model
inaccuracy/errors.