Engineers use Simulink
Engineers use Simulink
to model, simulate,
and analyze dynamic systems
for a wide variety of applications,
such as flight control shown here.
But how do you get started building a model?
To open Simulink, look in the Home tab of
your tool strip and click the Simulink icon.
Once open, you'll see that there are templates and
examples you can use to get
started on different types of projects.
Here, we'll walk you through
building your first model from scratch.
Select blank model.
In the model window, the blank space
in the middle is the model canvas,
which is where you'll build your block diagram.
There is also a tool strip at
the top that contains a variety of helpful features.
Here, you will use the simulation tab,
which includes the features you
need to simulate and save your model.
Later on, you'll see how to use other features in
the debug and modeling tabs to
adjust model settings and
better understand how your models run.
Now, to begin, you first need to add a block,
the main element used to construct any Simulink model.
The best way to view the list of
available blocks is using the library browser.
Blocks in Simulink are organized by library.
Note that the set of libraries you see
will depend on the toolboxes you have installed.
In this course, you'll be
working with the Simulink library.
But depending on your application,
you may need to use blocks from other libraries as well,
like Simscape or Stateflow.
Click into the Simulink library.
Notice that there are sub libraries,
organizing blocks further by topic.
Use the search bar if you're unsure
where to look for a particular block.
Let's create a simple model
adding together two sine waves,
and multiplying the result by two.
Combining sine waves is common in many applications,
such as modulating a carrier frequency
or mixing audio signals.
To add the first sine wave, look in sources,
a commonly used library containing
blocks that generate signals without any input.
Drag and drop the block into the model canvas to add it.
Double click on it to open the block dialog box.
Here, you can see more information about
the block and set any relevant parameters.
For example, you see that the default values for
amplitude and frequency for the sine wave block, are one.
Close the window to keep these values.
Now, you may want to visually check that this
sine wave aligns with
your expectations using the scope block,
which you can find in the syncs library.
This library contains blocks that have input signals,
but do not generate any output.
Add the scope block to the model,
and then drag the signal from
one block to the other to create the connection.
Now, run the simulation
and double click the scope to see the results.
You should see a sine wave just as expected.
Remember that this is only part of the model.
Let's add another sine wave block.
Instead of dragging it from
the library browser this time,
add the new sine wave by double clicking on
the canvas and typing the name of the block.
This is an efficient way of adding blocks,
but only if you know the block's exact name.
The block you want here is called
sine wave and is located in the sources library.
Select the first option.
Now, let's change this sine wave frequency by opening
its dialogue box and setting the frequency value to 0.5.
Click Okay to save your changes and close the dialogue.
You now have two blocks creating
sine wave signals with different frequency values.
But they look identical.
When building your own Simulink models,
you typically want to add
descriptive names for your blocks or signals,
so you know what each one represents.
Connect the new signal to the scope block,
which automatically creates a new port
to display both sine waves,
and simulate the model again to view the results.
Play video starting at :4:43 and follow transcript4:43
Because there are multiple signals shown,
add a legend to display the names you created for
each block. Looks great.
Now that we've confirmed the sine wave block settings,
recall that the goal is to add
the signals together and multiply the result by two.
First, disconnect the signals from the scope.
Then, sum the two sine waves together using
the add block in the math operations library.
Drag the block into the model,
and then drag the two signal connections into the block.
To multiply the result by two,
look in the same library to find
the gain block, which performs multiplication.
Add this block to the model,
connect the sum as the blocks input,
and change the blocks multiplier value
to two using its dialogue box.
Finally, delete the optional second input.
Connect the gain output to the scope
and give the signal a name
by double clicking on the signal line.
Then simulate the model to view the new result.
The result looks correct,
but we don't see the periodic behavior
of sine waves anymore.
Increase the simulation time to 20 to see if that shows
the periodic behavior. Good work.
You can see the repeating pattern in the result.
You now know how to use blocks to build, simulate,
and visualize results for a simple model in Simulink,
which are all key skills you will be using
and building upon throughout the rest of the course.
The Math Operations library provides many blocks for performing standard
mathematical operations on signals. Here are some key blocks in this library and
their functionalities:
1. Sum/Add blocks: Adds or subtracts input signals. Both blocks perform the
same operations and allow for multiple inputs. By default, the Sum block is a
circle, while the Add block is a square. This is a purely visual difference,
which can help improve model readability. It does not change the block's
function.
2. Gain block: Multiplies an input signal by a constant gain factor, which can be
adjusted.
3. Product block: Multiplies two or more input signals.
4. Math Function block: Performs various mathematical functions on the input
signal, such as logarithmic, exponential, square root, and power functions.
The specific function can be selected in the block parameters and is reflected
on the block icon.
5. Trigonometric Function block: Applies trigonometric operations (e.g., sine,
cosine, tangent) to an input. The specific function can be selected in the
block parameters and is reflected on the block icon.
6. Abs block: Outputs the absolute value of the input.
7. MinMax block: This block determines the minimum or maximum values from
multiple inputs, allowing configurations for running minimum/maximum
values over time.
Each block often includes options to adjust the functionality to specific
requirements. We encourage you to add some of these blocks to a blank Simulink
model and explore their properties and behavior. For example, add an Add block to
the model and try changing the List of signs option to ++-. Note how the block's
icon and number of inputs change.