Вы находитесь на странице: 1из 32

Control Systems Lab

Experiment 9
Name of the student
ID No.
BATCH & TIME

:
:
:

NISHANT PANI
2013A3PS298H
PS-3 (9.00 AM -11.00 AM)

Contents
A
SWING UP CONTROL1
9.1
Background .................................................................................................................................................................. 2
9.1.1 Energy Control ............................................................................................................................................................... 2
9.1.2 Hybrid Swing-Up Control .............................................................................................................................................. 4
9.2
In-Lab Exercises .......................................................................................................................................................... 4
B
FREQUENCY RESPONSE ANALYSIS
.11
9.3
Background ................................................................................................................................................................ 19
9.4
In-Lab Exercises ........................................................................................................................................................ 20
9.4.1
Bode Plot
.11
9.4.2 Gain and Phase Margin ..................................................................................................................................................... 23
9.4.3 Closed-Loop Performance ................................................................................................................................................ 28

A. SWING-UP CONTROL
Topics Covered
Energy control
Nonlinear control
Control switching logic
Prerequisites
Before starting this lab make sure:
Filtering Lab
Balance Control Lab
Rotary pendulum module is attached to the QUBE-Servo.

9.1
9.1.1

Background
Energy Control

If the arm angle is kept constant and the pendulum is given an initial position it would swing with constant
amplitude. Because of friction there will be damping in the oscillation. The purpose of energy control is to
control the pendulum in such a way that the friction is constant. The potential energy of the pendulum is

9.1
and the kinetic energy is
9.2
The pendulum angle, , and the lengths are illustrated in Figure 9.1. The moment of inertia in this case is
lp = Lp/2.

Fig. 9.1

Free-body diagram of pendulum

The potential energy is zero when the pendulum is at rest at = 0 and equals 2Mp g lp when the pendulum
is upright at = . The sum of the potential and kinetic energy of the pendulum is

9.3
Differentiating 9.3 results in the differential equation
9.4
Substituting the pendulum equation of motion
9.5
pendulum acceleration is given as,
9.6
Since the acceleration of the pivot is proportional to current driving the arm motor and thus also proportional
to the drive voltage we find that it is easy to control the energy of the pendulum. The proportional control law
9.7
drives the energy towards the reference energy Er. Notice that the control law is nonlinear because the
proportional gain depends on the pendulum angle, . Also, notice that the control changes sign when
changes sign and when the angle is 90 deg.
However, for energy to change quickly the magnitude of the control signal must be large. As a result the
following swing-up controller is implemented in the controller as

9.8
3

where is a tunable control gain and the satumax function saturates the control signal at the maximum
acceleration of the pendulum pivot, umax.

9.1.2

Hybrid Swing-Up Control

The energy swing-up control can be combined with the balancing control law to obtain a control law
which performs the dual tasks of swinging up the pendulum and balancing it.
Similarly as described in the Balance Control Lab, the balance control is to be enabled when the pendulum
is within 20 degrees. When it is not enabled, the swing-up control is engaged. Thus the switching can be
described mathematically by:

9.2

In-Lab Exercises
The LabVIEW Virtual Instrument (VI) shown in Figure 9.1 swings-up and balances the
pendulum on the QUBE Servo Rotary Pendulum system. The Swing-Up Control subsystem
implements the energy control described in Section 9.1

(a) Front Panel

(b) Block Diagram

Fig. 9.2 VI that implements the swing-up controller

9.2.1 Energy Control


Open the QUBE-Servo ROTPEN Swing Up.vi in LabVIEW .
2. To turn the swing-up control off, set mu to 0.
3. Run the VI.
4. Manually rotate the pendulum at different levels and examine the pendulum angle and energy in the
Pendulum (deg) and Pendulum Energy (mJ) scopes.
5. What do you notice about the energy when the pendulum is moved at different positions? Record the energy
when the pendulum is being balanced (i.e., fully inverted in the upright vertical position). Does this
reading make sense in terms of the equations developed in Section 9.1?.
1.

Observations and Results

6. Click on the Stop button to bring the pendulum down to the initial, downward position.
7. Set the swing-up control parameters (i.e., the Constant and Gain blocks connected to the inputs of the
Swing-Up Control subystem) to the following:
mu = 50 m/s2/J
Er = 10.0 mJ
u_max = 6 m/s2
8. If the pendulum is not moving, gently perturb the pendulum with your hand to get it going.
9. Vary the reference energy, Er , between 10.0 mJ and 20.0 mJ. As it is changed, examine the pendulum
angle and energy response in Pendulum (deg) and the Pendulum Energy (mJ) scopes and the control
signal in the Motor Voltage (V) scope. Attach the responses showing how changing the reference energy
7

affects the system.


Observations and Results

For increased energy in the system, the amplitude of the rotary arm remains the
same. Whereas the amplitude of the rotation of the pendulum increases.

10

Figure 9.3: Pendulum response when changing reference energy

10. Fix Er to 20.0 mJ and vary the swing-up control gain mu between 20 and 60 m/s2/J. Describe how this
changes the performance of the energy control.
Observations and Results

