## Ball & Beam Control - Frequency Response

코딩과 교육/전문코딩2008.07.26 18:07

Ball & Beam Problem Using Frequency Response Method

The open-loop transfer function of the plant for the ball and beam experiment is given below:

The design criteria for this problem are:

- Settling time less than 3 seconds
- Overshoot less than 5%

Open-loop Bode Plot

The main idea of frequency based design is to use the Bode plot of the open-loop transfer function to estimate the closed-loop response. Adding a controller to the system changes the open-loop Bode plot, therefore changing the closed-loop response. Let's first draw the bode plot for the original open-loop transfer function. Create an m-file with the following code and then run it in the Matlab command window:

.....m = 0.111;

.....R = 0.015;

.....g = -9.8;

.....L = 1.0;

.....d = 0.03;

.....J = 9.99e-6;

.....K = (m*g*d)/(L*(J/R^2+m)); %simplifies input

.....num = [-K];

.....den = [1 0 0];

.....bode(num,den)

NOTE: Matlab commands from the control system toolbox are highlighted in red.

You should get the following Bode plot:

From this plot we see that the phase margin is zero. Since the phase margin is defined as the change in open-loop phase shift necessary to make a closed-loop system stable this means that our zero phase margin indicates our system is unstable. We want to increase the phase margin and we can use a lead compensator controller to do this. For more information on Phase and Gain margins please refer to the Frequency Response Tutorial.

Phase-Lead Controller

A first order phase-lead compensator has the form given below:

The phase-lead compensator will add positive phase to our system over the frequency range 1/aT and 1/T, which are called the corner frequencies. The maximum added phase for one lead compensator is 90 degrees. For our controller design we need a percent overshoot of 5, which corresponds to a zeta of 0.7. Generally zeta * 100 will give you the minimum phase margin needed to obtain your desired overshoot. Therefore we require a phase margin greater than 70 degrees.

To obtain "T" and "a", the following steps can be used.

1. Determine the positive phase needed:

We need at least 70 degrees from our controller.

2. Determine the frequency where the phase should be added (center frequency):

In our case this is difficult to determine because the phase vs. frequency graph in the bode plot is a flat line. However, we have a relation between bandwidth frequency (wbw) and settling time (refer to the Bandwidth Frequency page for this equation) which tells us that wbw is approximately 1.92 rad/s. Therefore we want a center frequency just before this. For now we will choose 1.

3. Determine the constant "a" from the equation below, this determines the required space between the zero and the pole for the maximum phase added.

.....where phi refers to the desired phase margin. For 70 degrees, a = 0.0311.

4. Determine "T" and "aT" from the following equations:

..... For 70 degrees and center frequency (w) = 1, aT = 0.176 and T = 5.67

Now, we can add our lead controller to the system and view the bode plot. Remove the bode command from your m-file and add the following:

.....k=1;

.....numlead = k*[5.67 1];

.....denlead = [0.176 1];

.....numl = conv(num,numlead);

.....denl = conv(den,denlead);

.....bode(numl,denl)

You should get the following bode plot:

You can see that our phase margin is now 70 degrees. Let's check the closed-loop response to a step input of 0.25m. Add the following to your m-file:

.....[numcl,dencl] = cloop(numl,denl);

.....t=0:0.01:5;

.....step(0.25*numcl,dencl,t)

You should get the following plot:

Although the system is now stable and the overshoot is only slightly over 5%, the settling time is not satisfactory. Increasing the gain will increase the crossover frequency and make the response faster. Make k = 5, your response should look like:

The response is faster, however, the overshoot is much too high. Increasing the gain further will just make the overshoot worse.

Adding More Phase

We can increase our phase-lead compensator to decrease the overshoot. In order to make the iterative process easier use the following program. Create an m-file and copy the function from your web-browser into it (make sure the function command starts in the first column of the m-file).

.....function[ ] = phaseball()

.....%define TF

.....m = 0.111;

.....R = 0.015;

.....g = -9.8;

.....L = 1.0;

.....d = 0.03;

.....J = 9.99e-6;

.....K = (m*g*d)/(L*(J/R^2+m)); %simplifies input

.....num = [-K];

.....den = [1 0 0];

.....%ask user for controller information

.....pm = input('Phase Margin?.......');

.....w = input('Center Frequency?...');

.....k = input('Gain?...............');

.....%view compensated system bode plot

.....pmr = pm*pi/180;

.....a = (1 - sin(pmr))/(1+sin(pmr));

.....T = sqrt(a)/w;

.....aT = 1/(w*sqrt(a));

.....numlead = k*[aT 1];

.....denlead = [T 1];

.....numl=conv(num,numlead);

.....denl=conv(den,denlead);

.....figure

.....bode(numl,denl)

.....%view step response

.....[numcl,dencl]=cloop(numl,denl);

.....t=0:0.01:5;

.....figure

.....step(0.25*numcl,dencl,t)

With this m-file you can choose the phase margin, center frequency, and gain. Run your m-file with the following values and you should see the plots below on your screen.

.....Phase Margin?.......80

.....Center Frequency?...1

.....Gain?...............1

The overshoot is fine but the settling time is just a bit long. Try different numbers and see what happens.

Using the following values the design criteria was met.

.....Phase Margin?.......85

.....Center Frequency?...1.9

.....Gain?...............2

Note: A design problem does not necessarily have a unique answer. Using this method (or any other) may result in many different compensators. For practice you may want to go back and change the added phase, gain, or center frequency.