Sunteți pe pagina 1din 15

1

Bode Design Example #6


A. Introduction The plant model represents a linearization of the heading dynamics of a 250,000 ton tanker ship under empty load conditions. The reference input signal R(s) is the desired heading angle for the ship ref (s), and the output signal Y (s) is the actual heading angle (s). In this example, angles will be expressed in degrees. The input to the plant, U (s), is the commanded rudder angle rcom (s) that is used to control the heading of the ship. The open-loop transfer function for the plant is Gp (s) = Y (s) 3.2587 104 (s + 2.551 102 ) (s) = = 2 3 U (s) s (s + 0.3333) (s + 5.3288 10 ) (s + 6.8624 10 ) rcom (s) (1)

The gain 3.2587 104 , the poles at s = 5.3288 102 and s = 6.8624 103 , and the zero at s = 2.551 102 describe the dynamics of the system between the actual rudder angle and the rate of change in heading angle. The pole at s = 0 provides the integration from the rate of change in heading angle to the heading angle itself. The pole at s = 0.3333 models the hydraulic actuator dynamics between the commanded rudder angle rcom (s) and the actual rudder angle r (s). The only difference between the model given in (1) and the true linearized model is the sign of the gain 3.2587 104 . Because of the sign conventions used in ship steering, the sign of the gain should be negative. However, because of the same sign convention, the sign of the compensators gain would also be negative. To simplify this example, both gains will be assumed to be positive. There are no changes in the overall open-loop or closed-loop transfer functions due to this simplication. The performance specications that are imposed on the system are: Phase margin must be at least 50 ; The loop must be able to withstand a pure time delay of at least 15 seconds; Steady-state error in the closed-loop ramp response must not exceed 2 degrees. B. Evaluating Gp (s) Relative to the Specications The open-loop system is Type 1, so the plant has the correct System Type N to satisfy the steady-state error specication. The steady-state error of the plant for a ramp input is 1/Kxplant , where 3.2587 104 (s + 2.551 102 ) Kxplant = lim s = 0.0682 (2) s0 s (s + 0.3333) (s + 5.3288 102 ) (s + 6.8624 103 )

so the steady-state error is essplant = 1/0.0682 = 14.7. Therefore, in order to satisfy the steady-state error specication, the compensator must have a gain Kc = essplant 14.6618 = = 7.3309 essspec 2

(3)

The value in (3) will be the total compensator gain regardless of whether the compensator is phase lead, phase lag, or lag-lead and regardless of the number of stages in the nal compensator design. The maximum pure time delay that can be tolerated in the loop is related to both the phase margin (expressed in radians) and the gain crossover frequency x . Since both time delay and phase margin have specied minimum values, a specication on gain crossover frequency is also implied. The relation between the variables is Tdmax = PM x x = PM 50 /180 = 0.0582 rad/sec = Tdmax 15 (4)

Uncompensated Bode Plots for G (s) = 3.2587E04(s+2.551E02)/[s(s+0.3333)(s+5.328E02)(s+6.8624E03)]


p

100

50

Magnitude (db) & Phase (deg)

50

100

150 essspec = 2, ess = 14.7 200 PM 250


spec

= 50, PM = 31.0

Tdelayspec = 15, Tdelay = 22.9


xspec

= 0.058, x = 0.024
3 2 1 0 1

300 4 10

10

10

10 Frequency (r/s)

10

10

Fig. 1.

Bode plots for the uncompensated system Gp (s).

Smaller values for x than given in (4) can also be used; they will provide longer allowed time delays in the loop for a given phase margin, but the response time of the system will be correspondingly slower. Fig. 1 shows the Bode plots for the plant transfer function given in (1), and Fig. 2 shows the Bode plots when the compensator gain Kc = 7.3309 is placed in series with the plant. When the compensator gain Kc = 7.3309 is included in the system to satisfy the steady-state error specication, the phase margin drops from 31 to 8.2 and the maximum allowed time delay drops from 22.9 seconds to 1.84 seconds. It is clear that additional compensation is needed. C. Compensator Designs 1) Overview: Two approaches to compensator design using the Bode plot techniques discussed in class could be tried. The rst approach uses only phase lag compensators to drop the magnitude curve |Kc Gp (j )| down to 0 db at the frequency where the phase curve is 180 + 50 + 10 = 120 . This frequency is approximately = 0.0048 rad/sec. The magnitude |Kc Gp (j )| at this frequency is approximately 38.8 db, which corresponds to an absolute value of g = 86.8. This is generally considered too large for a single stage of lag compensationdue to the large numerical values for the resistors and capacitors to implement the compensatorso two stages would be used, each having = 86.8 = 9.32. The resulting design has a phase margin of 54.6 , which satises that specication, and a maximum time delay of 199 seconds, far exceeding the specication. The overshoot in the step response is 18%, which might be acceptable, but the settling time is over 3, 700 seconds, which is much too long. The

Bode Plots for System with K = 7.331


c

100

50

Magnitude (db) & Phase (deg)

50

100

150 e 200 PM 250


spec

ssspec

= 2, ess = 2.0 = 50, PM = 8.2

Tdelayspec = 15, Tdelay = 1.8


xspec

= 0.058, x = 0.078
3 2 1 0 1

300 4 10

10

10

10 Frequency (r/s)

10

10

Fig. 2.

Bode plots for the system to satisfy the steady-state error specication, Kc = 7.3309.

design is also conditionally stable, so gain reductions as well as gain increases could produce an unstable closed-loop system. Therefore, this design will not be shown. The second design approach will use a lag-lead compensator. The lead part of the compensator will be designed rst, with the goal of raising the phase curve up at the specied gain crossover frequency given in (4). After that, the lag part of the compensator will be designed to drop the combined magnitude of the plant, compensator gain, and lead compensator down to 0 db at that same frequency. Thus, the frequency specied in (4) will be used in both parts of the compensator design. 2) Design of the Lead Compensator: The rst step in the design of the lead compensator is to determine the amount of positive phase shift that must be added at a specied frequency in order to satisfy the phase margin specication. Since we know that a lag-lead will be designedrather than just a lead compensatorthe frequency where the phase shift will be measured is the specied value for the compensated gain crossover frequency given in (4) instead of the original value of x . At the compensated gain crossover frequency xc = 0.0582 rad/sec, the plant has a phase shift of 164.4 , as obtained from the data array in MATLAB using the bode function. It could also be computed directly from the transfer function Kc Gp (j) or it could be determined from the Bode phase plot. If the value is obtained graphically from the plot, the accuracy and resolution obviously will not be as good as if the value is determined analytically from the transfer function or from the MATLAB data array. With this value for Kc Gp (j xc ), the effective phase margin of the uncompensated system Kc Gp (j) is

P Muncomp = 180 + Gp (jxc ) = 180 164.4 = 15.6

(5)

It should be noted that this value for P Muncomp will not be obtained using the MATLAB margin function with the transfer function Kc Gp (s). Phase margin is only dened at the actual gain crossover frequency. In the design of a lag-lead compensator, the effective phase margin of the uncompensated system is computed at the nal value for the gain crossover frequency, not the current value. Therefore, the value shown in (5) is not truly a phase margin, but it is used in the computation of max as if it were a true phase margin. Using the value for P Muncomp given in (5), the amount of positive phase shift that must be added at xc = 0.0582 rad/sec is max = P Mspec + 10 P Muncomp = 50 + 10 15.6 = 44.4 The corresponding value for the parameter d is d = 1 sin (max ) 1 sin (44.4 /180) = = 0.1770 1 + sin (max ) 1 + sin (44.4 /180) (7) (6)

