{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

simulink_introduction

simulink_introduction - ace Transforms assume that both it...

Info icon This preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ace Transforms assume that both it is, : APPENDIX 3 SIM ULINK Tutorial ; case is ‘9. complex conju- <19] ,5 alwwmmwm ‘ lace transforms. h l , ; SIMULINK is a graphical, block-diagram—onented computer package for simulating ng t e c asswa dynamic systems.‘ It is a product that 1s layered on top of MATLAB and uses many of MATLAB’s functions. _It can also interface with the MATLAB environment for maximum 355 356 Appendix 3 SIMULINK Tutorial Figure A3.1 Example system. In this system, the input is the forcing function, f(t), and the output is the displacement of the mass, x(t). Table A3.1 summarizes the parameter values. Table A3.1 Parameter Values for Example System Parameter ' Value ‘ Units Mass (m) 1 kg Stiffness (k) 100 N/m Damping (b) , 1 N/m/s Before proceeding to construct the model, a few observations about the System are in order. First, one should determine the order of the system. This is fundamental to the simu- lation because it determines how many integrators (states) are required. In modeling physi~ cal systems, it is appropriate to count the number of energy storing elements in the system and assign one state to each element. In the system considered here, there are two energy storing elements: the mass and the spring. Therefore, this is a second-order system the mod? cling of which will require two integrators. Further, it can be shown that a good choice of state variables is (a) displacement of the mass, which determines the amount of potential energy stored in the spring, and (b), velocity of the mass, which determines the amount of kinetic energy stored in the mass. The outputs of the two integrators will be the two state ' variables. The state equations for this system are . 1 , ‘11 = ;{F(t) _ [€41 _ [9‘12] and Q2 = ‘11 where ‘ql is the velocity and (12 is the displacement. Construction of the simulation begins by starting the MATLAB program. From WIN- DOWS, double—click on the MATLAB, icon in the Program Manager. The MATLAB com- mand window will open, showing the >> prompt. At the >> prompt, you, can enter any MATLAB command. To activate SIMULINK, simply type >>simu1ink a 2 ; SlMULINK Tutoriai ple system. is the displacement it the system are in mental to the 5mm. In modeling physi« nents in the system ere are two energy .er system the mod» it a good choice of mount of potential ines the amount of ill be the two state )gram. From Wle he MATLAB com» you can enter any Appendix 3 SlMULINK Tutorial 357 A new window will open in the upper left—hand corner. Each icon in this window can be opened to reveal a group of blocks from which a simulation can be built. To Start a new model, chose New from the File menu, and an empty window will open. This window will contain your model, which can be saved using the Save command from the File menu. The File menu commands default to the MATLAB directory. Students are strongly advised to create their own directories for their own work to minimize confusion and the possibility of accidental loss of data. Model construction begins by selecting appropriate block icons from the library and copying them to the new window by clicking and dragging. First, open the SOURCES library group and select the Signal Generator block. While holding down the left mouse but— ton, drag the icon to your new window. Notice that the original Signal Generator is still there, and that a new copy has been placed in your window. This is a standard characteristic of SIMULINK. From the SINKS group, copy a “Scope” and a “To Workspace” block. The Scope block allows one to look at simulation variables as the simulation progresses, and the To Workspace block stores the data as a vector in the MATLAB workspace. This is useful for generating professional-looking plots using the MATLAB plot capabilities. Finally, open up the LINEAR library and copy over two integrators, three gains, and one summation block. To get multiple copies of a given block, you can either (a) repeat the drag and drop procedure outlined above fer each block or (b) select the block you wish to copy in your window using the right mouse button and drag and drop it within your window. This will create a copy of the selected block. ‘ Blocks are deleted by selecting the block and pressing the Delete key on the keyboard. After the above procedure, your window might look something like the assemblage of blocks shown in Figure A3.2. . ‘ Note that some of the blocks have only inputs, some have only outputs, and some have both. Note also that the blocks are designed assuming a general signal flow from left to right, so in Figure A3.2, the blocks are arranged with the source block on the left, the sink blocks on the right, and the other blocks placed in a somewhat arbitrary arrangement. Now, begin to manipulate and connect the blocks so that they reflect the system as described mathematically above. The first state equation indicates that the derivative of the velocity (acceleration) is equal to a summation of three terms divided by the mass. In terms of simulations, it can be said that velocity (one of our states) is the integral of this summa— tion divided by the mass. Our first step is to modify the summation block so that it can accept three inputs, not two. Double-click on the summation block and it will open into a dialog box with a single fieldthat holds two plus signs: + + . This indicates that the sum- mation block will take two inputs, both with positive signs. The first state equation requires the summation of three signals: one positive and the other two negative. Therefore, modify the input field to + — —- and click OK. The appearance of the summation block will change to reflect this modification. Now connect the signal generator to the first input of the sum- mation, the output of the summation to a gain block, and the output of that gain block to the first integrator. Make the connections by positioning the cursor at the output of the first block, press and hold the left mouse button, and drag the connection to the desired input of the other block. After you make these connections, the model should look something like Figure A3.3. ‘4 358 Appendix 3 SIMULINK TI )9) Gain I “E? -, )[>> ntegra or E - Sum - Sr nal Ga|n1 Gengrator 1* )9) lntegrat0r1 Gain2 . To Workspace Figure A3.2 Component blocks for the mass-spring-damper model, assembled to a new mod: window. Integrator E Si nal Sum ' , Gengrator 1' Integratofl out - To Workspace Figure A3.3 The first connections. i E - rkspace HMULINK Tutorial 3 :ope OUt I :o a new model 'OUt I )rkspace Appendix 3 SIMULINK Tutorial 359 So far, so good. Now connect the output of the first integrator (which is velocity, of course) to the input of the second integrator. The output of this integrator is displacement (we trust you’re following along here). The displacement is what you wish to monitor, so connect the output of the displacement integrator to the input of the scope. It is also instruc- tive to send the position to the MATLAB workspace as a vector. One can “tap” existing sig- nal connections easily in SIMULIN K. Position the cursor over an existing signal line at the location you need to “tap off.” Press the right-hand mouse button and drag the new connec— tion. Using this method, make an additional connection for the displacement to the “To Workspace” block. Figure A3.4 shows what your model should look like now. To complete the model, simply hook up the second two terms in the summation. Note that these are functions of velocity and displacement and, as such, are feedback loops in the integration. To make the diagram more readable, it would be nice, if the other two gain blocks could be “turned around” so that they could allow signal flow from right to left. Fortunately, SIMULINK offers this possibility. Simply select the block, choose Orientation from the Style menu, and choose “Right to Left” from the submenu that pops up. Repeat this process for both of the remaining gain elements and hook them up between the velocity and summation blocks and the displacement and summation blocks to complete the simula— tion structure. As a final step in building the simulation, rename the blocks with appropriate names so that the simulation is more easily understood. Click on the block name to highlight it, and edit the string. Figure A3.5 shows a completed simulation block diagram with appropriately named blocks. ‘ The structure of the modelis now complete. Take a moment to save the model file using the Save command from the'File menu. Always save your work often to guard against Gain Integrator Integrator1 Signal Generator Sum >{>> * Gain1 To Workspace lb) Gain2 Figure A3.4 The model grows. 360 . Appendix 3 SIMULINK Tutorial “Mass Velocity Displaceme t Signal Generator Damping To Workspace Stiffness Figure A3.5 Completed mass-spring—damper model. catastrophic crashes. There’s a wise saying in the computer business: “There are two kinds of computer users: those that have lost data and those that will.” Now, let’s set up the parameters of the model. Refer to Table A3.1 to find the values of the gain blocks. The mass is 1 kg, so you can set up the llmass block to be 1.0 also. Double—click on the gain block to open the dialog box. The default value of this gain block (and all others) is 1.0. Click OK and move on to the Stiffness block. Table. 1 indicates a value of 100 N/m. Modify this block accordingly and close it. The integrators can be modi- fied to reflect nonzero initial conditions; double—click on them to verify that the initial condi— tions are both zero. Now, open up the signal generator and inspect its controls It’s pretty self-explanatory, much like the signal generators one might find in an undergraduate dynam- ics or controls laboratory One last step before you are ready to simulate. Under the Simulation menu, choose parameters to open up the run—control dialog. In this box you can choose the simulation method (RK45 is probably the best general-purpose method), minimum and maximum step sizes, and error tolerance. Choosing a smaller value for tolerance will force the integration step size to smaller values until the minimum step size is met. Start and stop times can also be set here. For the purposes of this tutorial, the simulation will be terminated through key- strokes or mouse movements, so the defaults are fine here Now open up the scope and modify the scales so that the Horizontal Scale (time) is 10 (sec) and the Vertical Scale (displacement) is 0.05 (In). Open up the Signal Generator and set the Peak value to 1, Frequency to 0.2, and signal type to square-wave. Select START from the Simulation menu and watch the scope. You might have to click on the scope to bring it into the foreground of the simulation. —0.03 , O 50 100 150 200 250 300 350 400 450 500 Figure A3.6 MATLAB plot command for the variable yout.‘ MUUNK Tutoria' Appendix 3 SIMULINK Tutorial 361 0.03 _, 0.02 i 0.01 a, """ _, )8 -u -—0.01 f E —-0.02 ; (space You should see the response of the mass to the alternating forcing function. 'You should observe that the system is very underdamped, with a large overshoot and gradual decay. After running for a few seconds, choose STOP from the simulation menu and move to the MATLAB command window. At the prompt, enter the command .ere are two kinds to find the values :k to be 1.0 also. of this gain block ablel indicates a rtors can be modi— t the initial condi- ~ introls. It’s pretty :rgraduate dynam~ >>uhos to see what variables are present. You should see the variable yout, which is the output of your simulation, brought in through the “To Workspace” block. Examine the vector by entering the plot command >>p10t<yout) [on menu, choose ’se the simulation 3 nd maximum step ice the integration top times can also .ated through key- Depending on the duration of your simulation, you should get a plot that looks something like Figure A3.6. The x-axis of this plot is simply the index of the vector. In other words, there are 1000 elements in the yout vector plotted in Figure A3.6. \Time is not explicitly recorded in this vector. To make sure you get the time-dependency correctly recorded, you must modify the simulation model using a “clock” block from the SOURCES library and a “mux” (multi- plexor) block from the CONNECTIONS library. Figure A3.7 shows the approximate modi- fication. ‘ Run the model again with this modification and go back to the MATLAB command window. Enter the command Scale (time) is 10 1a] Generator and 'e. Select START k on the scope to s E s E >>plot(yout(=1L)1youtt:aE)) 362 Appendix 3 SIMULINK Tutorial Signal Generator Damping Stiffness Mux To Workspace Figure A3.7 Modification for explicit time recording. This command. says “Plot the vector in the second column of y 0 u t as the y—coordinate ver— sus the vector in the first column of yout as the x-coordinate.” You can also add titles, labels, and grids to the plot with the following commands: >>rgrid >>tit1e'(’A MATLAB PLOT’) >>xlabel(’_'l'ime (sec)’) >>y1abel(’Displacement(m)’) The resulting plot should look something like Figure A3.8. One final note: By default, the “To Workspace” block holds only the last 1000 data points and discards the oldest data. This is why the plot in Figure A3.8 does not start at zero. You can easily modify this limit by double—clicking on the block. ‘ iIMU LINK Tutoriai EOUI forkspace me y—coordinate ver- can also add titles, ,.8 does not start at the last 1000 data ‘ Appendix 3 0.03 0.02 Displacement (m) C —0.01 —0.02 —0.03 _ 100 SIMULINK Tutorial Figure A3.8 MATLAB plot with proper time scale. A MATLAB PLOT Time (sec) 363 250 ...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern