# 16.30 Topic 20: Digital control basics - MIT OpenCourseWare

Electronics - Devices

Nov 15, 2013 (4 years and 8 months ago)

73 views

Topic #20
16.30/31 Feedback Control Systems
Digital Control Basics

E ective Delay
Emulation

Fall 2010 16.30/31 20{1
Digital Control
Control picture so far

d
r
G
c
(s)
G
p
(s)
e u
y

Can implement this using analog circuits, but as you have seen, there

are many advantages to implementing these using a computer { much
more exible
In this case the new picture is:

G
c
(s)
D2A
A2D
G
p
(s)
A2D
r(t)
e
k
u
k
u(t)
y(t)
y
k

Digital Computer
November 5, 2010
Fall 2010 16.30/31 20{2
Digital Control Mechanics

Digital/discrete control runs on a clock

Only uses the input signals at discrete instants in time

So continuous e(t) is sampled at xed periods in time e(kT
s
)

Where T
s
is the sampling period and k is an integer

Must also get information into and out of the computer

Requires A/D and D/A operations

The A/D consists of 2 steps:
1.
Convert a physical signal (voltage) to a binary number, which is
an approximation since we will only have a 12-16 bits to cover a

10V range.
2.
Sample a continuous signal e(t) every T
s
seconds so that
y(t) y(k)
)
3.
Sampler clearly ignores a large part of the continuous signal.
November 5, 2010
y(t)
y(k)
T
s
Image by MIT OpenCourseWare.
Fall 2010 16.30/31 20{3

The D/A consists of 2 steps as well
1.
Binary to analog
2.
Convert discrete signal (at kT
s
) to a continuous one.

Basic approach is to just hold the latest value of u(k) for the entire
periods T
s

Called a zero-order hold (ZOH)

Need to determine what impact this \sample and hold" operation
might have on the loop transfer function

Approximate the A/D as sample

Approximate D/A as ZOH

Set control law to 1, so u(k) = e(k)
November 5, 2010
k = 1 1 2 3 4 5 6 7
u(k)
u(t)
Easiest way is to just
hold u(k) for period T
s
?
Image by MIT OpenCourseWare.
y(t) A/D CONTROL D/A u(t)
y(t) ZOH u(t)
T
s
u(k) = y(k)
Image by MIT OpenCourseWare.
Fall 2010 16.30/31 20{4
Sample and Hold Analysis

Can actually analyze the transfer function U(s)=E(e) analytically

Can also gain some insight by looking at basic signals

u(k) has a standard box car shape

Smoothed u(k) by connecting mid-points
)
u^(t)

So sampled and held e(t) looks like input e(t), but delay is obvious.

Analytic study of U(s)=E(e) shows that e ective delay of sample and
hold is T
s
=2 on average

Can be a problem if T
s
is too large
November 5, 2010
Fall 2010 16.30/31 20{5

So why not just make T
s
small?

Key point is that T
s
is how long we have to compute the control
command given the measurements received

Usually wait period is short, but length of calc 1 and calc 2,
A/D and D/A operations depend on the complexity of the algorithm
and the quality of the equipment

But quality
")
cost
""
Typically would set sampling frequency !
2
=
2

15!
BW

T
s
November 5, 2010
Time
Calc #1
Calc #2
Wait
Image by MIT OpenCourseWare.
Fall 2010 16.30/31 20{6
Control Law

Basic compensator
s + z U(s)
G
c
(s) = K
c
=
s + p E(s)

Equivalent di erential equation form
u_ + pu = K
c
( _e + ze)

Di erential equation form not useful for a computer implementation
- need to approximate the di erentials
u_
1
[u((k + 1)T
s
)

u(kT
s
)]

u
k+1

u
k
t=kT
s
j 
T
s
T
s

This uses the forward approximation, but others exist

Then u_ + pu = K
c
( _e + ze) approximately becomes
u
k+1

u
k
+ pu
k
= K
c
(
e
k+1

e
k
+ ze
k
)
T
s
T
s
or
u
k+1
= (1

pT
s
)u
k
+ K
c
e
k+1

K
c
(1

zT
s
)e
k
which is a recursive di erence equation, that can easily be imple<
mented on a computer.

Similar case for state space controllers
x_
c
= A
c
x
c
+ B
c
e
u = C
c
x
c
+ D
c
e
x
c
(k+1)

x
c
(k)
and x
_
c

T
s
so that
x
c
(k + 1)

x
c
(k)
= A
c
x
c
+ B
c
e
T
s
x
c
(k +1) = (I + T
s
A
c
)x
c
(k) + T
s
B
c
e(k)
u(k) = C
c
x
c
(k) + D
c
e(k)
November 5, 2010
Fall 2010 16.30/31 20{7
Computer Code Layout

Given previous information u
k
and e
k
and new information y
k+1
and
r
k+1
, form e
k+1

Need to use the di erence equation to nd u
k+1
u
k+1
= (1

pT
s
)u
k
+ K
c
e
k+1

K
c
(1

zT
s
)e
k

Then let u
old
= (1

pT
s
)u
k

K
c
(1

zT
s
)e
k
, so that
u
k+1
= K
c
e
k+1
+ u
old

Also de ne constants
1
= (1

pT
s
) and
2
=

K
c
(1

zT
s
)

Then the code layout is as follows:
initialize u
old
while k < 1000 do
k = k +1
sample A/D's (read y
k+1
, r
k+1
)
compute e
k+1
= r
k+1

y
k+1
update u
k+1
= K
c
e
k+1
+ u
old
output to D/A (write u
k+1
)
update u
old
=
1
u
k+1
+
2
e
k+1
wait
end while

Note that this outputs the control as soon after the data read as
possible to reduce the delay

result is that the write time might be unknown

Could write u
k+1
at end of wait { delay is longer, but xed
November 5, 2010
Fall 2010 16.30/31 20{8
Summary

Using a digital computer introduces some extra delay

Sample and hold

T
s
=2 delay

Holding u(k) to end of loop

T
s
delay

So the delay is

T
s
=2{3T
s
=2

Emulation process { design the continuous control accounting for an
extra
!
c
T
s
180

!
c
2 180

!
c
= = 180

2

 2!
s

 !
s
to the PM to account for the delay.

With !
s

15!
BW
, delay e ects are small, and the cts and discrete
controllers are similar

c2dm.m provides simple ways to discretize the continuous controllers

Lots of di erent conversion approaches depending on what proper<
ties of the continuous controller you want to preserve.
November 5, 2010
MIT OpenCourseWare
http://ocw.mit.edu
16.30
/ 16.31 Feedback Control Systems
Fall 2010