Control using State Feedback and State Augmentation

29
1 EE4302 Advanced Control System Mini Project CA3 Mohamed Isa Bin Mohamed Nasser U076183A

Transcript of Control using State Feedback and State Augmentation

Page 1: Control using State Feedback and State Augmentation

1

EE4302 Advanced Control System

Mini Project CA3

Mohamed Isa Bin Mohamed Nasser

U076183A

Page 2: Control using State Feedback and State Augmentation

2

1.0 Introduction

1.1 Overview

The objective of this project is to implement state-feedback and state-estimation

control methods on a pilot scale platform that involves the controlling of a DC motor

using two sensors that measures its velocity and position.

1.2 Components of DC servomotor platform

The DC motor is equipped with two sensors, a potentiometer to measure the angular

position and a tachogenerator to measure the angular velocity. The sensors are shown

in Figure 1. In this experiment, these sensors are treated as being perfect in the sense

that they have perfect response and are noiseless. This approximation can be seen

later to be a good one.

1.2 Form Developed for obtaining control Parameters

In order to ease the repetitive process of finding new control values in the subsequent

experiments, we have developed a form that is able to calculate these parameters

conveniently and fast.

The form is written in C#.net that is uses MATLAB functions through a .NET

assembly export. This form can be installed on any windows machine that has the

.NET framework installed. Its use is self explanatory.

Although this form is used throughout this project, the MATLAB codes used to

achieve the calculations in the experiments will still be reviewed.

Page 3: Control using State Feedback and State Augmentation

3

When the checkbox “show plot” is checked, the Bode plot of the corresponding

control scheme will pop up as shown in the screen shot below.

2.0 Sensor Calibration

The calibration step which will find the constant of proportionality between the

readings from the sensor in volts to the physical quantities measured. For the

tachogenerator, this constant is in volts/(rad/s) and for the potentiometer, it is in

volts/rad.

2.1 Obtaining the proportionality constant Kθ

The steps for finding the Kθ are:

1. Stop the operation of the motor

Page 4: Control using State Feedback and State Augmentation

4

2. Physically turn the motor a measured amount of degrees

3. Run the program

4. Read the corresponding voltage value in LabView

Experimental Results

Potentiometer Output

x1(volts)

Angular Position

(in degrees)

Angular Position

(in radians)

-4.795 -20 -0.3491

-4.336 0 0

-3.508 30 0.5236

-2.656 60 1.0472

-1.833 90 1.5708

-1.02 120 2.0944

-0.158 150 2.6180

0.664 180 3.1416

1.49 210 3.6652

2.329 240 4.1888

3.135 270 4.7124

3.977 300 5.2360

4.607 330 5.7596

A plot is made which relates the potentiometer output with the actual angular position.

A first order polynomial regression is used to find its gradient which is the

proportionality constant relating the voltage output from the sensor with the physical

quantity of angular position. This constant is Kθ. We can also observe that the fit is

very good which implies that the approximation for a perfect sensor is justified.

MATLAB Code

straightlinecoef = polyfit(angularpos , x1, 1);

Ktheta = straightlinecoef(1);

Kθ = 1.5687;

Page 5: Control using State Feedback and State Augmentation

5

-1 0 1 2 3 4 5 6-6

-4

-2

0

2

4

6

Angular Position (rad)

Pote

ntiom

ete

r O

utp

ut

(Volts)

Measured data

Straight Line fit

2.2 Obtaining the proportionality constant Ks

The steps for finding the Kw are:

1. Stop the operation of the motor

2. Input a certain constant voltage

3. Measure the tachogenerator output and Angular velocity

Input Voltage

u(volts)

Tachogenerator Output

x2(volts)

Angular Velocity

(rpm)

Angular Velocity

(rad/s)

-5 -4.71 -285 -29.8451

-4 -3.725 -227 -23.7714

-3 -2.74 -166 -17.3835

-2 -1.765 -107 -11.2050

-1 -0.78 -47 -4.9218

0 0 0 0

1 0.795 48 5.0265

2 1.77 107 11.2050

3 2.75 166 17.3835

4 3.735 227 23.7714

5 4.715 285 29.8451

A plot is made relating the tachogenerator output in volts with the actual angular

velocity. The first order polynomial regression is used in MATLAB to determine the

proportionality constant. Again the approximation of a perfect sensor is very good.

Page 6: Control using State Feedback and State Augmentation

6

MATLAB Code

straightlinecoef = polyfit(angularvel , x2, 1);

Komega = straightlinecoef(1);

Kω = 0.1576

-30 -20 -10 0 10 20 30-5

-4

-3

-2

-1

0

1

2

3

4

5

Angular Velocity (rad/s)

Tachogenera

tor

Outp

ut

(Volts)

Measured data

Straight Line fit

2.3 Modelling the DC motor

The DC motor is then modelled using the step response method and reading the time

constant and the static gain values for a first order transfer function model.

2.3.1 Steady State Gain

The steady state gain can be obtained from the proportional relationship between the

angular velocity which is the output and the voltage input. In the same way as

previously, first order polynomial regression is used to obtain this value.

Page 7: Control using State Feedback and State Augmentation

7

-8 -6 -4 -2 0 2 4 6 8-50

-40

-30

-20

-10

0

10

20

30

40

50

Input Voltage (Volts)

Angula

r V

elo

city (

rad/s

)

Measured data

Straight Line fit

Kstatic = 5.8881

The code for calculating the three gains so far together with the plots is given in the

following code.

MATLAB Code

%============================ % For X1 (Potentiometer) %============================ x1 = [-4.795 -4.336 -3.508 -2.656 -1.833 -1.02 -0.158 0.664 1.49

2.329 3.135 3.977 4.607]; angularpos = [-0.3491 0 0.5236 1.0472 1.5708 2.0944 2.6180 3.1416

3.6652 4.1888 4.7124 5.2360 5.7596]; grad1 = polyfit(angularpos,x1,1); Ktheta = grad1(1) fitgraph1 = zeros(1,1); for x = -1: 6 fitgraph1 =[fitgraph1 (grad1(1) * x + grad1(2))]; end fitgraph1(1) = []; figure(1); plot(angularpos,x1 ,'x');

hold on plot(-1:6, fitgraph1,'-r'); legend('Measured data','Straight Line fit'); xlabel('Angular Position (rad)') ylabel('Potentiometer Output (Volts)')

hold off

%============================

Page 8: Control using State Feedback and State Augmentation

8

% For X2 (Tachogenerator) %============================ inputvolt = [-5 -4 -3 -2 -1 0 1 2 3 4 5]; x2 = [-4.71 -3.725 -2.74 -1.765 -0.78 0 0.795 1.77 2.75 3.735 4.715]; angularvel = [-29.8451 -23.7714 -17.3835 -11.2050 -4.9218 0 5.0265

11.2050 17.3835 23.7714 29.8451]; grad2 = polyfit(angularvel,x2,1); fitgraph2 = zeros(1,1); Komega = grad2(1) for xb = -30: 30 fitgraph2 =[ fitgraph2 (grad2(1) * xb + grad2(2))]; end fitgraph2(1) = []; figure(2); plot(angularvel,x2 ,'x');

hold on plot(-30: 30, fitgraph2,'-r'); legend('Measured data','Straight Line fit'); xlabel('Angular Velocity (rad/s)') ylabel('Tachogenerator Output (Volts)')

hold off

%===================== % For Static Gain %=====================

grad3 = polyfit(inputvolt,angularvel,1); fitgraph3 = zeros(1,1); Kstatic = grad3(1) for xc = -8: 8 fitgraph3 =[ fitgraph3 (grad3(1) * xc + grad3(2))]; end fitgraph3(1) = []; figure(3); plot(inputvolt, angularvel,'x');

hold on plot(-8: 8, fitgraph3,'-r'); legend('Measured data','Straight Line fit'); xlabel('Input Voltage (Volts)') ylabel('Angular Velocity (rad/s)')

hold off

2.3.2 Time Constant

The final parameter to obtain to complete the first order transfer function model is the

time constant which is the time component when the signal has reached 63.3% of the

steady state value.

Page 9: Control using State Feedback and State Augmentation

9

Magnitude at time constant = 0.7 * 0.63 = 0.441

Time constant = τ = 0.28 seconds

2.4 Alternative Methods of Modelling the System

Another way to obtain the state space description of the system is by using inbuilt

functions in MATLAB that is able the state space equation. One such function is

n4sid(data) that takes an array of input/output measurements and estimates the state

space equation of the system using subspace methods.

We explore this method by exciting the motor with square waves. The data is then

input into the MATLAB function and the following code is used to obtain the state

space equations.

MATLAB Code

load velocity.txt; % input-output data %============================== % Get Data %============================== z = [velocity(:,1) velocity(:,2)]; z = dtrend(z);

%======================================== % Model into state space equation %======================================== MODEL = N4SID([z(:,2) z(:,1)],2,'DisturbanceModel','none',... 'ssparameterization','canonical');

Page 10: Control using State Feedback and State Augmentation

10

The state space description is reflected in the MATLAB console.

Console Output A =

x1 x2

x1 0 1

x2 -0.14605 1.1349

B =

u1

x1 0.19595

x2 0.028322

C =

x1 x2

y1 1 0

D =

u1

y1 0

K =

y1

x1 0

x2 0

In order to verify this result, it is compared with the first order transfer function. It is

first converted into an s-domain representation for easy comparison.

MATLAB code tau = 0.28; Ktheta = 1.5687; Kw = 0.1576; Kstatic = 5.8881;

[n2,d2]=ss2tf(MODEL.a, MODEL.b, MODEL.c,0); tf(n2,d2) % TF of model estimated by n4sid A1 = [0 1; 0 -1/tau]; B1 = [0; (Kstatic/tau)]; C1 = [1 0; 0 1]; D1 = [0;0]; sys_open = ss(A1,B1,C1,D1); [n1,d1]=ss2tf(A1,B1,C1,D1); tf(n1(2,:),d1) % reliable comparison from step response

Console Output

Transfer function:

0.1959 s - 0.1941

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

s^2 - 1.135 s + 0.1461

Page 11: Control using State Feedback and State Augmentation

11

Transfer function:

21.03 s

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

s^2 + 3.571 s

The two transfer functions are very different. Their poles are in completely different

places. This means that the estimation of the state space description us n4sid() has

returned unusable results.

2.5 Importance of calibration

The calibration process is extremely important. Firstly in the sensor viewpoint, a bad

calibration of the proportionality constant will give a bad feedback signal. This is

made worst since both feedbacks will then have values of different proportions.

Also, a bad model of the system will mean that subsequent methods of placing closed

loop poles in desired positions will not be valid. Hence, the success of subsequent

section is strongly reliant on a good model and feedback values which is dependent on

the quality of the calibration.

This method of calibration using a first order model is only useful for a low order

system such as the DC motor. Other parametric methods of modelling can be used for

higher order systems.

Page 12: Control using State Feedback and State Augmentation

12

3.0 State Feedback with Full Measurable

3.1 State Feedback with incorporation of integral action

This section explore feedback control techniques using both sensor inputs that

measures all states in the system with the incorporation of integral action.

3.1.1 Constructing the State Space Description

Firstly, we have to construct the state space model of the system with integral action.

The figure above shows the state feedback with integral action. The corresponding

values for the matrices are shown.

Where,

-1 / τ = - 3.5714

Kstatic / τ = 21.0289

In MATLAB language, the constructed matrices are shown in the code.

F = [0 1 0; 0 0 1; 0 0 -1/tau];

Gu = [0;0;Kstatic/tau];

Gr = [-1 0 0];

H = [1 0 0;0 1 0; 0 0 1];

J = 0;

These state space equations will be needed in the algorithms used to determine the

integral gain and the feedback gains for closed loop poles placement.

Page 13: Control using State Feedback and State Augmentation

13

3.1.2 Labview implementation of the Control

A Labview implementation of the control scheme has been provided. The parameters

obtained from the calibration, are entered in the connection diagram which is shown

in figure 1.

The signal used to test the choice of control parameters is a periodic square wave of

approximately 100 degrees. 100 degrees has to be converted to rads and divide it by