The zero and pole of the lead compensator can now be computed. They are given by zcd = xc d = 0.0582 0.1770 = 0.02448 zcd 0.02448 = pcd = = 0.13827 d 0.1770 The complete transfer function for the lead part of the compensator is s s Kc +1 + 1 7 . 3309 z 0.02448 cd = s Gclead (s) = s +1 +1 0.13827 pcd 41.411 (s + 0.02448) Kc (s + zcd ) = d (s + pcd ) (s + 0.13827) (8) (9)

(10)

(11)

The Bode plots for the series combination of the plant given in (1) and the lead compensator given in (10) are shown in Fig. 3. At the frequency = 0.0582 rad/sec, the phase curve has been moved up by 44.4 , the value of max . The actual phase margin at this stage of the design is not the correct value because gain crossover has not yet been established at that frequency. That will be the task of the lag part of the lag-lead compensator. The lead compensator has taken care of the positive phase shift that needed to be added to the system. 3) Design of the Lag Compensator: Now that the phase curve has been adjusted to have the correct value at the frequency that has been chosen to be the compensated gain crossover frequency, the only remaining task is to drop the magnitude curve down to 0 db at that same frequency. This establishes that frequency as the actual gain crossover frequency, and since the phase curve has the correct value at the frequency, the phase margin specication will be satised. Also, since xc was chosen based on the relationship between the phase margin and time delay specications, the time delay specication will be satised as well. The amount that the magnitude curve must be moved down in order to establish gain crossover at the specied xc is the magnitude of the series combination of plant and lead compensator, evaluated at that frequency. This can be done analytically from the product of the magnitudes of the transfer functions in (1) and (10), evaluated at s = j 0.0582. It can also be done from the data arrays in

Bode Plots for Intermediate System with 1Stage Lead Compensator 100

50

0
Magnitude (db) & Phase (deg)

max

= 44.4, = 0.1770
d

50

Kc = 7.331 zcd = 0.02448, pcd = 0.13827

100

150 e 200 PM 250


spec

ssspec

= 2, ess = 2.0 = 50, PM = 16.9

Tdelayspec = 15, Tdelay = 1.8


xspec

= 0.058, x = 0.164
3 2 1 0 1

300 4 10

10

10

10 Frequency (r/s)

10

10

Fig. 3.

Bode plots showing the effects of the lead compensator in raising the phase curve at xc = 0.0582 rad/sec.

MATLAB or graphically from the Bode plots. The values for |Gp (j 0.0582)| , |KcGp (j 0.0582)| , and |Gclead (j 0.0582) Gp (j 0.0582)| in both absolute values and decibels are shown in the table below. The absolute values were obtained from the corresponding MATLAB data arrays; the values in decibels were computed from ||db = 20 log10 ||abs val . Transfer Function |Gp (j 0.0582)| |KcGp (j 0.0582)| |Gclead (j 0.0582) Gp (j 0.0582)| Absolute Value Decibels 0.22755 12.858 1.6681 4.4447 3.9647 11.964

The total attenuation required at = 0.0582 rad/sec is given by the values in the last row of the table. If the magnitude value is obtained graphically from the Bode plots, the magnitude will be expressed in decibels, and the conversion to absolute value is |Gclead (j 0.0582) Gp (j 0.0582)|abs The value of the parameter g is g = |Gclead (j 0.0582) Gp (j 0.0582)|abs
val

val

= 10(|Gclead (j 0.0582)Gp (j 0.0582)|db /20) = 10(11.964/20) = 3.9647 (12)

= 3.9647

(13)

The zero of the lag compensator can be placed rather arbitrarily. If it is placed one decade below the compensated gain crossover frequency,or lower, then the phase margin specication will be satised due to the 10 safety factor included in the calculation of max . For this example, the zero will be placed one decade below xc . zcg = pcg 0.0582 xc = = 0.00582 10 10 zcg 0.00582 = = = 1.4674 103 g 3.9647 (14) (15)