As we increase the control gain the energy level of the pendulum increases,the
applied motor voltage increases,the rotation of the pendulum increases whereas
the angle of the rotary arm remains constant.

11

12

13

14

15

11. Click on the Stop button to stop running the controller.

9.2.2 Hybrid Swing-Up Control


1. Open the QUBE-Servo ROTPEN Swing Up.vi in

LabVIEW .

2. To turn the swing-up control off, set mu to 0.


3. Set the swing-up control parameters to the following:
mu = 20 m/s2/J
16

u_max = 6 m/s2
Question 9.18
4. Based on your observations in the previous lab, what should the reference energy be set to?
The reference energy should be set to 30 mJ, i.e., Er = 30. This is the energy that measured in Step 5 in
Section 8.6.4 when the pendulum was in the vertically upwards, balanced position.
5. Make sure the pendulum is hanging down motionless and the encoder cable is not interfering with the
pendulum.
6. Build and run the QUARC controller.
7. The pendulum should begin going back and forth. If not, manually perturb the pendulum with your hand.
Click
on the Stop button in the Simulink tool bar if the pendulum goes unstable.
8. Gradually increase the swing-up gain, , denoted as the mu Slider Gain block, until the pendulum swings
up to the vertical position. Capture a response of the swing-up and record the swing-up gain that was required.
Show the pendulum angle, pendulum energy, and motor voltage.
Observation / Result:

17

18

Figure 9.4: Sample hybrid swing-up control response

9. Click on the Stop button to stop running the VI.


10. Power OFF the QUBE-Servo if no more experiments will be conducted.

A. FREQUENCY RESPONSE ANALYSIS


Topics Covered

Bode Plots
Gain and Phase Margin
Closed-Loop Performance

9.3 Background
The frequency response method may be less intuitive than other methods you have studied previously.
However, it has certain advantages, especially in real-life situations such as modeling transfer functions
from physical data.
The frequency response is a representation of the system's response to sinusoidal inputs at varying
frequencies. The output of a linear system to a sinusoidal input is a sinusoid of the same frequency but
with a different magnitude and phase. The frequency response is defined as the magnitude and phase
differences between the input and output sinusoids. In this tutorial, we will see how we can use the
open-loop frequency response of a system to predict its behavior in closed-loop.
19

To plot the frequency response, we create a vector of frequencies (varying between zero or "DC" and
infinity) and compute the value of the plant transfer function at those frequencies. If G(s) is the open
loop transfer function of a system and w is the frequency vector, we then plot G(j*w) versus w. Since
G(j*w) is a complex number, we can plot both its magnitude and phase (the Bode plot) in the complex
plane .

9.4 In-Lab Exercises


9.4.1 Bode Plots
As noted above, a Bode plot is the representation of the magnitude and phase of G(j*w) (where the
frequency vector w contains only positive frequencies).
LabVIEW Graphical Approach

To see the Bode plot of a transfer function, you can use the CD Bode VI, located in the Frequency
Response section of the Control Design palette.

Figure 9.5 : Block Diagram for Creating a Bode Plot

20

LabVIEW MathScript Approach

Alternatively, you can use the following m-file code in the MathScript Window (Tools MathScript
Window):
num = 50;
den = [1 9 30 40];
sys = tf(num,den);
bode(sys)

With either approach, we display the transfer function and Bode plots for the system. Figure 9.6 shows the
front panel of the VI that was built. Change the terms in the numerator and denominator to observe the effect
on the systems Bode plots.

21

Figure 9.6: : Front Panel for Creating a Bode Plot

Note the axes of the plots in Figure. The frequency is on a logarithmic scale, the phase is given in degrees,
and the magnitude is given as the gain in decibels. A decibel is defined as 20*log10 ( |G(j*w)| ) .
Observation & Result

22

9.4.2 Gain and Phase Margin


Let's say that we have the following system:

Figure 9.7: A Closed-Loop System


In this system, K is a variable (constant) gain and G(s) is the plant under consideration. The gain margin is
defined as the change in open loop gain required to make the system unstable. Systems with greater gain
margins can withstand greater changes in system parameters before becoming unstable in closed loop. Keep
in mind that unity gain in magnitude is equal to a gain of zero in dB.
The phase margin is defined as the change in open loop phase shift required to make a closed loop system
unstable. The phase margin also measures the system's tolerance to time delay. If there is a time delay greater
than 180/Wpc in the loop (where Wpc is the frequency where the phase shift is 180 deg), the system will
become unstable in closed loop. The time delay can be thought of as an extra block in the forward path of the
block diagram that adds phase to the system but has no effect the gain. That is, a time delay can be represented
as a block with magnitude of 1 and phase w*time delay (in radians/second).
23

For now, we won't worry about where all this comes from and will concentrate on identifying the gain and
phase margins on a Bode plot.
The phase margin is the difference in phase between the phase curve and -180 degrees, at the point
corresponding to the frequency that gives us a gain of 0dB (the gain cross over frequency, Wgc). Likewise,
the gain margin is the difference between the magnitude curve and 0dB at the point corresponding to the
frequency that gives us a phase of -180 deg (the phase cross over frequency, Wpc).

