Seth on Simulink
August 21st, 2008
Mask Initialization and Self-Modifying Blocks
In previous posts, I introduced advanced
masking concepts and discussed how to build a masked library block with a dynamic
mask dialog. In this post, I will show how the example Saturation block
adds/deletes ports and rewires itself depending on its configuration.
The Saturation Block Example

After configuring the block dialog, clicking Apply or OK
executes the mask initialization callback. The mask initialization callback is
where most of the work for a mask happens. Mask initialization commands should
take the parameter values set in the mask dialog and configure the block so it
is ready to run. In the Saturation block example, the block is switching
between two basic configurations, the Dynamic Saturation and the Fixed
Saturation.

The difference between the configurations is the type of
block used for up and lo. They are ports to provide dynamic limits, and
constants to provide fixed limits.
Key point: do the least amount of work that you can
in the mask initialization.
Mask initialization code should do the minimum amount of
work that it can because mask initialization runs many times in the life of a
model. In addition to running when you click OK or Apply, mask initialization runs
at the start of every simulation and update diagram, when you call set_param to
modify the block, and when you are building the model as you drop the block
into the system.
The mask parameters are the variable names set on the
parameters page of the mask editor. (See below)

Blocks in the system under the mask can access these variables
in the mask workspace. Initialization commands also run in the mask workspace,
so these variables are part of the mask initialization callback. (see below) If
a block will rewire itself, or add ports, you must check Allow library block
to modify its contents.

For the saturation block, I chose to call an M-function to
do the work of the initialization command. I find it is more convenient to
debug and the MATLAB editor is a more comfortable development for mask
initialization commands that are more than a few lines.
Use the state of the mask GUI to control the code
My function is saturation_init_cb. I pass into the function
all the variables it needs from the mask workspace. This is more efficient
than calling get_param on the block. I always pass in the result of gcb
(get pathname of current block). I will use this path
when I need to reference the blocks inside the saturation block subsystem.
In order to do the least amount of work, my mask
initialization checks the system to see if changes are needed. The check for
the upper limit source runs through the switch statement to handle the two
possible values, internal or external. The code then checks for the BlockType
of the saturation/up block. If it is not the right type, we call the
local replace function to replace the block. If we have added a constant, we
set the Value of that constant to use the uplim variable from the mask. A
similar action is repeated for the lower limit.
% saturation_init_cb Mask Initialization
function saturation_init_cb(blk,uplimsrc,uplim,...
lowlimsrc,lowlim)
% Check for upper limit source
switch uplimsrc
case 'external'
% Check for constant
if strcmp(get_param([blk '/up'],'BlockType'),...
'Constant')
replace([blk '/up'],'built-in/Inport');
end
case 'internal'
% Check for inport
if strcmp(get_param([blk '/up'],'BlockType'),...
'Inport')
replace([blk '/up'],'built-in/Constant')
set_param([blk '/up'],'Value','uplim')
end
end
% Check for lower limit source
switch lowlimsrc
case 'external'
% Check for constant
if strcmp(get_param([blk '/lo'],'BlockType'),...
'Constant')
replace([blk '/lo'],'built-in/Inport')
end
case 'internal'
% Check for inport
if strcmp(get_param([blk '/lo'],'BlockType'),...
'Inport')
replace([blk,'/lo'],'built-in/Constant')
set_param([blk '/lo'],'Value','lowlim')
end
end
The replace function gets the position and orientation from
the old block, deletes it and then adds the new block in its place.
% Local replace function
function replace(oldblock,newblock)
pos = get_param(oldblock,'Position');
orient = get_param(oldblock,'Orientation');
delete_block(oldblock);
add_block(newblock,oldblock,'Position',pos,...
'Orientation',orient);
Note, the replace_block function in Simulink could not be
used here because it is meant for model wide changes. While it is possible to
limit the affect of replace_block to a specific system, replace block doesn’t
work on library blocks. Self-modifiable masked blocks are library blocks, so this
is a common helper function used for this kind of mask.
Renumbering ports to control the order
The port number affects the order that the ports show up on
the outside of the block. Wires cross the boundary of the block and remain
connected through the inport that they are originally connected to. A port can
be inserted before or after existing ports on the block by changing the
numbering of all ports. The following code sets the port numbers by checking
the values of uplimsrc and lowlimsrc. When the upper limit source is external,
that will be the first port. If not, the first port is the u input. I can
keep track of the order and number of the ports by incrementing the numbering
variable each time I set a port number.
% Renumber ports
% when using external upper limit, % set blk/up port to 1
n = 1;
if strcmp(uplimsrc,'external')
set_param([blk '/up'],'Port',num2str(n))
n = 2; % increase n
end
% set u port to n
set_param([blk '/u'],'Port',num2str(n))
% when using external lower limit, % set blk/lo port to n+1
if strcmp(lowlimsrc,'external')
set_param([blk '/lo'],'Port',num2str(n+1))
end
Now it’s your turn
I have shared some of my best practices for programming
self-modifying blocks. What techniques have you used to program masks? Share
your comments here.
10:30 pm |
Posted in Masking |
Permalink |
3 Comments »
August 13th, 2008
Dynamic Mask Dialogs
When configuring a Simulink block, you usually use a
graphical user interface (GUI). In this post I’m going to investigate the
basics of programming a dynamic GUI using the mask editor.
The Saturation block features
In my
last post, I introduced the example of a Saturation block that can use
fixed limits set in the mask dialog or dynamic limits set via input signals.
Here is an animation of the mask GUI that configures the block for these
different modes.

When the Upper and Lower Limit Sources are internal, the
block has a single input port. When the Upper/Lower Limit Source is set to
external, the block grows additional ports to accept signals that provide those
limits.
Mask dialogs can associate actions with its components. Most
Simulink block GUIs have a standard row of buttons along the bottom. These four
buttons provide a consistent interface for Simulink blocks, and when you use
the mask editor, you get them free.
- OK – apply changes and dismiss the GUI
- Cancel – abandon changes made in the GUI and do not change the
block
- Help – display documentation for the block
- Apply – apply changes made in the GUI
I added the other elements of the Saturation GUI through the
parameters tab of the mask editor:

Each parameter of the mask has a row in the Dialog
Parameters table. The Prompt (1) is the text displayed next to the
widget that sets the value. The Variable (2) is the name of the
variable set in the mask workspace when the GUI is applied. The Type (3)
controls the widget used for the parameter. You can choose edit, checkbox or
popup. I picked popup for the parameters Upper Limit Source and Lower Limit
Source parameters. I set the popups (4) to display internal or external.
The Upper Limit and Lower Limit parameters use the edit type.
Each of the parameters also has an Evaluate (5) and Tunable
(6) setting. I want uplim and lowlim to have the values that are entered into
the dialog. If a MATLAB expression (like 'sin(x)+1') is used to set the value
of the Upper Limit, I want that to be evaluated. I don’t want the variable to
hold the string that was typed into the edit field. Tunable means the value of
the parameter can change during the simulation. Upper and Lower Limits will be
tunable through the dialog if internal limits are used. The Limit Source
parameters are not tunable because they change the configuration of the block.
It is not possible to reconfigure the model structurally in mid simulation.
Dialog Callbacks
Dialog callbacks (7) are called when the parameter is changed in
the mask. Use dialog callback for error checking and controlling the
visibility and enabled/disabled setting of other parameters in the mask
dialog. In the Saturation mask dialog, the Upper Limit Source and Lower Limit
Source parameters fire a Dialog callback when you click on them. This is the
mechanism for enabling and disabling the Upper Limit and Lower Limit Edit
fields in the GUI.
Key Point: Just like a handle graphics GUI,
the Dialog callbacks run in the MATLAB base workspace. Program the
callback as if you are running it from the MATLAB command line.
Here is the uplimsrc_cb called when the uplimsrc parameter
changes:
% uplimsrc_cb Dialog Callback
function uplimsrc_cb(blk)
en = get_param(blk,'MaskEnables');
switch get_param(blk,'uplimsrc')
case 'external'
en{2} = 'off';
case 'internal'
en{2} = 'on';
otherwise
disp('Should never get here')
end
set_param(blk,'MaskEnables',en)
When you click on the uplimsrc popup and change it, this
callback fires. The callback:
- Gets the MaskEnables, which is a cell array of on/off values, one
for each parameter
- Assigns the second element (corresponding to uplim) to off if
uplimsrc is external, on if uplimsrc is internal
- Sets the MaskEnables to use the updated on/off values
If the block uses an external limit source, the
corresponding fixed limit is disabled.