The lag compensators transfer function is s s +1 +1 zcg = 0.00582 Gclag (s) = s s + 1 +1 1.4674 103 pcg 1 (s + zcg ) 0.25222 (s + 0.00582) = (s + pcg ) (s + 1.4674 103 ) g

(16)

(17)

Note that the gain Kc = 7.3309 was included with the lead portion of the compensator. It could have been included with the lag portion instead, or the gain could be split between the two stages in any manner desired, as long as the product of the gains (in the time-constant form of the transfer function) is 7.3309. The total compensator for the system is the product of the lead and lag parts. In the Bode or time-constant form, the compensators transfer function is s s 7.3309 +1 +1 0.02448 s 0.00582 (18) Gc (s) = Gclead (s) Gclag (s) = s +1 + 1 0.13827 1.4674 103 and in the pole-zero format, the transfer function is Gc (s) = 10.445 (s + 0.02448) (s + 0.00582) 41.411 (s + 0.02448) 0.25222 (s + 0.00582) = 3 (s + 0.13827) (s + 1.4674 10 ) (s + 0.13827) (s + 1.4674 103 ) (19)

Either form of the transfer function, (18) or (19), may be used. Note that the two transfer functions have different gains. In the time-constant form, the gain in the transfer function is Kc , computed in (3). In the pole-zero form, the gain in the transfer function is Kc / (d g ) . The Bode plots for the complete lag-lead compensated system are shown in Fig. 4. The actual phase margin is 55.6 , larger than the specied minimum value, so the phase margin specication is satised. The gain crossover frequency is equal to the value specied in (4).. Since the phase margin is larger than the required minimum value and the gain crossover frequency is equal to its specied value, the pure time delay that can be tolerated in the loop is larger than its specied minimum value. The actual value of the allowed time delay is 16.6 seconds.

Bode Plots for System with Final LagLead Compensator 100

50

0
Magnitude (db) & Phase (deg)

= 3.9647
g

50

zcg = 0.00582, pcg = 0.00147

100

150 e 200 PM 250


spec

ssspec

= 2, ess = 2.0 = 50, PM = 55.6

Tdelayspec = 15, Tdelay = 16.6


xspec

= 0.058, x = 0.058
3 2 1 0 1

300 4 10

10

10

10 Frequency (r/s)

10

10

Fig. 4.

Bode plots for the complete lag-lead compensated system.

D. Evaluation of the Design The table below summarizes the stages in the design process in terms of satisfying the specications. The following four closed-loop systems will be compared: TCL1 (s) = Gp (s) Kc Gp (s) , TCL2 (s) = 1 + Gp (s) 1 + Kc Gp (s) Gclead (s)Gp (s) Gc (s)Gp (s) , TCL4 (s) = TCL3 (s) = 1 + Gclead (s)Gp (s) 1 + Gc (s)Gp (s) (20)

where Gp (s), Kc , Gclead (s), and Gc (s) are given in equations (1), (3), (10), and (18), respectively. Specication Requirement TCL1 (s) TCL2 (s) TCL3 (s) TCL4 (s) Steady-State Error ess 2 14.662 2 2 2 Phase Margin P M 50 31 8.2 16.9 55.6 Time Delay Td 15 sec 22.9 sec 1.84 sec 1.80 sec 16.6 sec Gain Crossover Frequency xc = 0.058 r/s 0.024 r/s 0.078 r/s 0.164 r/s 0.058 r/s Clearly, only the nal design satises all the specications, and it is the only design to provide enough phase margin in the system.

Now that the specications presented in the Introduction have been satised by the nal design, several additional (performance) characteristics will be compared for the various stages of the design. These characteristics will be

closed-loop closed-loop closed-loop closed-loop

frequency response magnitude |TCL (j )|; step response of the output signal (t); step response of the control signal r (t); and ramp response of the output signal (t).

