0% found this document useful (0 votes)
536 views10 pages

Matlab, Simulink - Control Systems Simulation Using Matlab and Simulink

This document provides instructions for a control systems simulation assignment using MATLAB and Simulink. Students will simulate and analyze the step response of open-loop and closed-loop second order systems, including the effects of proportional, integral and derivative feedback control. Additional simulations include controlling a two-mass vibratory system and a ball and beam system. Gains will be varied for different controllers and their effects on the response will be analyzed.

Uploaded by

Tarkes Dora
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
536 views10 pages

Matlab, Simulink - Control Systems Simulation Using Matlab and Simulink

This document provides instructions for a control systems simulation assignment using MATLAB and Simulink. Students will simulate and analyze the step response of open-loop and closed-loop second order systems, including the effects of proportional, integral and derivative feedback control. Additional simulations include controlling a two-mass vibratory system and a ball and beam system. Gains will be varied for different controllers and their effects on the response will be analyzed.

Uploaded by

Tarkes Dora
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 10

UNIVERSITY OF CALIFORNIA AT BERKELEY Department of Mechanical Engineering ME134 Automatic Control Systems

Spring 2002 Report Due: Tuesday, February 26 One report per group is required.

Control Systems Simulation Using Matlab and Simulink 1 Introduction

In ME134, we will make extensive use of Matlab and Simulink in order to design, analyze and simulate the response of control systems.

Control of Second Order System

We will simulate the open loop and closed loop step response of the dynamic system described by the state and output equations
d x1 = dt d x2 = dt

.1 x1 + .1 x2 .2 x2 + .1 u

(1)

y = x1
(2) and transfer function

G(s) =

s2

.01 + .3s + .02

(3)

Y (s) = G(s)U (s)


Here u is the input, y is the output, and x1 and x2 are the two states of the system. The two tank uid system shown in Fig. 1 can be modeled by the above state and output equations and/or transfer function.
2.1 Open loop unit-step response

Consider the open loop unit-step input response of this system. The unit-step input is given by u(t) = (t), were

(t) :=

0 if t < 0 1 if t 0 1

Figure 1: uid system Load the simulink le tank open.m. Using simulink, modify the system to the obtain the open loop unit-step input response of this system. Plot the open loop response on a plot.
2.2 Continuous Time (C.T.) closed loop unit-step response

Consider now the closed loop unit-step input response of this system. The control system is described by the block diagram in Fig. 2 where the controller is a PID type controller given by the

Figure 2: feedback control system transfer function

C (s) = Kp +

Ki + Kds s

U (s) = C (s)E (s) .


In the time domain the PID control action can be described by
d d

up = Kp e , ui = Ki e , ud = Kd e dt dt u = up + ui + ud
where e = r y and the reference input is a unit-step r(t) = (t). (Notice that pure D action is unrealizable and must be approximated by numerical dierentiation.) Using simulink, modify the system in the le tank continuous.m so that the continuous time (C.T.) PID control block is connected in the feedback loop. Run simulations of the closed loop unit-step input response of this system for dierent combinations of the PID gains. Try rst P action only (i.e. Ki = 0) and observe how the response of the closed loop system varies when Kp is increased. Subsequently analyze the eect of introducing the I and D actions in the feedback control system. Try at least the following cases: 2

controller 1 controller 2 controller 3 controller 4 controller 5

Kp Ki Kd 1 0 0 10 0 0 20 0 0 20 1 0 20 1 20

Plot all the unit-step output (y(t) vs. t) responses of the system in one plot. Indicate which response corresponds to which feedback gain selection. Comment on your results and on the eect that each feedback action has on the response of the control system. Plot all the unit-step control input (u(t) vs. t) responses of the system in one plot. Indicate which response corresponds to which feedback gain selection. Comment on your results and on the eect that each feedback action has on the control input, u. What do you think would occur if the input u, saturates?
2.3 Discrete Time (D.T.) closed loop unit-step response

Consider now the closed loop unit-step input response of this system under a discrete time PID controller. The discrete time PID controller is given by

up (k) ui (k) ud (k) u(k)

= = = =

Kpe(k) ui (k 1) + Ki e(k) Kd[e(k) e(k 1)] up (k ) + ui (k) + ud (k)