Mask Dialog Callback Confusion
I have found callbacks that modify the block contents are a
major source of problems.
Key Point: The mask dialog callback is for modifying
the mask dialog, not the system.
The documentation on mask
callbacks also discusses this subject. If you need to modify the contents
of your system, do that in the Mask Initialization, which runs when you click
the Apply or OK button. That will be the topic of my next post.
Now it’s your turn
Do you have dynamic masks? Leave a comment here.
4:45 pm |
Posted in Masking |
Permalink |
7 Comments »
August 5th, 2008
Advanced Masking Concepts
Masking does more than just put a professional interface on
your algorithm. Simulink blocksets provide elaborate graphical user interfaces
(GUIs) to control the behavior of blocks. The block dialog can dynamically
enable and disable its GUI elements. Blocks can sprout additional ports in
order to accept parameters as input signals. The algorithm can rewire itself
based on the setting in the dialog. Did you ever ask yourself, “how can I do
that?”
This is the first in a series of posts that will introduce these
advanced masking concepts. I have created an example that has:
- A block dialog that enables and disables parameters based on user settings
- The option to add and delete ports to match dialog settings
This example builds on top of the basic concepts introduced
in my
recent post on masking. That post covered how to make a mask icon, and
provide a mask dialog to control the parameters used in an algorithm.
Two saturation blocks
The example I have created combines the dynamic saturation
block from a recent
post on libraries and the fixed saturation block in my
recent post on masking. The algorithms for these two blocks differ
slightly. The dynamic saturation block uses inports to provide the limits, and
the fixed saturation uses constant blocks to provide the same signals.

The Fixed Saturation block has a mask that sets the values
of the uplim and lowlim variables in the mask workspace.

A combined saturation block interface
To combine these blocks, I present the user with a simple
interface that allows them to control the source of their upper and lower
saturation limits. The value can be internal or external.

When internal limits are used, the value comes from the
Upper Limit and Lower Limit fields. When using external limits, those fields
are disabled, and inports provide the limit signals.

How does this combined block work?
Here is a test model that exercises some of the different
modes of this saturation block. The three saturation blocks in this model are
actually three instances of the same library block.

The top block uses the fixed limits. The middle block uses
an external source for the upper limit and a fixed value for the lower limit.
The bottom block uses external sources for both the upper and lower limit.

How does the same block behave in these three different
ways? To see how, you can look under the masks of these blocks and see the
blocks involved in the algorithm.

All three instances of the subsystems get their upper limit
from a block named system/up, and their lower limit from a block named system/lo.
In the case where the limits are fixed, the block is a constant block. In the
case where the limit is dynamic (external source), the block is an inport. To
achieve this, the block runs some M-code that replaces the Constant block with
an Inport when the source is external and replaces the Inport with a Constant
block when the source is internal.
In future posts we will examine:
- Mask dialog callbacks
- Mask initialization and self modifiable library blocks
- Best practices for masking
Now it’s your turn
Have you implemented masks using these concepts? Share your
experience here.
5:15 pm |
Posted in Libraries, Masking |
Permalink |
1 Comment »
July 27th, 2008
How To Make Your Own Simulink Block
Today I want to introduce a fundamental Simulink concept: masking
a block. Masking provides you with a way to put an interface on an
algorithm. This can centralize the system parameters for easier viewing, or hide
the complexity from unintentional tampering by other users. Masking can also
be used to dress up your model for more inviting or professional looking
presentations. Let me show you how by masking a subsystem that I made.
The subsystem holds the algorithm
In my example, I am masking a subsystem that contains a
fixed limit saturation algorithm:

I will come back to this in my examples below.
Improved Presentation: The Mask Icon
Simulink models provide an executable specification. The
model allows you to share a picture of the system schematics that can be
understood by everyone on the team, especially your boss or customer. The best
way to do this is to make the components in your diagram really obvious. A
great example of this is the f14_digital demo model. This model uses images for
the icon on three root level subsystems.

You can grab a picture of the stuff you are modeling and put
it on the corresponding subsystems. To do this, use the Edit > Mask
Subsystem... menu when the block is selected. This is also available from the right
click menu on the block. This opens the mask editor and brings up the icon tab
for the block.

For my Saturation subsystem I have used the basic plot
command to put an icon on the block. I set the Units to normalized, which
provide x and y range from zero to one for the canvas.

The allowed drawing commands are a subset of MATLAB graphics.
There are examples at the bottom of the mask editor. The image command can be
combined with IMREAD to load an image from your MATLAB path. For example, the
following drawing command adds a Boeing 747 icon to your block
image(imread('b747.jpg'))

Adding an icon to your system doesn’t change the behavior.
When you double click on the block, you will still open the system it contains.
Mask Dialog and Documentation
A mask can also provide a simplified interface to the blocks
underneath. As a trainer, I used to introduce this concept as a method for
preventing unintended tampering with the contents of your system. The parameters
tab of the Mask Editor is where you set the parameters for the system.

The Prompt is the string you want to display before the box
where the user enters the value. The Variable holds the value entered in the
mask. Adding dialog parameters creates a local workspace for the blocks under
the mask. In my fixed saturation example, the up and lo constant blocks will
now use the variables from the mask as their value, instead of hard coding the
constant in those blocks.

Add some details to the documentation
tab to complete the mask dialog.

Mask type is used to specify a title for the dialog. Mask
description shows up right below that and provides a place for some quick
reference documentation. The Mask help field can be a long description that
will be displayed as HTML when the user pushes the Help button. HTTP links are
also acceptable. For a full list of the Mask help alternatives click
here. Double clicking on the icon of the Saturation block displays the finished
dialog:

As you make edits in the Mask Editor you will notice that
your parameter values in this dialog are set to 0. Before you finish with your
mask, make sure to set the parameter values for your system in the dialog.
How do I get back to the system?
Now that the block has a mask, double clicking on the icon
opens the mask dialog. The way you know you are looking at a mask dialog is
the label following the system name: Saturation (mask). To see the
algorithm beneath the mask, right click on the block and select Look Under
Mask. This will bring you back to the contents of the system.
Now it’s your turn
This is the tip of the masking iceberg. Do you have masked
blocks in your model? What tricks have you used to polish up your model and
make it look professional? Tell me about it here.
11:58 pm |
Posted in Libraries, Masking, Modeling |
Permalink |
2 Comments »
July 22nd, 2008
R2008b: Simulink!
I just downloaded and installed the R2008b prerelease, and
you can too!

Currently licensed users of MathWorks products have access
to download and install the R2008b prerelease here (requires login).

The prerelease gives you two important benefits:
- You get instant access to evaluate all the new features in R2008b.
- Ensure compatibility for your models and workflow.
The prerelease is an important part of the process used by
the MathWorks to ensure smooth upgrades. This is your best chance to
report any issues you run into with R2008b. Tell us now, and there’s a chance
we can address it before the general release this Fall. We’re excited about the
new release. Give it a try and see what you think.
3:15 pm |
Posted in What's new? |
Permalink |
2 Comments »
July 18th, 2008
Libraries in Simulink
Have you ever noticed the same block constructs occurring
repeatedly in your model? Simulink libraries provide you with a way to capture
the template for an algorithm, and then reuse that template all over your
model. For this post, I will to introduce the basic concepts of libraries,
library blocks, and library links.
Creating a library
To create a Simulink library, you have to create a new
Simulink library from the File> New > Library menu, or using the new_system
function.

Libraries are special MDL-files. When you look at a library,
you will notice that it does not have the simulation controls a normal model
has. The library is not a functional model; it is a palette of components.
Here is an example library that contains a block for doing variable saturation
of a signal.

The library can be constructed in the same way a model is
constructed, by dragging blocks into the library canvas and connecting
signals. The Saturation Dynamic block is just a subsystem that contains the
algorithm for dynamic saturation of the signal u:

Locking the library
When a library is first created, it is unlocked.

This allows you to edit and build the components. Once you
save the library and close it, the library is locked.

No changes are allowed without unlocking the library. This
can be done from Edit > Unlock Library. Most people just drag a block a few
pixels to trigger Simulink to prompt you to unlock the library.

Reference blocks and algorithm reuse
Just like the blocks from the Simulink libraries, you can
add the library blocks to any model you are working on. There is some
terminology that goes along with library blocks. When you add the library block
to your model, you are creating a reference
block.

The reference block is an instance of the library block, but
the contents are not stored in the model. A model using the reference block stores
only a library link, which holds the path to the library block.
>> get_param('satModel/Saturation Dynamic','ReferenceBlock')
ans =
SatLib/Saturation Dynamic
Set the Format > Library Link Display to User to see
which blocks in your model are actually library links. This setting adds a
library link icon to the corner of your block.

Adding your library to the browser
At this point, you might be asking how to add the library to
the library browser. The short answer is: >> doc slblocks. I provided
an example of this in the historical
tour of the library browser.
What do you do with libraries?
Do you maintain your own libraries? How many components
does a typical library contain? Do you share your work with other modelers?
Post your library to the file exchange, or leave a comment here.
9:00 pm |
Posted in Libraries |
Permalink |
6 Comments »
July 3rd, 2008
How did I get an algebraic loop error, when the diagnostic was set to warning?
I once faced a problem where Simulink reported, “Cannot solve algebraic loops...”

Algebraic
loops can be solved by Simulink, but often slow down the simulation. For
this reason, we have the algebraic
loop diagnostic that can be set to Error, Warning or None.
What was peculiar about this model was that the algebraic loop diagnostic was
set to Warning, yet the model would report an error, and not simulate! To
makes things more difficult, all I had to work with was a screen shot of the
model, not the model it self.
What are algebraic loops?
Algebraic loops exist when a variable shows up on both sides of the equation. For
example,

Algebraic loops generally occur in Simulink when there are un-modeled delays, for
example, sensors that just feed through a signal from input to output.
Read the error message
The first step in debugging a problem like this is to read and understand the error
message. Algebraic loop errors occur for different reasons. To understand the
cause of the error I had to understand the message.
Cannot solve algebraic loop involving 'model/.../Sensor System' because it consists of blocks that
cannot be assigned algebraic variables, i.e., blocks with discrete-valued
outputs, blocks with non-double or complex outputs, Stateflow blocks, or nonvirtual
subsystems.
Picking apart this message, we learn that Simulink cannot solve algebraic loops unless
it can assign an algebraic variable. The blocks that cannot be assigned
algebraic variables are listed in the error.
- Discrete-valued outputs, like logic blocks [0 or 1]
- Blocks that have non-double outputs
- Blocks that output complex values (3+2i)
- Stateflow blocks
- Nonvirtual subsystems
Figure out how the message relates to the model
Next, I looked at the screen shot and see if I could find those blocks. This is roughly
similar to the screen shot sent to technical support:

The first thing I noticed was that all the signals are of type uint8. Those are
non-double types, so that could be part of the problem. Another thing I
noticed was the heavy lines on the subsystems. That means these are atomic
subsystems. Atomic subsystems are nonvirtual, and those are on the list of
blocks that could cause this problem.
Possible Resolution
Because
these were atomic subsystems, I suggested enabling the Minimize
algebraic loop occurrences optimization.

The
subsystem can be thought of a function of its inputs and states

In some systems, the output signal calculations do not directly rely on the inputs.
If this is true, you can separate the system into two equations.


This option is also available for model
reference blocks through the configuration parameters on the Model
Referencing entry.
How did this happen?
This model was the result of integrating components from many different teams. The
original model contained virtual subsystems, and the new components used to
upgrade the model were atomic subsystems. Switching back to virtual might have
resolved this error also.
The algebraic loop diagnostic did not control this error because this was part of
the check for the minimum solvability requirements for this type of problem.
Now it’s your turn
There is additional information in the technical support solutions on
understanding algebraic loops, and how
does Simulink solve them. Have you encountered this error? How did you work
around it? Leave a comment
here about your experience.
9:30 pm |
Posted in Debugging, Modeling |
Permalink |
4 Comments »
June 25th, 2008
Community Favorite Accelerators
In a recent post,
I kicked off the discussion of Simulink workflow accelerators. The
comments for that post were a great look at ways people work with Simulink.
The discussion reminded me of some tricks I had forgotten about, and I learned
some new ones. Do you know what you can do with the left and right mouse
button when you click together? How about the Q key?
Viewing the model
Han Geerligs shared that his biggest
accelerator is “using mouse and keyboard in conjunction.” The example he gave
was using the Shift + mouse scroll wheel in order to pan horizontally. Use the
mouse scroll wheel alone to pan vertically.

Dan Lluch
was nice enough to point out that “there are quite a few handy Simulink shortcut keys available”
listed in the Doc. He likes the P and Q key, as well as the space bar and F key. If you
use the mouse with your right hand (like me) you can push Q with your left, then
click to drag the diagram view. If you are a left-handed mouse user, the P key
will be more convenient. The developer who designed this feature uses the
mouse with his left hand.

Editing the model
Phil Taylor livened up the discussion by reminding
us of how to “disconnect a block without deleting it or the lines that connect
to it.” Hold shift before you select and drag a block, it will disconnect
rather than dragging the lines with it. This also works for groups of blocks.
Phil
also proposed a workflow for surgically snipping the complicated lines in our
diagram. “Imagine you’ve laid out a complicated connection path that feeds
into lots of blocks (subsystems, scopes, displays, etc.) and you want to insert
a block near the beginning of the path without deleting all the routing you’ve
already laid down.” For single input, single output (SISO) blocks, this is as
easy as just dropping the block on the line where you want to add the block.
This will automatically insert the block into the line. If the block has
multiple inputs and outputs, Phil suggests using SISO blocks to break the line
and then deleting those blocks to get the signals you want.
I have reproduced this workflow with a little animation below.

Devdatt Lad, a developer at the MathWorks,
reminded me that you can “disconnect a block from a line without deleting it by
using both mouse buttons simultaneously to select and drag it.”
Devdatt
also pointed out the right click option to align, distribute and resize blocks.

Now it’s your turn
Are there other accelerators you use that we have not talked about here? How do
you like the animated GIF files in this blog post? Leave a
comment here and add to the conversation.
10:00 am |
Posted in Community, Modeling, Simulink Tips |
Permalink |
1 Comment »
June 19th, 2008
What’s in your model?
This morning I was telling my colleague Rob about the blog
post I was writing on sample time colors. We talked about models that
demonstrated the concept, and he dove into his computer to find an example he
had made a couple years ago. I liked the model, so I asked him if he would
send it to me, but here was a problem. The model was in a directory with about
50 other M-files, MAT-files and MDL files. How would Rob know which files to
send me? Without much thought, Rob was able to identify the two files I would
need to run that model. How did he do it?
Model Dependencies
A Simulink model is rarely just a single file. Simulink
models often depend on the entire MATLAB environment to run. Most models rely
on many more files run correctly. You may need MAT-files, M-files, reference
models, S-functions, and C code to recreate the working environment. I have
suffered through this repeatedly when working with models sent in to technical support.
Many times, the models are missing just a couple files. We discover which file
is missing and request it, only to find out there are additional dependencies.
Most engineers have experienced this on some kind of development project and
then resolve to keep their work more organized.
Model Manifest Tools
My colleague quickly identified his model dependencies using
the model manifest tools in Simulink. In R2007a the model manifest tools were
added. They provide a short cut method for analyzing your model to identify
its dependencies, and then make it simple to package those files into a ZIP
file. Take for example, this Lunar_Mission
model (download) from the 2007
Simulink World Tour.

(Click here for Simulink WebView)
If I wanted to upload this to the File Exchange and share
this with the Simulink Community, how would I do that? The documentation
on model dependencies goes over this process step-by-step. Access the Tools->Model
Dependencies->Generate Manifest… menu to generate the XML manifest file.
The dialog presents you with some options to control the scope of your search
for dependencies. I started by unchecking the items I did not want to include
in the initial Simulink Manifest File (.smf).

When you click Okay, it begins analyzing your model and
produces an HTML report. Here is a snapshot of the output from the
Lunar_Mission model.

(Click
here for the full dependency report, links in the report won’t work)
The final step to allow me to share this is to export the
files in the manifest. I can package these files up in a ZIP file with just a
couple clicks. This is another menu found at Tools->Model
Dependencies->Export Files in Manifest…

Maintaining a manifest for your Simulink project is
extremely helpful. This enhances collaboration between people working on the
same project. A manifest can also be included in a configuration management
system as a way to record all the files needed to run.
Now it’s your turn
Do you collaborate in Simulink? How do you keep your models
organized? Are there any naming conventions that help you? Post a comment here and
tell me about it.
4:18 pm |
Posted in Simulink Tips |
Permalink |
4 Comments »
June 13th, 2008
Announcing SimElectronics!
In early April, our physical modeling team released a new
add-on for Simulink, SimElectronics.
SimElectronics extends Simscape
by adding tools for modeling electronics and electromechanical systems.
What is Simscape?
Simscape is a platform for physical modeling. Instead of
connecting together blocks that define the equations of your system, Simscape
and its add-on tools enable modeling and simulation of multidomain physical
systems, such as those with mechanical, hydraulic, and electrical components.
The connections between physical modeling elements are not signals, the
connections don’t represent data flow. They represent physical connections between things
like bodies and joints, or resistors and transistors.
What’s new with SimElectronics?
SimElectronics adds components for modeling electronics and
electromechanical systems.
- Includes semiconductors, actuators, sensors, and IC elements
- Includes the ability to simulate in PWM or Averaged mode to balance the level of
fidelity vs simulation speed
- Import SPICE net lists containing Transistors, JFET, diode, sources, and passive SPICE
components
I think it helps to look at the web demos to
understand what you might do with SimElectronics. These demos have great SVG
published models that you can explore. Start with this plant
model of a DC motor connected to a worm gear as part of a linear actuator.
This plant model might be your first step in developing a controller for such a
system.
 (click for a WebView of the model)
Next, you might add an H-Bridge, a current controller, and a
speed controller for the linear actuator. Take a look at this plant
model with a controller.

(click for a WebView of the model)
This model would show that you have good controllers, but
notice the controllers consist of transfer function pre-filters and PI
controllers with Simulink integrator blocks. These controllers can now be
modeled using SimElectronics components. The final step in the series would be
a validation model
with the op-amps, resistors and capacitors that would implement the
controller you designed.

(click for a WebView of the model)
This model uses a 10 kHz PWM waveform to achieve a high fidelity simulation. Download a
trial of SimElectronics if you think this type of workflow would be useful
to you.
Video of SimElectronics in action
Steve Miller has made a video demo of Modeling
an Electromechanical System. I recommend watching this to get the
SimElectronics experience.
Now it’s your turn
Are you using the physical modeling tools? Have you tried
SimElectronics? Post a comment
here and tell us about it.
7:23 pm |
Posted in Modeling, What's new? |
Permalink |
3 Comments »
|
Recent Comments