You are on page 1of 19

1/18

Lecture 4: Experiment 3
EE380 (Control Systems)

Ramprasad Potluri Manavaalan Gunasekaran


Associate Professor PhD student
potluri@iitk.ac.in manvaal@iitk.ac.in
JJ
Department of Electrical Engineering II
Indian Institute of Technology Kanpur
J
I
Back
August 19, 2011 Forward
Close
2/18

Contents
1 Announcements 4

I Procedure of Exp.3 5
2 Outline of the experiment 6

3 Tasks common to all 6 experiments 7

4 Second Ziegler-Nichols method 8

5 Homework (HW) vs. Lab work (LW) 9

6 Discretization 10

7 Simulate; LW: C code, Implement, Analyze 11


JJ
II
J
II Review of Exp.2: Least squares sys-id theory 12 I
Back
8 Bilinear transform and Z-transform 13
Forward
Close
9 G (s) ←→ G (z) 14 3/18

10 How Z-transform used in our sys-id 15

11 What is least squares sys-id? (1/2) 16

12 What is least squares sys-id? (2/2) 17

III Review of Exp.2: What the experiment taught 18

JJ
II
J
I
Back
Forward
Close
4/18

Announcements
• Before doing an experiment, download latest versions of sup-
porting documents from Brihaspati.
• Turn off power supply to board when not programming dsPIC or
taking readings.
• After completion of experiment
– Shut down PC, FG, PS.
– Remove PICkit 2 from dsPIC board.

JJ
II
J
I
Back
Forward
Close
Part I 5/18

Procedure of Exp.3

JJ
II
J
I
Back
Forward
Close
6/18

Outline of the experiment


Want speed of motor to track a reference step. Steps:
• Convert plant into 3rd order by prefixing 2nd order TF.

H (s) Saturation
û 29 u

u u 1 Vreq
≤ 0.8 actual δ
PWM H-bridge Motor
ω
2
s + 10s + 29 Vs Vs

Here, û is controller’s output, uactual is numerical value of voltage applied to motor’s arma-
ture. Vreq is actual voltage applied to motor’s armature, δ is duty ratio of PWM signal.

• Apply step & tune k p so that CL system’s output oscillates sus- JJ


tainedly. II
J
• Determine coefficients of P, PI, PID controllers. I
• Observe CL system’s response to step under P, PI, PID control. Back
Forward
Close
7/18

Tasks common to all 6 experiments


Simulation
• Perform PC-based simulation of CL system using GNU Octave.
• Perform PC-based simulation of digital control of a continuous-time system using
GNU Octave.

Realization on hardware
• Utilize the various components of an integrated development environment (IDE):
editor, compiler, linker, debugger, and programmer to program a µC.
• Program controller using C language into µC.
• Monitoring: read data into PC from µC using UART modules.
JJ
Analysis II
J
• Compare actual performance with predicted performance.
I
Back
Forward
Close
8/18

Second Ziegler-Nichols method


Applies to plants exhibiting sustained oscillations in CL propor-
tional control for some k p = k cr > 0.
ωref + u ω
kp Plant
Step 1: Form CL system with k p > 0. −

Step 2: Apply step ωref to CL system and record ω.


Step 3: With ωref on, increase k p from 0 to k cr .
Step 4: Determine period Pcr of oscillations.
Step 5: Tune parameters of PID controller according to table.
JJ
Type of controller kp Ti TD II
P 0.5k cr ∞ 0 J
PI 0.45k cr (1/1.2) Pcr 0 I
PID 0.6k cr 0.5Pcr 0.125Pcr Back
Forward
Close
9/18

Homework (HW) vs. Lab work (LW)


HW LW

29
Prefix s2 +10s +29
to math model from Exp.1 Program H (s) into dsPIC

Determine k cr & Pcr Form CL sys with k p


Apply step ωref
Tune k p until sustained oscillations
Determine P, PI, PID controllers Determine k cr , Pcr

Simulate using tf, step, easysim.m Determine PID controller


JJ
II
Comment on observations
Simulate using easysim.m J
I
Descretize & code in C
Back
H (s) and controllers Program PID controller & verify
Forward
Close
10/18

Discretization
a1 s + a0
s2 + b1 s + b0

Simulation
diagram

ẋ1 = x2
ẋ2 = −b0 x1 − b1 x2 + u
y = a0 x1 + a1 x2

Euler’s
approximation
JJ
x1(k+1) = x1(k) + ∆t x2(k) II
x2(k+1) = −b0 ∆t x1(k) + (1 − b1 ∆t) x2(k) + ∆t uk J
y k = a 0 x 1( k ) + a 1 x 2( k ) I
Back
Forward
Close
11/18

Simulate; LW: C code, Implement, Analyze


• Simulation: easysim.m • Implement: As in demo slides
• Discretized controller
−→ C code: • Analyze: Compare results

x1 (k + 1) = a11 x1 (k ) + a12 x2 (k ) + b1 u(k )


x2 (k + 1) = a21 x1 (k ) + a22 x2 (k ) + b2 u(k )
y(k ) = c1 x1 (k ) + c2 x2 (k ) + du(k )

In main-prog.c before main() insert float x1[2],x2[2];


In main() insert x1[0] = x2[0] = 0;

