THE UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING Control...

11
1 Revised 2018 G. Pang C23 THE UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING Experiment C23: Control System Simulation and PID Control Objectives: (i) Parameter identification for a servo position system, and (ii) to study the effects of PID control actions in a servo position control system. Apparatus: Feedback servo trainer with a mechanical unit & an analogue unit; Digital storage oscilloscope (DSO). Introduction In this experiment, the servo position control system which has been considered in Experiment C21 will be used to further study other aspects of control. You should refer to the laboratory sheet for that experiment for a detailed description of the servo system. A block diagram of the servo system under closed-loop control is shown in Fig. 1. The power amplifier input u is used to drive a dc motor which controls the output position θo of the servo system. In closed-loop operation, the output position θo is compared with the reference input θi to generate an error signal e=θi θo. The controller K(s) acts on this error signal to produce the control signal u for the power amplifier. Using the results developed in the Lab. Sheet for C21 (see equation (16) there), the transfer function relating θo to u is given by () () = ( + ) (1) where a and b are constant parameters dependent on the mechanical and electrical characteristics of the system. The experiment is consisted of three parts. In the first part, a closed-loop experiment is performed to identify the parameters a and b of the open-loop transfer function and the results of the identification will be verified by means of a time simulation. In the second part, the effects of derivative and integral actions are studied. Finally, application of an PID ( 3-term) Σ θ i θ o e u Fig. 1 + - + s s b ( ) a K s ( ) Servo Position System Controller Output Position Reference Input Position Error Power Amp. Input

Transcript of THE UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING Control...

Page 1: THE UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING Control ...ugsnews/lab-sheet/level3/C23.pdf · 2018-10-11 · 1 Revised 2018 G. Pang C23 THE UNIVERSITY

1

Revised 2018 G. Pang C23

THE UNIVERSITY OF HONG KONG

DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING

Experiment C23: Control System Simulation and PID Control

Objectives: (i) Parameter identification for a servo position system, and (ii) to study the

effects of PID control actions in a servo position control system.

Apparatus:

Feedback servo trainer with a mechanical unit & an analogue unit;

Digital storage oscilloscope (DSO).

Introduction

In this experiment, the servo position control system which has been considered in

Experiment C21 will be used to further study other aspects of control. You should refer to

the laboratory sheet for that experiment for a detailed description of the servo system.

A block diagram of the servo system under closed-loop control is shown in Fig. 1. The power

amplifier input u is used to drive a dc motor which controls the output position θo of the

servo system. In closed-loop operation, the output position θo is compared with the reference

input θi to generate an error signal e=θi −θo. The controller K(s) acts on this error signal to

produce the control signal u for the power amplifier. Using the results developed in the Lab.

Sheet for C21 (see equation (16) there), the transfer function relating θo to u is given by

𝜃𝑜(𝑠)

𝑢(𝑠)=

𝑎

𝑠(𝑠 + 𝑏)

(1)

where a and b are constant parameters dependent on the mechanical and electrical

characteristics of the system.

The experiment is consisted of three parts. In the first part, a closed-loop experiment is

performed to identify the parameters a and b of the open-loop transfer function and the results

of the identification will be verified by means of a time simulation. In the second part, the

effects of derivative and integral actions are studied. Finally, application of an PID ( 3-term)

Σ θ i θ o

e u

Fig. 1

+

- + s s b ( )

a K s ( )

Servo Position

System Controller Output Position

Reference Input

Position Error

Power Amp. Input

Page 2: THE UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING Control ...ugsnews/lab-sheet/level3/C23.pdf · 2018-10-11 · 1 Revised 2018 G. Pang C23 THE UNIVERSITY

C23

2

controller to the servo system is considered. Digital simulation of a closed-loop system using

matlab can be carried out after the lab session.

Parameter Identification for the Servo Position System

To identify the parameters a and b of the servo position system shown in Fig. 1, we apply

proportional feedback of the form

K(s) = K1 (2)

where K1 is a constant. With this simple proportional gain controller, the closed-loop transfer

function relating θo(s) to θi(s) is given by

𝜃𝑜(𝑠)

𝜃𝑖(𝑠)=

𝐾1 𝑎

𝑠2 + 𝑏𝑠 + 𝐾1 𝑎

(3)

Comparing this with a standard second-order transfer function of damping ratio 𝜉 and

natural frequency ωn:

𝐺(𝑠) =𝜔𝑛

2

𝑠2 + 2𝜉𝜔𝑛𝑠 + 𝜔𝑛2

(4)

we have

b = 2 𝜉 ωn and K1 a =ω2n (5)

If the system described by (4) is underdamped with 𝜉, then the step response is oscillatory with

maximum overshoot

𝐻 = 𝑒−𝜉𝜋/√1−𝜉2

