Modeling and Simulation

April 3, 2017 | Author: digiblood | Category: N/A
Share Embed Donate


Short Description

Download Modeling and Simulation...

Description

EE4307 Control System Design and Simulation Prof Sam’s Portion

Mohamed Isa Bin Mohamed Nasser U076183A

1

1

Introduction

This experiment will cover the whole process of control system design and simulation. This whole process is described in the flow chart below. In beginning stages, we are familiarized with Labview in order to do extract data in a meaningful manner from the system. This data is then treated to remove noise. With the collected data, non-parametric as well as parametric methods are used to identify the system which is used in the many methods to control the system.

2

The DC Motor

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.

2

4

Data Acquisition and Conditioning

In this section, the developments of the required Labview program to acquire data as well as methods to condition them are explored. 4.2

Conditioning Data Acquired from Plant

The data that has been acquired looks like the following:

3

20 Velocity 0.2Hz 3V Square Wave input

15 10 5 0 -5 -10 -15 -20

0

1

2

3

4

5

6

7

8

9

10

The data is actually very clean with little noise. Most of the noise is high frequency and at the peaks. Firstly the butterworth filtered is used to attenuate the high frequencies. The parameters used for the function is shown in the MATLAB code. Wn = 1.9999995; %fraction of Nyquist W = idfilt(z(:,1), 100, Wn, 'noncausal','low'); t = 1:printsize; plot(t,z(:,1),t,W), legend('original','filtered'), axis tight

4

original filtered

15

10

5

0

-5

-10

-15 100

200

300

400

500

600

700

800

900

1000

When the high frequencies are filtered away, many of the harmonic components to maintain the shape of the square wave is removed. This causes it to slant. A frequency domain filter is therefore not ideal for removing this noise. The next step is to try down-sampling the signal to reduce the effect of the high frequency noise.

5

20 4X resampled output Signal Input Signal

15 10 5 0 -5 -10 -15 -20

0

1

2

3

4

5 time(s)

6

7

8

9

10

The high frequency noise has now been visually reduced. In order to smoothen it further a spline smooth has been used. The details of this method are covered in the next section. The result is shown.

6

20 Spline Smoothed output Signal Input Signal

15 10 5 0 -5 -10 -15 -20

0

1

2

3

4

5 time(s)

6

7

8

9

10

Although the noise is reduced further, it introduces notch on the transitions at the edges. This is not a desirable property since these notches do not appear in the actual system. Although the spline smoothing works well in smoother waveforms, it is not good for signals with large drops and very sharp edges such as the square wave. We therefore will use the previous conditioning result for modeling.

4.3

Data Conditioning

In this exercise, a set of noisy input-output data has to be conditioned. The data contains time, input and output information. The unfiltered data looks like the following:

7

1.4 Originial Noisy Signal Input Signal

1.2 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4

0

5

10

15

20 time(s)

25

30

35

40

It is stated that the output has been contaminated with high frequency noise with zero mean. After much experimentation with the processes to clean the signal, a very effective method has been realized. The signal is first downsampled in order to reduce the number of points. This will reduce the resolution and the high frequency components will be reduced significantly. The output of this part is shown in the following figure.

8

1.4 40X resampled output Signal Input Signal

1.2 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4

0

5

10

15

20 time(s)

25

30

35

40

For this particular signal, it has been downsampled by 40 times. However it is found to be only effective for the current problem. A more general downsampling amount is 10 times. As observed in the above figure, the high frequency oscillations have been removed. This is a good improvement. The next step required should be to smooth out the jagged points which are a result of sampling sharp oscillations. In order to this, a spline smoothing technique written by Damien Garcia is used. Splines are multiple segments of piecewise curve fits, often by a polynomial regression, that is used to fit data that are otherwise difficult to fit and often non-linear. It can be used to smooth signals by fitting a series of smooth curves to the signal. Knots are the points between two piecewise curves. The choice of knots as well as the order of polynomial regression can therefore be used to smooth the curve. This type of smoothing is ideal for of data since it has zero mean and the center of the amplitude of the sharp oscillations

9

is the desired signal. A least square curve fit will achieve this. The result of the spline smoothing is shown in the following figure.

1.4 Spline Smoothed output Signal Input Signal

1.2 1 0.8 0.6 0.4 0.2 0 -0.2

0

5

10

15

20 time(s)

25

30

35

40