Each of these characteristics will be discussed in turn. 1) Closed-Loop Frequency Response Magnitude: The Bode plots shown thus far have been for the open-loop system at a particular stage in the design. Closed-loop stability and performance have been inferred from these plots through the phase margin and gain crossover frequency. The frequency response magnitude of the closed-loop system provides additional information from the bandwidth, resonant peak, and resonant frequency. The bandwidth is the frequency where the magnitude has dropped to 1/ 2 of its value at = 0. Since the plant has System Type N = 1, the magnitude of the closed-loop transfer function has unity magnitude at = 0, so the bandwidth corresponds to the frequency where the Bode plot magnitude is 3 db. The closed-loop bandwidth is a measure of the range of frequencies that can pass through the system without signicant attenuation. The resonant peak is the maximum value of the closed-loop frequency response magnitude. It is the largest gain of the closed-loop system for any sinusoidal input. Large values of the resonant peak Mpw correspond to small amounts of damping in the system, so large overshoot and oscillations are expected in the step response. For example, the standard second-order system with damping ratio has a resonant peak given by Mpw = 1 p , 2 1 2 1 2 (21)

so the value of the resonant peak increases rapidly for decreasing , becoming innitely large for the undamped = 0 case. Overshoot in the step response also increases with decreasing , with overshoot being 100% for = 0. Thus, large overshoot in the time domain corresponds to a large magnitude peak in the frequency domain. The resonant frequency is the frequency at which the resonant peak occurs. The resonant frequency of the standard second-order system is q 1 (22) r = n 1 2 2 , 2 For > 1/ 2, the resonant frequency and resonant peak are r = 0 rad/sec and Mpw = 1. For = 0, r = n , indicating that the systems step response oscillates at the undamped natural frequency when there is no damping. The closed-loop magnitude plots for the four systems are shown in Fig. 5. The bandwidths, resonant peaks, and resonant frequencies are shown in the table below. System TCL1 (s) TCL2 (s) TCL3 (s) TCL4 (s) Bandwidth Resonant Peak Resonant Frequency 0.039 rad/sec 1.89 (5.53 db) 0.022 rad/sec 0.123 rad/sec 7.08 (17.0 db) 0.079 rad/sec 0.259 rad/sec 3.65 (11.2 db) 0.174 rad/sec 0.110 rad/sec 1.19 (1.50 db) 0.023 rad/sec

Looking at the closed-loop bandwidth, the following pattern is evident. Starting with the uncompensated system TCL1 (s), increasing the gain by Kc = 7.3309 to form system TCL2 (s) increases the open-loop

ClosedLoop Magnitudes 20 2 3 0 4 20 1 40
Magnitude (db)

Uncompensated bandwidth = 0.039 r/s 60 Bandwidth with Kc = 0.123 r/s Bandwidth with intermediate compensator = 0.259 r/s Bandwidth with final compensator = 0.110 r/s 80

100

120

140 4 10

10

10

10 Frequency (r/s)

10

10

Fig. 5.

Closed-loop frequency response magnitudes for the four stages of the design.

gain crossover frequency and the closed-loop bandwidth. When a lead compensator is then designed to form system TCL3 (s), the bandwidth is increased further. Lastly, when the lag compensator is added to the system, the bandwidth drops, in this case nearly to its original value. 2) Closed-Loop Step Response of the Output Signal: The time domain is the nal and true testing place for any design. The step responses of the output signals of the four designs dened in (20) are shown in Fig. 6. Even though there was no specication on overshoot or settling time, common sense would say that there are still limits on what acceptable values would be. The output signal in this example is the actual ship heading angle (t). Each of the rst three designs have excessive overshoot, and system TCL2 (s) also has an excessive settling time. Only system TCL4 (s), the nal design, has overshoot that is close to being reasonable. Its settling time is also acceptable, and there are no oscillations in the response. If the overshoot of 18% is still considered to be too large, the design would need to be iterated to provide additional phase margin, or perhaps the Derivative-on-Output-Only (DOO) implementation of the compensator could be used. For purposes of this example, we will assume that the overshoot and settling time are both acceptable. 3) Closed-Loop Step Response of the Control Signal: In any design, the response of the control signal u(t) should also be evaluated. The control signal is the output of the compensator. In this example, the control signal is the commanded rudder angle rcom (t), expressed in degrees. The shapes of the control signals are similar to those of the output signal except for being inverted. The maximum absolute values (magnitudes) of the control signals should be checked. In any real system, the control signals will be limited in their peak values and in their rates of change. For a surface ship such as the one used in

