Pendulum Project: Difference between revisions

From Sccswiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Coming soon...
== Introduction ==
<math>\alpha\,\!</math>
 
<math> 10^{10^{ \overset{8}{} }}</math>
An inverted pendulum is a pendulum which is attached to a cart. (Fig. 1.1)
 
[[Image:invpen.gif]]
 
Even though a regular inverted pendulum has a point mass attached to its rod, our hardware consists
of a cart which is free to move horizontally and a rod attached to it. An inverted pendulum is
inherently unstable, and must be actively balanced in order to remain upright, either by applying a
torque at the pivot point or by moving the pivot point horizontally as part of a feedback system. [1]
 
In control theory and classical dynamics the inverted pendulum is considered to be a classic problem
which is used as benchmark for testing of the control algorithms. As some examples of the control
algorithms we used the inverted pendulum system to experiment with PID controller, fuzzy controller
and lastly neural networks.
 
Besides its theoretical importance the inverted pendulum system has also seen action in real life.
An inverted pendulum-like system is used during the take-offs of the rocket to keep the rocket in
balance. Moreover, the shipping cranes in the seaports use a similar idea. Last but not the least,
a self-balancing transportation device called Segway[2] uses same working principle as it is in an
inverted pendulum.
 
== BGCE Project Scope ==
 
The classical approach of control theory is to develop a mathematical model for the system and
then to develop a corresponding controller so that the closed loop is stable (PID- controller). A
second approach is the use of a so-called fuzzy-controller, which doesnt need an explicit model of
the system. Another interesting possibility is to use self-learning controllers that learn automatically
how to control the system. Techniques such as neural networks can be used for this task. In
the scope of this project, these different approaches will be studied. The focus is not only on the
controllers themselves, but also on their visualization and demonstration via an interactive graphical
user interface.
 
== Classical Controller ==
 
Classical Controller tries to solve the physical equations governing the system in order to find the
trajectory of the rod from the stable equilibrium position at rest to the unstable equilibrium position.
To achieve this goal we first have to find the mathematical representation of the system, meaning
, we will model the system at first and then we try to find the relation between the output of the
system which is the current state as feed back and the next input which hopefully helps us get closer
to the unstable equilibrium position.[3]
 
=== Classical Model ===
The purpose of system modeling is to provide an accurate mathematical description of the system.
Once this description is obtained, the numerical constants of the system will be substituted into the
equations to provide a working representation of the system. From there this model can be simulated
and manipulated to obtain gain values on which the state feedback control is based.
This section will derive two sets of mathematical models of the system. The first model is a set of
nonlinear differential equations. The second model is a set of linearized differential state equations.
Due to the difficulty level of nonlinear control and the scope of this project, the nonlinear equations
will not be used for control calculations. However, the linearized equations provide a good estimate
of the system under conditions mentioned in this chapter, and will be used for all control calculations.
Since the inverted pendulum is a complex system, the more accurate one wants to be the more
complex the model gets and the slower the controller.
So having this fact on mind , we tried to use the most important terms and leave away the parts
where we thought wouldn’t be much of importance but of course doing this we moved away from a
complex model to an easier to solve one in cost of accuracy.
The physical model of the inverted pendulum on a moving cart is seen in figure 1. The inverted pendulum system is free to move only in the X-Y plane. The symbolic descriptions are shown in
table 3.1.
 
Using the physical model of the inverted pendulum from Fig. 1, we can now derive the differential
equations that describe the system as seen in the following section. [3]
 
[[Image:Pendel.PNG]]
 
==== Nonlinear Dynamical Model ====
The equations describing the center of gravity of the pendulum rod with respect to the origin on the Cartesian axis of reference can be written as [4]
 
 
\begin{center}
$x_g = x+l\sin\theta$,
\end{center}
 
\begin{center}
$y_g = l\cos\theta$.
\end{center}
The balance of forces of the rod in the vertical direction with respect to its
center of gravity is given by
 
<math>m\frac{d^2}{dt^2}(l\cos\theta)=V-mg. </math>
 
Completing the differentiation above gives
 
\begin{equation}
\begin{aligned}
mg-ml\ddot{\theta}\sin\theta-ml\dot{\theta}\cos\theta=V.
\end{aligned}
\end{equation}
 
The balance of forces of the rod in the horizontal direction with respect to its
center of gravity is given by [4]
 
 
 
