The very first step in the control design process is to develop appropriate mathematical model of the system derived either from physical laws or experimental data. We introduce the state-space and transfer function representations of dynamic systems. We then review some basic approaches to modeling mechanical and electrical systems and show how to enter these models into MATLAB for further analysis.

### 1. Dynamic systems

Dynamic systems are systems that change or evolve in time according to a fixed rule. For many physical systems, this rule can be stated as a set of first-order differential equations:

x_dot = dx/dt = f( x(t), u(t), t) (1)

x(t) - state vector at time t

u(t) - control input vector at time t

f - nonlinear function giving the time derivative (rate of change) of the state vector, for a particular state, input, and time.

The state at any future time x(t1), may be determined exactly given knowledge of the initial state x(t0) and the time history of the inputs u(t) between t0 and t1 by integrating Eq.(1).

The relationship given in Eq.(1) is very general and can be used to describe a wide variety of different systems; unfortunately, it may be very difficult to analyze. There are two common simplifications which make the problem more tractable.

1) If the function f does not depend explicitly on time, i.e. x_dot = f(x,u) then the system is said to be time invariant. This is often a very reasonable assumption, since the underlying physical laws themselves do not typically depend on time. For time invariant systems, the parameters or coefficients of the function f are constant. The control input, however, may still be time dependent, u(t).

2) In reality, nearly every physical system is nonlinear. In other words, is typically some complicated function of the state and inputs. These nonlinearities arise in many different ways, one of the most common in control systems being "saturation" in which an element of the system reaches a hard physical limit to its operation. Fortunately, over a sufficiently small operating range (think tangent line near a curve), the dynamics of most systems are approximately linear, that is:

x_dot = Ax + Bu

### 2. State-Space Representation

For continuous linear time invariant (LTI) systems, the standard state-space representation is given below:

x_dot = Ax + Bu

y = Cx + Du

x - vector of state variables

u - input = control vector

A - system matrix

B - input matrix

C - output matrix

D - feed-forward matrix (often is zero)

### 3. Transfer Function Representation

LTI systems have the extremely important property that if the input to the system is sinusoidal, then the output will also be sinusoidal at the same frequency but in general with different magnitude and phase. These magnitude and phase differences as a function of frequency are known as the frequency response of the system.

Using the Laplace transform, it is possible to convert a system's time-domain representation into a frequency-domain output/input representation, known as the transfer function. In so doing, it also transforms the governing differential equation into an algebraic equation which is often easier to analyze.

http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=SystemModeling

### 3. Octave

Octave is free alternative to MATLAB.

1. Download and install Octave from http://www.gnu.org/software/octave/download.html

2. Download pkg "Control" from http://octave.sourceforge.net/control/index.html

Tips:

http://octave.sourceforge.net/index.html

**3.1 Installing packages**

You can find the list of packages by clicking on the Packages link at the top. To install a package, use the pkg command from the Octave prompt by typing:

pkg install -forge package_name

where package_name is the name of the package you want to install.

### 4. Entering State-Space Models into Octave

Let's have following LTI system. This system is "A point mass system in 2D".

x_dot = Ax + By;

y = Cx;

A = {{0,1},{0,0}};

B = {0;1};

C = {1,0};

D={};

x_dot = 1st derivative of the vector x: x = {x1, x2};

x1 = positon p

x2 = p_dot => velocity

u = p_dot_dot = acceleration

so x_dot = {x2,u} since x2 = p_dot && x2_dot = u = p_dot_dot

**4.1 To enter matrixes into Octave write this:**

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

B=[0;1];

C=[1,0];

stname = {"position","velocity"};

sys = ss (A,B,C,[],"stname", stname);

Now, we have our system defined in the Octave and the next point of interest is a "stability".

### 5. Stability

We want to analyze whether the open-loop system (without any control) is stable. The eigenvalues of the system matrix (matrix A) (equivalent to the poles of the transfer fucntion) determine the stability. Now the Octave comes into play. To determine eigenvalues of the matrix A simply run:

eig(A)

and something like this should be returned:

ans =

0

0

which means, our eigenvalues are {0,0}. What does this mean?

System can generally be:

a/ unstable - there is at least one positive rational element in eigenvalues. Check eigenvalues of this system out: A=[0,1;1,0]

b/ critically stable - there is a zero real element in eigenvalues, but none positive [at least one Re( eig(A) ) = 0]. Check eigenvalues of this sytem out: A=[0,1;0,0]

c/ asymptotically stable - our GOAL - all real elements of eigenvalues are negative [all Re( eig(A) ) < 0]. Check eigenvalues of this system out: A=[0,1;-1,0]

