22 Pages

CFN_chapter4

Course: ME 383, Fall 2009
School: University of Texas
Rating:
 
 
 
 
 

Word Count: 8175

Document Preview

"Modeling From: and Analysis of Dynamic Systems" by C.M. Close, D.K. Frederick, J.C. CH ER Newell, Wiley; 3rd edition, 2001 4 BLOCK DIAGRAMS AND COMPUTER SIMULATION ., In Chapter 3 we presentedthe two major forms of modeling equations: state-variableand input-output. In this chapter,we introduce a powerful tool for solving theseequationsand obtaining the responseof a system to different...

Register Now

Unformatted Document Excerpt

Coursehero >> Texas >> University of Texas >> ME 383

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
"Modeling From: and Analysis of Dynamic Systems" by C.M. Close, D.K. Frederick, J.C. CH ER Newell, Wiley; 3rd edition, 2001 4 BLOCK DIAGRAMS AND COMPUTER SIMULATION ., In Chapter 3 we presentedthe two major forms of modeling equations: state-variableand input-output. In this chapter,we introduce a powerful tool for solving theseequationsand obtaining the responseof a system to different inputs. This tool is the digital computer, using numerical simulation software. Both linear and nonlinear differential equationscan be solved numerically with high precision and speed, allowing system responsesto be calculated and displayed for many input functions. An easy way to make an interface between a system's modeling equationsand the digital computer is to use block diagrams that can be drawn from the system's differential equations. With the aid of appropriate software, the diagrams can then be used to produce a computer program that solves the original differential equations. Inspecting the block diagram of a system may provide new insight into the system's structure and behavior beyond that available from the differential equationsthemselves.In this chapterwe restrict the discussionto fixed linear systems,but the useof block diagrams is valid also for nonlinear systems,as we will seein Chapter9. We begin by defining the componentsto be used in our diagrams. We then show how theseblocks can be interconnectedto representdifferential equations.Finally, we introduce a computational languagecalled MATLAB and its graphical user interface, Simulink, to obtain solutions from theseblock diagrams. The operations that we generally use in block diagrams are summation, gain, and integration. Other blocks, including nonlinear elementssuch as multiplication, sqdareroot, exponential, logarithmic, and other functions, are available. Provisions are also included for supplying input functions, using a signal generatorblock, and for displaying results, using a scopeblock. f ; .. 4.1 DIAGRAM BLOCKS A block diagram is an interconnection of blocks representingbasic mathematical operations in such a way that the overall diagram is equivalent to the system's mathematical model. In such a diagram, the lines interconnecting the blocks representthe variables describing the systembehavior. Thesemay be inputs, outputs, statevariables,or other related variables. The blocks representoperationsor functions that use one or more of thesevariables to calculate other v~ables. For example, the force f produced by a spring can be calculated from its displacementby multiplying the displacementx by the spring constant K. In block-diagram form, this can be shown as in Figure 4.1. 73 I II, "oW,"d""" i'~~""""!' 74 %1"Block Diagrams and Computer Simulation ~m~ -l~_JFigure 4.1 A block diagramrepresentingf = Kx. ':~C-).2..xV-:Figure 4.2 A summer representing= Xl y +X2 - X3. ~ I Summer The additionand subtraction variables represented a summer, or summing of is by junction. A summer is usually drawn as a circle or rectangle that has any number of arrows directed toward it (the inputs) and a single arrow directed away from it (the output). Associatedwith each entering arrowheadis a plus or minus symbol indicating the sign of the associatedterm. The output variable, appearingas the single arrow leaving the circle or rectangle, is defined to be the sum of all the incoming variables, with the associatedsigns taken into account. For example, a summer that producesy = Xl + X2- X3 is shown in Figure 4.2. Gain The multiplication of a single variable by a constant is representedby a gain block. We place no restriction on the value of the gain, which may be positive, zero, or negative. Figure 4.1 shows a gain block that obeys the relationship f = Kx. c I t. . i I Integrator Integration with respect to time is performed in an integrator block, as shown in figure 4.3(a). The output of an integrator is given by y(t) = y(O)+ ~tU(A)dA y(t) so that = u(t) If the input to this block is the derivative of y with respectto time, its output must be y(t). This is shown explicitly in Figure 4.3(b). The initial condition, y(O), is not usually shown explicitly in block diagrams,but it is nevertheless important and must be specified or assumedto be zero. For now, we will assumethe initial. conditions to be zero. ..~-{~}2: (a) ..1..{~}2:..(b) ~ ---"~.,"~" ~""!;,,..,!-,',!: ::A"", "'~~~~" .ei L 4.2 Combining Blocks to Solve Modeling Equations" 75 ~ Figure 4.4 A constantblock. Constant The constantblock in Figure4.4 hasno input, andits outputneverchanges. shown,it As obeys relationship =c. the y .. 4.2 COMBINING BLOCKS TO SOLVEMODELING EQUATIONS We now show how to combine these elements into a block diagram that representsthe solution to a differential equation. Consider the modeling equation I I r i x =/o(t) -Ax (1) where A is a known constant,f 0 (t) is a knowninput function,andx is the output.Before using the single modeling equation in (1), we must take advantageof the relationship between x and x, so that the diagram has only one unknown variable. We do this by making x the input to an integrator, whose output must then be x, as shown in Figure 4.5(a). Becausethe equation for x is the difference of two terms, we show it as the output of a summer. The inputs to the summer are /o(t) andAx, with appropriatesigns, as shown in part (b) of the figure. Finally, we complete the diagram by using a gain block to form the signal Ax, as in part (c) of the figure. Notice that the only external signal coming into the final diagram is the known input /o(t). Diagrams for Input-Output Equations The processof writing block diagrams for models in input-output form can be developed from this simple beginning. For a systemhaving a single output and no input derivatives, the stepsare as follows: 1. Solve the given equationfor the highest derivative of the unknown output ;variable. 2. Connectone or more integrator blocks in seriesto integratethat derivativb successively as many times as necessaryto produce the output variable. 3. Use the result of step 1 to form the highest output derivative as the output of a summer and a gain block. The signals entering the summer usually consist of the output and its lower-order derivatives, each multiplied by a constant, and with the appropriate sign. There will also generally be a term representing the input. -_.~{~~J...:x fdt ~~()~-{:~Jfdt x ::.._a ( t) x + ~ ~L~j_a (t) x f + dt A x (c) -tAx (a) (b) Figure 4.5 The block diagram representation (1). (a), (b) Partial diagrams.(c) Complete of diaeram. , "".,".~ j 76 ~. Block DiagramsandComputerSimulation . .~i~~~..~~:~}~_. x x . fdt (a) x fdt (b) Figure 4.6 The block diagramrepresentation (2). (a) Two integrators. Completediagram. of (b) .. EXAMPLE 4.1 Constructa block diagramfor the systemshownin Example2.1, whoseinput-outputmodel wasgiven by Equation(2.15) as Mx+Bi+Kx=/a(t) SOLUTION Solving for the highestderivativeof x, namelyX, we obtain 1 x= M[/a(t) -Bi-Kx] (2) I I We use two integratorsin seriesto relate X, i, and x to one another,as shown in Figure 4.6(a). Because the equation for x is a constant times the sum of three terms, we form this quantity by meansof a gain block precededby a summer. The signalsentering the summerare the threetermsinside the brackets:/a(t), Bi, and Kx, with appropriate signs. The last two of thesesignalsareformed by picking off i andx from the diagramand then multiplying themby the gain constants Band K, respectively. The completeblock diagram is shownin part (b) of Figure4.6. ... EXAMPLE 4.2 Constructa block diagramfrom the input-outputequationfor the systemshownin Figure 2.13(a), which has two massesand two springs and a force input /a(t). Let B ~ ] = 0 and take i the output to be Xl . SOLUTION (3.31) with B = 0, We found the input-output equationin Example 3.12. From Equation MIM2X~iV) + [MIK2 + M2(KI + K2)]XI + KIK2XI = K2/a(t) so +K2/a(t)] {3) I 2 where A = MIK2 + M2(KI + K2). We start with a chain of four integrators to relate Xl and its four derivatives to one another. Looking at the equation for the fourth derivative of Xl, we form it as the output of a gain block preceded by a summer. The signals entering the summer are the three terms inside the brackets in that equation. The complete diagram is shown in Figure 4.7. 1 x~iV) M M [-Ai'I-KIK2XI =- We see from the last two examples that for an nth-order input-output differential equa- tion, we would start with a chain of n integratorsin series.Notice, however,that if B :10 '"'%W~., j 4.2 CombiningBlocks to SolveModeling Equations 77 ~r-i:1~ -l~ .I KIK:! Figure 4.7 The block diagramrepresentation (3). of in Example 4.2, the input-output equation will contain a derivative of the input. It might be argued that because !a(t) is a known function, we should be able to obtain its derivative as another known function, perhaps by defining and using a differentiator block in our diagram. We do not normally do this, however, becausethat could lead to numerical inaccuracies when we use the diagram to obtain a computer solution. Instead, Chapter 13 will contain a ~ore ~om.pletetreat~ent, which ~ill in~lude representing input-output eqUations that contam denvatlves of the mput on the nght sIde. Diagrams for the Original Modeling Equations I / Diagrams based on the input-output equations of complex systems may become quite cluttered and, more importantly, may not convey as much understanding of the physical system as we might wish. Rather than trying to first find an input -output model, we may start with the original modeling equations. If we have several free-body diagrams, then the overall model will probably consist of a set of coupled second-order equations. It is sensible to draw the block diagram directly from these coupled equations. Because the variables associated with a single mass are its position, velocity, and acceleration, the corresponding portion of the diagram generally consists of a chain of two integrators with the variables being fed back to a summer. The complete diagram then becomes an interconnection of subdiagrams that contain two-integrator chains, each with a summing junction. These ideas are illustrated in the following example. EXAMPLE 4.3 Consider again the fourth-order mechanical system studied in Examples 2.2 and 4.2. Draw a block diagram representing the original modeling equations that were found in Equations (2.16a) and (2. 16b). SOLUTION In these modeling equations there are two unknown displacements, Xl and xz, and their highest derivatives are Xl and xz. As step 1, we solve for Xl and xz to get Xl= - 1 [-BXl - (Kl + KZ)Xl +Bxz+Kzxz] Ml xz = i (4) [!a(t) -Bxz +Bxl -Kzxz + KZXl] As step 2, for each of these two equations we connect two integrators in series in order to relate the unknown displacement to its two derivatives. In step 3, we see from (4) that each second derivative can be formed as the output of a gain block, preceded by a summer whose inputs are the terms inside the brackets. Except for the external input !a(t), each of the signals entering the summers can be obtained by picking off Xl, xI, Xz, or .1:Z from one of the integrator chains as the input to a gain block. The complete diagram is in Figure 4.8. This diagram represents two coupled second-order subsystems. The two rows containing the integrators represent the two subsystems, and the connections between the I " 78 Block Diagramsand ComputerSimulation .. . fa(t) Figure 4.8 A block-diagram representation of (4). I J subsystemsshow the effects of the forces in the springs and dashpot connecting the masses. The short arrows labelled XI and X2 pointing to the right are shown at the right side of the diagram to designate these variables as outputs. I : . Diagrams for State-Variable Models To construct a diagram for a state-variable model, we first draw an integrator for each state variable. The inputs to these integrators are the first derivatives of the corresponding state variables. We then use the state-variable equations to form each of these derivatives in terms of state variables and inputs. In general, each derivative will be the output of a gain block preceded by a summer, although some derivatives may be formed in a simpler way. The steps can be summarized as follows. 1. 2. Draw an integrator for each state variable. Assemble the terms needed to form the derivative of each state variable, as specified in the state-variable equations. These will be functions of the state variables and inputs. Assemble the blocks needed for any output equations, using the state variables and inputs as required. 3. We now illustrate this process by constructing a diagram for a fourth-order system. ~ EXAMPLE 4.4 Draw a block diagram to represent the state-variable model of the system shown in Figure P2.4. It can be shown that for the four state variables XI, VI, X2, and V2, the state-variable equations are Xl VI = VI -Klxl -Blvl -B3(VI -V2) -K3(XI -X2)] (5a) (5b) 1 = M;[/a(t) Xz = Vz (5c) (5d) 1 vz = M;- [-Kzxz -Bzvz +B3(VI - v2)+K3(XI -xz)] ,-..,+ H " 4.2 CombiningBlocks to SolveModeling Equations ~ . 79 ! I , f Figure 4.9 The block-diagram representation (5). of SOLUTION Figure 4.9 is a block diagram that represents these equations. It contains an integrator for each state variable, plus a number of summers and gain blocks to produce the terms required for the derivative of each state variable. The integrators that produce the velocities have inputs, VI and V2,that are formed by summing the appropriate terms in (5b) and (5d). The system input fa(t) is shown here as a line entering the uppermost of these summing junctions from the left. As presented, this example does not have an output equation. However, if we wanted to study the compressive force in spring K3, which obeys the relationship fK3 K3(XI - X2), c ~ ~ ~ 1c i " " = I I ;. , we observe that this value exists as the output of the gain block K3 near the center of the diagram. Hence, we need only to add a short line with an arrow labelled fK3 to represent this force as an output. Similarly, the forces in either of the springs KI or K2, or the viscous drag forces in the dashpot B 3 or the sliding surfacesB I and B2, are all available in the diagram at the left sides of the blocks labeled KI, K2, B3, BI, and B2, respectively. i Structure of Block Diagrams The form of the block diagram in Figure 4.8 is different from that of Figure 4.9 in an important detail. In Figure4.8, there has been an algebraic simplification in (4), in which the coefficients of each variable were collected together. In this example, the coefficients of Xl, namely K I and K2, were added together. This simplifies the block diagram by minimizing the total number of blocks required. In (5) and Figure 4.9, on the other hand, terms are grouped as they occur in the free-body diagram. In the block diagram in Figure 4.9, the differences in displacement and velocity are formed explicitly and then multiplied by the appropriate coefficient, K or B. This results in an interesting and useful isomorphism between the block diagram in Figure 4.9 and the physical description. In particular, the spring KI and the damping BI are located between MI and a fixed frame. As a result, the gain blocks representing KI and BI connect only to the variables XI and VI, respectively. ! ! !.~'i"~""~,"' 8 , 80 Block DiagramsandComputerSimulation Furthermore, the spring K3 and the dashpot B3 are placed between MI and M2. Consequently, in the block diagram, the relative velocity and relative displacement are formed by two summers and then multiplied by B3 and K3, respectively. The signs of the resulting forces onMI are directed oppositely from those onM2. Finally, the spring K2 and damping B2 are located between M2 and a fixed reference frame. Again, in the block diagram, these gains are associatedonly with the inputs to the integrator for V2, and do not affect the inputs to the integrator for VI. A further desirable feature of the structure used in Figure 4.9 is that it naturally produces output equations for many physical variables in the system. Forces in all the components are calculated explicitly before they are applied to the massesupon which they act. , t: ~7'" ~J: cc 'J~ ~' "V C ~ 4.3 RUNNING SIMULINK WITH MATLAB In the previous section, we showed how to draw block diagrams to represent modeling equations in both input-output and state-variable form. A principal reason for doing so :-vasto prepar~ to solve these equations.nu~erically. We now describe a syste~ of numerical computation called MATLAB, which is a product of The Math Works available on all commonly used computer platforms and operating systems. A Student Version is available for the PC. This powerful system for simulating and displaying complex systems is widely used in academic and industrial settings. Only a small subset of the functions of MATLAB will be considered here. The examples chosen can all be solved using the Student Version of these programs. Other simulation and modeling programs are available, and everything that is covered in this book can be translated into other programs. We use MATLAB with its companion package Simulink, which provides a graphical user interface (GUI) for building system models and executing the simulation. These models are constructed by drawing interconnected blocks that represent the algebraic and differential equations that describe the system behavior, similar to a block diagram. MATLAB is used in a supporting role to initialize parameter values and to produce plots of the system response. Simulink provides access to an extensive set of blocks that accomplish a wide range of functions useful for the simulation and analysis of dynamic systems. The blocks are grouped into libraries, by general classes of functions. Mathematical functions such as summers and gains are in the Math library. Integrators are in the Continuous library. Constants, common input functions, and a clock can all be found in the Sources library.1 Simulink is a graphical interface that allows the user to create programs that are actually run in MATLAB. When these programs run, they create arrays of the variables defined in Simulink that can be made available to MATLAB for analysis and/or plotting. The variables to be used in MATLAB must be identified by Simulink using a ToWorkspace I / " ' ! I 1 block, which is found in the Sinks library. (Whenusingthis block,openits dialogbox and specify that the save format should be Matr ix, rather than the default, which is called Structure.) The Sinks library also contains a Scope, which allows variables to be displayed as the simulated system responds to an input. This is most useful when studying responsesto repetitive inputs, as discussed in Section 4.4. Blocks Simulink uses blocks that are similar to the ones in Section 4.1. The summer block can be represented in two ways in Simulink: by a circle or by a rectangle. Both choices are shown .t i IThroughoutthe remainderof this book, we will use courier MATLAB commands names. or type to designate fonnal Simulink or I f c ,I r """"~"""""cjcc Conrrned llt~ng lpmg these Iputs ~ ~ x1 2 4.3 RunningSimulink with MATLAB .. 81 :- y x1 x2 x3 . . - y x3 Figure 4.10 Two Simulink blocksfor a summerrepresenting = Xl y +X2 -x3. I luces aents >--+1::3:> + Gain ~~~ merIII all ~able Figure4.11 TheSimulink blockfor a gainof K. in Figure 4.10. The configurationof the summer,allowing any numberof inputs and the sign of each,is established a dialog box obtainedby double-clickingon the block. by I Idely if it will fit. If not,thesymbol- k - is used. Thisblockis shown Figure in 4.11.Thevalue usedin eachgain block is established a dialog box that appears the userdouble-clicks in if on its block. The block for an integratoras shownin Figure 4.12 looks unusual. The quantity 1/ s comesfrom the Laplacetransformexpression integration,and will seemmore natural for after we havecoveredthe Laplacetransformin Chapter7. If the userdouble-clickson the symbol for an integrator,a dialog box appears allowing the initial condition for that integratorto be specified.It may be implicit, andnot shownon the block, asin Figure 4.12(a). Alternatively, a secondinput to the block can be displayedto supply the initial condition explicitly, as in part (b) of Figure 4.12. Initial conditionsmay be specificnumericalvalues, literal variables, or algebraic expressions. The user is encouraged to consult the help function and other documentation supplied by The Math Works for details. A gain block is shownby a triangularsymbol, with the gain expression written inside ! , 'f L~B rSlon thing . hlcal :nodIffer;ram. ns of ange I s are :h as ,raryi ary. ually fined The 'ace ; box alled :o.be lYIng Constantsare createdby the Constant block, which closely resembles Figure 4.4. Double-clicking on the symbol opensa dialog box to establishthe constant's value. It can be a number or an algebraicexpression using constantswhosevaluesare defined in the workspace arethereforeknown to MATLAB. and Two additionalblockswill be needed we wish to useMATLAB to plot the responses if versustime. Thesearethe Clock andthe ToWorkspace blocks. The clock produces the variable"time" that is associated with the integratorsas MATLAB calculates numerical a (digital) solutionto a model of a continuoussystem.The result is a string of samplevalues of eachof the output variables. Thesesamplesare not necessarily uniform time increat ments,so it is necessary havethe variable"time" that containsthe time corresponding to to eachsamplepoint. Then MATLAB can makeplots versus"time." The clock output could be given any arbitraryname;we use"t" in most of the examples. l~r1l~OutPu.t ~-L~ m be lown 0 IC ~~:=:CJ.!!;n put 1 S Output P Integrator Initial Condition Integrator (a) nk or (b) Figure 4.12 Two forms of the Simulink block for an integrator. (a) Implicit initial condition. (b) Initial condition shown explicitly. I "cc'c,,'-"w;,"~'"'""C, J !. ~cc " I 82 \!Ii" Block Diagrams and Computer Simulation The ToWorkspace workspace, can and output block is used to return and/or block. the results plotted. In the usually with of a simulation variable all to the MATLAB diagram variables of any where they can be analyzed Any in a Simulink of the state result be connected the input equation Simulink to a ToWorkspace are may usually be scores Simulink simulated of other returned our examples, In to variables that provides the to workspace. be sent addition, the the would blocks and workspace. different the online functions. Help facility Users are encourwith aged to browse libraries consult provided MATLAB. Inputs A system responds to one or more inputs or initial conditions. It may have an input shown explicitly, such as the force fa (t) in (5b). Simulink provides several blocks that can produce such inputs. It is also possible that no input is applied, but that the system's response to some set of initial conditions is desired. If this is the case, the initial condition can be s~cified for a~y integ~ator double-clicking~n its bloc.k. The intial conditionscan be by gIven / I as numencal or lIteral constants or algebraIc expressIons of constants. A Simulink block is provided for a Step input, a signal that changes (usually from zero) to a specified new, constant level at a specified time. These levels and time are Another specified by double-clicking on the Step block, which is found in the Sources library. block designates the Signal Generator, which can produce a sinusoidally varying input, a seriesof square pulses,a sawtoothwave,or a randomsignal. Running the Simulation I To create a simulation in Simulink, the user should follow these steps: . . Start MATLAB. Start Simulink. Open the libraries that contain the blocks you will need. These usually will include the Sources, Sinks, Math, and Continuous libraries, and possibly . others. . . . . Open a new Simulink window. Drag the needed blocks from their library folders to that window. The Math library, for example, contains the Gain and Sum blocks. Arrange the blocks in the window in an orderly way that corresponds to the equations to be solved. Interconnect the blocks by dragging the cursor from the output of one block to the input of another block. Interconnecting branches can be made by right-clicking on an existing branch. Double-click on any block having parameters that must be established, and set these parameters. For example, the gain of all Gain blocks must be set. The number and signs of the inputs to a Sum block must be established. The parameters of any source blocks should also be set in this way. . The details of these procedures can be found in the MATLAB and Simulink documentation. Users are particularly encouraged to read the Student Versions of Learning MATLAB and Learning Simulink. It is necessary to specify a Stop time for the solution. This is done by clicking on the Simulation> Parameters entry on the Simulink toolbar. In order to be able to produce MATLAB plots versus time, the output of a Clock block must be sent to MATLAB by using a ToWorkspace block. At the Simulation> Parameters entry, other parameters can be selected in this dialog box, but the default values of all of \ c " ~" . 4.3 RunningSimulink with MATLAB , , 1 ) ~ 83 , . 1 Sum forms v) (forms x) Step ce ace 1 ~ ent) Damping ) , C9 Clock .[IJ To Workspace (time) Spring . ~ Figure 4.13 A Simulink diagramto solve(2) for the systemin Figures4.6 and2.12. them should be adequate for almost all of the examples used in this book. If the response before time zero is needed, it can be obtained by setting the Start time to a negative value. It may be necessary in some problems to reduce the maximum integration step size used by the numerical algorithm. If the plots of the results of a simulation appear "choppy" or composed of straight line segments when they should be smooth, this problem can be solved by reducing the Max step size permitted. .. EXAMPLE 4.5 t I ..' 1 ~ , . ! Construct a Simulink diagram to calculate the response of the system shown in Example 4.1 to an input force that increases from 0 to 8 N at t = 1 s. The parameter values are M = . 1 . ~ ~ t ~ - 2kg,K= 16N/m,andB=4N.s/m. SOLUTION We wrote the modeling equation, solved for the highest derivative of the output, and drew a block diagram to represent this equation in Example 4.1. The corresponding Simulink diagram is shown in Figure block with diagram, we have emphasized the importance of the integrator by drawing its 4.13. In this a drop shadow, which appears to give the block depth. This is accomplished in the Simulink window by highlighting the integrator block, then clicking on the Show Drop Shadow option on the For~t drop-down menu. We use the ToWorkspace MATLAB to plot the desired responses. blocks for t ,fa(t),x, and v in order to allow I ~ ~ t 3 f Note that the Step block has been used to provide the input fa(t). We have set the initial and final values and the time at which the step occurs. For clarity, we have also written these values underneath the symbol. We next cause MATLAB to solve the equations represented by this Simulink diagram. The duration of the simulation is selected to be 10 seconds from the Simulation> Parameters entry on the toolbar. The simulation is run by clicking the Start entry. When the computer makes a short chirp sound, the simulation is complete, and the variables that have been sent to the workspace are available there for analysis and/or plotting. If we enter the command plot (t , x) in the main MATLAB window, the desired plots are displayed. Several functions are available to make plots more informative. Among these are: xlabel, ylabel, title, gtext, text, grid, axis, and subplot. Figure 4.14 shows the complete response of this system. Some properties of this solution can be checked manually, a practice that is recommended whenever a simulation is employed. For example, the steady-state value of x is . ~ 84 Block Diagramsand ComputerSimulation g' ~O : .. .j : , c 0.4... Q) ~ 0 is ~0.2 ..:j..j... . .cj..j~ 00 1 0- 2 4 Time (8) 6 8 10 I -,0.5.""'. .5 0 " .. "".'.""..".." " ; " i?:' ~ 0 fI 8 10 I 0 2 4 Time (8) 6 I Figure 4.14 The displacement and velocity responsesof the system in Figure 4.13 to a change in 'I fa(t) from 0 to 8 N at t = 1 s. 0.5 m. This can be calculated by setting the derivatives equal to zero in (2) and solving for x when fa = 8. This steady-statevalue is seen in Figure 4.14. Note that the responsesof both variables are oscillations that decay exponentially to steady-statevalues. The displacement shown in the upper plot shows an overshoot starting at t = 1.8 s that peaks at t = 2.2 s. There is a smaller undershoot of the displacement between t = 2.9 s and t = 4.0 s. Another important feature of a numerical simulation is the easewith which parameters can be varied and the results observed directly. In Example 4.5, the effect of changing B is to alter the amount of overshoot or undershoot. These are related to a term called the damping ratio, a topic we will examine in detail in Chapter 8. To illustrate, begin the simulation in Example 4.5 with B = 4 N .s/m, but with the input applied at t = 0, and plot the result. Then rerun it with B = 8 N.s/m. Hold the first plot active, by the command hold on, and reissue the plot command. The second plot is superimposed on the first. This can be repeated for B = 12 N.s/m and B = 25 N.s/m, with the result shown in Figure 4.15. Another convenient feature of MATLAB, or other numerical simulation tools, is the ability to introduce initial conditions on any integrator. This process allows energy stored in the system at t = 0 to be represented explicitly. Double-clicking on an integrator block opens a dialog box where the initial condition on the output of that integrator can be set. ~ EXAMPLE 4.6 Find the response of the system in Example 4.5 when there is no input for t ~ 0, but when the initial value of the displacement x is zero and the initial velocity i(O) is 1 m/s. SOLUTION The Simulink diagram shown in Figure 4.13 is u~ed. with the size of the input step setto zero and with the initial condition on Int.egratorl sulting displacement and velocity are shown in Figure 4.16. set to 1.0. The re- "".+" . 4.3 Running Simulink with MATLAB .c1 85 0.7 0.6 . . .. . . .. . ; I 0.5 'E 0.4 OJ . .. . . .. .. .. .. E ~ 0.3 is 0.2 ... In OJ () . . . . . .. . . .. ...... .. .. I 0.1 . . , . . .. .. . .. " I , 0 0 I. Figure Time (s) ' , I 4.15 Responses B = 4,8,12,and25N.s/m. for x :h 1t 0.3 s. rs Ig ~d Ie )1 d is .sO. ~ ., . .. .. . ..' ,. ..:. . . . . , .. . . .:.. . ... . . . . . . ..' 'E OJ ~ 0.1 In . :!.." .. . . ..:. . . . . . . . .:.. . . . . . .. . . () CIS "Q. is -0.1 0 1 2 4 Time (s) 6 8 10! , 5. le ~ 0.5 ~ .... .. . . : .. . .. . . .. .c:. .. . . . . . :. . . . . . ., . . .. . :d Z'(3 .k , 0 w > ... -0.5 0 2 4 Time (s) 6 8 10 ~n Figure4.16 Responsesaninitial velocityof 1 mfs. to Ie eI 86 .. Block DiagramsandComputerSimulation M-files MATLAB has a feature called M-files that can simplify its operational use. These are files containing MATLAB statements,which can be saved and reexecutedby a single MATLAB command. Three types of statements are particularly useful with Simulink. The values of the parameters of a model can be saved in an M-file and changed by editing this file if needed. Commands to execute a model can be included, so that.the results of a simulation are created. Finally, plot commands and other postsimulation data analysis and display commands can be used to cause the production, printing, or storage of the desired product. M-files are produced with a text editor; there is one built into MATLAB that is accessible from the toolbar or through the edi t command. A file that will set up the MATLAB workspace by establishing the values of th~ parameters needed for the Simulink simulation of Example 4.5 is shown below. % This file is named ex4_5_setup.m. % Everything % is ignored % parameter 9,0 after a % sign on a line is a comment that the ! ( I by MATLAB. This file establishes values for ex4_5_model.mdl. % kg % N/m M = 2; 16; K B = j! .. = 4; = 8; % Ns/m % N fafinal The next M-file can be run to produce the upper plot in Figure 4.14. % This file % It makes plot(t,x) xlabel ( , Time is named ex4_5-plot.m. a plot of the data produced ; grid % Plots x for (s)'); by ex4_5_model.mdl. the case with B=4. ylabel (' Displacement (m)'); EX; A semicolon in a physical line ends the logical line, and anything after it is treated as if it were on a new physical line. A semicolon at the end of a line that generatesoutput to the command window suppressesthe printing of that output. These files can be used by first entering the command ex4_5_setup in the command window. Then open the Simulink model and start the simulation by clicking on the toolbar entry Simulation> Start. Finally, enter the command ex4_5_plot in the command window to make the plot. When two or more variables are being studied simultaneously, it is frequently desirable to plot them one above the other on separateaxes, as is done for displacement and velocity in Figure 4.14. This is accomplished with the subplot command. The following M-file uses command produce partsof Figure this to both 4.14. % This file is named ex4_5-plot2.m. % It makes both parts of Figure 4.14. % Execute ex4_5_setup.m first. 9,0 subplot (2,1,1) ( , Time ; plot(t,x); xlabel grid (s)'); % Plots x for the case with B=4. ;""," 'i . 4.3 RunningSimulink with MATLAB ylabel('Displacement subplot (2, (' 1, 2) ; ~ 87 (m)'); v for the 'case with B=4. plot(t,v); xlabel ylabel grid % Plots Time (s)'); ('Velocity (m/s)'); If a complex plot is desired, in which severalruns are neededwith different parameters, this can all be accomplished by executing ex4_5_setup followed by this M-file: % This file is named ex4_5-plots.m. % It plots the data produced by ex4_5_model.mdl for % several values of B. Execute ex4_5_setup.m first. 9" 0 % Has the same effect as clicking % Start on the toolbar. plot(t,x) % Plots the initial run with B=4. hold on % Plots later results on the same % as the first. B = 8; % New value of B; other parameter % stay the same. sim('ex4_5_model') % Rerun the simulation with new B plot(t,x) % Plots new x on original axes. B = 12; sim('ex4_5_model'); plot(t,x) B = 25; sim('ex4_5_model'); plot(t,x) hold off Entering the command ex4_5_plots ilar to Figure 4.15. XAMPLE 4.7 sim('ex4_5_model') on I axes I values value. I in the command window results in a figure sim- A person wearing a parachute jumps out of an airplane. Assume that there is no wind and that the parachute provides viscous damping relative to a fixed reference frame. The parachute has a relatively small mass M p and a large damping coefficient B p. The jumper has a larger mass M j and a smaller drag coefficient B j. The cords attaching the parachute to the jumper are called risers and are assumedto be quite springy. The elastic effect of the risers is represented by the spring constant KR. The deformation of the parachute itself can also be included in the value of KR. A simple model of the system is shown in Figure 4.17. A more comprehensive model will be discussed in Chapter 9. Write the modeling equations describing the motions of the jumper and the parachute. Choose the references such that the displacements x j of the jumper and x p of the parachute are both zero at t = O. Take the positive direction of these displacements to be downward, as shown in Figure 4.17. Draw a Simulink diagram to solve these equations. Use the following parameter values: Mp = 10 kg, M j = 60 kg, Bp = 100 N.s/m, B j = 10 N.s/m, and KR = 400 N/m. Simulate the following experiment: The jumper jumps out of the plane, and the parachute opens. Let t = 0 be the instant the parachute opens. At that time, the risers are fully extended, so they are neither slack nor stretched. At t = 0 the parachute and the jumper are falling at 20 rn/s. Run the simulation for the first 3 secondsafter the parachute opens. /. ') ,. ,- 88 ... Block DiagramsandComputerSimulation Bp 2 Bp 2 I!f/ XP1- xI -1 2 -1 2 I Figure 4.17 A parachute jumper anda mechanical modelfor thejumper. f t SOLUTION When we drawthe free-bodydiagrams M p andM j, sumthe forces,and for solvefor thehighest derivatives thedisplacements, obtain of we xp= - 1 [-Bpip+KR(Xj -xp) + Mpg] ~p x . - - [M .g - B .x . - KR(X . - x j-M. j j j j P)] j (6) which arerepresented the Simulink diagramin Figure4.18. in The following M-file canbe executed setup andrun this model. to %file is ex4 7 run.m Mp = 10; Mj = 60; Bp KR = = 100; 400; Bj = 10; sim('ex4_7_model') subplot(4,1,1) plot(t,xj ,t,xp,' subplot(4,1,2) plot(t,vj,t,vp, subplot(4,1,3) plot(t,aj) subplot(4,1,4) plot(t,delx) --') '--') The resulting MATLAB plots are similar to Figure 4.19. They have been labeled with letters A through E to help the reader identify the following features: A. B. C. The rapid slowing of the parachute as its drag becomes active but the jumper's weight has not yet extended the risers to pull down hard on the parachute. The increase in velocity of the jumper due to gravity, before the parachute and risers begin to take effect. The increase in length of the risers as the weight of the jumper is supported by the parachute. "",...4 , " r " , 4.3 RunningSimulink with MATLAB 89 Bp ParachuteDrag Coefficient KR Riser Spring Coefficient I I , 'f - . . (9--+0 Clock Time Bj Jumper Drag Coefficient Figure 4.18 A Simulink diagram to model (6) and the parachute jumper in Figure 4.17. 50 E 0 0 0.5 Jum e Pa 1 1.5 . . 4 20 ~ E 10 0 10 0 . . 2 . Jumper 2.5 3 3.5 4 C\J ~ E-10 -20 5 E 0 0 0.5 1 1.5 2 2.5 Time (s) 3 isers . 3 Accele ation 3.5 4 tion 3.5 4 Figure 4.19 Responsesfor Example 4.7. iIJ_-,,",,:c.+' , l , i i 90 BlockDiagrams Computer and Simulation D. The increase parachute in velocity due to the weight of thejumper. E. The terminal velocity of the jumper and parachute. The readermay show that this velocity is (Mp + Mj) 9/ (Bp + Bj), which is 6.24 rn/s for the statedparameter values. .. 4.4 REPETITIVE INPUTS In the previoussections,we havebeenconcerned with the responses systems to when the input is a function that only occursonce, such as a step. Many systemsare designedto operatewith repetitive inputs suchas a sinusoidor a train of pulses. Other systems may be testedthis way, evenif they areto be usedwith nonrepeating inputs. Simulink provides a sourcefor suchinput signalsand a convenient way to displaythe resultingresponses. By settingthe final time for a simulationto a very largenumber,we canobserve simulation the continuously,and study the effect of changes the parameters the model or the input. in of This ability to simulate a systemand study it while it runs is analogous building the to systemand studyingit in a laboratory.We demonstrate ability by providing a train of this pulsesasthe input to the modeldescribed Example4.5. in ./ ; "! r I .. Signal Generator One sourceof repetitive signalsin Simulink is called the Signal Generator. This block, which is located in the Sources library, is placed on the Simulink diagram in place of the Step input. Double-clicking on the Signal Generator block opensa dialog box, where a sine wave,a squarewave,a ramp (sawtooth),or a randomwaveform can be chosen. In addition, the amplitudeand frequencyof the signal may be specified. The signalsproducedhavea meanvalueof zero. The repetition frequencycanbe given in Hertz (Hz), which is the sameascyclesper second, in radians/second. or Scope When the signalsto be examinedare repetitive, and the startuptransientis not of interest, the systemresponse can be examinedgraphically,as the simulation runs, using the Scope block found in the Sinks library. This nameis derived from the electronic instrumentcalled an oscilloscope, which performsa similar function with electronicsignals. Any of the variablesin a Simulink diagram can be connected the Scope block, and to when the simulation is started,that variable is displayed. It is possibleto include several Scope blocks. The Scope normally chooses scalesautomaticallyto best display the its data. When using the scope,it is sometimes necessary slow down the executionof the to simulation in order to make the display occur at a rate the user can see. Particularly on fast computers, scopemay flash the entire answertoo quickly for the userto see.One the methodto preventthis is to openthe Simulation> Parameters dialog box on the Simul...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 340
v 1o := 100 V v 2o := 0 VR1 := 100 kC1 := 1 F C2 := 1 F Ceq := C1 C2 C1 + C2io :=v 1o - v 2o R1 io = 1 mA = 0.05s := R1 Ceqv 2ss :=io C2 C1 v 1ov 2ss = 50Vu o :=C1 + C2u o = 50V-tv 1( t) := v 1o e-t + uo 1 -
University of Texas - ME - 383
University of Texas - ME - 383
University of Texas - ME - 383
University of Texas - ME - 383
-)->q-L-9es l Au{,',t91,i", - .*ut-9 z06 2,<yLrd. 'ut{) , se -\|tnoJ.lrhor,/1 | 1 A "tr,Rol.i ;11r:L1 lt' (F,-lIffi r;:[sle"n "{ i',.\crestr^1hSe?dt\c|"Jj- axciklrvtott (dc-I| I* -lIlrn-etsjSo [6 rYe{^l
University of Texas - ME - 383
University of Texas - ME - 383
1tA'L-l-lar*"'.ic F"t;r5 c{lo ,cttvuJoLf,("c.d O.J.a (3s.1."15 ryrpo^soiro-'r*o: ic),J. .lo)L J2).J\4e-xarv!i neP"'v ,o_I+"S i n v S o i d o r l (-.{u {"x.<n3Se cot 'd, l -n.r.Jev(.!tJ .(-^-/l{sU s. {cy,^ArI-Lt-)
University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 383
Basic Modeling of Lumped-Parameter Electromechanical SystemsProf. R.G. Longoria Fall 2006ME 383Q Prof. R.G. Longoria Modeling of Physical SystemsDepartment of Mechanical Engineering The University of Texas at AustinTypical Energy-Storing Tran
University of Texas - ME - 383
University of Texas - ME - 383
Posted 11-9-06 RGL
University of Texas - ME - 383
University of Texas - ME - 383
University of Texas - ME - 383
Example: Angular-Motion EM systemsThe device shown has a driving blade that is made of iron, and can move in the air gap. Given:L( ) = A + BAs well as other parameters. This system also lends itself to an IC-multiport model.iTIC1 i = i
University of Texas - ME - 383
Example: Woodson and MelcherNote, when you see in a problem, it indicates you can assume that you can ignore the energy stored in the core material. For example, in this case most of the energy would be stored in the air gap. Basically, when go
University of Texas - ME - 383
University of Texas - ME - 383
University of Texas - ME - 383
University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 340
University of Texas - ME - 340
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "Programs must be written for people to read, and only incidentally for machines to execute." - Abelson & Sussman, SICP, preface to the first edition "That language is an instrument of human reason, and not merely a me
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "Lisp has jokingly been called "the most intelligent way to misuse a computer". I think that description is a great compliment because it transmits the full flavor of liberation: it has assisted a number of our most gif
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "Lisp was far more powerful and flexible than any other language of its day; in fact, it is still a better design than most languages of today, twenty-five years later. Lisp freed ITS's hackers to think in unusual and c
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "The key to performance is elegance, not battalions of special cases." - Jon Bentley and Doug McIlroy "Don't worry about what anybody else is going to do. The best way to predict the future is to invent it." Alan KayQ
Taylor IN - CSE - 280
Lisp-ish quotes while waiting The wheel needs reinventing, but not just yet. Nir Oren You've got to stop looking at the big picture. Gunnar Grimnes Pattern recognition and association make up the core of our thought. These activities involve milli
Taylor IN - CSE - 280
Lisp-ish quotes while waitingAn individual understands a concept, skill, theory, or domain of knowledge to the extent that he or she can apply it appropriately in a new situation. - Howard Gardner.Quotes from http:/www.csd.abdn.ac.uk/~fguerin/quot
Taylor IN - CSE - 280
AI-ish quotes while waiting In the scale of life there is a gradual decline in physical variability, as the organism has gathered into itself resources for meeting the exigencies of changing external conditions; and that while in the mindless and mo
Taylor IN - CSE - 280
Lisp quotes while waiting Programming in Lisp is like playing with the primordial forces of the universe. It feels like lightning between your fingertips. No other language even feels close. - Glenn Ehrlich, Road to Lisp Lisp is the red pill. - Joh
Taylor IN - CSE - 280
Lisp quotes while waiting "Lisp is the most sophisticated programming language I know. It is literally decades ahead of the competition . it is not possible (as far as I know) to actually use Lisp seriously before reaching the point of no return." -
Taylor IN - CSE - 280
Lisp quotes while waiting "Lisp . made me aware that software could be close to executable mathematics." - L. Peter Deutsch "Will write code that writes code that writes code that writes code for money." - on comp.lang.lisp "Lisp is a language for
Taylor IN - CSE - 280
COS 280 Session Notes #1SPRING 2006-Session 1 February 1, 2006 -AGENDA: 0 Admin 1 Syllabus review 2 What is AI? 3 Introduction to LISP --0 ADMIN -AI track Class web page SP aspect of class Get the textbooks! (Both of them). See the web page fo
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "Programs must be written for people to read, and only incidentally for machines to execute." - Abelson & Sussman, SICP, preface to the first edition "That language is an instrument of human reason, and not merely a me
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "the greatest single programming language ever designed" - Alan Kay, on Lisp "One of the most important and fascinating of all computer languages is Lisp (standing for "List Processing"), which was invented by John McC
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "Lisp is a programmable programming language." - John Foderaro, CACM, September 1991 "One can even conjecture that Lisp owes its survival specifically to the fact that its programs are lists, which everyone, including
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "Greenspun's Tenth Rule of Programming: any sufficiently complicated C or Fortran program contains an ad hoc informally-specified bug-ridden slow implementation of half of Common Lisp. - Philip Greenspun "Including Comm
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "Some may say Ruby is a bad rip-off of Lisp or Smalltalk, and I admit that. But it is nicer to ordinary people."- Matz, LL2 "We were not out to win over the Lisp programmers; we were after the C+ programmers. We manage
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "Lisp has jokingly been called `the most intelligent way to misuse a computer'. I think that description is a great compliment because it transmits the full flavor of liberation: it has assisted a number of our most gif
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "Lisp . made me aware that software could be close to executable mathematics." - L. Peter Deutsch "I object to doing things that computers can do." - Olin Shivers "Common Lisp, a happy amalgam of the features of previ
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "Inside every fat person is a thin person screaming to get out." - Richard Simmons "Common Lisp is politics, not art." - Scott Fahlman "Lisp was far more powerful and flexible than any other language of its day; in fa
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "Lisp doesn't look any deader than usual to me." - David Thornley, reply to a question older than most languages Most papers in computer science describe how their author learned what someone else already knew. - Peter
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "If I had a nickel for every time I've written "for (i = 0; i < N; i+)" in C I'd be a millionaire. - Mike Vanier "SQL, Lisp, and Haskell are the only programming languages that I've seen where one spends more time thin
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "A man, a plan, a canoe, pasta, heros, rajahs, a coloratura, maps, snipe, percale, macaroni, a gag, a banana bag, a tan, a tag, a banana bag again (or a camel), a crepe, pins, Spam, a rut, a Rolo, cash, a jar, sore hats
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "I have heard more than one LISP advocate state such subjective comments as, "LISP is the most powerful and elegant programming language in the world" and expect such comments to be taken as objective truth. I have neve
Taylor IN - CSE - 280
Lisp-ish quotes while waiting Although my own previous enthusiasm has been for syntactically rich languages, like the Algol family, I now see clearly and concretely the force of Minsky's 1970 Turing Lecture, in which he argued that Lisp's uniformity
Taylor IN - CSE - 280
Lisp-ish quotes while waiting "The key to performance is elegance, not battalions of special cases." - Jon Bentley and Doug McIlroy "Don't worry about what anybody else is going to do. The best way to predict the future is to invent it." - Alan Kay