\begin{equation}
\begin{aligned}
m\frac{d^2}{dt^2}(x+l\sin\theta)=H, \\
m\ddot{x}+ml\ddot{\theta}\cos\theta-ml\dot{\theta}^2\sin\theta=H.
\end{aligned}
\end{equation}
 
 
The balance of forces of the cart in the x direction is described by
 
\begin{equation}
\begin{aligned}
M\frac{d^2}{dt^2}x=F-H \Rightarrow m\ddot{x}=F-H.
\end{aligned}
\end{equation}
 
The balance of rotational motion of the pendulum rod around its center of
gravity is given by
 
 
\begin{equation}
\begin{aligned}
l\ddot{\theta}=Vl\sin\theta-Hl\cos\theta.
\end{aligned}
\end{equation}
 
 
The nonlinear dynamical equations are found by substituting (2) into (3),
and (1) into (4) as follows
 
\begin{equation}
\begin{aligned}
(M+m)\ddot{x}+ml\ddot{\theta}\cos\theta-ml\dot{\theta}^2\sin\theta=F,
\end{aligned}
\end{equation}
 
\begin{equation}
\begin{aligned}
(l+ml^2)\ddot{\theta}+ml\ddot{x}\cos\theta-mgl\sin\theta=0.
\end{aligned}
\end{equation}
 
Therefore, the nonlinear equations (5) and (6) mathematically describe
the inverted pendulum on a cart. [3]
 
\subsection*{Linearization of the Dynamical Equations}
To be able to apply a linear controller to the inverted pendulum system for
stabilization, we need to linearize the dynamical equations (5) and (6).
 
Under stabilization conditions of the pendulum we assume the angle of the
rod, $\theta$, is small. By assuming the angle of the rod is always small, the
dynamical equations may be linearized by applying the following
mathematical rules. For small values of $\theta$:
 
\[\dot{\theta}\approx 0, \sin\theta = \theta, \cos\theta=1.
\]
 
By applying the above rules for small values of $\theta$, equations (5) and (6)
transform to
 
\begin{equation}
\begin{aligned}
(M+m)\ddot{x}+ml\ddot{\theta}=F,
\end{aligned}
\end{equation}
 
\begin{equation}
\begin{aligned}
(l+ml^2)\ddot{\theta}+ml\ddot{x}-mgl\theta=0.
\end{aligned}
\end{equation}
 
Therefore, the linearized equations (7) and (8) mathematically describe
the inverted pendulum on a cart for small values of $\theta$.
 
==== Control Force / Electro-Mechanical System Equations ====
 
The control force, $F$ , of the system is delivered by a DC-motor mounted on
the cart. The control input to the motor is measured in voltage, $V$, while the
control force delivered is in Newtons. The control force, $F$, must be related to
the input voltage, $V$, of the motor attached to the cart. This involves deriving
the electro-mechanical equations of the motor and solving these with
respect to the control force and the motor voltage.
 
Assuming negligible armature inductance, the mathematical model of the
motor is given by
 
\begin{equation}
\begin{aligned}
V=R_AI_A+K_m\omega_m
\end{aligned}
\end{equation}
 
 
where $V$ is the input voltage to the motor, $R_A$ is the armature resistance
of the motor, $I_A$ is the armature current drawn by the motor, $K_m$ is the
motor torque constant, and $\oemga_m$ is the motor speed.
The mechanical equation relating the motor torque to the input armature
current is given by
 
\begin{equation}
\begin{aligned}
\tau_m=K_mK_gI_A.
\end{aligned}
\end{equation}
 
where $\tau_m$ is the torque produced at the output shaft of the motor, and
$K_g$ is the gear ratio of the gear head on the motor if present.
 
The linear force applied to the cart by the motor can be described by
 
 
\begin{equation}
\begin{aligned}
F=\frac{\tau_m}{r}
\end{aligned}
\end{equation}
where $r$ is the radius of the output gear.
 
The angular velocity of the output shaft relates to the linear velocity of the
cart by
 
 
\begin{equation}
\begin{aligned}
  \omega_m=\frac{\dot{x}}{r}K_g
\end{aligned}
\end{equation}
 
where $x$ is the linear velocity of the cart.
 
 
We may now combine (11) into (10) and solve for $I_A$ obtaining the
following
 
 
\begin{equation}
\begin{aligned}
  I_A=\frac{Fr}{K_mK_g}.
\end{aligned}
\end{equation}
 
Finally, combining (12) and (13) into (9) we obtain an equation relating
the input motor voltage V to the linear force F applied to the cart given
by
 
