## LTI systems 2

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.

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}$].

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

0 #277 eventbrite.com 2019-05-09 01:12
Please let me know if you're looking for a writer for your site.

You have some really great articles and I think I would be a good asset.
If you ever want to take some of the load off, I'd love to write some articles for
me an email if interested. Cheers!

My web site - eventbrite.com: http://eventbrite.com

0 #276 Viagra Piller 2019-04-21 17:12
Hmm it appears like your website ate my first comment (it
was super long) so I guess I'll just sum it up what I wrote and say, I'm
thoroughly enjoying your blog. I as well am an aspiring blog blogger but I'm still new to everything.
Do you have any tips for beginner blog writers?
I'd certainly appreciate it.

0 #275 Viagra Piller 2019-04-17 17:33
I visited many sites however the audio feature for audio songs existing
at this website is actually fabulous.

0 #274 Viagra Piller 2019-04-15 09:26
You could certainly see your expertise within the article you write.
The arena hopes for even more passionate writers like you who are not afraid to mention how they believe.
All the time go after your heart.

0 #273 Dusty 2019-04-14 16:33
Today, I went to the beachfront with my children. I found a sea shell and gave it
to my 4 year old daughter and said "You can hear the ocean if you put this to your ear." She put the shell to
her ear and screamed. There was a hermit crab inside and it pinched her ear.
She never wants to go back! LoL I know this is
totally off topic but I had to tell someone!

Feel free to surf to my blog :: Dusty: http://sogou.com

0 #272 Douglaslek 2018-11-28 14:47

0 #271 gtaletqwus 2018-10-15 23:11
cheap levitra: http://top-monterey-salinas-dentists.com levitra 20 mg film coated tablets http://top-monterey-salinas-dentists.com

0 #270 otaletkcep 2018-10-15 19:11

0 #269 staletinuv 2018-10-15 08:27

0 #268 gtaletdfff 2018-10-15 00:31

0 #267 gtaletfnyv 2018-10-14 14:51

0 #266 etaletqlck 2018-10-14 12:17

0 #265 utaletmrtf 2018-10-14 12:15

0 #264 etaletztun 2018-10-14 07:33

0 #263 gtalethgts 2018-10-14 00:59
cheap cialis tablet: http://gigawatt6.com order generic cialis online no prescription http://gigawatt6.com

0 #262 mtaletnrll 2018-10-13 23:15

0 #261 ktaletwndz 2018-10-13 22:49
generic cialis online pharmacy: http://rabbitinahat.com cheap cialis in the usa http://rabbitinahat.com

0 #260 htaletgbku 2018-10-13 19:34
how long for cialis to work: http://valladium.com usa rundreise erfahrungsberic ht cialis http://valladium.com

0 #259 btaletweqb 2018-10-13 11:36
cialis 90 pills: http://baymontelreno.com red cialis viagra usa http://baymontelreno.com