(6)

and period of damped oscillations

𝑇 =2𝜋

𝜔𝑛√1 − 𝜉2

(7)

It follows that a and b can be expressed in terms of H and T as (show this in your report):

𝑎 =4[𝜋2 + (ln 𝐻)2]

𝐾1𝑇2

and

𝑏 =−4 ln 𝐻

𝑇

(8)

Hence, if a step response is obtained for the closed-loop system and the quantifies H and T

are measured from the step response, then a and b can be determined.

Page 3: THE UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING Control ...ugsnews/lab-sheet/level3/C23.pdf · 2018-10-11 · 1 Revised 2018 G. Pang C23 THE UNIVERSITY

Revised 2018 G. Pang C23

3

Digital Simulation

Suppose it is necessary to verify whether the model depicted in Fig. 1 with parameters

determined by the above method is a good description of the physical system. One way to

do this is to perform a time simulation of the step response using our model and check if the

simulation result matches the experimentally recorded response. The simulation can be

performed using the software package MATLAB running on a PC. For the purpose of the

time simulation, we define two state variables for the servo system:

𝑥1 = 𝜃𝑜 , 𝑥2 = �̇�𝑜

(9)

The relationship between the power amplifier input u and the output position θ o can be

described in terms of the following differential equations:

�̇�1 = 𝑥2

(10)

�̇�2 = −𝑏𝑥2 + 𝑎𝑢

(11)

You should verify (in your report) that the Laplace transform of (10) and (11) yields the

same input-output relationship described by the transfer function given in (1).

We may write (10) and (11) in matrix notation as

x= Ax + Bu (12)

where

𝑥 = [𝑥1

𝑥2] 𝐴 = [

0 10 −𝑏

] 𝐵 = [0𝑎

] ;

(13)

Integrating (13) gives

𝑥(𝑡) = 𝑥(𝑡0) + ∫ [𝐴 𝑥(𝜏) + 𝐵 𝑢(𝜏)]𝑡

𝑡0

𝑑𝜏

(14)

In a digital simulation, the integration can be performed numerically using one of the many