\begin{equation}
\begin{aligned}
F=\frac{K_mK_g}{rR_A}V-\frac{K^2_mk^2_g}{r^2R_A}\dot{x}.
\end{aligned}
\end{equation}
 
 
==== State Space Representation ====
 
Now that we have the linearized dynamical equations and the control force
equation relating the motor voltage to a linear force, we can substitute
(14) into (7) and rearrange to solve for the linear acceleration $\ddot{x}$ as
follows

Revision as of 01:47, 17 January 2009

Introduction

An inverted pendulum is a pendulum which is attached to a cart. (Fig. 1.1)

Error creating thumbnail: Unable to save thumbnail to destination

Even though a regular inverted pendulum has a point mass attached to its rod, our hardware consists of a cart which is free to move horizontally and a rod attached to it. An inverted pendulum is inherently unstable, and must be actively balanced in order to remain upright, either by applying a torque at the pivot point or by moving the pivot point horizontally as part of a feedback system. [1]

In control theory and classical dynamics the inverted pendulum is considered to be a classic problem which is used as benchmark for testing of the control algorithms. As some examples of the control algorithms we used the inverted pendulum system to experiment with PID controller, fuzzy controller and lastly neural networks.

Besides its theoretical importance the inverted pendulum system has also seen action in real life. An inverted pendulum-like system is used during the take-offs of the rocket to keep the rocket in balance. Moreover, the shipping cranes in the seaports use a similar idea. Last but not the least, a self-balancing transportation device called Segway[2] uses same working principle as it is in an inverted pendulum.

BGCE Project Scope

The classical approach of control theory is to develop a mathematical model for the system and then to develop a corresponding controller so that the closed loop is stable (PID- controller). A second approach is the use of a so-called fuzzy-controller, which doesnt need an explicit model of the system. Another interesting possibility is to use self-learning controllers that learn automatically how to control the system. Techniques such as neural networks can be used for this task. In the scope of this project, these different approaches will be studied. The focus is not only on the controllers themselves, but also on their visualization and demonstration via an interactive graphical user interface.

Classical Controller

Classical Controller tries to solve the physical equations governing the system in order to find the trajectory of the rod from the stable equilibrium position at rest to the unstable equilibrium position. To achieve this goal we first have to find the mathematical representation of the system, meaning , we will model the system at first and then we try to find the relation between the output of the system which is the current state as feed back and the next input which hopefully helps us get closer to the unstable equilibrium position.[3]

Classical Model

The purpose of system modeling is to provide an accurate mathematical description of the system. Once this description is obtained, the numerical constants of the system will be substituted into the equations to provide a working representation of the system. From there this model can be simulated and manipulated to obtain gain values on which the state feedback control is based. This section will derive two sets of mathematical models of the system. The first model is a set of nonlinear differential equations. The second model is a set of linearized differential state equations. Due to the difficulty level of nonlinear control and the scope of this project, the nonlinear equations will not be used for control calculations. However, the linearized equations provide a good estimate of the system under conditions mentioned in this chapter, and will be used for all control calculations. Since the inverted pendulum is a complex system, the more accurate one wants to be the more complex the model gets and the slower the controller. So having this fact on mind , we tried to use the most important terms and leave away the parts where we thought wouldn’t be much of importance but of course doing this we moved away from a complex model to an easier to solve one in cost of accuracy. The physical model of the inverted pendulum on a moving cart is seen in figure 1. The inverted pendulum system is free to move only in the X-Y plane. The symbolic descriptions are shown in table 3.1.

Using the physical model of the inverted pendulum from Fig. 1, we can now derive the differential equations that describe the system as seen in the following section. [3]

Error creating thumbnail: Unable to save thumbnail to destination

Nonlinear Dynamical Model

The equations describing the center of gravity of the pendulum rod with respect to the origin on the Cartesian axis of reference can be written as [4]


\begin{center} $x_g = x+l\sin\theta$, \end{center}

\begin{center} $y_g = l\cos\theta$. \end{center}

The balance of forces of the rod in the vertical direction with respect to its center of gravity is given by

<math>m\frac{d^2}{dt^2}(l\cos\theta)=V-mg. </math>

Completing the differentiation above gives

\begin{equation} \begin{aligned} mg-ml\ddot{\theta}\sin\theta-ml\dot{\theta}\cos\theta=V. \end{aligned} \end{equation}

The balance of forces of the rod in the horizontal direction with respect to its center of gravity is given by [4]