Figure 9.8 : Gain and Phase Margins

One nice thing about the phase margin is that you don't need to re-plot the Bode in order to find the new phase
margin when changing the gains. If you recall, adding gain only shifts the magnitude plot up. This is the
equivalent of changing the y-axis on the magnitude plot. Finding the phase margin is simply the matter of
finding the new cross-over frequency and reading off the phase margin.
To observe this effect, first look at the Bode plots in Figure 9.8. You should see that the phase margin is about
100 degrees.
Now suppose you added a gain of 100.
LabVIEW Graphical Approach

To achieve this in a VI, add a second CD Construct Transfer Function Model VI to your block diagram from
Figure 1. Create a constant input to the numerator terminal, and enter 100 into the first cell of this array. Next,
add the CD Series VI to the block diagram (from the Model Interconnection section of the Control Design
palette) and connect both transfer function models to the inputs of the CD Series VI. Connect the Series Model
output of the CD Series VI to the CD Bode and CD Draw Transfer Function VIs as before.

24

Figure 9.9: Bode Plot of a System with Gain

LabVIEW MathScript Approach

If you used m-file code to model the system, enter the command bode(100*sys) into the MathScript
Window.
Observation & Result

25

LabVIEW Graphical Approach

Using the VI from Figure 9.5, replace the CD Bode VI with the CD Gain and Phase Margin VI, found in the
Frequency Response section of the Control Design palette. Create indicators for Magnitude Plot, Phase Plot,
and Gain and Phase Margins.

26

Figure 9.11: Block Diagram for Gain and Phase Margin in LabVIEW

LabVIEW MathScript Approach

Alternatively, you can use the margin command in the MathScript Window. This command returns the gain
and phase margins, the gain and phase cross over frequencies, and a graphical representation of these on the
Bode plot. If you used m-file code to model the system, enter the following command into the MathScript
Window:
margin(sys)
Plotting the gain and phase margins returns the graphs shown below in Figure 9.12.

Figure 9.12 : Front Panel forGain and Phase Margins

27

Observation & Result

9.4.3 Closed-Loop Performance


In order to predict closed-loop performance from open-loop frequency response, we need to have several
concepts clear:

The system must be stable in open loop if we are going to design via Bode plots.

If the gain cross over frequency is less than the phase cross over frequency (i.e. Wgc < Wpc), then the
closed-loop system will be stable.

For second-order systems, the closed-loop damping ratio is approximately equal to the phase margin
divided by 100 if the phase margin is between 0 and 60 degrees. We can use this concept with caution if
the phase margin is greater than 60 degrees.

A very rough estimate that you can use is that the bandwidth is approximately equal to the natural
frequency.

Let's use these concepts to design a controller for the following system:

28

Figure 9.13: A Closed-Loop System

In this system, Gc(s) is the controller, and G(s) is:

The design must meet the following specifications:

Zero steady state error.

Maximum overshoot must be less than 40%.

Settling time must be less than 2 seconds.

There are two ways of solving this problem: one is graphical and the other is numerical. In LabVIEW, the
graphical approach is best, so that is the approach we will use. First, let's look at the Bode plot. Use the VI
from Figure 9.5 (or the MathScript Window) to graph the Bode plots for the above transfer function.

Figure 9.14: Bode Plots

There are several characteristics of the system that can be read directly from this Bode plot. First of all, we
can see that the bandwidth frequency is around 10 rad/sec. Since the bandwidth frequency is roughly the same
as the natural frequency (for a first order system of this type), the rise time is 1.8/BW = 1.8/10 = 1.8 seconds.
This is a rough estimate, so we will say the rise time is about 2 seconds.
The phase margin for this system is approximately 95 degrees. The relation damping ratio = (phase
margin)/100 only holds for phase margins less than 60 degrees. Since the system is first-order, there should
be no overshoot.
The last major point of interest is steady-state error. The steady-state error can be read directly off the Bode
plot as well. The constant (Kp, Kv, or Ka) is found from the intersection of the low frequency asymptote with
the w=1 line. Just extend the low frequency line to the w=1 line. The magnitude at this point is the constant.
Since the Bode plot of this system is a horizontal line at low frequencies (slope = 0), we know this system is
29

of type zero. Therefore, the intersection is easy to find. The gain is 20dB (magnitude 10). What this means is
that the constant for the error function is 10.
The steady-state error for this system is 1/(1+Kp) = 1/(1+10)=0.091. If our system was type one instead of
type zero, the constant for the steady-state error would be found in a manner similar to the following:

Figure 9.15: Finding Constant for Steady-State Error

Let's check our predictions by looking at a step response plot.


LabVIEW Graphical Approach

This can be achieved in LabVIEW by using the CD Step Response VI (from the Time Response section of
the Control Design palette), along with the CD Feedback VI.

Figure 9.16: Step Response Using Feedback

LabVIEW MathScript Approach

Alternatively, you can add two lines of code into the MathScript Window:
sys_cl = feedback(sys,1);
step(sys_cl)
Which controller is required to be chosen to meet the desired specifications and why ? PID controller is

required to meet the design specifications.


30

Observation & Result

31

Conclusion

32