Sunteți pe pagina 1din 4

MEEN 364

Vijay Alladi, 2001. Aninda Bhattacharya, 2002.


Andrew Rynn, 2002. Justin Mlcak 2005. Brandon Simmons 2015
Last Update: January 22, 2016 by Sammy Meleika

Lab 1 Introduction to MATLAB & Simulink


Introduction
As they become more powerful and less expensive, computers are increasingly important tools
for mechanical engineers. They are often used to design and implement control systems because
programming offers great flexibility. By simply changing the value of a parameter, or by just
changing a few lines of code, the characteristics of the controller can be changed. The computer
also offers tools for instant feedback of the results and means for storing the data. The use of
computers and different software tools for measurements on dynamic systems and their control
will be emphasized throughout the course.
Simulink is a graphical programming language that uses icons instead of text to create
applications. Simulink works in parallel with MATLAB such that it can seamlessly read and use
values that are in the MATLAB workspace as well as manipulate and save data to the
workspace.
Through toolboxes such as the Data Acquisition Toolbox and the Real-Time Windows Target
Toolbox, Simulink has the capability to communicate with hardware such as Data Acquisition
boards. With these toolboxes Simulink can facilitate hardware instrumentation, data acquisition,
and control systems programming.
Objective
The objective of this lab session is
1. To become familiar with creating models in Simulink and using it to build your own
applications.
2. To learn how to solve a system of differential equations in MATLAB.
Lab Procedure
Part 1. Simulink
1. Build a model that generates a sinusoid and displays it on a scope.
a. Select a sine waveform from Sources and change the following parameters
i. Sine type: Time based
ii. Amplitude: 25
iii. Frequency: 5
iv. Sample time: 0.01
b. Take the mean and the rms of signal
i. Open the RMS box in the model and check running rms and click ok
ii. Repeat this with the mean
iii. Use a numeric display for each
1

MEEN 364
Vijay Alladi, 2001. Aninda Bhattacharya, 2002.
Andrew Rynn, 2002. Justin Mlcak 2005. Brandon Simmons 2015
Last Update: January 22, 2016 by Sammy Meleika

2.

3.
4.
5.

c. Add both the discrete derivative and discrete integral of the sine signal
i. Under the integrator parameters change:
1. Initial condition: -5
2. Sample time: -1
ii. From Sinks add a scope to the model
1. Open the scope and select the parameters
2. Change the number of axes from 1 to 3
iii. Right-Click to the left of each subplot and adjust the scale of each
individual so that the signal is fully visible
d. In the main model window click the system parameters (gear) and change:
i. Stop time: 10
ii. Type: Fixed Step
iii. Solver: discrete
Add white noise to the sinusoidal signal
a. Use the search bar to find the AWGN Channel
b. Add the AWGN (Gaussian White Noise) box right after the sine generator
c. Change the Eb/No to 20.
Save the model.
Run the model by clicking the green play button
In the AWGN use the following values for Eb/No: (80, 20, 0, -20), and detail the results

Things to consider in the Memo for Part 1


Explain HOW AND WHY any changes that occur for the following
1. Varying the amplitude. Effect on the rms and mean?
2. Varying the frequency. Effect on the derivative and integral?
3. Varying Eb/No. Effect on the sine, its derivative, and its integral?
NOTE: formulas or definitions may be necessary for explanations
Part 2. Ordinary differential equations using MATLAB and Simulink
The following is a very simple slider/pendulum system

MEEN 364
Vijay Alladi, 2001. Aninda Bhattacharya, 2002.
Andrew Rynn, 2002. Justin Mlcak 2005. Brandon Simmons 2015
Last Update: January 22, 2016 by Sammy Meleika

Figure 1 - Slider Pendulum


Consider a right handed Cartesian coordinate system, with gravity facing downwards. There is a
slider mass that can translate horizontally without friction, but is constrained by a spring with
spring constant k. Attached to the slider, is a pendulum of length L. The spring is at equilibrium
when x is zero. The EOMs that govern this example were linearized about = 0 and are shown
below
1
(1 + 2 ) + 2 + 2 = 0
2

1
1
1
2 + 2 2 + 2 = 0
2
3
2

It can also be modeled using matrices such that =


Where

0
=
0

1 + 2
0
1

2 2

1
0
2
2

1
0
1

0
2
3 2

MEEN 364
Vijay Alladi, 2001. Aninda Bhattacharya, 2002.
Andrew Rynn, 2002. Justin Mlcak 2005. Brandon Simmons 2015
Last Update: January 22, 2016 by Sammy Meleika

Parameter convention
1 2 -

2 2

10 kg
2 kg
50 N/m
1m
25 cm
15o

Simulate the position and angle of the system using an M-file in MATLB
1. Refer to the MATLAB tutorial for examples
2. Solve the differential equations for and
3. Plot the position and angle vs time using MATLAB
Things you learned in the lab
1.
2.
3.
4.

Building a model in Simulink


Using basic functions for discrete simulation
Using numeric displays and scopes
Solving simple ODEs using MATLAB

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