x1[1] = a11 ∗ x1[0] + a12 ∗ x2[0] + b1 ∗ u; JJ


x2[1] = a21 ∗ x1[0] + a22 ∗ x2[0] + b2 ∗ u; II
y = c1 ∗ x1[0] + c2 ∗ x2[0] + d ∗ u; J
x1[0] = x1[1];
x2[0] = x2[1];
I
Back
Forward
Close
Part II 12/18

Review of Exp.2: Least


squares sys-id theory

JJ
II
J
I
Back
Forward
Close
13/18

Bilinear transform and Z-transform


Sampling at Ts seconds
g(t) g(k)
1
L−

1
a n sf o r m Z −
Lap
la c e T ra n sf o r m

Z -tr a n sfor m Z
l a c e T r a n sf or m

e Z -tr
ap

rs
eL

ve
Bilinear Transform
s

In
er

v
In = Tustin’s method
G (s) G (z)
2 z −1 1+ sT2s
s= or z =
Ts z+1 1− sT2s JJ
• Both s-domain & z-domain are fictitious domains. II
• s-domain simplifies working with differential equations; z-domain simplifies working with J
difference equations. I
• Bilinear transform is not the only way to go G (s) ↔ G (z). Back
• Ts determined by Nqyquist sampling rate. Forward
Close
14/18

G (s) ←→ G (z)
• Consider definitions of L and Z
Z ∞
Y (s) = L {y(t)} , y(t)e−st dt
t =0

Y (z) = Z {y(k )} , ∑ y ( k ) z−k
k =0

• Comparison suggests z = esTs .


ln z
• To convert G (s) to G (z), can substitute s = Ts .

• Easier to work with an approximation JJ


sTs ( sT2s ) ( sT2s )
2 II
sTs sTs sTs e 2 1+ 1! + 2! +··· 1 + sT2 s J
z=e =e e
2 2 = = ≈ I
1 − sT2 s
2
− sT2s (− sT2s ) (− sT2s )
e 1+ + +···
1! 2! Back
Forward
Close
15/18

How Z-transform used in our sys-id


u(k) ω (t) ω (k)
PWM H-bridge Motor Encoder

• u(k) denotes sample of u(t) at sampling instant t = kTs .


• Let u(k) → ω (k) TF be G (z).
• Use u(k), ω (k) pairs to build G (z).
• Use bilinear transform to go from G (z) to G (s).
Important property of Z-transform used:

z−l X (z) ↔ x (k − l ) given X (z) ↔ x (k). JJ


II
J
I
Back
Forward
Close
16/18

What is least squares sys-id? (1/2)


b1 z2 + b2 z + b3 Y (z)
• Let G (z) = 3 = .
z + a1 z2 + a2 z + a3 U (z)
• Cross multiply:
b1 z2U (z) + b2 zU (z) + b3U (z) = z3Y (z) + a1 z2Y (z) + a2 zY (z) + a3Y (z).

• Multiply throughout by z−3:

b1 z−1U (z) + b2 z−2U (z) + b3 z−3U (z) =


Y ( z ) + a 1 z −1 Y ( z ) + a 2 z −2 Y ( z ) + a 3 z −3 Y ( z ) .
JJ
−1
• Take Z to obtain difference equation II
J
b1 u(k − 1) + b2 u(k − 2) + b3 u(k − 3) = I
y ( k ) + a1 y ( k − 1) + a2 y ( k − 2) + a3 y ( k − 3). Back
Forward
Close
17/18

What is least squares sys-id? (2/2)


Consider b1 u(k − 1) + b2 u(k − 2) + b3 u(k − 3) =
y(k) + a1 y(k − 1) + a2 y(k − 2) + a3 y(k − 3). (1)

• Let σ = [b1 b2 b3 − a1 − a2 − a3 ]| .
• Suppose we have data of u(k) and y(k) for k = 0, 1, . . . , N.
• Problem: Find σ such that (1) holds for this data.
I.E., find parameters of a TF that fits to input-output data.
• Let error in the fit be
ε(k, σ ) = b1 u(k − 1) + b2 u(k − 2) + b3 u(k − 3) − y(k) JJ
− a1 y ( k − 1) − a2 y ( k − 2) − a3 y ( k − 3). II
J
• Modified problem: Find σ to minimize J (σ ) , ∑kN=0 ε2 (k, σ). I
Back
• If J (σ = σ0 ) = 0, then find best estimate σ̂ of σ0. Forward
Close
Part III 18/18

Review of Exp.2: What the


experiment taught
• Sys-id techinques from Exp.1 & Exp.2 give different results.
• Likely cause is not only the dead zone nonlinearity in the plant,
but also the input signals the sys-id technique uses.
E.g., the step input (u = 7) in Exp.1 does not keep plant in
dead zone, while the low-frequency (5 – 10 Hz) triangular input
makes the plant go into dead zone twich every cycle. JJ
II
• Will using rectangular waveform instead of triangular waveform J
(TW) give a different model with least squares sys-id (LSS)? I
Back
• If plant behaves as 1st order even with TW, LSS will say that Forward
Close
plant has one LHP pole that is 10 – 20 times deeper than the 19/18

other.

JJ
II
J
I
Back
Forward
Close

You might also like