where e(k ) = r(k ) y(k) and the reference input r(k) is a unit-step. Notice that the D.T. PID control gains should not be chosen to be numerically equal to the corresponding gains of the C.T. controller. Factors in the the I and D gains should be included to account respectively for numerical integration and dierentiation. Modify the simulink le tank discrete.m so that the discrete time PID blocks are in the feedback path. Set the controller sampling time T = 2.5 sec. Use the procedure describe Section 6. The following performance specications should be satised: settling time: overshoot: steady state error:

30 sec 20% (for a unit step response) 0.01

Compare the response of the D.T. and C.T. PID controllers for similar conditions. Comment on the eect of the length of the sampling time on the response of the discrete time feedback system.

Two-mass vibratory system

Consider the two-mass vibratory system shown in Fig. 3 below. This system is similar to the experimental setup which will be used in subsequent ME134 laboratories (although the values of the masses and spring constant are vastly dierent). The system in Fig. 3 also represents a model for a computer disk le actuator. The state of the system are dened as: x1 is the position of m1, (relative to an inertial frame); x2 is the velocity of m1 ; x3 is the position of m2, (relative to an inertial frame); and x4 is the velocity of m2 . 3

Figure 3: spring-mass system The reference trajectory is denoted by ref(t). The objective of the control system is to make the position of m2, which is x3, follow the reference trajectory as close as possible. Hence, we could dene an error at each time t by
error(t) := ref(t) x3 (t)

(4)

In a disk-drive system (which we used to motivate this example) the reference trajectory would be a staircase-like signal, and x3 would be the position of the read/write head. The read/write head must be moved to a particular track, and held there for a short time to either read or write, and then moved to a dierent track. The head must be very still before the read/write process can take place. Hence, the response of the head position due to a step-change in desired position is important. In this investigation, we will simply use a unit-step reference trajectory, ref(t) = (t), where

(t) :=

0 if t < 0 1 if t 0

In this simulation example, rather than using the error in Eq. (4), we will rst assume that only the position of the rst mass, m1, is measured and the error signal used by the controller is

e(t) := ref(t) x1 (t) .


Notice that the control input u gets applied to m1. The controller has 1 state, and its dynamics are governed by

(5)

x c = ac xc + bc (ref x1) u = ccxc + dc (ref x1)


where the gains, ac, bc, cc and dc are chosen to achieve the tracking objective. The parameters of the two mass vibratory system and the state equations for this system are:

m1 m2 k c x 1 x 2 x 3 x 4

0 1 k c m1 m1 = 0 0
k m2 c m2

= = = =

1 kg 0.1 kg 5 newtons/meter 0.1 newtons/meter/sec


k m1

0 0

c m1

0 1

k m2

c m2

x1 x2 x3 x4
4

0
m1

0 0

1. The le twomass.m in Simulink contains the model of the mechanical system described above and the dynamic controller. This le is not complete and has some errors. You are asked rst to check the dimensions of the system matrices and insert some of the missing elements in the le. Secondly, you are asked to test the response of the feedback control system due to a unit-step reference input of 1 meter for each of the following 5 control gain selections: ac bc cc dc controller 1 5 -4 1 1 controller 2 5 -4 4 4 controller 3 5 -4 8 8 controller 4 5 -4 16 16 controller 5 5 -4 20 20 Notice that, for the above control gain selections, the controller transfer function can be written as follows

C (s) = K

s + b1 , U (s) = C (s) E (s) s + a1

where K = cc = dc, a1 = ac and b1 = ac + bc . Be sure to save as output the position of each mass, as well as the control force (ie., the output of controller) used to cause the motion. 2. Compare the performance of each controller. Keep in mind that the motor which is actually providing the force on MASS 1 is probably limited in the total amount of force it can generate, as well as the rate at which it can develop force. 3. Try a constant-gain controller (no dynamics) of the form

u(t) = K (ref(t) x1 (t))


(you get to pick the value of K ). Are you able to achieve good performance with such a simple controller? 4. Modify the control structure so that the error which is fed to the controller is

e = ref x3 .
Test the performance of the 5 controllers described in 1. above when the position of the second mass x3 is measured instead of the position of the rst mass x1 . Comment on the results obtained.

Ball-and-Beam