integration methods (e.g. forward rectangle rule, Simpson's rule or Runge-Kutta method).

For simplicity, we apply the forward rectangle rule to (14) to give

x(t) = x(t0) + [A x(t0) + B u(t0)] (t − t0) (15)

For the rectangular rule to give a good approximation, the integration time step T = t −t0

should be small. Using a fixed time step T and putting t0 = kT and t = kT+ T , (15) becomes

x(kT +T) =Φ x(kT) +Γ u(kT) (16)

where

Φ=(I + AT) and Γ =BT (17)

Page 4: THE UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING Control ...ugsnews/lab-sheet/level3/C23.pdf · 2018-10-11 · 1 Revised 2018 G. Pang C23 THE UNIVERSITY

C23

4

(16) is of the form of a discrete-time state-space model. If the initial condition x(0) = x0 and

the control input u(kT) are given, then x(kT) (k=0,1,2,…)can be calculated by iterating

equation (16). The control input is determined according as

u(kT) = K1 [ θ i (kT)−θ o(kT) ]

= K1 [1(kT)− x1(kT)] (18)

where we have assumed that the input reference is a step function, i.e., θ i (t) = 1(t).

PID (Proportional-Integral-Derivative) Controller

In Experiment C21, it is shown that velocity feedback can be used to improve the transient

response for servo position tracking. In that experiment, the motor speed is measured by a

tachometer coupled directly to the motor shaft, which provides a velocity signal for feedback.

In servo position control systems where only the position signal is measured but the motor

speed is not measured, there is no velocity signal for feedback. In such systems, we can

however generate the derivative of the position signal (e.g. using an op-amp circuit) to replace

the velocity signal. In addition, we can also generate an integral signal from the position signal.

Integral action can be used to eliminate steady-state tracking error between the output response

and a step command signal. Fig. 2 shows a realization of a PID controller using an op-amp

circuit.

Fig. 2

Assuming that the capacitors are initially discharged and that R2 = 0 (for ideal

differentiation), the output u of the controller is related to the input e by

𝑢(𝑡) =𝑅6

𝑅7{

𝑅3

𝑅4𝑒(𝑡) + 𝑅1𝐶1

𝑑𝑒(𝑡)

𝑑𝑡+

1

𝑅5𝐶2∫ 𝑒(𝑡)

𝑡

0

𝑑𝑡}

(19)

A transfer function representation for the PID controller can be readily obtained by taking the

Laplace transform of (19). You should show (in your report) how the transfer function is

modified by the incorporation of R2, and explain why it is necessary to include R2 in the circuit.

R 1

R 2

R 3

R 4

R 5

R 6

R 7

C 1

C 2

R 7

R 7

e u

Page 5: THE UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING Control ...ugsnews/lab-sheet/level3/C23.pdf · 2018-10-11 · 1 Revised 2018 G. Pang C23 THE UNIVERSITY

Revised 2018 G. Pang C23

5

Experimental Procedures

Important:

Always switch off the power supply before making connections on the Analogue Unit.

Check that all connections are correct before switching on the power.

Make a note in your Log Book of the Set No. of the Apparatus shown on the panel of the

mechanical unit.

In the following, potentiometer settings are given as percentages of the full range. For the

data acquisition system, the range for the time (horizontal) and voltage (vertical) axes are

referred to as the t-range and v-range, respectively.

1. Position Control with Proportional Feedback and Parameter Identification

(1a)

Switch off the power.

Connect up the Analogue Unit as shown in Fig. 3, with the error amplifier feedback

resistor set to 1 MΩ to give an amplifier gain K1 = 10.

Fig. 3 Connections for Experiment 1

Page 6: THE UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING Control ...ugsnews/lab-sheet/level3/C23.pdf · 2018-10-11 · 1 Revised 2018 G. Pang C23 THE UNIVERSITY

C23

6

Initially set both P1 and P3 to zero.

Set the signal frequency to 0.2 Hz (0.1 Hz for Apparatus Set No. 4). Get the data

acquisition system ready for recording the output response.

(1b)

Switch on the power.

Set P1 to 100 (70 for Set No. 4) and adjust P3 to 15 to provide a square wave command

input to the servo.

Observe that the step response to the edge of the square wave should show some

overshoot before settling down to a steady-state value. Adjust the scales of the data

acquisition system to make good use of the range of the plots, e.g. t-range = 2 sec and v-

range = +2 volts, so that accurate measurements can be obtained for the purpose of

parameter identification. Record the output response which should be similar to the

following:

Switch off the power after you are done.

(1c)

Measure the maximum overshoot H and the period of damped oscillations T from the

step response.

Determine the parameters a and b of the servo system using (8).

2. To examine the effects of Derivative and Integral Actions

Before we make use of a 3-term (i.e. PID) controller to control the servo, we will study the

effect of the derivative and integral actions.

Some capacitor and resistance values of the derivative and integral op-amp circuits are not

labelled in Fig. 4. Record the missing values especially resistor R20.

Page 7: THE UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING Control ...ugsnews/lab-sheet/level3/C23.pdf · 2018-10-11 · 1 Revised 2018 G. Pang C23 THE UNIVERSITY

Revised 2018 G. Pang C23

7

(2a) Derivative Action

Connect up the Analogue Unit as shown in Fig. 4 with P3, P4 (derivative gain) and P5

(integral gain) initially set to zero.

Fig. 4 Connections for Experiments 2

Set the signal frequency to 0.5 Hz. Do not make the three gray connections yet. Use a

t-range = 5 sec throughout this experiment.

Switch on the power. Set P3 (to approximately 20) to provide a +1.0 V triangular wave

input to the controller. The following photo shows the 0.5 Hz triangular wave signal.

Turn up P4 to 100 and observe whether the output of the derivative op-amp gives a signal

which represents the derivative of the input. Record the response.

Bypass the R20 resistor at the input of the op-amp and note that derivative signal becomes

very noisy. The following photo shows the bypassing of R20.

Page 8: THE UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING Control ...ugsnews/lab-sheet/level3/C23.pdf · 2018-10-11 · 1 Revised 2018 G. Pang C23 THE UNIVERSITY

C23

8

Record the response. Gradually turn down P4 and make a note on the effect of this on

the quality of the derivative signal.

Now re-install the R20 resistor, turn up P4 to 100, and replace the triangular wave

input with a square wave input. Record the response.

(2b) Integral Action

Keep P3 = 20. Move the Y2 input of the data acquisition system from the derivative op-

amp to the integral op-amp.

Turn up P5 to 100 and record the output of the integral op-amp for a square ware input.

Close the switch SW2 (by pressing lever towards you, i.e. press down) and re-open it to

obtain the integral action before recording the response. Explain the effect of doing this

in your report.

(2c) To prepare for an PID controller

Switch off the power.

Keep the settings of P4 and P5 at 100 and make the gray connections shown in Fig. 4 to

realize a 3-term controller. The derivative, proportional and integral signals are now

added together by the op-amp at the output of the controller.

Switch on the power.

Record the signal at the output op-amp of the 3-term controller. The signal you obtain

should be similar to the following:

Page 9: THE UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING Control ...ugsnews/lab-sheet/level3/C23.pdf · 2018-10-11 · 1 Revised 2018 G. Pang C23 THE UNIVERSITY

Revised 2018 G. Pang C23

9

3. PID Control for the Servo System

(3a) PD Control

Switch off the power.

Connect up the Analogue Unit as shown in Fig. 5 which realizes PID control for the servo.

Fig. 5 Connections for Experiments 4(a) & (b)

Page 10: THE UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING Control ...ugsnews/lab-sheet/level3/C23.pdf · 2018-10-11 · 1 Revised 2018 G. Pang C23 THE UNIVERSITY

C23

10

Set P3, P4 and P5 to zero initially.

Push the switch SW2 to the closed position (towards you) to disable integral action

so that the controller is of PD type to start with.

Set the signal frequency to 0.2 Hz. Do not make the gray connections yet.

Switch on the power. Set P1 to 100 and P3 to 15 to provide a square wave input to the

servo system. Since P4 = 0, the servo is effectively under proportional control and the

output should track the square wave input with some overshoot.

Now gradually turn up P4 to increase the amount of derivative action in the PD

controller. Make a note of the effect of increasing derivative action on the transient

response. Adjust P4 to get a critically damped response and record the response using a

t-range = 5 sec.

(3b) PD Control with Input Disturbance

In this experiment, an external disturbance signal will be simulated by injecting an arbitrary

constant voltage at the input of the power amplifier.

Switch off the power.

Make the gray connections shown in Fig. 5.

Check that SW2 is in the closed position (towards you) to disable the integral action.

Initially set the switch SW1 at the central position. Keep the value of P4 obtained in (3a).

P2 is providing the input disturbance. Turn P2 up to some arbitrary value (but not too

big, say, around 20).

Switch on the power.

Now switch SW1 to the up-position (+10V) and note the effect of this disturbance on the

output response.

Switch SW1 to the down-position (-10V) and note the result.

Record the response of the output to the disturbance (one diagram is sufficient) using a

fairly long t-range (e.g. 60 sec).

(3c) PID Control (Integral Action included for Steady-State Disturbance Rejection )

Switch off the power.

Reset SW1 to the central position.

Switch SW2 to the open position (away from you) to enable integral action. The

controller now of PID type.

Keep the value of P4 (derivative action) obtained in (3a).

P5 is providing the integral action. Set P5 to 15.

Turn P2 to 50 to provide input disturbance.

Switch on the power.

Now switch SW1 to the up-position (+10V) and note the effect of this disturbance on the

output response.

Switch SW1 to the down-position (-10V) and note the result.

Record the effect of the disturbance input on the output response.

Switch off the power.

Page 11: THE UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL & ELECTRONIC ENGINEERING Control ...ugsnews/lab-sheet/level3/C23.pdf · 2018-10-11 · 1 Revised 2018 G. Pang C23 THE UNIVERSITY

Revised 2018 G. Pang C23

11

4. Digital Simulation of the Closed-Loop System

This part can be carried out at your own time after the laboratory session.

(4a) For the purpose of simulation, obtain a discrete-time state-space model of the form

similar to equation (16) with numerical values set by the results of step 1.

(4b) Start MATLAB running on the PC by the command:

MATLAB

This puts you in the command mode of MATLAB. Get to know MATLAB by trying out a

few basic commands:

Commands

Remarks

A = [ 1 2 ; 3 4 ] defines a 2x2 matrix called A

B = eye(2) B = 2x2 identity matrix

C = A + B C = matrix sum of A & B

D = [ A B ] D = matrix formed by putting A & B side by side

F = [ A ; B ] F = matrix formed by putting A on top of B

kT = 0 : 0.05 : 1 kT = [ 0 0.05 0.10 0.15 . . . 1 ]

y = [ ] y = empty matrix

for t = kT, Start for-loop: set t successively to elements of kT

y = [ y sin(2*pi*t) ] compute sin(2π t) and accumulate the results in y

end end of for-loop

plot ( kT, y ) plot y against kT

MATLAB supports the running of commands from a macro-file (a script file containing

MATLAB commands) which can be created using any text editor.

(4c) Write a macro-file program to simulate the step response of the closed-loop system

using the discrete-time state-space model obtained. Run your program and check whether

the simulation result agrees with the experimental result.

Report

Each student is required to submit a report for this experiment.

State the Apparatus Set No. on the Front Page of your report. The theory section of your

report should be brief (no more than two pages) to address the points which you are

specifically asked to show in the Introduction of this document. Include in your report the

time responses and simulation results you obtained in the experimental session with brief

observations and discussions as appropriate.

References

[1] B.C. Kuo and F. Golnaraghi, "Automatic Control Systems", 8th edition, Wiley, 2003.

[2] G.F. Franklin, J.D. Powell & A. Emami-Naeini, "Feedback control of Dynamic Systems",

5th edition, Prentice Hall, 2006.