Mostrando postagens com marcador engineering. Mostrar todas as postagens
Mostrando postagens com marcador engineering. Mostrar todas as postagens

quarta-feira, novembro 04, 2009

How to plot the state-space output using Matlab

Suppose we need to determine the wave form, overshoot , rise time, settling time and the final value (steady state output value) of a specific process.

Moreover, instead of function transfer G(s) we've got the State-Space equations. How to do it in a easy way? I mean, how to do it without any kind of math ?

Simulink has block named State-Space. It requires four matrices (A, B, C e D) that are the solution of State-Space equations, as shown below.

State-Space equation are

and

where
x = state vector (n-vector)
u = control vector (r-vector)
y = system's output vector (m-vector)
A = n x m constant matrix
B  = n x r constant matrix
C = m x n constant matrix
D = m x r constant matrix

All we need to do is to determine these four matrices and to use the State-Space block. Is it too complicated? No at all.


Let me use an example to explain the process.

Suppose we have the following State-Space equations:


We can rewrite these equations in order to let them look like matrices. Take a look:

 

By inspection we get the four matrices:

  
 
 

Now you must create a new Simulink model and then you will insert the State-Space block (you can find it on Simulink->Continuous)

The next step is to connect Step and Scope blocks, as show below.


You need to use Matlab syntax to express the matrices. So, we have

A = [0 1; -4 -2]
B = [0;4]
C = [1 0]
D = [0;0]

As all D's elements are zero, we can rewrite D matrix as

D = 0

Double-click the State-Space block then insert A, B, C e D values as shown in the picture below.


Ok. Now you just need to simulate it, get the output system's graphic and get all values directly from it.

The graphic to this sample system  can be seen in the next picture.


I recommend you to read Ogata's Modern Control Engineering.

Did you like this post? Please rate it. Did you dislike it? So your rate is much more important!

Did I make any mistake? Wrong theory? Bad English? Wrong command? Please, post a comment complaining about it. So I can improve my posts.

sábado, outubro 10, 2009

How to use matlab to get the digital controller when we already have its analog version

Suppose you have the transfer function of an analog controller and that you wish to get the digital version of it.

How to accomplish this in an easy way? It's simple. Matlab has a function named c2dm that does the trick.

On Matlab's command window type
[numDz, DenDz] = c2dm(num, den, Ts, 'zoh')
where
  • numDz is the discrete system numerator we want to obtain
  • denDz is the discrete system denominator we want to obtain
  • num it is analog controller's numerator
  • den it is analog controller's denominator
  • Ts it is the sample time we want to use
  • 'zoh' It tells to c2dm function we wish converte the continuos system to discrete system using the Zero Order Hold operation.
I'm going to use an example to explain you how to use c2dm.

Let me say you have the process shown of picture 1.

Picture 1 - a process that uses an analog controller
num e den are obtained by inspecting our analog controller transfer function:
num = [4 1]
den = [4 0]
Let me assume you want sample time equals 0.25 seconds. It means Ts = 0.25s.

Picture 2 shows all commands you must type and the expected results:

Picture 2 - c2dm command executed and the result

What now? Now you will use block Discrete Transfer Function, numDz and denDz to write the discrete controller transfer function. This controller will replace the analog controller as shown on picture 3.

Picture 3 - a process that uses the digital controller

It's easy, isn't it?

To finish, picture 4 shows the output produced by both analog regulator and digital regulator (in yellow and in purple colors, respectively).

Picture 4 - outputs produced by analog and digital regulators

sábado, agosto 22, 2009

Free ARM microcontroller

Three weeks ago I read on blog do Jê, that NXP was offering free samples of its microcontrollers LPC1766, LPC2478, LPC3130 and LPC3250.

I ordered the samples at NXP's home page. It arrived on August 18, 2009.

I didn't receive samples of all microcontrollers as I've ordered, I received just one sample of LPC1766. Anyway, I am very satisfied and I plan to use it as soon as possible.

If you like Electronics like me and you're interested on microcontrollers, give you a chance to get some free samples too. Up to the moment I was writting this post you could order them here.