two since the peak to peak midpoint is zero.

(100 degrees / 2) × π / 180 degrees = 0.872

The unfilled parameters left are the integral gain KI and the feedback gains K1 and K2.

3.1.3 Finding values for Integral Gain and Feedback Gain

The important part of the experiment for this section is finding “good” values for KI,

K1 and K2 such that the input signal is tracked fast, without much oscillations and

achieve a constant steady state gain.

There are two parts in designing these parameters for most of the methods. The first

part involves the identification of good closed loop poles. This is not a trivial task

since performances of the pole placements are dependent on the system itself.

However the DC motor is a relatively simple system and finding poles that will

achieve decent performance in a robust manner should not be difficult.

Page 14: Control using State Feedback and State Augmentation

14

With the pole designed, Ackermann’s formula is used to find the feedback matrix

(feedback gains and integral gain) required to place the pole at the desired position.

The methods used are:

a) ITAE Prototype table

b) Bessel Prototype table

c) LQR Method

d) Second order dominant poles Method

A) ITAE Prototype table

The coefficients in the ITAE prototype table maximize performance according to the

ITAE performance criterion. Looking at the table for a system of order three, the

following pole placement is obtained.

Pole placement

Wn × [-0.7081; -0.5210+1.068j; -0.5210-1.068l]

Wn is varied and the corresponding KI, K1 and K2 values are obtained through the

Ackermann’s formula. The performance is compared.

Wn Ki K1 K2 Bandwidth

3 1.2838 0.9201 0.0798 3.0920

The following diagrams shows the inputs, outputs and control signal of the DC motor

from using the values from the table above.

This will be the organization of the data for the whole report. The parameters will be

listed in tables and the actual results will follow together with observations made.

The important observation at this low value of Wn is that the control signal has a peak

of about 0.9V. The saturation level is much higher at 5V. This means that the system

could be much faster if the control signal was more than it is. The rise time

Page 15: Control using State Feedback and State Augmentation

15

ITAE Wn = 3

Wn Ki K1 K2 Bandwidth

5 5.9435 2.5559 0.2463 5.1533

With the increase of Wn we notice that the bandwidth increases. Also the feedback

gains are higher. Consequently, the control signal is now peaking at 1.75V and it can

be observed that the step response is visibly faster that is the rise time becomes

shorter. Since 1.75V is still a rather low value, Wn should be increased further.

Page 16: Control using State Feedback and State Augmentation

16

ITAE Wn = 5

Wn Ki K1 K2 Bandwidth

7 16.3090 5.0095 0.4127 7.2146

At this value, the control signal peaks at 3V. This is a safe value to be at. The motor

can encounter mechanical load or electrical disturbances in a practical situation. In

order to keep the control predictable as designed, the control signal should not operate

near the saturation level. Otherwise it will hit saturation when the disturbances occur.

Page 17: Control using State Feedback and State Augmentation

17

ITAE Wn = 7

Wn Ki K1 K2 Bandwidth

9 34.6625 8.2811 0.5792 9.2759

At Wn = 9, the control signal saturates for the given reference signal. This can be seen

from the control peak which touches 5V. Wn should hence be set lower than this

value. Also we observe that the bandwidth still increases proportionally to Wn.

Page 18: Control using State Feedback and State Augmentation

18

ITAE Wn = 9

B) Bessel Prototype Table

Like the ITAE, Bessel is a prototype method that selects pole from a table based on

the order of the system.

Pole placement

Wn × [-0.7081; -0.5210+1.068j; -0.5210-1.068l]

Again we shall vary Wn and observe the trend.

Wn Ki K1 K2 Bandwidth

3 1.2840 1.0554 0.1773 2.1325

Page 19: Control using State Feedback and State Augmentation

19

At this value, the Bessel method produces a control signal which has a lower peak

than that of the ITAE. The same observation on slow response due to low value of

feedback gains apply to the Bessel method.

However, one interesting difference is that the Bessel method at this low value

produces no noticeable overshoot unlike the ITAE method. This is a good property in

general however it is less meaningful since the Wn is set at a value that is too low to

be useful.

Bessel Wn = 3

Page 20: Control using State Feedback and State Augmentation

20

Wn Ki K1 K2 Bandwidth

5 5.9442 2.9318 0.4087 3.5541

The peak control signal value is now 1.25V compared to ITAE 1.75V. Also, the

bandwidth of the system does not increase proportionally to the value of Wn unlike in

the ITAE method. The same observation of a faster response due to higher feedback

gains as in the ITAE method applies here.

One difference is that the form of the step response has much less overshoot

compared to the ITAE method. This is a desirable property. Peaking at 1.25V there is

still better performance that can be achieved by increasing Wn.

Page 21: Control using State Feedback and State Augmentation

21

Bessel Wn = 5

Wn Ki K1 K2 Bandwidth

7 16.3109 5.7463 0.6401 4.9758

The response is faster as expected. Again, the bandwidth does not increase

proportionally to Wn. The control signal peaks at 2.5V and the response is fast and

without oscillation. This is a very good result.

The peak at 2.5V is a good value since right now the control signal is changing from

100 degrees to minus 100 degrees. This can be bigger from 179 degrees to minus 179

degrees and saturation might occur if the control signal is operating at a high voltage

at 100 degrees. Furthermore the response is fast and smooth at this value.

Page 22: Control using State Feedback and State Augmentation

22

Bessel Wn = 7

Wn Ki K1 K2 Bandwidth

9 34.6667 9.4990 0.8714 6.3974

This is the point where the peak of the control signal hits 5V. It can be observed that

the signal starts oscillating at this point. Hence, the value of Wn should always be

lower than 9.

Page 23: Control using State Feedback and State Augmentation

23

Bessel Wn = 9

Wn Ki K1 K2 Bandwidth

12 82.1729 16.8871 1.2185 8.5299

The significance of taking these plots is the oscillations observed. It shows that at

high values of Wn, the system starts becoming less stable.

Page 24: Control using State Feedback and State Augmentation

24

Bessel Wn = 12

C) Linear Quadratic Regulator Weighting (LQR) Method

The LQR method minimizes deviation in the feedback signals depending on the

weightings given to the individual feedback loops which makes up the cost function

that is being minimized.

For this experiment, the weights for the three adjustable gains will be increase one by

one and the performance is observed. The one with the best performance will then be

tweaked to achieve better performance.

Page 25: Control using State Feedback and State Augmentation

25

Q KI K1 K2 Bandwidth

[1 0 0; 0 1 0; 0 0 300] 1 5.9729 17.1679 0.2365

Weighting K2 heavily gives an unstable performance. Large oscillations are observed.

The low relative values of KI and K1 is due to the weightings turn out to be a bad

choice.

LQR, Wi = 1 W2 = 1 W3 = 300

Q KI K1 K2 Bandwidth

[1 0 0, 0 300 0,

0 0 1]

1.0000 17.4149 1.4688 0.0576

Weighting K1 highly gives similar performance as the previous result. The signal is

highly oscillatory. This means that the larger weight should set to the integrator gain

or a combination of the three adjustable gains.

Page 26: Control using State Feedback and State Augmentation

26

LQR, Wi = 1 W2 = 300 W3 = 1

Q KI K1 K2 Bandwidth

[300 0 0, 0 1 0,

0 0 1]

17.3205 6.7675 1.1234 4.0344

Weighting KI heavily gives relatively good results. At a weight of 300, the

performance is similar to the Bessel method at Wn = 5. The peak control signal is at

1.9V and there is a slight overshoot. This result motivates increasing the weights for

KI.

Page 27: Control using State Feedback and State Augmentation

27

LQR, Wi = 300 W2 = 1 W3 = 1

Q KI K1 K2 Bandwidth

[600 0 0; 0 1 0; 0 0 1] 24.4949 8.1758 1.1742 4.8006

Doubling the weight for KI, the control signal increased from 1.9V at the previous

weight of 300 to 3.75V. The response is noticeably faster and has no oscillation. It has

slight overshoot as before.

Page 28: Control using State Feedback and State Augmentation

28

Page 29: Control using State Feedback and State Augmentation

ERROR: stackunderflowOFFENDING COMMAND: ~

STACK: