After all the theory we went through in the part 1 it is time for a real design of control system. In this part we are about to design a full state feedback control system of the magnetically suspended ball.

### 1. Mathematical model

Let's first mathematically describe a behavior of the magnetically suspended ball. It is an iron ball with a weight M that is situated under the electromagnet. There are basically two forces acting on the ball:

1. gravitational force,

2. force of the magnet with the opposite direction to the magnetic one.

Since the forces have opposite direction they are acting against each other = one will be subtracted from the other one.

Let's create a mathematical formulation of the behavior of the ball and magnet. That means let's create a mathematical model of the system.

\begin{aligned} \ddot{x} = g - \frac{c}{M} \frac{i}{x} \qquad (1)\end{aligned}

c = 1 [N*m/A] is a proportionality constant included to make sense of the units.

g = 10 m/s^2 (usually is 9.81, but 10 is pretty close and easy to calculate)

i = current through the coil. The bigger the current is, the stronger is the magnetic force.

x = position of the ball with respect to the magnet = distance from the magnet

M = weight of the iron ball - 0.05kg

$\ddot{x}$ = 2nd derivative of the position = acceleration

Due to a learning purpose it is a very simplified model. More realistic one can be found here. For instance, in our model we do not take into account control of the current. We simply pretend there are no limits to how high the current can be.

### 2. Linearization

The next step is linearization (that is transformation of the model) into a state-space form:

\begin{aligned} \dot{x} & = A \vec{x} + B \vec{u} \qquad (2) \end{aligned}

where

$\vec{x}$ - state vector

$\vec{u}$ - input vector. Since size of the $\vec{u}$ is 1, it is simply a variable "u".

Sometimes it is pretty easy, for instance ....** TODO**

But it is not the case. We need to linearize equation (1) about a steady point.

Steady Point

is a point where 'all is steady', that is all derivatives are zero. In equation (1) there is the only derivative, so we can write:

\begin{aligned} 0 = g - \frac{c}{M} \frac{i}{x} \qquad (3)\end{aligned}

Solving of the equation reveals there is infinite number of solutions:

\begin{aligned}0.5 x = i \qquad (4)\end{aligned}

so let choose x (distance from the magnet) to be 10 so i = 5. Then our steady state chosen for linearization is [x,i]=[10,5].

Let's define a few variables to begin with linearization:

input u=i (current)

output y=x (distance from the magnet)

state vector (distance, velocity) $\vec{x}=[x1, x2]=[x, \dot{x}]$ (do not confuse $\vec{x}$ as state vector with x as distance of the ball from the magnet)

1st derivative of the vector $\vec{x}$ is $\dot{\vec{x}}=[\dot{x1}, \dot{x2}]=[x2, g - \frac{c}{M} \frac{i}{x}]$.

Let's call $\dot{x1} = f1$ and $\dot{x2} = f2$.

To linearize equation (1) we have to compute Jacobian matrix:

\begin{aligned} A & = \begin{bmatrix} \frac{\partial f1}{\partial x1} & \frac{\partial f1}{\partial x2} \\ \frac{\partial f2}{\partial x1} & \frac{\partial f2}{\partial x2}\end{bmatrix} \qquad (5) \\ B & = \begin{bmatrix} \frac{\partial f1}{\partial u} \\ \frac{\partial f2}{\partial u} \end{bmatrix} \qquad (6) \end{aligned}

Solving Jacobian (eq. 5, 6) will give us:

\begin{aligned} A & = \begin{bmatrix}0 & 1\\1 & 0\end{bmatrix} \qquad \\ B & = \begin{bmatrix}0 \\ -2 \end{bmatrix} \qquad \\ C & = \begin{bmatrix}1 & 0 \end{bmatrix} \qquad \end{aligned}

note: Matrix C was chosen to be [1, 0] because output variable y is distance from magnet and y=C$\vec{x}$, where $\vec{x}$=[x1,x2]=[x,$\dot{x}$].

http://www.physicsforums.com/showthread.php?p=4408273#post4408273

Now we have LTI model in state-space form, let's continue according to part 1:

### 3. Stability

Start Octave and issue:

A=[0,1;1,0];

B=[0;-2];

C=[1,0];

eig(A)

ans =

-1

1

we can see that system is unstable. Hence needs feedback controller to be stabilized.

### 4. Controlability

isctrb(A,B)

ans = 1

which means the system is controllable.

### 5 Design of the full state feedback controller

To stabilize the system we need to place eigenvalues so that they are all negative. Let's design them to be both poles -1.

P=[-1,-1];

K=place(A,B,P);

Matrix K is computed to be [-1,-1].

Now we can compute new system matrix A and let's call it A_dash:

A_dash=A-B*K;

Matrix is computed to be A_dash=[0,1;-1,-2].

Check the eigenvalues out:

eig(A_dash)

ans =

-1

-1

to find out that the system with a feedback is now stable.

### 6. Conclusion

In this point I'd like to emphasize one thing the whole philosophy behind design of the controller is this. We have a real system which is likely to be non-linear. We linearize the system because then we are able to better analyze it and design controller. Linearization means that we create another system, which is linear but has the same output as the original one (non-linear) when operating close to the point of linearization = steady point. Then we design a controller for the linearized model **BUT** apply the controller for the original non-linear model. Please, keep in mind there are 2 different things:

1. system that has to be linearized (if not linear by itself which usually is not the case)

2. controller designed for linearized system but used in real life on non-linear system.

It is also important to realize that matrixes A,B,C,D, vector, x, equation x_dot = Ax + Bu; y = Cx, all this is just to model the system. The controller itself is hidden in the K matrix.

Therefore:

- Model the system (linearize about an operating point if needed)

- Close the loop by u=-Kx (use for example pole placement)

- Implement the non-linear system

- Use K to control the system = to drive it to the zero

- Use r*N_scale to drive the system to the desired value represented by r

Note: refer to N_scale in here.

### 7. Simulation

Below you may find a processing applet that is demonstrating our full-state feedback controller. The simulation runs non-linear equation (1) and the ball is stabilized by the controller designed in point 3.

- pres "RUN" button to run the simulation

- move a ball by the mouse

## Comments

1234567891011»c2231c2074322.com: http://c2231c2074322.com,

c2231c2074322.com,

http://c2231c2074322.com

c2231c2074322.com: http://c2231c2074322.com,

c2231c2074322.com,

http://c2231c2074322.com

1234567891011»RSS feed for comments to this post