Consider the Ball-and-Beam system shown in Fig. 4: A ball of mass m slides on a beam which has moment of inertia J about its center of mass. The control torque u is applied to the beam at its center of mass. The equations of motion for this system are: 2 + mg sin() + b r =0 mr mr + mgr cos() u = 0 , JT + 2mrr 5

Figure 4: ball-and-beam where JT = J + mr2 and b is the coecient of viscous friction between the ball and the beam. The state vector for this system is x= rr
T

The objective of the control system is to bring the state to x = 0. 1. Load the le ball n beam.m using simulink. This le contains a simulink model of the beamand-ball system in the block labeled ball and a linear state-feedback controller. This controller is of the form (t) (t) + k (t) + k u(t) = kr r(t) + kr r = kr x1(t) + kr x2 (t) + k x3 (t) + k x4 (t) where the constant gains kr , kr , k and k are real numbers chosen by the control system designer to achieve the objective, which in this case is to regulate the ball/beam system at the point

r 0 r 0 = 0
0

Simulate the response of the feedback system for the following initial conditions:

1 0 , x(0) = 0
0

0 2 , 0
0

0 0 , 1
0

0 0 , 0
2

In words, what do each of these initial conditions represent? 2. Find initial conditions of the form

ro 0 x(0) = 0
0

0 0 , , x(0) = 0
o

for which the controlled system is unstable (ie., when started from this initial condition, the system does not restore all of the states to 0). For each case try to nd both a stable initial condition and an unstable initial condition that are within 10 to 20 percent of each other. 6

1 0 is an equilibrium point. , such that the state x 3. Find the constant input torque T = 0
0

Report: ( One report per group)

Write a small report describing your ndings when performing this lab.
5.1

Abstract- This is a short (1/2 to 1 page) synopsis of the intent and results of the exercise. Often Introduction- In this section the objective should be stated and backed up with details. AssumpTheory- Any relevant theory can be included here. Proofs are recommended, again, if relevant. Discussion- This is the main body of the report. In this section should be discussed the questions Results- Any pertinent results should be included here.
asked in the laboratory handouts. the most dicult part of the report to do correctly, it may be prudent to write it last. tions to be made should be listed and explained. The boundaries of the experiment, (i.e., what the experiment will encompass) should be clearly dened. The apparatus and/or model should also be described.

Recommended Form for Lab Reports:

Calculations- As implied by the heading, relevant calculations are included here.


multiple similar calcs., only one example need be presented.

Tabular forms of presenting results are encouraged. Plots or graphs should be placed in an organized manner at the end of this section. In cases of

Conclusion- The general conclusions for the experiment should be summarized here. Remember, Note:

hard numbers carry weight, e.g. The overshoot was 30specication, is better than The overshoot was unsatisfactory.

While I realize than many will have other formats for the the writing of lab reports, it will be appreciated if students attempt to follow the above plan.
5.2 Helpful Hints

The report should be comprehensive, so that anyone could read and understand it without having the lab handout in front of them. For example, in the rst lab instead of writing In part B of this lab we did..., it should be After applying a unit step reference input, it was found that.... In other words, the report should stand alone. Try to write the report as if the reader knows the material, but doesnt know the specic details of your project. Figure titles should be as descriptive as is reasonably possible so the gures can stand alone. For example, the title Digital PID Control of the Hubble Telescope (with accompanying parameter values) is better than PID Control or Output vs. Time. Be sure to label the axes and include units. 7

Step Response of second order system 1.4

1.2

0.8
position

0.6

0.4

0.2

20

40

60 time (secs)

80

100

120

Figure 5: Step Response of second order system

Hands-on Design of Control Systems

Hands on Design systems refers to directly working with the system to be controlled and trying a variety of controllers and control parameters.
6.1 Performance Specication

One of the rst things that must be done during hands-on design is deciding upon a criterion for measuring how good a response is. For example, when we deal with systems where we are not bothered with the actual dynamics of how the steady state is reached, but only care about the steady state itself, a good measure will be the steady state error of the system dened by

e = xf inal xref

(6)

However, in dynamic systems where the transient behaviour is also important, it becomes important to introduce several other criterion. The most common are:

Settling Time : This is a measure of how long it takes for the system to stabilize in its new nal Overshoot : This is the maximum distance beyond the nal value that the response reaches. It
8

value and is usually dened by the time it takes for the system response to come within a specied tolerance band of the setpoint value and stay there. is usually expressed as a percentage of the change from the original value to the nal, steady state value.