pic with balls from http://www-control.eng.cam.ac.uk/gv/p6/Handout3.pdf

note: except for rational elements, there also can be irrational element in the eigenvalue number for instance "0 -1i" or "0 -1j". Often denoted as Im( eig(A) ). If Im( eig(A) ) != oscillations of the system may come into play.

note: since eigenvalues of system matrix A = poles of LTI sytem, you can also use command below to get the same result.

pole(sys)

note: to plot poles of the LTI system simply run:

pzmap(sys)

**5.1 But what does it mean?**

System by itself may be stable or unstable. For instance pendulum and inverted pendulum. Pendulum will always 'want' to get to its basic position - heading downwards. You do not have do anything to achive that. On the other hand you have to do 'a lot' to keep an inverted pendulum in its basic position - heading upwards.

To check it out use this system matrixes of pendulum and inverted pendulum we also used above:

a/ pendulum: A=[0,1;-1,0]

b/ inverted pendulum: A=[0,1;1,0]

**5.2 Is our LTI system stable by itself?**

Issue

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

eig(A)

eigenvalues are [0,0] which means that system is critically stable (often called marginally stable). To achieve our goal, asymptotic stability we may close the loop.

### 6. Closing the loop

To close the loop we introduce a new matrix K. This our control matrix. For simplicity, let's assume the reference is zero (desired output), R=0. The input is then:

u = -K*x

Note: With reference r it would be: u = -K*x + r

Then:

x_dot = Ax + B*( -Kx ) = (A - BK)x

and (A - BK) is a new system matrix, let's call it A_dash. A_dash represents now the new system with the closed loop in it. Wen can analyze its stability the same way as we did matrix A. The job is to take such matrix K that the closed-loop system is stabilize, **Re( eig(A_dash) ) < 0**.

We can (a) guess what K= [k1, k2] might be, for example [1,1] or (b) use method called **"pole placement"**.

**6.1 Pole placement**

The name "pole placement" might be confusing unless you know that the poles are eigenvalues of the matrix. Pole = Eigenvalue :).

Now we can again use the Octave. Let's pick some negative eigenvalue to achieve asymptotic stability eig=[-1,-1]. To get K=[k1,k2] issue following command:

P=[-1,-1];

K=place(A,B,P)

where A,B are our old system matrix (use A, not A_dash).

Result: K=[1,2]

**6.2 Beyond pole placement**

If you are interested, look at this methods:

- LQ optimal control

- Kalman filters.

- LQR

### 7. Controlability

Is it always possible to find such K that closes-loop system is asypt.stable? The answer is NO. Let's introduce 2 theorems that will be very helpful:

Theorem 1:

The system

x_dot = Ax + Bu

where x is vector of real numbers with dimension "n", is completely controlable (Cc) if and only if it is possible to go from any initial state to any final state = there is such control input "u", in finite time. To check this compute rank of the controllabilty matrix G (gama).

rank(G) = n; => then the system is Cc.

Theorem 2:

Pole placement to arbitrary eigenvalue(s) is possible if and only if the system is Cc.

In Octave:

G = ctrb(A,B); or G=ctrb(sys);

rank(G);

In our case G=[0,1;1,0] and rank(G) = 2, which is OK since size of input vector x is 2.

You can also use direct command:

isctrb(sys) to get 0/1 boolean result weather is "sys" controllable.

General form of G is G=[B|AB|A^2B|A^n-1B]

### 8. LTI system simulation

To simulate response of the system, we can again use Octave. A few steps above () we have created variable "sys" which represents our system:

A = {{0,1},{0,0}};

B = {0;1};

C = {1,0};

D={};

To graphically visualize response of the system to initial condition x0 use this command:

x0 = [10;0]

initial(sys,x0,10)

after a while (took almost 2 minutes for me) an extra window with a graph appears:

The graph is pretty simple. The straight line demonstrates the critically stable system which our point mass open-loop system really is (to prove that check eig(A) :)).

However we have already closed the open-loop system and created A_dash matrix. eig(A_dash) tells us the system should be asymp. stable. To find out how it looks like issue:

K=[1,2];

A_dash=(A-B*K);

sys_ = ss(A_dash,B,C,[],"stname",stname);

initial(sys_,x0,10);

To visualize LTI model response to arbitrary inputs use this commands (in this case u are only zeros):

t=0:0.1:5;

u=zeros(size(t));

lsim(sys_,u,t,x0);

To visualize step response of LTI system use command below. A step input can be described as a change in the input from zero to a finite value at time t = 0. By default, the step command performs a unit step (i.e. the input goes from zero to one at time t = 0).