\begin{equation} \begin{aligned} m\frac{d^2}{dt^2}(x+l\sin\theta)=H, \\ m\ddot{x}+ml\ddot{\theta}\cos\theta-ml\dot{\theta}^2\sin\theta=H. \end{aligned} \end{equation}


The balance of forces of the cart in the x direction is described by

\begin{equation} \begin{aligned} M\frac{d^2}{dt^2}x=F-H \Rightarrow m\ddot{x}=F-H. \end{aligned} \end{equation}

The balance of rotational motion of the pendulum rod around its center of gravity is given by


\begin{equation} \begin{aligned} l\ddot{\theta}=Vl\sin\theta-Hl\cos\theta. \end{aligned} \end{equation}


The nonlinear dynamical equations are found by substituting (2) into (3), and (1) into (4) as follows

\begin{equation} \begin{aligned} (M+m)\ddot{x}+ml\ddot{\theta}\cos\theta-ml\dot{\theta}^2\sin\theta=F, \end{aligned} \end{equation}

\begin{equation} \begin{aligned} (l+ml^2)\ddot{\theta}+ml\ddot{x}\cos\theta-mgl\sin\theta=0. \end{aligned} \end{equation}

Therefore, the nonlinear equations (5) and (6) mathematically describe the inverted pendulum on a cart. [3]

\subsection*{Linearization of the Dynamical Equations} To be able to apply a linear controller to the inverted pendulum system for stabilization, we need to linearize the dynamical equations (5) and (6).

Under stabilization conditions of the pendulum we assume the angle of the rod, $\theta$, is small. By assuming the angle of the rod is always small, the dynamical equations may be linearized by applying the following mathematical rules. For small values of $\theta$:

\[\dot{\theta}\approx 0, \sin\theta = \theta, \cos\theta=1. \]

By applying the above rules for small values of $\theta$, equations (5) and (6) transform to

\begin{equation} \begin{aligned} (M+m)\ddot{x}+ml\ddot{\theta}=F, \end{aligned} \end{equation}

\begin{equation} \begin{aligned} (l+ml^2)\ddot{\theta}+ml\ddot{x}-mgl\theta=0. \end{aligned} \end{equation}

Therefore, the linearized equations (7) and (8) mathematically describe the inverted pendulum on a cart for small values of $\theta$.

Control Force / Electro-Mechanical System Equations

The control force, $F$ , of the system is delivered by a DC-motor mounted on the cart. The control input to the motor is measured in voltage, $V$, while the control force delivered is in Newtons. The control force, $F$, must be related to the input voltage, $V$, of the motor attached to the cart. This involves deriving the electro-mechanical equations of the motor and solving these with respect to the control force and the motor voltage.

Assuming negligible armature inductance, the mathematical model of the motor is given by

\begin{equation} \begin{aligned} V=R_AI_A+K_m\omega_m \end{aligned} \end{equation}


where $V$ is the input voltage to the motor, $R_A$ is the armature resistance of the motor, $I_A$ is the armature current drawn by the motor, $K_m$ is the motor torque constant, and $\oemga_m$ is the motor speed. The mechanical equation relating the motor torque to the input armature current is given by

\begin{equation} \begin{aligned} \tau_m=K_mK_gI_A. \end{aligned} \end{equation}

where $\tau_m$ is the torque produced at the output shaft of the motor, and $K_g$ is the gear ratio of the gear head on the motor if present.

The linear force applied to the cart by the motor can be described by


\begin{equation} \begin{aligned} F=\frac{\tau_m}{r} \end{aligned} \end{equation}

where $r$ is the radius of the output gear.

The angular velocity of the output shaft relates to the linear velocity of the cart by


\begin{equation} \begin{aligned}

 	\omega_m=\frac{\dot{x}}{r}K_g

\end{aligned} \end{equation}

where $x$ is the linear velocity of the cart.


We may now combine (11) into (10) and solve for $I_A$ obtaining the following


\begin{equation} \begin{aligned}

 	I_A=\frac{Fr}{K_mK_g}.

\end{aligned} \end{equation}

Finally, combining (12) and (13) into (9) we obtain an equation relating the input motor voltage V to the linear force F applied to the cart given by


\begin{equation} \begin{aligned} F=\frac{K_mK_g}{rR_A}V-\frac{K^2_mk^2_g}{r^2R_A}\dot{x}. \end{aligned} \end{equation}


State Space Representation

Now that we have the linearized dynamical equations and the control force equation relating the motor voltage to a linear force, we can substitute (14) into (7) and rearrange to solve for the linear acceleration $\ddot{x}$ as follows