10

Uncompensated ClosedLoop Step Response 1.5 2 1.8 1.6 1.4


Yaw Angle (deg)

Step Response with Kc = 7.331

1
Yaw Angle (deg)

1.2 1 0.8 0.6

0.5

PO = 43.8%, T = 451 sec s

0.4 0.2 PO = 85.1%, T = 650 sec s

200

400 600 Time (s)

800

1000

200

400 600 Time (s)

800

1000

Step Response With Lead Compensator 1.8 1.6 1.4

Step Response With Final LagLead Compensator 1.4

1.2

1 1.2
Yaw Angle (deg) Yaw Angle (deg)

1 0.8 0.6

0.8

0.6

0.4 0.4 0.2 0 PO = 61.6%, T = 169 sec s 0.2 PO = 18.9%, T = 183 sec s

200

400 600 Time (s)

800

1000

200

400 600 Time (s)

800

1000

Fig. 6.

Closed-loop step responses of the output signal (t) for the four systems.

11

this example, the rudder angle would be limited to 20 or 25 . The maximum rate of change would probably be in the range 35 deg/sec. The plots of the control signals when a unit step is applied at the reference input are shown in Fig. 7. The peak magnitude of the control signal for the lead compensator TCL3 (s) is larger than could actually be achieved. From the data array for the signal, the maximum rate of change of the rudder angle is approximately 5.1 deg/sec. The other designs have peak control signal magnitudes that are within bounds, but it should be remembered that for a linear system model, if the magnitude of the input signal is scaled by some factor, then the magnitude of all other signals in the system will be scaled by the same factor. The most interesting thing to note about the peak values of the various controls signals is that they are equal in each case to the compensator gain when the compensator is expressed in pole-zero format. This will always be true if the number of poles and zeros in the compensator are equal. For the uncompensated case, Gc (s) = 1, so that gain equals 1. For system TCL2 (s), the compensator is Gc (s) = Kc . For the lead compensated design and the nal lag-lead compensated design, the compensator transfer functions in pole-zero format are given in (11) and (19), respectively. For each of these designs it can be seen that |u(t)|max equals the controller gain value. 4) Closed-Loop Ramp Response of the Output Signal: The fact that the steady-state error specication on the ramp response has been satised by all the designs except for the uncompensated system is known because of the calculation of the gain Kc . Its value was determined specically to reduce the uncompensated systems steady-state error down to the correct value. The ramp responses of the four systems are shown in Fig. 8 to verify that we achieved what was desired. One point to note in checking the ramp response of a system in MATLAB. In many cases, the settling time of the ramp response is much longer than that of the step response. This is particularly true if the compensator has a lag or special lag term in the design. From the MATLAB data arrays at t = 1000 seconds, the steady-state errors for the four systems are 14.6492 (TCL1 ), 1.9939 (TCL2 ) , 2.0000 (TCL3 ) , and 2.0035 (TCL4 ) . This indicates that 1000 seconds is essentially steady-state for the ramp responses since the exact (innite time) values of the errors are 14.6618, 2, 2, and 2. The lower right-hand graph in the gure shows that all the designs except for the uncompensated system have identical responses in steady-state.

12

Uncompensated ClosedLoop Control Signal 1 8 6 4


Rudder Angle (deg) Rudder Angle (deg)

Control Signal with K = 7.331


c

0.5

2 0 2 4

|u(t)|

max

= 1.000 deg 6 |u(t)|


max

= 7.331 deg 800 1000

0.5

200

400 600 Time (s)