Steady State Error : This is a measure of how far the nal value reached in the step response
is from the actual desired value.
Feedback Control 6.2

In feedback control, we are interested in designing a Control Law which operates on the present error of the system (xdesired xactual ) and provides an actuation (u) which will act upon the system and bring it nearer to the desired value. We are interested in three types of controllers:
6.2.1 Proportional Control (P-control):

This is the simplest type of continuous control law. The controller output is made proportional to the error. The proportionality constant is called the gain.

up = Kp e

(7)

where up is the output and Kp is the gain. One important thing to be noted about Proportional Control is that is incapable of maintaining the output steady state value at the desired value. This is clear from the equation above. We can see that as long as a non-zero actuation is required to maintain the system at the desired value, the error cannot be zero. Mathematically, up = 0, therefore e = up/Kp = 0. As we increase the value of the gain, we can see the steady state error will decrease. However, Kp is limited by the dynamics of the system. Therefore the value of Kp will have to be arrived at by compromising between the steady state error and the dynamic stability of the system.
6.2.2 Integral Control (I-control):

If we want a zero steady state error, we want a control mode that is a function of the history of error accumulation. The longer the error persists, the stronger the control action should be to cancel it. The mathematical operation of integration is a means of implementing this action. Mathematically,

ui = Ki

t 0

e( )d

(8)

It can be seen that the integral action is capable of reducing the steady state to zero. This is because even though the steady state error is reduced to zero, the integral controller is still capable of maintaining some actuation (i.e ui = 0) because of the past history of error values. Integral control is usually combined with Proportional Control to give a PI controller.

upi = Kp e + Ki

t 0

e( )d

(9)

The PI controller has two tuning parameters, namely Kp and Ki . The easiest way to tune the control system is to start with the integrator turned o, i.e Ki = 0. and nd a reasonable proportional gain, as described in P-control. The integral gain (Ki ) can then be slowly increased until the steady state error is brought to zero in a reasonable amount of time. It should be noted that the Integral action has a de-stabilizing inuence on the system and therefore it may be necessary to reduce the proportional gain somewhat if the integral action causes too much oscillation. Ideally, we may have a mechanism whereby the integral action does 9

not start till the system has actually settled down a little. (say come within a 5% error band of the desired value). However, for our case, we will simply set the integral gain to a small value as compared to Kp, to minimize oscillation.
6.2.3 Derivative Control (D-control)

The use of integral action is sucient to reduce the steady state error to zero. However, the dynamic or the transient response may still be poor because of large oscillations, overshoots etc. Derivative control can be used in such cases to stabilize the dynamic behaviour of the system. Mathematically the derivative control law can be written as

ud = Kd

de dt

(10)

Thus the derivative action can be used to create damping in a dynamic system and thus stabilize its behaviour. It must however be noted that derivative action slows down the initial response to the system. Derivative action is usually used with proportional and integral control to achieve what is called PID control. Mathematically,

upid = Kpe + Ki

t 0

e( )d + Kd

de dt

(11)

We now have three independent parameters (Kp, Ki and Kd ) to play around with and optimizing them may present a formidable problem. However, a reasonable performance can be obtained by following the procedure described below:
Start with the P and D actions only. That is, initially set the integral gain to zero. This

means that initially we are concentrating on making the system exhibit a suciently good dynamic response. This is done by rst increasing Kp until unacceptable dynamic behaviour is obtained. Then we increase Kd and see if the behaviour improves. If it does, we again increase Kp. We keep iterating like this till a reasonable response time and steady state has been obtained. after Ki has increased enough to cause too much oscillations, the steady state error has not decreased enough, then we may need to go back to the rst step and alternately increase and decrease P and D gains.
Sampling Time with PID controllers

After this, we start increasing Ki to decrease the steady state error. If we notice that even

6.3

We can state intuitively that the sampling time has to be much smaller than the open loop settling time for discrete control to be eective. This is because, between two successive applications of the actuation, we are leaving the system to behave without interference. In other words, the response between two successive applications of control actuation is essentially open-loop behaviour. In order to choose a reasonable sampling time, we start with a sampling time which is quite small (say, 1/20th of the open loop settling time). Then we gradually increase the sampling time and stop when the dynamic behaviour becomes unacceptable.

10

You might also like