The result is very good. By visual inspection with the noisy signal, we can see that this signal is almost identical with the original clean signal. The MATLAB code to achieve the above smoothing has been created into a function for easy use in later exercises.

function [out] = conditionplot(data, showplot, DCoff, smoothness) X = data; if(showplot == 1) figure(1); plot(X(:,1),X(:,2),'-r');

10

hold on; plot(X(:,1),X(:,3)); hold off; legend('Originial Noisy Signal', 'Input Signal'); Xlabel('time(s)'); end %========================== % DC offset %========================== startidx = 1; endidx = length(X(:,1)); X_DC = X;

for i = 1:endidx X_DC(i - startidx + 1,3)=X(i,3) - DCoff; end

%========================== % Resample %========================== j = 1; m=10; for i = startidx:endidx if(rem(i,m) == 0) X_filtered(j,1) = X_DC(i,1); X_filtered(j,2) = X_DC(i,2); X_filtered(j,3) = X_DC(i,3); j = j+1; end end if(showplot == 1) figure(2); plot(X_filtered(:,1),X_filtered(:,3)); hold on plot(X(:,1),X(:,2),'-r'); hold off legend('10X resampled output Signal', 'Input Signal');

11

Xlabel('time(s)'); end %========================== % Spline smooth %==========================

% the Z = SMOOTHN(X_filtered(:,3),smoothness); if(showplot == 1) figure(3); plot(X_filtered(:,1),Z); hold on plot(X(:,1),X(:,2),'-r'); hold off legend('Spline Smoothed output Signal', 'Input Signal'); Xlabel('time(s)'); end [X_filtered(:,1);X_filtered(:,2);Z] out = [X_filtered(:,1)';X_filtered(:,2)';Z'];

4.4 Design of Labview Program In this section, a Labview program has to be made to perform step response as well as impulse response analysis. The format of the data must be in the following form: Time

Input

Output

A square wave generator has been used to produce the impulse as well as the step response. Of course an ideal impulse is not realizable since it has a peak at infinity. A simulation of this can be achieved by the signal:

12

This guarantees that the area of the impulse response still has an area of 1 that is,

Therefore a sharp square wave will be used as an approximation for the impulse response for small pulse widths. These calculations are made at this portion of the block diagram.

13

The full block diagram is shown below.

The controls on the front panel are shown.

A convenient switch is used to switch between a step responses to an impulse response. When a user stops the program, the plots will be saved into text files. The user can set the sampling rate, magnitude and pulse width for the step response. Except for the pulse width, every other parameter can be directly set to the square-wave box. The only way to set the pulse width is by adjusting the duty cycle of the square wave. Therefore the pulse width is set using, Constants Frequency = 0.2 Hz 14

Period = 10s Input Pulse Width = X seconds Calculated and Set the Square Wave Box Duty cycle = X / 10

For the impulse response, the user can only set sampling rate and magnitude in order to satisfy the requirements. The relation used again to set the pulse width from the magnitude is, Pulse width = 1 / Magnitude The following figure shows the front panel in impulse response operation. The amplitude chosen is 5. This will mean the pulse width is 0.2 seconds. This generates a thin pulse. This is the best pulse attainable by the system with the available headroom.

15

The next figure shows the impulse response but this time with amplitude of 1. The pulse width is therefore 1 second. This is significantly thicker than the wave form above.

The step response is simply a square wave with a big enough period for the whole step response to occur; the pulse width must be set bigger than the settling time. The snapshot of the schematic used to achieve the requirement is shown below. The pulse width and amplitude is adjustable.

16

5 Non-Parametric Approach for system Identification This part will explore non-parametric approach for system identification. 5.1

Time domain Method

This section covers impulse response and step response method of non-parametric approach for system identification in MATLAB . 5.1.1 Impulse Response The given system is,

The code used to obtain the impulse response has been obtained by the using the code below. MATLAB Code G1 = tf([1 0],[1 0.5], 1); % the tf

17

disp(' Impulse Response Coefficients:') X = impulse(G1, [0:1:15]) figure(1); impulse(G1, [0:1:15])

The coefficients are shown in the console output: Impulse Response Coefficients: X= 1.0000 -0.5000 0.2500 -0.1250 0.0625 -0.0313 0.0156 -0.0078 0.0039 -0.0020 0.0010 -0.0005 0.0002 -0.0001 0.0001 -0.0000

The corresponding impulse response plot is shown below.

18

Impulse Response 1

Amplitude

0.5

System: G1 Time (sec): 10 Amplitude: 0.000977 0

-0.5

0

5

10

15

Time (sec)

From the above plot, we can see that it is oscillating and settles at t = 10 seconds.

5.1.2 Step Response The system is given as,

In order to find the step response, the method step() is invoked. The command stepinfo() can be used to find the step response characteristics. This method is then compared against using numerical methods of obtaining the settling time as well as verifying it on the plot.

19

MATLAB Code %================================ %

Get Step response and Plot

%================================ disp('Step Response Analysis:') G = tf([1],[1 1 2],'inputdelay', 0.3); [Y T] = step(G,0:0.001:50); step(G);

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

Find All 2nd Order Param

%============================== S = stepinfo(G,'RiseTimeLimits',[0.05,0.95])

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

Verify by checking Settling time

%==================================== settling_percent = 0.02; % Find the time when all values of response % are within 2% of final output

chan1 = Y(:,:,1); % Get channel 1 from the STEP output maxtime = max(find(abs((chan1 - chan1(end)) / chan1(end) > settling_percent))); % Find the maximum time where you are MORE than 2% away from the final % value Settling_time_check = T(maxtime + 1) % Settling time is then the next time step

The console output shows all the characteristics of the response. These quantities need to be subtracted by the delay time of 0.3 in order to be used to model the system using the 2nd order system estimation for rise time and overshoot. Console Output Step Response Analysis:

20

S= RiseTime: 1.1778 SettlingTime: 8.0411 SettlingMin: 0.4535 SettlingMax: 0.6515 Overshoot: 30.3097 Undershoot: 0 Peak: 0.6515 PeakTime: 2.7551 Settling_time_check = 8.0430 This is the step response with the overshoot and 90% and 10% magnitude points marked.

21

X: 2.755 Y: 0.6446

0.7

Step Response

0.6

Amplitude

System: G Time (sec): 1.63 0.5 Amplitude: 0.45

0.4

0.3

0.2

0.1

0

0

System: G Time (sec): 2 0.637 Amplitude: 0.0502

4

6

8

10

12

Time (sec)

To illustrate the previous point about having to subtract the delay time from the rise time, two plots are made. The first one without subtraction and the next, with subtraction.

22

Step Response 0.7 original estimate 0.6

Amplitude

0.5

0.4

0.3

0.2

0.1

0

0

2

4

6

8

10

12

14

16

Time (sec)

The estimate above fit is bad since the delay is not taken into consideration.

23

Step Response 0.7 original estimate 0.6

Amplitude

0.5

0.4

0.3

0.2

0.1

0

0

2

4

6

8

10

12

Time (sec)

In contrast the above estimate is very good. The formulas used for the estimates of the damping ratio and natural frequency will be covered in the following section.

5.2 Non – Parametric Identification (Time Domain Models) There are two sets of data provided which comes from the same signal. The data is in the usual form of: Time

Input

Output

Using Step Response The data in set1 contains the step response of the system. However, the data is noisy and the step response does not occur neatly at t = 0. The first task is to use the function

24

conditionplot(,,,) created in the preceding part to smooth the signal. The results are as follows.

1.4 Originial Noisy Signal Input Signal

1.2 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4

0

5

10

15

20

25 time(s)

30

35

40

45

50

This is the original signal. Notice it has high frequency noise. The shape of the signal can be seen visually.

25

1.4 10X resampled output Signal Input Signal

1.2 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4

0

5

10

15

20

25 time(s)

30

35

40

45

50

It is the downsampled by 10 times and a smoother plot is observed. The high frequency oscillations are no longer present.

26

1.4 Spline Smoothed output Signal Input Signal

1.2 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4

0

5

10

15

20

25 time(s)

30

35

40

45

50

The final filtered signal is shown. Notice that the signal has an initial condition. This is not a delay because it starts at a negative value on the positive edge. To find the overshoot, rise time and other parameters from the discrete data, a simple program can be made that finds magnitude of individual samples and compare it with the DC gain. The sample corresponding to the 10% and 90% point can be deduced from this code snippet. MATLAB code for J = length(T):-1:1, % T is the time component of the discrete data % search for when Y is ~90% of U. Y is the output. U is input. if (Tr_ucount == 0) && (abs(Y(J))
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF