Simulink - Modeling Dynamic Systems | MEM 351, Lab Reports of Mechanical Engineering

Material Type: Lab; Class: Dynamic Systems Laboratory I; Subject: Mechanical Engr & Mechanics; University: Drexel University; Term: Unknown 1989;

Typology: Lab Reports

Pre 2010

Uploaded on 08/19/2009

koofers-user-i8s-1
koofers-user-i8s-1 🇺🇸

10 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
MEM 351 Dynamic Systems Lab 4
Hands-on Lab 4:
Simulink – Modeling Dynamic Systems
This lab introduces Simulink concepts necessary to model dynamic systems. Simulink is
an extension of MATLAB that provides a graphical environment for the construction of a
block diagram representation of a system. Simulink contains a number of libraries which
allow the accurate modeling of a variety of systems (e.g. continuous, discrete, etc.).
Concept 1: Getting to Know Simulink
Step 1: Open up MATLAB and click on the Simulink icon to open up the Simulink
Library Browser. Create a new block diagram by clicking File => New => Model.
Step 2: Create the model shown below by dragging the appropriate blocks from the
library browser into the workspace (Step is contained in the Sources library; Scope is
located in the Sinks library, and the Gain block can be found under Math Operations).
Step 3: Signals enable you to pass data between blocks. To connect the workspace above
with signals, place your cursor over the output port of Step (notice that the pointer will
change to a crosshair) and drag to the input port of the Gain block. Similarly connect the
Gain block to Scope. Note: Simulink has an auto-connect feature. To see how this
works, erase the newly added signal from the above step. Click on the Gain block to
highlight it, hold down the control key and click on the Scope block.
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Simulink - Modeling Dynamic Systems | MEM 351 and more Lab Reports Mechanical Engineering in PDF only on Docsity!

Hands-on Lab 4:

Simulink – Modeling Dynamic Systems

This lab introduces Simulink concepts necessary to model dynamic systems. Simulink is an extension of MATLAB that provides a graphical environment for the construction of a block diagram representation of a system. Simulink contains a number of libraries which allow the accurate modeling of a variety of systems (e.g. continuous, discrete, etc.).

Concept 1: Getting to Know Simulink

Step 1: Open up MATLAB and click on the Simulink icon to open up the Simulink Library Browser. Create a new block diagram by clicking File => New => Model.

Step 2: Create the model shown below by dragging the appropriate blocks from the library browser into the workspace ( Step is contained in the Sources library; Scope is located in the Sinks library, and the Gain block can be found under Math Operations ).

Step 3: Signals enable you to pass data between blocks. To connect the workspace above with signals, place your cursor over the output port of Step (notice that the pointer will change to a crosshair) and drag to the input port of the Gain block. Similarly connect the Gain block to Scope. Note: Simulink has an auto-connect feature. To see how this works, erase the newly added signal from the above step. Click on the Gain block to highlight it, hold down the control key and click on the Scope block.

The Step block has a default step time of 1 which denotes at what time in the simulation the step occurs. Change this value to 5 by double-clicking on it. The Gain block has a default value of 1 which has no affect on the signal. To change the value, double-click on it and type in 2 for the gain. Run the simulation by clicking the Play button. Double- click on the scope to view the signal.

Step 4: If a block needs to be inserted in the middle of two blocks which are already connected, just drag the block over the signal connecting the two blocks. The inserted block automatically attaches itself to the signals. To test this out, try inserting a Saturation block (found under the Discontinuities tab) between the Gain and Scope blocks. The Saturation block is used to impose upper and lower bounds on a signal.

Step 7: Annotations help create a well documented Simulink model. To add an annotation, double-click anywhere on the background. Add the text, “This is my first Simulink model” in the box which pops up. Change it to 14pt and italicize the font by going to Format => Font menu.

Step 8: A subsystem allows you to combine multiple blocks and signals into a single block. Drag a box around both the Gain and Saturation blocks to highlight them and then go to Edit => Create Subsystem (or just hit Ctrl+G). Double-click on the subsystem in order to view its components.

Step 9: Click the Play button to run the model and double-click on the scope to view the data. Click the binoculars to fit the graphs in the window.

Exercise 1: In Simulink create a model for the following

1-1. Display a sine wave of amplitude 4 on a Scope using Sin Wave (Sources), Constant (Sources), and Product (Math Operations) blocks.

Concept 2: Modeling Continuous Systems

The generic building block of a continuous system is the Integrator block (found under the Continuous tab). The integrator block will, as the name implies, integrate the input signal:

Note: Derivative blocks are not commonly used to construct differential equations because they do not allow you to store any initial conditions.

Step 4: Based on the differential equation,  has to go into a sinusoid function and then sin  has to be multiplied by (-mgd / J). Instead of grabbing Product blocks to achieve the above expressions, it is easier to use a Gain block. The sin  term can be achieved with a Trigonometric Function block (located under Math Operations). Highlight the Trigonometric and Gain blocks and hit Ctrl + I to get them to face to the left. Similarly, add another Gain block for the damping term, c.

Step 5: Finish the model by defining the initial conditions (double-click on the Integrator1 block and enter in 3.14/3 in the initial condition box) and initializing the constants (go to File => Model Properties => Callbacks and type in L=0.495; m=0.43; d=0.023; J=(1/12)mL^2+m*d^2; g=9.81; c=0.00035). Hit play and double-click the scope to view your output. Note that theta is in radians.

You can see from the scope’s output that the pendulum has a decaying oscillatory response starting at /3 radians and eventually stabilizing at zero degrees.

Exercise 2: In Simulink create a program for the following

2-1. In the above model, theta is in radians. Edit/modify your model such that the scope displays theta in degrees.

Concept 3: State Space Form

For a continuous time system, state space notation expresses its dynamics in the form of first-order differential equations. The general equation of state space representation is:

where A, B, C, and D are matrices of size (# states)-by-(# states), (# states)-by-(# inputs), (# outputs)-by-(# states), and (# outputs)-by-(# inputs), respectively. Let’s model the compound pendulum from above, but with an applied torque at the pivot point (see Figure below).

You can see from the scope’s output that the pendulum has a decaying oscillatory response eventually stabilizing at around 30 degrees. However, if a faster response time is required, control methodologies (pole placement, PID, etc.) MUST be implemented on the system’s input, T.

Exercise 3: In Simulink create a program for the following

3-1. Create a state space model to display theta in degrees when the applied torque is removed and a thrust vector FT (  to the beam) is added at the end of the beam.

Concept 4: Utilizing Simulink’s Pendulum Animation Function

Step 1: Recreate the pendulum model in concept 2 but without the scope.

Step 2: Simulink comes with a pendulum animation function called pndanim1.m. S- Function blocks allow you to call a Matlab function from your model. So let’s bring an S-Function block into our workspace (located under User-Defined Functions ). Double- click on the block and enter in pndanim1 in the S-Function Name box. Also enter in ts for the S-Function parameter (ts, or the sampling time, is the argument taken by the pndanim1 function) and hit OK.

Step 3: Highlight the S-Function block and create a subsystem (Ctrl + G). Double-click on the subsystem and delete the Out1 block since we will not need it.

Step 4: Close the subsystem window. Right-click on the S-Function block and select Mask Subsystem. Select the Parameters tab and click on the Add button in the top left. Enter in the parameters to match the window below and click OK.

Step 6: Hit play and you should see an animation window pop up.