800

1000

200

400 600 Time (s)

Control Signal With Lead Compensator 50 40 30

Control Signal With Final LagLead Compensator 12

10

8
Rudder Angle (deg)

20 10 0 10 |u(t)| 20 30
max

Rudder Angle (deg)

4 |u(t)| 2
max

= 10.445 deg

= 41.411 deg 0

200

400 600 Time (s)

800

1000

200

400 600 Time (s)

800

1000

Fig. 7.

Closed-loop step responses of the control signal r (t) for the four systems.

13

ClosedLoop Ramp Responses 1000 900 800 700 Yaw Angle (deg) 600 500 400 300 200 100 0

100

200

300

400

500 Time (s)

600

700

800

900

1000

Ramp Responses, Zoomed View 200 180 160 140 Yaw Angle (deg) 120 100 80 Uncompensated 60 40 20 0 965 960 955 950 950 Yaw Angle (deg) 1000 995 990 985 980 975 970

Ramp Responses, Zoomed View

Uncompensated

50

100 Time (s)

150

200

960

970 980 Time (s)

990

1000

Fig. 8.

Closed-loop ramp responses of the output signal (t) for the four systems.

14

E. Simulation of the System Using Simulink To start Simulink, type simulink in MATLAB workspace In Simulink Library Browser, click on icon for New (or menu File/New/Model) to open a window for your model. Save your model with a lename of your choice. Extension for Simulink models is .mdl Drag and drop blocks from the Library Browser to your model window. Draw lines between blocks to establish connections (or click on rst block, press and hold CTRL and click on second block). Double click on a block to enter data, change parameters, etc. In Simulink window, under Simulation/Conguration Parameters: Solver Stop time: set to the desired value Type: choose Fixed Step or Variable Step Solver: choose ODE3, ODE4, or ODE5 for Fixed Step; choose ODE45 for Variable Step Fixed Step Size (fundamental sample size): choose the time between consecutive sample points Data Import/Export Check boxes for Time and Output under Save to Workspace Uncheck box for Limit data points to last: under Save Options Select Array for Format under Save Options Locations of blocks in the Libraries Transfer functions: Continuous Summing Junctions: Math Operations Step, ramp, constant inputs: Sources Save to workspace: Sinks Multiport switches, multiplexers: Signal Routing Save to Workspace block Select Array under Save Format Limit data points to last: should be set to inf Step block Set step time (time that step is applied) to desired value Set nal value (size of step) to desired value Ramp block Set start time to desired value Set slope to desired value Transfer Function blocks Numerator and denominator arrays can be entered directly into the block by double-clicking on the block Names for numerator and denominator arrays can be entered instead; the arrays must be present in the MATLAB workspace when the simulation is run. Summing Junctions: make sure you have the correct signs at the input terminals Running the simulation In MATLAB workspace, type sim(model lename) In Simulink Simulation/Start Press black triangle (like Play button on a CD player) Simulation data is stored in the MATLAB workspace in the array name that you used for the Save to Workspace block (default name is simout).

15

2 Flag signal1 num_c(s) Ramp den_c(s) Multiport Switch Add Compensator num_p(s) den_p(s) Plant uy_out signal2 To Workspace

Step

Fig. 9.

Simulink diagram for the nal design.

Time values are stored in the MATLAB workspace in the array tout Simulations generally run faster if you store the data in the MATLAB workspace and then plot it rather than using a Scope in Simulink to display the data as the simulation runs. Fig. 9 is the Simulink diagram for this example. Either a step or a ramp input can be applied. The value of the constant in the block labeled Flag is set to 1 for a ramp input or 2 for a step input. The control signal and the output signal are stored in the array uy_out; time is stored in the array tout (which does not appear as a block in the diagram). Data in the arrays are overwritten each time you run the simulation, so you have to rename the arrays in MATLAB after a simulation or change the name of the array in the Save to Workspace block in Simulink.

S-ar putea să vă placă și