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

Nenhum comentário: