# "True" Digital Control

Electronics - Devices

Nov 15, 2013 (2 years and 11 months ago)

54 views

“True” Digital Control

.. or using the fact that we are
sampling the signals to our

More on the z
-
transform

We need to examine the z
-
transform in
more detail.

First, we look at two of the elements we
have considered before
--

SAMPLERS and
the ZERO
-
ORDER HOLD (often referred
to just as a HOLD).

The sampler

When the switch (sampler) closes, the
signal at A proceeds to B.

No signal reaches B except when the
sampler closes.

This idea represents the action of a digital
controller in that it only calculates its output
at the sampling instants.

A

B

The Hold

But the ‘plant’ will need to be given an
input all the time
--

just a ‘punch on the
nose’ at the sampling instants is unlikely to
work well.

This is where the Zero
-
Order Hold comes
into action ...

The Zero
-
Order Hold

This is the idea:

The value of the signal at C is ‘caught’ by
the hold and held constant until the sampler
closes again.

Hold

A

B

C

Why a ‘Zero
-
Order Hold’ ?

Because it just catches the value of the
signal at C.

A ‘First
-
Order Hold” would also catch the
rate of change of the signal ...

... and keep it changing at that rate.

But that is complicated, so the Zero
-
Order
Hold is invariably used !

What will it consist of ?

Normally a latching
-
type output port on the
control computer attached to a D
-
A
converter.

Now for the z
-
transform

It only tells us what happens at sampling
intervals

Consider this diagram:

y

Time ( t)

T
s

3T
s

5T
s

etc

y(T
s
)

y(4T
s
)

The z
-
transform
--

Continued

Suppose the switch closes for a time T
c

at
each sampling instant

We have a series of impulses

Each has a Laplace Transform equal to its
area (‘strength’) times e
-
nTs

to allow for the
time at which it occurs

So the Laplace Transform of the complete
sampled signal will be:

..and continues further ...

T
c
(y(0) + y(T
s
)e
-
sTs

+ y(2T
s
)e
-
2sTs

+ ...)

or

We now put z = e
sTs

and it simplifies ...

T
y
rT
e
c
s
srT
r
s
(
)

0
T
y
rT
z
c
s
r
r
(
)

0
So working them out looks heavy
going ...

But fortunately, like Laplace Transforms,
they can be looked up in tables ...

... or converted by MATLAB using the
‘c2dm’ function.

This time, we leave the ‘tustin’ out...

[npd,dpd]=c2dm(num,den,ts,
’zoh’
)

The
‘zoh’
can be omitted.

Rules for converting Block
Diagrams to z

If blocks are separated by a sampler,
convert the TFs to z and then combine the
blocks.

If they are not, combine them in s and then
convert to z.

This sounds complicated but it is actually
easier than it looks ...

An Example

The samplers close at each sampling instant

We must first combine the zero
-
order hold
and the plant in s ...

... and then convert to z.

Zero
-
order

hold

Plant

G(s)

+

--

Send for MATLAB !

‘c2dm’ will convert the hold
-
plant
combination to z for us.

In order to determine the required D(z), we
then specify the required closed
-
loop
performance as a C.L.T.F. in z ...

... and work out what D(z) will have to be in
order to provide it.

We will find that a problem arises but it is
not insurmountable.

An example situation

We will re
-
examine our plant of transfer
function

40/(s
2

+ 10s + 20)

and we will try to work out a controller D(z)
which will produce a unit step
-
response
following a nice gentle first
-
order
exponential.

We will use a time constant of 0.4 second.

Our intended step
-
response

0

0.5

1

1.5

2

0

0.2

0.4

0.6

0.8

1

Time (secs)

Amplitude

Converting the plant T.F. to z

We enlist the aid of MATLAB and ‘c2dm’,
entering

num=40;

den=[1 10 20];

[npd,dpd]=c2dm(num,den,.1)

and we obtain

The digitised plant T.F.

npd =

0 0.1449 0.1038

dpd =

1.0000
-
1.2435 0.3679

So the TF of plant + hold is

(0.1449z + 0.1038)/(z
2

-

1.2435z + 0.3679)

The digitised plant TF
-

Continued

or since it is (apart from MATLAB) usually
more convenient to use negative powers of
z

(0.1449z
-
1

+ 0.1038z
-
2
)/(1
-

1.2435z
-
1

+
0.3679z
-
2
)

The required closed
-
loop T.F.

Input = unit step converting to z/(z
-

1)
(from tables)

Output = 1
-

e
-
t/0.4

Another ‘bout’ with the tables produces

Output(z) =

(
)
(
)(
)
.
.
1
1
0
4
0
4

e
z
z
z
e
T
T
s
s
The required C.L.T.F.
--

Continued

Which becomes with T
s

= 0.1 second

And we divide by the input z/(z
-

1) to give
the CLTF

0.2212/(z
-

0.7788)

0
2212
1
0
7788
.
(
)(
.
)
z
z
z

Now for the required D(z)

We do a DG/(1 + DG) act again:

DG/(1 + DG) = 0.2212/(z
-

0.7788)

and by rearranging

DGz
-

0.7788DG = 0.2212 + 0.2212DG

and

D = 0.2212/[(z
-

1)G]

And now for D(z) ...

G(z) was

(0.1449z + 0.1038)/(z
2

-

1.2435z + 0.3679)

so by rearranging, D(z) becomes

1.5267
-

1.8985z
-
1

+ 0.5616z
-
2

-------------------------------------

1.0000
-

0.2833z
-
1
-

0.7167z
-
2

We will try this in SIMULINK ....

The resulting step
-
response

1

2

3

4

0

0.5

1

1.5

Time (second)

Not quite as intended !

Oh dear ! There is a slight wobble on the
plant output ...

... and a much worse one from the
controller.

Let us examine D(z) again.

The Ringing Pole

The denominator of the controller transfer
function was calculated by:

(z
-

1)(0.1449z
-
1

+ 0.1038z
-
2
)

The second bracket is zero when z =
-

0.72

So the controller has a pole at z =
-

0.72

This is a Ringing Pole .. a Bad Thing

The s
-

and z
-
planes

We remember that in s ...

...poles with positive real parts meant
unstable systems, and ..

...poles with non
-
zero imaginary parts
meant systems with overshoot.

What is the situation in z ?

This one may be ignored by non
-
mathematicians ...

We think of s as a + jw

Normally a > 0 means instability

For z, e
(a + jw)Ts
= e
aTs

x e
jwTs

De Moivre: e
jwTs

= cos(wTs) + j sin(wTs)

so its magnitude is 1.

And |z| > 1 if a > 0

So for stability |z| < 1.

Rules of the z
-
plane

Systems with all their poles inside a circle
of radius 1 unit centred on the origin
--

the
Unit Circle
--

are stable.

Again, poles off the real axis indicate step
overshoot.

parts indicate oscillatory behaviour at half
the sampling frequency.

We avoid them at all costs !!!

“Oh, my controller is ringing !”

What we need to do to stop it is to replace
the offending bracket by an equivalent static
gain.

Not as difficult as it sounds

Calculate the gain by putting z = 1 ...

... and keep the most positive (or least
negative) power of z.

“The bell is removed ... ”

We start from 0.1449z
-
1

+ 0.1038z
-
2

Putting z = 1 gives 0.2487

Reinstating the z
-
1
gives 0.2487z
-
1

The complete controller T.F. becomes

0.8894
-

1.1062z
-
1

+ 0.3273z
-
2

------------------------------------

1
-

z
-
1

This one works much better

Response
-

no ringing pole

1

2

3

4

0

0.2

0.4

0.6

0.8

1

Time (second)

The Kalman Controller

“Back to basics !”

nth
-
order systems can be made to settle in n
sampling intervals

For a second
-
order, we could regard the first
interval controller action as the
“accelerator” and the second one as the
“brakes”.

Producing a Kalman Controller

... in our example:

(0.1449z + 0.1038)/(z
2

-

1.2435z + 0.3679)

and we make the coefficients in the
numerator add up to 1 (known as
‘normalising’ the T.F.)

We do this by adding the 0.1449 and the
0.1038 together, giving 0.2487 ...

The Kalman
--

Continued

... and dividing top and bottom of our T.F.
by that number.

The plant T.F. becomes

0.5825z
-
1

+ 0.4175z
-
2

------------------------------------

4.020
-

4.9995z
-
1

+ 1.4790z
-
2

and we regard it as P(z)/Q(z).

Nearly to the Kalman !

It turns out that the controller TF should be
Q(z)/[1
-

P(z)] !

So it will be

4.020
-

4.9995z
-
1

+ 1.4790z
-
2

-----------------------------------

1
-

0.5825z
-
1

-

0.4175z
-
2

and we duly test with SIMULINK ...

The response with the Kalman

0.2

0.4

0.6

0.8

1

-
1

0

1

2

3

4

Time (second)

Why don’t we always use the
Kalman ?

It depends on a good plant model being
available (and the plant dynamics not
changing) in order to work well

A heavy controller action is usual unless we
sample slowly enough to encounter aliasing
problems
--

we will revisit this problem in
the lecture on ‘Practicalities’