step(sys_);

The processing applet below demonstrates response of the point mass system in 2D to a finite input. The system drives from the initial state to its reference (input) state by itself.

Note: press any key to reset the graph.

A = {{0,1},{0,0}};

B = {{0};{1}};

C = {1,0};

D={};

K={1,2};

x={{100};{0}}

u={20}

**8.1 Reference input**

To visualize response of LTI system to arbitrary input use "lsim" command.

Important note:

In the schematic above you can see that we compare reference input to result of u=K*x multiplication and not output of the system y !!! So very often there is a problem with variable scale. To get correct result you have to scale your input vector "u" by a scale factor of the LTI sytem "N_scale". N_scale can be computed:

s = size(A,1);

Z = [zeros([1,s]) 1];

D = sys.d; or sys_.d;

N = inv([A,B;C,D])*Z';

Nx = N(1:s);

Nu = N(1+s);

N_scale=Nu + K*Nx;

and now run the simulation. N_scale for our system "sys" is "1":

t=0:0.1:5;

u=50*ones(size(t));

lsim(sys_,N_scale*u,t);

or

lsim(sys_,N_scale*u,t,x0);

Note: It took me a while to realize that there are actually 2 different u variables as u - input into system. One 'u' is u that is computed as a result of closing loop by feedback, eg. u = -K*x (the system is driven to get to the 0, that is steady state) or u = -K*x + r (the system is driven to get to the value of r). This u basically changes over time.

Second 'u' appears in lsim command (http://octave.sourceforge.net/control/function/lsim.html) and refers to input signal of a simulated system. Since we simulate sys_ which is actually system with the closed loop, the 'u' is kind of reference r.

### 9. Observer

So far we have pretended that all variables of state vector "x" are fully available. In reality that often is not the case.

**9.1 Observability**

Actual state of the controlled system is denoted by variable "x". In our example it is x=[x1,x2]=[position,velocity]. Both of these variables (x1,x2) are directly measurable, but there are a lot of systems having such state variables that are not measurable directly. For instance if the component is in an inaccessible location. In these cases it is neccesary to estimate the values of the unknown internal state variables using only the available system outputs - y.

Luenberger was the first to realise that practically any other LTI system (which we'll call the "observer") could act as a estimator of the state of a completely observable (CO) LTI target system.

For LTI systems, the system is observable if and only if the observability matrix, OB, has full rank (if rank(OB) = n where n is the number of states = size of state vector x). The observability of an LTI model can be determined in Octave using the command:

rank(obsv(A,C)) or rank(obsv(sys)) or isobsv(sys)

General form of OB is OB = [C;CA;CA^2;CA^n-1]

**9.2 Separation principle**

*Controllability and observability are nicely interconnected. A system (A,B) is controllable if and only if a system (A',C,B',D) is observable. This fact is very useful when designing an observer.*

Assume that system is CC & CO (Completely Controllable and Completely Observable) then:

1. design the state feedback controller as if we had state x

2. estimate x using an observer and let's call it $\hat{x}$

\begin{aligned} \dot{\hat{x}} & = A \vec{\hat{x}} + B \vec{u} + L*(y - C*\hat{x}) \end{aligned}

where

\begin{aligned}A \vec{\hat{x}} + B \vec{u} & = predictor \\ L*(y - C*\hat{x}) & = corrector\end{aligned}

Then error e

\begin{aligned} e & =x - \hat{x} \\ \dot{e} & = \dot{x} - \dot{\hat{x}} \\ \dot{e} & = (A - LC)*e \end{aligned}

### How to design controllers and observers using state-space (or time-domain) methods.

http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=ControlStateSpace

### Reference

http://faculty.salina.k-state.edu/tim/robotics_sg/Control/controllers/linear.html

## Comments

1234567891011»of writing i thought i could also create comment due to this sensible article.

have got here on this post. I will be coming

back to your website for more soon.

have got here on this post. I will be coming

back to your website for more soon.

have got here on this post. I will be coming

back to your website for more soon.

have got here on this post. I will be coming

back to your website for more soon.

this blog carries remarkable and truly excellent material in favor of

readers.

this blog carries remarkable and truly excellent material in favor of

readers.

this blog carries remarkable and truly excellent material in favor of

readers.

absolutely useful and it has aided me out loads. I hope to contribute & assist other customers like its helped

me. Good job.

absolutely useful and it has aided me out loads. I hope to contribute & assist other customers like its helped

me. Good job.

high in google. But you can fix this issue fast. There is a tool that creates articles like human, just search in google: miftolo's tools

1234567891011»RSS feed for comments to this post