Continuous Systems And Sampled Systems
Background
More Complex Systems (2nd Order, Real Poles)
Implementing Digital Control


Background

        Many control systems are implemented digitally.  The usual control process goes something like this.

        If we want to predict the behavior of a system that performs as described above, then we need to be able to work with systems that contain both discrete time parts (described in the language of Z-transforms) and continuous time systems (described in the language of Laplace transforms).  Here are the steps that you have to be concerned with.

That's the process.  We'll look at a simple example to discover how each of these steps unfolds.

        The first step in the process is to describe the continuous system when it is driven by a zero-order-hold (ZOH) signal.  If you aren't sure of how that works, click here to see how to get a sampled description of a continuous time, first order system.

        We will begin with a very simple system.

Next, we construct a block diagram to represent this system.  Here's what we get.

We can get the equivalent transfer function in the z-domain for the transfer function we have - G(s) = 1/(s + 1).  For a first order linear system, the general form is:

G[z] = (1 - e-Ts/t)/(z - e-Ts/t)

With:

Now, we can examine the performance of this system.  We can see some aspects of how the system performs by looking at a root locus.  Note the following: That means that our example system will have a root locus like this one.

Note the following about this root locus.


More Complex Systems

        The example system is pretty simple.  There are lots of ways the system can become more complex.  Here are some things to consider.

We will look at these two possibilities and we will look at more complex systems first.

        If the system is more complex, you will still have the problem of determining how the system responds when driven by a ZOH element.  That's important for the following reasons.

There are easy ways to compute the ZOH equivalent.  This is an important enough problem that you can find a function in Matlab that will do the computation.  We'll show that with an example system.

        Here is the block diagram of our system again.

We are going to consider a more complex, G(s).  In particular, we will look at what happens when G(s) is a second order system with two real poles.  The example we will use is:

G(s) = 1/(s + 1)(s + 2)

        We need a way to convert this system to the ZOH equivalent.  We could try to represent the system as two parallel systems using a partial fraction representation.  However the simplest way is to use Matlab to convert it.  Here's the Matlab code that not only converts G(s) to Geq[z], but also plots the root locus for the system.

Num = 1
Den = [ 1 3 2]
Sys = tf(Num,Den)
SysD = c2d(Sys,TS,'zoh')
rlocus (SysD)
zgrid
The discrete version of the system is given by the form below, using the Matlab output format.
Transfer function:
  0.07741 z + 0.04695
-----------------------
z2 - 0.9744 z + 0.2231

Sampling time: 0.5

Then, using this transfer function, we can plot the root locus, and obtain the following root locus.

This root locus looks interesting because is shows that this second order system can also become unstable for high enough gains, although there comes a time when one pole re-enters the unit circle.  However, it is still unstable at that point because there is still one pole outside the unit circle.

        For higher order systems, the process is the same.  If someone has programmed the conversion algorithm take advantage of that and use it.


Control Algorithms

        If we are trying to implement something like integral control, for example, we might use code like the following:

// I = Integral
I = I + Ts*Error;
ControlSignal = Ki*I;
This code really implements a difference equation:

Ik = Ik-1 + Ts*Errork-1

Then, we can take the Z-transform of this difference equation for the integral computation.  (We will assume zero initial conditions since we are trying to determine a transfer function.)

I[z] = z-1I[z] + z-1Ts*Error[z]

So,

I[z](1 - z-1) = z-1Ts*Error[z]
and:
I[z] = z-1Ts*Error[z]/(1 - z-1)
and:
I[z] = Error[z]*{Ts/(z - 1)}

        The transfer function of this digital integrator is then given by:

Gint[z] = Ts/(z - 1)

How do we use this result?  Well, if you implement digital control in a program - as above - then, the equivalent block diagram for that digital implementation is the one shown below.

In this system, the digital integration is shown with Gint[z].

        Let's go back to our particular example above.  Here are the details of the system we used.

Next, we refer to the block diagram above, and we note that we need the equivalent transfer function for the continuous system in the sampled representation.  That equivalent transfer function is given by:

G[z] = (1 - e-Ts/t)/(z - e-Ts/t)

With:

The block diagram for the equivalent system is the one shown below.

Note that the numerator of the integral controller block has a term .5*Ki.  That term is really Ts*Ki, but the process transfer function, G(s), was transformed assuming that the sampling period was 0.5 second.  You have to use the same sampling period in the calculation of the integral.

        Now, you can do some analysis of the equivalent system.  Doing a root locus, we find some interesting things can happen in this system also.  Here is the root locus for this system.

In this root locus, we again see that the system can become unstable.  To calculate the gain at which the system becomes unstable, we first calculate the root locus gain as the product of pole distances to the point on the locus where the poles exit the unit circle.  That's shown in the plot below.

We need to determine the length of the two lines shown in purple on the plot.  Actually, they are both the same length, and each length is about 0.6.  Taking that value, we calculate the root locus gain.

KRL = (0.6)2 = 0.36

Then, we have (Check the block diagram above.):

KRL = 0.5*Ki * 0.393

So, the integrator gain, Ki, at which the system becomes stable is:

Ki  = 0.36/(0.5 * 0.393)

or:
Ki = 1.83


Some Reflections On The Integral Control System Implementation

        There are some interesting things going on in the integral control system, and they can be confusing.

        Now, there are some other unposed questions that will require you to go to another lesson.  Here's the most important question. Click here to go to that lesson.