The software described in this document is furnished under a license agreement. The software may be used
or copied only under the terms of the license agreement. No part of this manual may be photocopied or
reproduced in any form without prior written consent from The MathW orks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation
by, for, or through the federal government of the United States. By accepting delivery of the Program
or Documentation, the government hereby agrees that this software or documentation qualifies as
commercial computer software or commercial computer software documentation as such terms are used
or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and
conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern
theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand
Documentation by the federal government (or other entity acquiring for or through the federal government)
and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the
government’s needs or is inconsistent in any respect with federal procurement law, the government agrees
to return the Program and Docu mentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
The MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
September 1999 Online onlyNew for Version 1.0
September 2000 First printingRevised for Version 1.1 (Release 12)
May 2001Online onlyRevised for Version 1.1.1 (Release 12.1)
July 2002Second printingRevised for Version 1.1.2 (Release 13)
June 2004Online onlyRevised for Version 1.2 (Release 14)
October 2004Third printingRevised for Version 2.0 (Release 14SP1) (New title)
March 2005Online onlyRevised for Version 2.0.1 (Release 14SP2)
September 2005 Online onlyRevised for Version 2.0.2 (Release 14SP3)
March 2006Online onlyRevised for Version 2.0.3 (Release 2006a)
September 2006 Online onlyRevised for Version 2.0.4 (Release 2006b)
March 2007Online onlyRevised for Version 2.0.5 (Release 2007a)
September 2007 Online onlyRevised for Version 2.0.5 (Release 2007b)
March 2008Online onlyRevised for Version 2.0.5 (Release 2008a)
October 2008Online onlyRevised for Version 2.0.5 (Release 2008b)
March 2009Online onlyRevised for Version 2.0.5 (Release 2009a)
September 2009 Online onlyRevised for Version 2.0.5 (Release 2009b)
March 2010Online onlyRevised for Version 2.0.5 (Release 2010a)
External Mode Support
Real-Time W orkshop Product Support
Installation
Installing and Confirming Installation
Troubleshooting the Installation
Accessing the Preconfigured Blocks
Using the gaugeslib Command
Using the Simulink Library Browser
Moving and Selecting Blocks
Example: Building a Simple Model
Overview
The Original Simulink Model
Replacing Simulink Blocks with Gauges
Building the Model
Running the Simulation
Saving the Model
Printing the Model
........................................1-8
..................................1-3
.............................1-3
.......................................1-4
.....................1-4
.......................1-5
.......................1-7
........................1-8
................................1-9
............................ 1-10
..................................1-11
................................1-11
................1-3
................1-4
.................1-5
..................1-6
..................1-8
...............1-9
Modifying Properties of Blocks
Accessing the Properties
Example of Modifying Properties
Learning More About Properties
............................ 1-13
..................... 1-13
..................... 1-14
..................... 1-15
v
Using Gauges in a Model
2
Connecting Blocks in a Model......................2-2
Modifying Properties of a Control
Overview
Using Multiple Styles Within One Block
Understanding ID Properties
Displaying Te xt on a Block
Modifying the Displayed Ran ge
Modifying Multiple Tick Marks
Controlling Multiple Graphical Elements
Overview
Simulating a Multiple-Needle Stopwatch
Updating Multiple Portions of a Pie Chart
Saving and Reusing a Customized Control
Saving Customized Controls Automatically
Saving Customized Controls Using the Library Panel
Library Overview
Customizing Numeric Displays
Customizing the Odometer Block
.................................3-11
...................... 3-11
..................... 3-13
On Off Gauges
Library Overview
Customizing On Off Gauges
Percent Indicators
Library Overview
Customizing Percent Indicators
Strip Chart
Using Your Own Microsoft
Adding the ActiveX Control Block to a Model
Notes on Third-Party Controls
Block Parameters for the ActiveX Control Block
Summary of Parameters
Program ID
Connections
Input Property
Initialization Command
Other Events and Handlers
Update Command
In-Block Control
Border
.....................................3-14
.................................3-14
......................... 3-14
.................................3-15
.................................3-15
...................... 3-15
........................................3-18
®
ActiveX Control .........3-19
...........3-19
....................... 3-20
............................ 3-23
......................................3-24
......................................3-24
....................................3-25
............................ 3-25
......................... 3-25
.................................3-26
..................................3-26
..........................................3-27
.....3-23
Placing Controls in a Different Window
4
Placing Controls in a Different Model ...............4-2
Example Overview
Creating a Model Window Containing Gauges
Associating the Main Model with the Gauges
................................4-2
..........4-2
...........4-4
vii
Placing Controls in a Subsystem ....................4-7
Example Overview
Creating a Subsystem Containing Gauges
Associating Top-Level Blocks with the Subsystem
................................4-7
.............4-7
.......4-8
Placing Controls in a Figure Window
Example Overview
Creating Helper M-Files and Building the Model
Saving and Reopening the Model
................................4-10
................ 4-10
........4-10
..................... 4-13
Block Reference
5
Examples
A
Getting Started ....................................A-2
Modifying Properties of Controls
Controlling Multiple Graphical Elements
...................A-2
............A-2
viiiContents
Placing Controls in Different Windows
..............A-2
Index
Getting Started
• “Product Overview” on page 1-2
• “Related Products” on page 1-3
• “Installation” on page 1-4
• “Accessing the Preconfigured Blocks” on page 1-5
• “Moving and Selecting Blocks” on page 1-7
• “Example: B uilding a Simple Model” on page 1-8
• “Modifying Properties of Blocks” on page 1-13
1
1 Getting Started
Product Overview
Gauges Blockset™ software is a collection of blocks that provides graphical
displays for monitoring signals in Simuli nk
can set up realistic-looking icons that are custom-desig ned for your Simulink
model and visually representative of the environment that you are modeling.
Typical applications include displaying signals as one would see in
• Automobile dashboards
• Airplane cockpits
• Control and process plants
• Communication and power systems
• Medical systems
The Gauges Blockset software requires the MATLAB
products. It uses Component Object Model (COM) technology and runs only
on Microsoft
Gauges Blockset software is extensible. A general-purpose block is provided
in which you can place your custom-built controls.
Support for external mode enables you to incorporate gauges into any target
that you can connect to through external mode (such as the xPC Target™
and Real-Time Windows Target™ products; see the documentation for those
products for details).
For more information about external mode, see “Communicating With
Code Executing on a Target System Using Simulink External Mode” in the
Real-Time Workshop
®
documentation.
Related Products
Real-Time Workshop P roduct Support
You can use the Real-Time Workshop software to generate code from models
that include blocks from the Gauges Blockset library.
Gauges are ignored during code generation, except through the use of external
mode (see above). If you want to view the gauges, you can do so through the
Real-Time Workshop external mode.
1-3
1 Getting Started
Installation
In this section...
“Installing and Co nf irming Installation” on page 1-4
“Troubleshooting the Installation” on page 1-4
Installing and Confirming Installation
To build and run the models in this manual, you must first install the
Simulink and Gauges Blockset products. You can find instructions for
installing these products in the installation guide for your platform.
To determine what products are installed on your system, enter
MATLAB Command Window.
ver in the
Troubleshooting the Installation
Normally, the installation process automatically registers the Microsoft
ActiveX®controls associated w ith Gauges Blockset software. However,
in exceptional cases you might see an error message referring to an
component, similar to the following message:
Copying Gauges Blockset f iles
ads.ocx self registering file did not register
If you see such a message, or if the graphical icons do not appear on the blocks
in this blockset, then enter
Window.
gauges_register_ocx in the M ATLAB Command
®
.ocx
1-4
Accessing the Preconfigured Blocks
In this section...
“Using the gaugeslib Command” on page 1-5
“Using the Simulink Library Browser” on page 1-6
Using the gaugeslib Command
1 Enter the gaugeslib command in the MATLAB Command Window. The
following window opens.
Accessing the Preconfigured Blocks
2 Doub
it co
le-click the Global Majic ActiveX Library icon to access the libraries
ntains.
1-5
1 Getting Started
1-6
3 Double-click an icon to access the blocks in the library that the icon
represents. If all the blocks say “ActiveX” and do not look like graphical
displays, then follow the instructions in “Troubleshooting the Installation”
on page 1-4. Each library also includes a question-mark block that prov ides
access to online help for the controls in that library.
Using the Simulink Library Browser
As an alternative to the gaugeslib command, you can u se the Simulink
Library Browser to access the preconfigured blocks. For details, see “Simulink
Library Browser” in the Simulink documentation.
Moving and Selecting Blocks
Thewayyoumoveandselectblocksinthe Gauges Blockset library differs
from how you move and select a block in the Simulink library. Blocks in
the Gauges Blockset library consist of an “active” area containing the actual
Microsoft ActiveX control, and a border surrounding the active area. The
border give s you a way to manipulate the block without affecting the control.
Moving and Selecting Blocks
The table
TaskMouse Action
Add block to model
Move
Select blockClick the block’s border. Or “rubber-band select”
Res
below describes how to manipulate a Gauges Blockset block.
From the Simulink Library Browser, drag the
block by its icon in the right pane.
From the library wind ow (displayin g blocks as
icons), drag the block by its border.
block
ize block
Drag the block’s border. You can do this only if
the border is visible.
the block.
Select the block, and then drag one of the selection
handles (as you would resize a Simulin k block).
1-7
1 Getting Started
Example: Building a Simple Model
In this section...
“Overview” on page 1-8
“The Original Simulink Model” on page 1-8
“Replacing Simulink Blocks with Gauges” on page 1-9
“Building the Model” on page 1-9
“Running the Simulation” on page 1-10
“Saving the Model” on page 1-11
“Printing the Model” on page 1-11
Overview
This section illustrates how to build and use a simple system, first using
Simulink blocks alone, and then using a Gauges Blockset block. By building
the latter model, you can practice finding and using a Gauges Blockset block.
By comparing the two models, you can get a better sense of how graphical
icons might enhance the look, feel, and usability of your own models.
1-8
The Original Simulink Model
Consider a system in which a Sine Wave block feeds into a Gain block, while a
Scope block displays the output from the Gain block. All these blocks are in
the Simulink library.
If you simulate this system and double-click the Scope block, then the Scope
traces the value of its input signal over time.
Example: Building a Simple Model
Replacing Simul
You can replace t
realistic-look
sine wave value
ing display. For example, a Lower Right block can display the
at each instant during the simulation.
ink Blocks with Gauges
he Scope block from the S imulink library with a
Building the Model
To build the model described earlier, follow the steps below. Alternatively,
enter
gauges_simple in the MATLAB Command Window to open a completed
copy of the model.
1 Open the Simulink Library Browser and create a new model window. For
details on how to do this, see “Starting Simulink Software”.
2 From the Angular Gauges library, drag the Lower Right block into the
model.
3 From the Simulink Sources library, drag the Sine Wave block into the
model window.
4 Double-click the Sine Wave block and set the block’s parameters as
indicated below.
1-9
1 Getting Started
5 From the Si
model wind
6 Double-click the Gain block and change the Gain parameter to 4.
7 Draw connection lines from the Sine Wave block to the Gain block, and
mulink Math Operations library, drag the Gain block into the
ow.
from the Gain block to the Lower Right block.
8 From the
Paramet
9 In the Simu lation time section of the Solver pane, set the Stop time
parameter to
model window’s Simulation menu, choose Configuration
ers.
Inf.IntheSolver options section of the Solver pane, use
the Solver menu to select discrete (no continuous states) since this
model does not have any continuous states.
Now y ou can run the model and watch how the sine wave affects the needle
on the Lower Right block.
Running the Simulation
Run the simulation by choosing Start from the model window’s Simulation
menu. While the simulation is running, you can observe results on the Lower
Right block. This figure shows the model afte r the needle of the Lower Right
block is displaced from its default position.
1-10
Example: Building a Simple Model
To stop the si
menu.
Saving the M
Save the mod
you save a m
file autom
in the bloc
Printing
You can pr
window’
print th
Command
print -smodelname -dbitmap filename
print(['-s','modelname'],'-dbitmap','filename')
modelname and filename list the names of the Simulink model and the
Here,
p file, respectively. For example, if the open model is called
bitma
this command saves itinafilecalled
then
mulation, choose Stop from the model window’s Simulation
odel
el by choosing Save from the model window’s File menu. When
odel that contains blocks from the Gauges Blockset library, the
atically reflects the current state of the control that is embedded
k.
the Model
int the structure of the model by choosing Print from the model
s File menu. Or you can capture the same image in a
e file by entering either of the following commands in the MATLAB
Window.
samplepic.bmp.
.bmp file and
sample,
print -ssample -dbitmap s amplepic
er the application creates the bitmap file, you can insert it into an
Aft
lication that can print it.
app
1-11
1 Getting Started
Note Note that the printing functionality in Simulink software does not
print the active areas of Gauges Blockset blocks. Instead, it sho ws only the
outline of those blocks.
1-12
Modifying Properties of Blocks
In this section...
“Accessing the Properties” on page 1-13
“Example of Mod i fying Properties” on page 1-14
“Learning More About Properties” on page 1-15
Accessing the Properties
You can view properties of the controls by using one of these procedures:
• Double-click the active area of the block that contains the control.
• Right-click the active area of the block and select the Control Display
Properties option.
This figure shows the context menu that appears when you right-click the
Lower Right block.
Modifying Properties of Blocks
After you select the Control Display Properties option, the ActiveX
Control Properties dialog box appears. This dialog box enables you to modify
properties of the co n tro l. The next figure shows the dialog box for the Lower
Right block.
1-13
1 Getting Started
If you modify any values in this dialog box, then the block is visually updated
immediately. However, the changes are not permanent until you choose OK
or Apply; if you choose Cancel, then the changes will be undone.
1-14
Example of Modifying Properties
Returning to the model that y ou built in the section “Example: Building
a Simple Model” on page 1-8, you can modify the range of output values
by modifying the properties of the Lower Right block. For example, the
instructions below change the maximum needle value from
1 Open the ActiveX Control Properties dialog box by double-clicking the
active area of the Lower Right block.
2 Display the panel that controls the scaling of values by clicking the Scales
tab.
3 Set the Max parameter to 150.
4 Display the panel that controls tick marks by clicking the Ticks tab.
5 Set the TickCount (Major Ticks) parameter to 3. This prevents the block
from looking too crowded.
100 to 150.
Thefigureshowstheresultingmodel.
Modifying Properties of Blocks
Learning Mo
Gauges Bloc
block might
“Modifyin
common cha
For infor
by double
within th
one ques
signifi
Propert
g Properties of a Control” on page 2-3 discusses how to make some
mation about specific properties, consult the help for the control
-clicking the question-mark b lock that appears in each sublibrary
e Gauges Blockset library. Some sublibraries provide more than
tion-mark block when the blocks contained in that sublibrary are
cantly different from each other. Once in the Help window, use the
ies link to display information about block properties.
re About Properties
kset blocks have many properties. Changing the appearance of a
require changing several properties and can be quite complex.
nges, such as changing the range of values displayed on a block.
1-15
1 Getting Started
1-16
Using Gauges in a Model
• “Connecting Blocks in a Model” on page 2-2
• “Modifying Properties of a Control” on page 2-3
• “Controlling Multiple Graphical Elements” on page 2-18
• “Saving and Reusing a Customized Control” on page 2-30
2
2 Using Gauges in a Model
Connecting Blocks in a Model
Before you connect a Gauges Blockset block with other blocks, you should
know whether it is meant to be an output device (with an input connection), or
a pass-through device (with an input and output connection). Gauges Blockset
blocks cannot serve as input devices (with only an output connection). Gauges
Blockset blocks initially appear with both an inport and an outport, but
unused ports disappear when you start the simulation or update the block
diagram.
To determine whether a Gauges Blockset block is meant to be used as an
output or pass-through device, right-click the block and select the BlockParameters option.
Note If you customized the generic ActiveX Control block to accommodate
your own control, t hen another way to display the custom block’s Block
Parameters dialog box is to double-click the border of the block.
2-2
In the Block Parameters dialog box, the Connections field determines the
type of connection the block currently uses:
•
Input indicates that the block is a sink; that is, it has an inport and
receives a signal. The Input property parameter indicates the block’s
property whose value is changed by the input.
•
Both indicates that the block has an inport and an outport. The values at
both ports are the same. That is, the block becomes a unity function.
•
Neither indicates that the block has neither an inport nor an outport.
To specify a connection different from the block’s default setup, change the
block’s Connection setting and make sure that the Input property field
is filled in with the appropriate property name. See “Block Parameters for
the ActiveX Control Block” on page 3-23 for information about the other fields
and check boxes. You can also use the Help button to find out about other
parameters.
Modifying Properties o f a Control
In this section...
“Overview” on page 2-3
“Using Multiple Sty les Within One Block” on pag e 2-3
“Understanding ID Properties” on page 2-7
“Displaying Text on a Block” on page 2-9
“Modifying the Displayed Range” on page 2-11
“Modifying Multiple Tick Marks” on page 2-13
Overview
You can modify many properties of a preconfigured Gauges Blockset block
using its ActiveX C ontrol Properties dialog box, introduced in “Accessing the
Properties” on page 1-13. This section discusses some of the more complicated
tasks and concepts associated with the modification of prop erties.
Modifying Properties of a Control
For m ore information about individual p roperties of the preconfigured blocks,
see the online help for the corresponding controls. To access such help, open
the library window and double-click the question-mark block. The online
help summarizes the functionality and contains links to information about
properties, events, and me thods.
Using Multiple Styles Within One Block
Some control properties let you use more than one style fo r a given component
or characteristic, in the same block. For example, you might use multiple
styles to create
• Different font chara cteris tics for text in different places
• Multiple colors within a graphical element such as an annular region or a
divided pie chart
• Multiple sets of ticks, each with its own size or labeling characteristics
• Multiple components, such as LEDs or needles, each with its own
characteristics
2-3
2 Using Gauges in a Model
These sections discuss the use of multiple styles in preconfigured Gauges
Blockset blocks:
• “Blocks That Use Multiple Styles by Default” on page 2-4
• “Determining When Multiple Styles Are Allowed” on page 2-4
• “Creating Styles” on page 2-5
• “Applying Styles” on page 2-6
Blocks That Use Multiple Styles by Default
Many Gauges Blockset blocks include multiple styles by default:
• The Vacuum block in the Angular Gauges library uses three text styles:
one for the tick labels, one for the number at the bottom of the gauge, and
one for the text near the center of the gauge.
• The Volume block in the Angular Gauges library uses three adjacent
annular regions, each with a different color.
2-4
• The Thermometer block in the Linear Gauges library uses two styles fo r
ticks: one for numbered ticks every 10 degrees and ano the r for unnumbered
ticks every 2 degrees.
• The Circle Meter block in the LEDs library applies one of three LED styles
to each of 10 LEDs. The three styles differ in their colors.
Determining When Multiple Styles Are Allowed
If a component supports multiple styles, then its property dialog box has
properties that enable you to set the number of styles and refer to the styles
by number. As an example, the figure below shows how a dialog box supports
multiple font styles. The Fonts property indicates the number of font styles,
while the FontID property refers to a given style by number.
Modifying Properties of a Control
To determine whether a component supports multiple styles, look in the
block’s property dialog box for a pair of properties whose names are
• A plural noun describing the component, such as Fonts or Scales
• A word that combines the noun and the letters “ID,” such as FontID or
ScaleID
If the dialog box has no such properties for the component, then you cannot
createmultiplestylesforthatcomponent. For example, in the Background
panel of a block’s dialog box, you can define the color of an outline, but you
cannot create multiple concentric outlines of different colors.
Creating
Styles
After locating the style-identifying pair of properties for the component you
are interested in, follow these steps to create an additional style:
1 Click once on the up arrow next to the value of the first property in the pair
(Fonts in the figure). This value is the number of defined styles. If N
styles are defined, then each is associated with an integer between 0 and
N–1. The corresponding ID property (FontID in the figure) can assume
values between 0 and N–1.
2 Click
3 Configure other properties in the dialog box panel to match the attributes
repeatedly on the up arrow next to the ID property to set it to its
mum v alue. This causes the dialog box panel to reflect the attributes
maxi
at particular style instead of the other defined styles.
of th
that you want that particular style to have. In the figure, the Set Font
button enables you to set font attributes and the Sample bo x displays text
using those attributes. In many cases, all properties in the panel except the
original style-identifying pair are attributes of the style. In a few cases,
2-5
2 Using Gauges in a Model
only part of the panel contains attributes of the style and o thers are global
attributes that apply to all styles.
To view attributes of an existing style, set the ID property to the integer
associated with that style. Then, prope rties on the dialog box panel other than
the style-identifying pair reflect attributes of that style. For example, the
following figures show how the Sample portion of the Fonts panel of a dialog
box displays either a large bold font or a font of medium size and weight,
depending on whether the FontID value is set to
0 or 1.
2-6
Applying Styles
In some cases, creating a style implicitlycausestheblocktoapplyit. For
example, creating an additional style for tick marks automatically creates an
additional set of tick marks on the block. In other cases, creating a style
does not implicitly cause the block to apply it. For example, even after you
create an additional font style, you will not see its effect on the block until you
indicate which text should use that style. This section describes how to apply
styles that the block does not apply immediately after you create them.
Modifying Properties of a Control
To determine where you can apply a style you have created, look for the
corresponding ID property on a panel of the dialog box other than the panel
where you defined the style. For example, the figure below shows part of a
Captions panel containing the FontID property. The fact that the FontID
property is not preceded by a Fonts property indicates that this is a panel
that enables you to apply font styles but not define them.
Once you have located a part of the dialog box where you can apply a style you
previously created, set the ID property to match the ID property of that style.
For example, the figure above shows that the block has exactly one caption,
and that the caption’s font style is the one whose ID is
FontID value in the Captions panel to a different number, then you will
probably notice a change in some text on the block.
1.Ifyouchangethe
Understanding ID Properties
Many blocks have properties whose names end with ID,suchasFontID,
ScaleID,andNeedleID.Suchpropertiesenableyoutousemorethanone
style in the same block, as in the situations listed in “Using Multiple Styles
Within One Block” on page 2-3. This section describes how to interpret ID
property settings. For an example that examines ID property settings among
a block’s default settings, see “Modifying Multiple Tick Marks” on page 2-13.
The value of an ID property refers to a style by number. To determine the
purpose of the ID property, first see w hether the property directly above it is
a plural noun similar to the ID property’s name . (For example, see whether
the property directly above FontID is Fonts.) Then,
• If the property directly above the ID property is a plural noun similar to the
ID property’s name, then this panel of the dialog box defines a set of style s.
The ID property associates a number with each style. Other properties in
the dialog box panel reflect the definition of the style whose number is the
current value of the ID property. By changing the value of the ID property,
you can view the definition of a different style.
2-7
2 Using Gauges in a Model
For example, in the Fonts panel of the Volume block, the FontID property
occurs directly underneath a Fonts property. This panel of the dialog box
defines font styles, and the Sample box displays text using the font style
whose number is the current value of the FontID property.
Caution If you decrease the value of the property named by the plural
noun (for example, the Fonts property), then the style corresponding to the
highest ID value is removed. To replace that style, you have to add a new
style and recreate the settings of the deleted style from the default settings.
• If the property directly above the ID property is not a plural noun similar
to the ID property’s name, then the ID property applies a style that was
previously defined in another panel of the dialog box. Other properties
in the dialog box panel indicate the context in which the style is applied.
By changing the value of the ID property, you can select a different style
to apply.
For example, in the Captions panel of the Volume block, the FontID
property does not occur directly underneath a Fonts property. The purpose
of the FontID property in this case is to reference previously defined
font styles and apply them to captions. (The font styles are defined on
the Fonts panel of the dialog box.)
2-8
Sometimes, multiple styles are combined so seamlessly that it is not obvious
why multiple styles are needed or which parts of the block correspond to
which style definitions. You can often adjust the definition of the style to
make the style usage more apparent. For example, if you change the colors
of different annular regions and then look for the corresponding change in
theblock,thenyoushouldbeabletodetermine how the design is split among
multiple annular regions.
Modifying Properties of a Control
Displaying Text
Many blocks enab
the quantity bei
The table below
of the block, as
panel that def
Type of Text
Title appearing in block’s outline
Numerical
Numerica
needle
Caption
block
Using t
When it is present, the Captions panel of the ActiveX Control Properties
dialog box enables you to place text anywhere on the block. Blocks that
use text captions by default include Mixer Scale, Tank, Thermometer, Amp
Meter, and Volume. This section describes how to add, remove, and change
characteristics of text captions using the Captions panel.
s appearing anywhere on
he Captions Panel to Display Text
ng measured, the units of measurement, or other information.
lists some types of text that are associated with a specific part
well as the part of the ActiveX Control Properties dialog box
ines the text. Some types of text apply only to certain blocks.
labels near tick marks
l labels near pointer or
on a Block
le you to include text on the block. Such text might describe
Part of Dialog Box That Defines
or Enables Text
Title property on Background
panel
Labels area on Ticks panel. On
Strip Chart block, Labels properties
on Track s and XAxispanels.
Digital p
Caption
anel
s panel
Adding Text Captions. To create a new text caption, follow these steps:
1 IncreasethevalueoftheCaptions property by one.
CaptionID to its maximum value. This is the index that corresponds
2 Set
the newest text caption.
to
3 Type the desired text in the Caption edit field.
2-9
2 Using Gauges in a Model
Removing Text Captions. To remove the most recently added text caption
(that is, the one with the largest CaptionID value),decreasethevalueof
the Captions property by one. Note that this removes a ll characteristics of
that text caption.
Changing Fonts and Other Characteristics of Text Captions. To change
the font of an ex isting text caption, you must create a numbered font style
and then apply that style to the caption. Follo w these steps:
1 Open the Fonts panel of the dialog box.
2 Allocate space for a new font style by increasing the value of the Fonts
property by one.
3 Set FontID to its m a xi m um value. This is the index that corresponds to
the newest font style.
4 Use the Set Font button to select font characteristics.
5 Open the Captions panel of the dialog box.
2-10
6 Set CaptionID to the index that corresponds to the text caption whose font
you want to change.
7 Apply the font style to the caption by setting FontID to the font style’s
index.
To change other characteristics of an existing text caption, first set the
CaptionID property on the Captions panel to the value that corresponds
to the text caption you want to change. Then use other properties on the
dialog box panel, except the Captions counter, to configure the text caption
accordingly.
Note For text captions, the color choice on the Captions dialog box panel
overrides the color choice on the Fonts dialog box panel.
Modifying Properties of a Control
Modifying the Displayed Range
Changing the range of values displayed on a block i nvolves adjusting these
properties:
• Scale properties define the extent of the units displayed by the block, the
location of the block’s center, and the block’s start and stop positions.
• Tick-mark properties define tick marks on the block, including start and
stop values, the interval between tick marks, and label positions.
• Needle or pointer properties indicate the value.
To illustrate how to use these properties to adjust the range of values
displayed on a block, this example changes the Generic Linear Gauge to
display values from
shows the tick-mark labels. This figure shows the Generic Linear Gauge with
itsdefaultsettings(left)andwith modified settings (right).
-20 to 20, sets the interval between tick mark s to 5,and
Changing the Scale
Click the Scales tab to display the scales properties page. This figure shows
the d efault scale properties for the Generic Linear G auge.
2-11
2 Using Gauges in a Model
To modify the scale range, change ScaleMax to 20 and ScaleMin to -20.
Displaying Labels Next to Tick Marks
Click the Ticks tab to display the tick-mark properties page. This figure
shows the default tick-mark properties.
2-12
To show tick-mark labels, check the Label On/Off check box.
To set the starting and ending tick m arks so they mark the minimum and
maximum scale settings, set StartV alue to
Change the DeltaValue property, which sets the spacing between tick marks.
Avalueof
5 is reasonable for default block size.
-20 and StopValue to 20.
Setting the Current Pointer Value
Click the Pointers tab to display the pointer properties page. This figure
shows the default pointer properties.
Modifying Properties of a Control
The Value property indicates the current pointer value. Set the initial value
to
0, h alfway between the maximum and minimum scale va lu es. Click OK to
accept the changes and close the dialog box.
Modifying Multiple Tick Marks
This example illustrates the use of multiple tick marks and the use of the
ID property to manage them. Instead of modifying a block, this example
examines the default settings for a particular block.
This figure shows the Amp Meter block. Notice that the tick marks have two
different lengths. These are created by defining two sets of tick marks.
The first set consists of 11 longer tick marks, each positioned at one of the
label values, positioned at increments of 1.0. The second set consists of
five shorter tick marks for each integer change in the scale, positioned at
increments of 0.2.
2-13
2 Using Gauges in a Model
To examine how these tick marks have been created, double-click the Amp
Meter block to display its properties dialog box. Select the Ticks tab.
2-14
The Ticks and TickID properties, in the box labeled 1, are defined as follows:
• The Ticks property specifies how many sets of tick marks are used by the
block. For this block, this property is set to 2.
• The TickID property indicates which set of tick marks is defined by the
other properties on this page. When specifying the characteristics of a set
of tick marks, you set the TickID property, and then define the property
values for that set of tick marks. In the dialog box page above, the settings
for all the properties on the page apply to the first set, identified as TickID
0.
Note When y ou define multiple components, the first instance is iden tif ied
by an ID of 0. In this example, the two sets of tick marks have IDs of
0and1.
Modifying Properties of a Control
The Position/Size properties, in the box labeled 2, are defined as follows:
• The Inner property defines the edge of the tick mark closest to the needle
center and the Outer property defines the edge of the tick mark farthest
from the needle center. To see where the tick marks are lo cated relative
to the needle length, examine the needle length by selecting the Needles
page. T he needle length is
position is
2.00. These tick marks are 0.3 units long.
2.0.TheInner position is 1.70 and the Outer
• The Width property of the tick marks is
0.00, the narrowest width.
The Range properties, in the box labeled 3, are defined as follows:
• StartValue determines at which scale value the first tick mark is
displayed. For these tick marks, the value is
0.
• StopValue determines at which scale value the last tick mark is displayed.
For these tick marks, the value is
10.
• DeltaValue determines the interval between tick marks. For these tick
marks, the value is
1.
The Labels properties On/Off check box, in the box labeled 4, determines
whether the la b e l s are displayed. For the first set of tick marks, the labels
are displayed.
The FontID property, i n the box labeled 5, determines which of multiple
fonts defined for this block is used for the label. In this case, two font sets are
defined. The first (FontID
1) is for the caption, “Amps.”
0)isforthetickmarks,whilethesecond(FontID
2-15
2 Using Gauges in a Model
To examine the second set of tick marks, change the TickID property value
to
1 by clicking the up arrow to the left of the value. The Ticks page looks
like this.
2-16
The Position/Size properties, in the box labeled 2, are defined as follows:
• The Inner position is
marks are
0.10 units long, one-third the length of the longer tick marks.
• The Width property of the tick marks is
1.90 and the Outer position is 2.00.Thesetick
0.00,thesameasthelongertick
marks.
The Range properties, in the box labeled 3, are defined as follows.
• StartValue for these tick marks is
0. The first short tick mark and the
firstlongtickmarkappearinthesameplace.
• StopValue for these tick marks is
10. The last short tick mark and the
last long tick mark appear in the same place.
• DeltaValue determines the interval between tick marks. For these tick
marks, the value is
0.2.
Modifying Properties of a Control
The Labels properties On/Off check box determines whether labels appear
next to the tick marks. No labels appear next to this set of tick marks.
If you decrease the Ticks property, then the tick-mark settings corresponding
to the highest TickID value is removed. To replace that set of tick marks, you
will have to recreate the settings from the defaults.
2-17
2 Using Gauges in a Model
Controlling Multiple Graphical Elements
In this section...
“Overview” on page 2-18
“Simulating a Multiple-Needle Stopwatch” on page 2-18
“Updating Multiple Portion s of a Pie Chart” on page 2-23
Overview
This section describes techniques for displaying multiple input values
simultaneously and dynamically on a gauge block that includes multiple
graphical elements. Examples of multiple-component gauge blocks include
these preconfigured blocks:
• Multiple Scales in the Linear Gauges library
• Pie Chart and Dynamic Pie in the Percent Indicators library
2-18
• Analog Clock and Stop Watch in the Angular Gauges library
Simulating a Multiple-Needle Stopwatch
This example model simulates a typical sailing stopwatch. The model uses the
Stop Watch block, which displays three needles on individual angular scales.
The needles mark simulation time simultaneously, as follows:
• The large needle spans 1 minute.
• The small needle on the left spans 1 second.
• The small needle on the right spans 15 minutes.
To open this example, enter
Window. Run the simulation and watch how the three needles move.
gauges_stopwatch in the MATLAB Command
Controlling Multiple Graphical Elements
These secti
• “How Needle
• “Configur
• “Prepari
ons describe how the model works:
ID Values Correspond to Needles” on page 2-19
ation of the Stop Watch Block” on page 2-21
ng th e Input Signal for the Stop Watch Block” on page 2-22
How NeedleID Values Correspond to Needles
To expla
how the b
has an as
• Needle
• Value i
You ca
Activ
in how the model controls three needles, this section first explains
lock makes its needles accessible to you. Each needle on the block
sociated pair of NeedleID and Value parameters, where
ID is a number that distinguishes that needle from other needles
on the b
lock.
s the numerical value for that needle along its angular scale.
n view or control these parameters via the Needles panel of the block’s
eX Control Properties dialog box.
2-19
2 Using Gauges in a Model
To find out which needle and range of values correspond to a given ID
number, use this procedure:
1 Right-click the Stop Watch block and choose Control Display Properties.
2 Click the Needles tab.
3 Set NeedleID to the ID number you want to investigate: 0, 1,or2 in this
case.
2-20
4 Change the Value parameter while watching which needle on the block
moves. By dragging the Value slider to its extremes, you can also find out
the minimum and maximum values for the needle with that NeedleID
number.
The table below summarizes what the procedure reveals.
NeedleIDNee dle on BlockRange of Values
0
1
2
Large needle[
Small needle on right
Small needle on left[
0, 60] seconds
0, 15]minutes
[
0, 5]fifthsofasecond
For more information about ID properties, see “Understanding ID Properties”
on page 2-7.
Controlling Multiple Graphical Elements
Configuration of the Stop Watch Block
After you run the model, the number 6 appears near the connector line that
represents the input to the Stop Watch block. This indicates that the signal
on that line is a vector of length 6. To understand why, first right-click the
Stop Watch block and choose Block Parameters.
Then notice that the Input property field in the dialog box is set to
By contrast, the default value for this property is NeedleValue,whichyoucan
see by examining the block in the Angular Gauges library.
The comma-separated list in this example model causes the Stop Watch block
to use the six values in its vector input signal to assign these parameters to
the block, in sequence:
• The ID number,
0,ofthelargeneedle
• The numerical value for the large needle
• The ID number,
2, of the small needle on the left
• Thenumericalvalueforthesmallneedleontheleft
• The ID number,
1, of the small needle on the right
• The numerical v alue for the small needle on the right
2-21
2 Using Gauges in a Model
Note It is impo rtan t that each needle’s ID number precede its numerical
value. Referring first to the ID number tells the block which needle to apply
changes to.
Preparing the Input Signal for the Stop Watch Block
The model aims to reflect the time on the Stop Watch block. However, it
is necessary to process the Clock block’s output somewhat to prepare it for
theStopWatchblock. Double-clicktheSubsystemblocktoopenit. The
subsystem accomplishes these key tasks:
• Processing the C lock block’s output value, measured in seconds, to make
itanappropriatenumericalvalueforeachneedle. Todothis,theblock
performs these computations:
- Reduces modulo 60, to get the large needle’s value.
- Reduces modulo 1 and then multiplies by 5, to get the left needle’s value.
Recall that values for the left needle range between 0 and 5.
2-22
- Reduces modulo 15*60 and then divides by 60, to get the right needle’s
value. Recall that values f or the right needle range between 0 and 15.
• Forming a six-element vector corresponding to the comma-separated list in
“Configuration of the Stop Watch Block” on page 2-21. T o form this vector,
the subsystem uses three Constant blocks, the three processed Clock block
signals, and a Mux block.
Controlling Multiple Graphical Elements
Updating Multiple Por tions of a Pie Chart
This example model enables you to control four portions of a pie chart
independently using four sources. The model uses the Dynamic Pie block.
Internally, the model uses an M-file S-function to drive the Dynamic P ie block.
Compared to the technique in “Simulating a Multiple-Needle Stopwatch”
onpage2-18,theS-functiontechniqueismorecomplicatedbutalsomore
flexible and p owerful.
To open this example , enter
Change the values of the Constant blocks to alter the composition of the pie
chart. Note that because Constant is a source block, the simulation will pause
while the block dialog box is open. You must close the dialog by clicking OK,
which will resume the simulation and a llow you to see the result of your
changes.
gauges_pie in the MATLAB Command Window.
2-23
2 Using Gauges in a Model
These sections describe how the model works:
• “How PortionID Values Correspond to Portions of the Pie” on page 2-24
• “Configuration of the Dynamic Pie Block” on page 2-25
• “How the S-Function Updates the Pie” on page 2-27
2-24
• “Initial Portion Sizes in the M odel” on page 2-28
How PortionID Values Correspond to Portions of the Pie
To explain how the model controls four portions, this section first explains
how the block makes its portions accessible to you. Each portion on the block
has an associated pair of PortionID and PortionValue parameters, where
• PortionID is a number that distinguishes that portion from other portions
on the block.
• PortionValue is the numerical value for that portion, as a percentage.
The S-function that assigns the set of PortionValue parameters ensures
that the percentages for all portions add up to 100.
You can view or control these parameters via the Portions panel of the
block’s ActiveX Control Properties dialog box.
Controlling Multiple Graphical Elements
To find out which portion corres ponds to a given ID number, use this
procedure:
1 Right-click the Dynamic Pie block and choose Control Display
Properties.
2 Click the Portions tab.
3 Set PortionID to the ID number you want to investigate: 0, 1, 2,or3
in this case.
4 Change the PortionValue parameter while watching which portion on
the block changes in size.
The table below summarizes what the procedure reveals.
PortionIDPortion on Block
0
1
2
3
Red portion
Yellow portion
Magenta portion
Green portion
For more information about ID properties, see “Understanding ID Properties”
on page 2-7.
Configuration of the Dynamic Pie Block
In the model, a vector containing the four constant values is the input to the
Dynamic Pie block. While the simulation is running, an S-function called
the constant values. While the behavior of the S-function is discussed below
(“How the S-Function Updates the Pie” on page 2-27), this section describes
how the Dynamic Pie block is linked with the S-function.
The Dynamic Pie block in this model is a customized copy of the original
one in the Percent Indicators library. The customized copy differs from the
original in these ways:
• The Input property field in the Block Parameters dialog box is blank.
This is because the block is being updated by an S-function that ignores
the data in the Input property field. To see the Input property field,
right-click the block and choose Block Parameters.
2-26
• The block is driven by a customized S-function, ax_pie_sfun.m,rather
than the S-function that drives the original library block. To see this, select
the outer border of the block and choose Edit -> Look under mask from
the model window’s menu.
Controlling Multiple Graphical Elements
The S-function ax_pie_sfun.m is a customized version of ax_strip_sfun.m,
which is an S-function designed to drive the Strip Chart block. Many parts of
ax_pie_sfun.m arealsosimilartosfuntmpl.m, which is an M-file S-function
template. Many features of that S-function template a re not required for
controlling Gauges Blockset blocks, which simplifies the task of writing
S-functions for use with the blockset. For more information about S-functions
in general, see the Writing S-Functions documentation.
If you were building this model yourself starting from the original library
block, then you would have to break the library link before changing the
values in the S-Function dialog box shown previously. To break the libr ary
link for a library b lock, use this procedure:
1 Select the outer border of the block.
2 Choose Edit -> Link options -> Disable link.
3 Choose Edit -> Link options -> Break link.
How the S-Function Updates the Pie
While the simulation is running, the S-function ax _pie _sfun.m drives the
Dynamic Pie block. In particular, this S-function
• Receives the vector that is the input signal to the Dynamic Pie block
• Normalizes the vector so that the values add up to 100
2-27
2 Using Gauges in a Model
• Updates each portion of the pie to reflect the corresponding number from
the vector
Receiving the Vector Input Signal. During the simulation, the Simulink
engine invokes the S-function and passes it the Dynamic Pie block’s input
vector. Within the S-function, the vector is called
u. The engine also passes
to the S-function a handle of the Dynamic Pie control. The handle is called
hActx.
Normalizing the Input Vector. The S-function uses the code below to
normalize the vector
% First make sure there is no division by zero.
if sum(u)==0
u=u+0.001;
end
% Now perform the normalization.
u = 100/sum(u).*u;
u so that its elements add up to 100:
2-28
Updating the Dynamic Pie Block. After sum(u) is 100, the S-function
updates the portions of the Dynamic Pie block by setting each one to the
corresponding element of
u. The code uses the handle hActx to access the
PortionID and PortionValue parameters of the Dynamic Pie block.
% Loop through the portions and update their values.
%
if (length(u) ~= 0)
for n=1:length(u)
hActx.PortionID = n-1;
hActx.PortionValue = u(n);
end
end
Initial Portion Sizes in the Model
When y ou first open the gauges_pie model, the portions of the pie have equal
sizes, unlike the portions in the default instance of the Dynamic Pie block
in the Percent Indicators library. The equal-sized portions result from the
configuration from which the model was saved.
Controlling Multiple Graphical Elements
If you were building this model yourself starting from the original library
blocks, then you would first run the model to make the portion sizes reflect
the values on the Constant blocks, and then save the model to record the
blocks’ configurations.
2-29
2 Using Gauges in a Model
SavingandReusingaCustomizedControl
In this section...
“Saving C ustomized Controls Automatically” on page 2-30
“Saving Custom ized Controls Using the Library Panel” on page 2-30
Saving Customized Controls Automatically
Saving the model also saves all property settings for Gauges Blockset blocks
in the model file. To share your customized controls with other users, give
them the model file. To use your customized block in a new model, copy the
block from the old model and paste it into the new model.
Saving Customized Controls Using the Library Panel
Alternatively, you can use the ActiveX Control Properties dialog box to save
property settings for later use on your own machine. However, this method
does not enable you to share these customized controls with users of other
machines. The steps are
2-30
1 Select the Library tab of the ActiveX Control Properties dialog box.
2 Assign a name to the collection of modified settings by entering a new name
in the Configuration Name field.
Note If you leave this field blank, the new property settings write over the
previous setting s, which m eans that yo u cannot access the original version
except by reinstalling the blockset or by registering the controls again. To
learn how to register the controls, see “Troubleshooting the Installation”
on page 1-4.
Saving and Reusing a Customized Control
3 To provide te xtu al information abou t the block, click Notes. This dialog
box appears.
4 Enter a description in the text area and click OK.
5 Select th
library h
the folde
6 Click OK to accept all the changes and close the dialog box.
e folder in which to store the modified control by expanding the
ierarchy at the left. The new set of property settings is stored in
r you select. Click Store.
The next f igure shows the dialog box with fields filled in. The customized
control is stored in the Linear Gauge folder.
2-31
2 Using Gauges in a Model
2-32
An alternative to this procedure is to export customized controls to .gms files.
To do this, select a folder from the left side of the panel and click Export.
You can later access these controls by using the Import button, or share
the controls by sharing the
.gms files.
Categories of Controls
• “Angular Gauges” on page 3-2
• “LEDs” on page 3-5
• “Linear Gauges” on page 3-7
• “Numeric Displays” on page 3-11
• “On Off Gauges” on page 3-14
• “Percent Indicators” on page 3-15
• “Strip Chart” on page 3-18
®
• “Using Your Own Microsoft
ActiveX Control” on page 3-19
3
• “Block Parameters for the ActiveX Control Blo ck” on page 3-23
3 Categories of Controls
Angular Gauges
In this section...
“Library Overview” on page 3-2
“Customizing Angular Gauges” on page 3-2
Library Over view
The Angular Gauges library contains controls that show their input value
graphically along an arc of a circle. B locks in the library differ from each
other in their numerical ranges and in their use of needles, numerical labels,
text captions, annular components, and tick marks.
Customizing Angular Gauges
This section describes how to customize angular gauges by making changes
that are specific to the Angular Gauges library. For changes that apply to
multiple categories of blocks, see these sections:
3-2
• “Using Multiple Styles Within One Block” on page 2-3
• “Displayin g Text on a Block” on page 2-9
• “Modifying the Displayed Range” on page 2-11
• “Modifying Multiple Tick Marks” on page 2-13
ThetablebelowlistssomecommoncustomizationsinvolvingtheActiveX
Control Properties dialog b ox that arespecifictoblocksintheAngular
Gauges library.
TaskDescriptio n
Angular Gauges
Change the shape or
size of a needle
Label a needle
by displaying the
corresponding number
Change the appearance
of a needle label
Move a needle label
Draw an annular region
along the scale
On the Needles panel, set NeedleID to the ID
of the nee dle you want to change (
0 if there is
exactly one needle). Then use the Style property
to choose the shape, and the Length and Width
properties to determine the length and thickness.
On the Digital panel, set NeedleID to the ID
of the needle you want to label and check the
Enabled check box.
On the Digital panel, first set NeedleID to the
ID of the n eedle whose label you want to change.
Then use Decimals to set the number of digits
after the decimal point, Color to set the color of
the number, and FontID to refer to a previously
defined font (on the Fonts panel).
On the Digital panel, first set NeedleID to the
ID of the n eedle whose label you want to change.
Then use XPositionand Y Position to set the
fixed position for the label.
On the Annulars panel, increase the value of the
Annulars property. The ID of the new region
is the Annulars property value minus one. To
specify properties of the new region, see the next
task.
Change the appearance
of an annular region
Delete the most
recently added annular
region
On the Annulars panel, first set AnnularID to
the ID of the annular region you want to change.
Use the Radius properties to control the annular
region’s thickness and radial position. Use the
Value properties to control the portion of the
scale’s range that the annular region includes.
Use Color to control the annular region’s color.
On the Annulars panel, decrease the Annulars
property. This deletes all properties associated
with the region, such as its color and thickness.
3-3
3 Categories of Controls
Combining Multiple Needles in One Display
To display multiple needles on a single block, see the table below. To learn
how to control multiple needles simultaneously, see “Controlling Multiple
Graphical Elements” on pa ge 2-18.
TaskDescriptio n
Add another ne edle to
the display
Delete the most
recently added needle
from the display
On the Needles panel, increase the Needles
property. The ID of the new region is the Needles
property value minus one. To specify properties
of the new needle, set NeedleID to that ID and
then set the remaining properties on the dialog
box panel accordingly.
On the Needles panel, decrease the Needles
property. This deletes all properties associated
with the needle, such as its color and shape.
3-4
LEDs
LEDs
In this section...
“Library Overview” on page 3-5
“Customizing LEDs” o n page 3-5
Library Over view
The LEDs library contains controls that use graphical elements to imitate
light-emitting diodes (LEDs). Each block reflects its input value by setting
one or more graphical elements to an on or off state. By default, the number
of LED s in the on state is the rounded value of the block’s input.
Most blocks in this library contain a single LED. These blocks differ from each
other in the appearance of their LEDs. The Vertical Meter, Horizontal Meter,
and Circle Meter blocks contain multiple LEDs per block.
Customizing LEDs
The table belo w lists some common ways to customize a block in the LEDs
library, using its ActiveX Control Properties dialog box.
TaskDescriptio n
Add or remove LEDsChange the NumLEDs property on the
LEDs/General panel.
Change the shape or
color of a particular
LED
On the LEDs/General panel, se t LEDIndex to
the number corresponding to the LED you want
to customize. To apply a previously defined style,
set the LEDStyleID to the number corresponding
to the style. To define a new style for this LED,
increase the StyleID property on the Styles
panel and then configure the color, picture, or
shape properties accordingly.
3-5
3 Categories of Controls
TaskDescriptio n
Change the size or
layout of a set of LEDs
Display a binary
representation of the
(rounded) input
Display decaying
maximum value of
the input, in addition to
the current input
On the LED s/General panel, use LEDWidth
and LEDHeight to control the size of each LED.
Use LEDSeparation to control the spacing
between successive LEDs. Use Orientation
and/or Direction to control how multiple LED s
are arranged along a line.
Set the Mode property on the LEDs/General
panel to
the least significant bit.
Check the M axDecay check box on theLEDs/General panel. The DecayRate value
controls how quickly the displayed value decays
from the maximum to the current input value.
Larger positive values correspond to a slower
decay. A value of zero causes the block to reflect
its m aximum value with no decay.
Bitwise. The first LED corresponds to
3-6
Linear Gauges
In this section...
“Library Overview” on page 3-7
“Customizing Linear Gauges” on page 3-7
Library Over view
The Linear Gauges library contains controls that show their input values
graphically along a linear scale. Blocks in the library differ from each other
in their numerical ranges and in their use of pointers, numerical labels, text
captions, and tick marks.
The blocks in this library fall into two categories, as listed below:
Linear Gauges
Pointer L
Generic L
Min-Max Thermometer
Mixer
Mixer S
Multi
Blocks in the two categories have slightly different interfaces, capabilities,
and appearances. Pointer linear gauges use one or more pointers to indicate
values. Bar gauges use a level indicator or a two-color bar to reflect a single
value or level.
inear Gauges
inear Gauge
cale
ple Scales
Bar Gauge
Generic B
Reverse
Scaled
Tank
Thermometer
s
ar Gauges
Sliding Scale
Bar Gauge
Customizing Linear Gauges
This section describes how to customize linear gauges by making changes that
are specific to the Linear Gauges library. For changes that apply to multiple
categories of blocks, see these sections:
• “Using Multiple Styles Within One Block” on page 2-3
• “Displayin g Text on a Block” on page 2-9
3-7
3 Categories of Controls
• “Modifying the Displayed Range” on page 2-11
• “Modifying Multiple Tick Marks” on page 2-13
Customizing Pointer Linear Gauges
ThetablebelowlistssomecommoncustomizationsinvolvingtheActiveX
Control Properties dialog box that arespecifictopointerlineargaugesin
the Linear Gauges library.
TaskDescriptio n
Change the shape or
size of a pointer
Label a pointer
by displaying the
corresponding number
Change the appearance
of a pointer label
Move a pointer label to
a fixed position
Move a pointer label to
a position relative to
the pointer
On the Pointers panel, set PointerID to the
ID of the pointer y ou want to change (
is exactly one pointer). Then use the Style
property to choose the shape, the Inner and
Outer properties to determine the length, and
the Width property to determine the thickness.
On the Digital panel, set PointerID to the ID
of the pointer you want to label and check the
PointerDigital check box.
On the Digital panel, first set PointerID to the
ID of the pointer whose label you want to change.
Then use Decimals to set the number of digits
after the decimal point, PointerDigitalColor to
set the color of the number, and FontID to refer
to a previously defined font (on the Fonts panel).
On the Digital panel, first set PointerID to the
ID of the pointer whose label you want to change.
Clear the PointerDigitalAttach check box and
use PointerDigitalX and PointerDigitalY to
set the fixed position for the label.
On the Digital panel, first set PointerID to the
ID of the pointer whose label you want to change.
Check the PointerDigitalAttach check box. For
a vertical linear scale, use PointerDigitalX to
set the independent coordinate for the label. For
a horizontal linear scale, use PointerDigitalY to
set the independent coordinate for the label.
0 if there
3-8
Linear Gauges
Customizing Bar Gauges
ThetablebelowlistssomecommoncustomizationsinvolvingtheActiveX
Control Properties dialog box that arespecifictobargaugesintheLinear
Gauges library.
TaskDescriptio n
Change the range of
values along the bar
Change the orientation
or direction of the bar
Change the size or
position of the bar
Change the colors of
the portions of the bar
on either side of the
indicated level
Change the shape
or size of the level
indicator
On the General panel, use the Min Value and
Max Value properties to define the range.
On the General panel, use Orientation to
determine whether the bar is horizontal or
vertical. Use Direction to determine which end
of the bar corresponds to the minimum value.
On the Bar panel, use the BarInner and
BarOuter properties to define the width and
position of the bar in the direction perpendicular
to the linear scale. Use the BarStart and
BarStop properties to define the length and
position of the bar in the direction of the linear
scale. These properties do not affect the numerical
values associated with the bar, only the graphical
depiction of the bar.
On the Bar panel, use the OnColor and OffColor
properties to define the colors associated with
values below and above, respectively, the
indicated level along the bar.
On the Knob panel, use the Style property
to choose the shape. Use the Inner Value
and Outer Value properties to determine
the thickness and position in the dimension
perpendicular to the linear scale. Use the Width
property to determine the width along the linear
scale.
Label the indicated
level using a number
On the Digital panel, check the Enabled check
box.
3-9
3 Categories of Controls
TaskDescriptio n
Change the appearance
of the label
Move the label to a
fixed position
Move the label to a
position relative to the
level indicator
On the Digital panel, check the Enabled check
box. Then use Decimals to set the number of
digits after the decimal point, Color to set the
color of the number, and FontID to refer to a
previously defined font (on the Fonts panel).
On the Digital panel, clear the Attach check
box. Then use X Position and YPositionto set
the fixed position for the label.
On the Digital panel, check the Attach check
box. For a vertical (respectively, horizontal) linear
scale, use XPosition(respectively, YPosition)
to set the inde pe nd en t coordinateforthelabel.
Combining Multiple Pointers in One Display
To disp la y multiple po int ers on a pointerlineargauge,seethecustomizations
in the table below. To learn how to control multiple pointers simultaneously,
see“ControllingMultipleGraphicalElements”onpage2-18.
TaskDescriptio n
Add another pointer to
the display
On the Pointers panel, increase the Pointers
property. The ID of the new region is the
Pointers property value minus one. To specify
properties of the new pointer, set PointerID to
that ID and then set the remaining properties on
the dialog box panel accordingly.
3-10
Delete the most
recently added pointer
from the display
On the Pointers panel, decrease the Pointers
property. This deletes all properties associated
with the pointer, such as its color and shape.
Numeric Displays
In this section...
“Library Overview” on page 3-11
“Customizing Numeric Displays” on page 3-11
“Customizing the Odometer Block” on page 3-13
Library Over view
The Numeric Displays library contains controls that display the n u merical
values of their i nput signals. The Odometer block differs from the other blocks
in this library in its appearance and dialog box. The topics in this section are
Customizing Numeric Displays
The table below lists some common ways to customize any block in the
Numeric Displays library, except the Odometer block, using the General
panel of its ActiveX Control Properties dialog box.
Numeric Displays
TaskDescriptio n
Change the number of
digits in the display
Specify the number of
digits after the decimal
point
Pad the display with
leading zeros
play a plus or m inus
Dis
gn
si
Set Digits to the total number of digits.
Set Decimals to the number of digits you
want after the decimal point, and check the
FixedDecimal check box.
Check the LeadingZeros check box.
Check the LeadingPlusMinus check box.
3-11
3 Categories of Controls
TaskDescriptio n
Change the appearance
of all digits
Avoid u sing
nonnumeric characters
such as a colon in the
display, making the
block ea sier to use with
Simulink signals
Use the ItalicsOffset property to control the
slanting angle of digits. Use the Segment Width
and Segment Separation properties to control
the width of the line segments that compose each
digit and the spacing between the line segments,
respectively. Use the two Spacing properties to
control the padding around each digit.
First set DisplayMode to
open the block’s Block Parameters dialog box by
double-clicking the block’s border, and set Inputproperty to
Value.
0 - Numeric.Then
3-12
Numeric Displays
Customizing the
Thetablebelowl
using the Genera
TaskDescriptio n
Change the number of
digits in the display
Make the dis
change gra
from old to
values, in
register
instanta
ing the change
neously
ists some common ways to customize the Odometer block,
play
dually
new
stead of
Odometer Block
l panel of its ActiveX Contro l Properties dialog box.
Set Digits to the total number of digits. Set
Decimals to the number of digits after the
decimal point. The block does not display a
decimal point character, but digits that represent
proper fractions appear with inverted colors.
Check the Transition Enabled check box. Set
the Steps value to the number of steps in the
gradual transition. Use the Rate valuetocontrol
thespeedofthetransition,wherelargervalues
indicate a slower transition.
3-13
3 Categories of Controls
On Off Gauges
In this section...
“Library Overview” on page 3-14
“Customizing On Off Gauges” on page 3-14
Library Over view
The On Off Gauges library contains gauges that can display two states, on
and off. A block input of
1 corresponds to an “on” state. The blocks in this library differ in cosmetic
ways, such as the images show n on the block.
0 corresponds to an “off” state and a block input of
Customizing On Off Gauges
The table below lists some common ways to custom ize a block in the On Off
Gauges library, using its ActiveX Control Properties dialog box.
3-14
TaskDescriptio n
Associate an image
with a state
Associate text with a
state
Associate a sound with
a state
Use beveling to make
the button appear
three-dimensional
Use the Picture button on the On or Off panel to
select a graphics file. You cannot associate both
an image and text with a state.
Use the Caption field on the On or Off panel.
The X and Y values control the position of the
text. The BackColor and ForeColor buttons
control the colors of the background and text,
respectively. You cannot associate both an image
and text with a state.
On the On or Off panel, check the Sound check
box and type the name of a
file field. You can either type the name of the
sound file or browse for it using the ... button.
Use the BevelInner and BevelOuter properties
on the Background panel.
.wav file in the Wave
Percent Indicators
In this section...
“Library Overview” on page 3-15
“Customizing Percent Indicators” on page 3-15
Library Over view
The Percent Indicators library contains controls that are designed to display
percentages and ratios. The Generic Percent and Simple Light Blue blocks are
probably the most useful blocks in this library. By default, these blocks reflect
scalar input values between 0 and 100 by coloring a corresponding segment of
a linear scale. By customizing the blocks, you can also h a ve them display an
input value X between m and M as the percentage 100 * ((X - m) / (M - m)).
Customizing Percent Indicators
The table below lists som e common ways to customize a block in the Percent
Indicators library, using its ActiveX Control Properties dialog box.
Percent Indicators
TaskDescriptio n
Use a radial percentage
scale that reflects the
input as a sector of a
circle
Change the direction
in which a radial
percentage scale
increases
Use a linear percentage
scale that reflects the
input as a portion of a
rectangle
On the Misc.panel,setDisplayMode to
Use the StartAngle valuetoindicatewhere
the sector begins; a value of 0 corresponds to a
vertical radius above the circle’s center, while a
value of 90 corresponds to a h orizontal radius to
the right of the circle’s center.
On the Misc.panel,usetheDirection property
to reverse the scale’s polarity. If Direction is set
to
Forward, then the scale increases clockwise.
On the Misc. panel, set DisplayMode to
Radial.
Linear.
3-15
3 Categories of Controls
TaskDescriptio n
Change the direction
in which a linear
percentage scale
increases
Specify the range to use
when converting the
input to a percentage
Display a number
near or inside the
corresponding colored
area
Display a number in a
fixed position
On the Misc. panel, use the Orientation
property to indicate whether the linear scale
is horizontal or vertical. Use the Direction
property to reverse the scale’s polarity. If
Direction is set to
scale increases to the right and a vertical scale
increases downward.
On the Misc. panel, use the Min and
Max properties. If the input value is X,
then the block displays the percentage
100 * ((X - Min)/(Max - Min)).
On the Portions panel, set DigitalStyle to
Floating.YoucanusetheDigitalPosition
value to vary the position along one dimension
(radius in the case of a radial scale, height in
the case of a horizontal scale, and horizontal
coordinate in the case of a vertical scale).
On the Portions panel, set DigitalStyle to
Fixed. Tospecifythepositionofthenumber,
first set PortionID to the ID of the portion
you want to co nfig u re (
only the scalar input signal) and then use the
PortionDigitalX and PortionDigitalY values
to indicate the position.
Forward, then a horizontal
0 if you are displaying
3-16
Percent Indicators
Combining Multiple Regions in One Display
To display multiple regions on a singleblock,seethecustomizationsinthe
table below. To learn how to control multiple regions simultaneously, see
“Controlling Multiple Graphical Elements” on page 2-18.
TaskDescriptio n
Add another region to
the display
Delete the most
recently added region
from the display
On the Portions panel, increase the Portions
property. The ID of the new region is the
Portions property value minus one. To specify
properties of the new region, set PortionID to
that ID and then set the remaining properties
on the dialog box panel accordingly. Note that
the DigitalStyle and DigitalFormat properties
apply to all regions on the block.
On the Portions panel, decrease the Portions
property. This deletes all properties associated
with the region, such as its color.
3-17
3 Categories of Controls
Strip Chart
The interface to the Strip Chart block is different from the interface to the
other preconfigured blocks in the Gauge s Blockset library. You can configure
the Strip Chart block using properties in its dialog box, just as you would for
other preconfigured blocks. However, to plot data on the chart, you must
invoke methods for the block. You can use the MATLAB command
call methods and pass arguments to them.
An M-file S-function provided with Gauges Blockset software plots data on
the Strip Chart block by using the
S-function illustrates how to communicate with any Microsoft ActiveX control
through an M -file S-function.
invoke method. More generally, this
invoke to
Thefileiscalled
command to view the contents of the file.
edit ax_strip_sfun
During initialization, the Simulink block attributes (sample time, input
width, etc.) are configured and the Strip Chart configuration is set. The
infrastructure of Gauges Blockset software provides the handle of the control
(
hActX) and is available in this S-function.
Youcanusethishandletosettheproperties of the Strip Chart through
the standard dot notation. For example, the following line sets the
property of the Strip Chart to zero.
hActx.LastX = 0;
Any property of the Strip Chart can be set in this fashion.
In the outputs section of the S-function, each track of the Strip Chart is
initialized to zero on the time axes and the actual plotting of the data is
performed. A loop in this section accounts for input signals that are vectors
instead of scalars.
Note that S-functions offer more options than those shown in this example.
See t he Writing S-Functions documentation for m ore details on writing your
own S-functions.
ax_strip_sfun.m and you can use the following MATLAB
LastX
3-18
Using Your Own Microsoft®ActiveX®Control
Using Your Own Microsoft ActiveX Control
In this section...
“Adding the ActiveX Control Block to a Model” on page 3-19
“Notes on Third-Party Controls” on page 3-20
See als o “Block Param eters for the ActiveX Control Block” on page 3-23.
Adding the ActiveX Control Block to a Model
To use your own control in a Simulink model,youmustassociateitwiththe
generic ActiveX Control block. To configure the ActiveX Control block to
display your control, you need to know some of the programming features of
the control:
• The name under which the control is registered on your system
• The events that cause the control to perform an action
• The control properties that are affected by events, by signals passed to the
block, or by initia lization commands
To use an ActiveX Control block in a Simulink model:
1 Drag the ActiveX Control b lock from the top level of the Gauges Blockset
library to your m odel. Place the block where you want the control to appear.
2 Double-click the block to display its Block Parameters dialog box. Specify
the a ppropriate values, described in subsequent sections.
3-19
3 Categories of Controls
3-20
Note Doub
the bloc
lists pr
you crea
Block P
Notes o
ection contains additional notes about third-party controls. One note
This s
ut editing controls that ignore mouse events, while another concerns
is abo
lors of controls.
the co
le-clicking the border of a preconfigured block (supplied w ith
kset) displays its ActiveX Control Properties dialog box, which
operties in multiple tabbed panels. Double-clicking a block that
ted b y customizing the generic ActiveX Control block displays its
arameters dialog box.
n Third-Party Controls
EditingControlsThatIgnoreMouseEvents
ain controls do not handle typical mouse events (double-click, right-click,
Cert
.). It appears that you cannot edit these controls when you use them with
etc
ActiveX Control block; double-clicking or right-clicking blocks that use
the
se controls has no effect. To edit this type of block, you must first select the
the
Using Your Own Microsoft®ActiveX®Control
block so that it is current in the Simulink model. Then enter the following
commands in the MATLAB Command Window:
This opens the properties dialog box for that control. See the COM sections in
the MATLAB documentation for more information on the
propedit command
and assigning event callbacks to controls.
Additionally, you can choose an event on your control through which you want
to open the property editor. For example, write an M-file function to open the
property editor (or whatever you want the event to do). The function must
take multiple arguments, of which the first one is the handle of the control.
For example, a simple function to open the property editor of a control looks
like this:
function axeventhandler(varargin)
propedit(varargin{1})
Next enter an event with the handler you just wrote in the Other Events
and Handlers parameter field. Assuming the
keypress event is valid, the
event and handler entry looks like this:
{'keypress','axeventhandler'}
To use the error-checking code already written for Gauges Blockset software,
you can enter
ax_block_dclk for events that should open the property editor
(note that the editor does not open when the simulation is running). For
example, to make a keystroke open the property editor (assuming that the
keypress event is valid), enter the event and handler pair as follows:
{'keypress','ax_block_dclk'}
Colors of Controls
Controls that try to determine their colors by inheriting from the window
in which they reside do not work properly in Simulink. More specifically,
controls that send the
WM_CTLCOLOR message to their parent have this
3-21
3 Categories of Controls
problem. WM_CTLCOLOR is a Microsoft Windows message sent by a control to
enable the parent conta iner to determine the color used by the control.
Caution Placing one of these controls in the ActiveX Control block causes
MATLAB software to crash.
3-22
Block Parameters for the ActiveX Control Block
Block Parameters for the ActiveX Control Block
In this section...
“Summary of Parameters” on page 3-23
“Program ID” on page 3-24
“Connections” on page 3-24
“Input Property” on page 3-25
“Initialization Command” on page 3-25
“Other Events and Handlers” on page 3-25
“Update Command” on page 3-26
“In-Block Control” on page 3-26
“Border” on page 3-27
Summary of Parameters
Name
Program ID
ConnectionsWhether the ActiveX Control block
Input property
Initialization comm and
Other events and handlers
Update command
Description
Name of the control
has ports
Name of the property that is set
when the ActiveX Control block
receives a signal
Command that sets the initial
conditions for the ActiveX Control
block
Events that trigger a n action by the
ActiveX Control block
Function that the Simulink engine
invokes when it updates the block
during the simulation
3-23
3 Categories of Controls
Name
In-block control
BorderWhether a border appears around
Description
Whether the ActiveX Control block
displays a control or is connected to
an ActiveX Control block somewhere
else
the control
Program ID
The Program ID parameter is the name of the control displayed on the block.
To determine the Program ID of other c ontrols, consult their documentation.
Connections
The Connections parameter determines whether the block has an inport
only, both an inport and an outport, or no ports. If the block has both an
inport and an outport, then the values at both ports are the same.
3-24
Block Parameters for the ActiveX Control Block
Input Property
The Input property parameter indicates the name of the block property
whose v alue is set by the input signal. Each preconfigured Gauges Blockset
block stores the block’s current value in a property, as listed in the table below.
Names of Input Properties
LibraryProperty Name
Angular Gauges
LEDs
Linear Gauges
NeedleValue
Value
•
BandStop (Min-Max
Thermometer)
•
PointerValue (other pointer
linear gauges)
•
Value (bar gauges)
Numeric Displays
•
Value (Generic Numeric LED,
Odometer, PlusMinus XX.XXX)
•
AlphaNumeric (others)
On Off G auges
Percent Indicators
Value
PortionValue
Initialization Command
The Initialization command parameter is a string that sets the initial
conditions of the ActiveX Control b lock.
Thehandleofthecontrolis
hActX.
Other Events and Handlers
The Other events and handlers parameter specifies actions taken by the
ActiveX Control block when you perform a defined action on the ActiveX
Control block. You must enter an event as an nx2 cell array. The first entry in
3-25
3 Categories of Controls
each row must be the name of the event. The second entry in each row must
be the MATLAB callback to be executed.
For a list and description of supported events fo r a control, consult the
control’s help.
Update Command
The Update command parameter is the name of the function that Simulink
software invokes when it updates the block during a simulation. The function
has these input arguments:
• Thehandleofthecontrol
• The current input value
The function is not invoked when you update the diagram.
In-Block Control
The In-block control check box determines where the ActiveX Control block
value is displayed. The control can be on the block icon, in the same model
window, in a different model, in a subsystem, or in a MATLAB figure.
3-26
If checked, the control whose name is specified in the Program ID field
appears on the ActiveX Control block.
If cleared, the block is connected to the control whose handle is specified in
the Handle location field (this field appears when you clear the box):
• If the window is a MATLAB figure window, specify the name of a function
whose return value is the fig ure handle. You can also specify initialization
commands in the function to set the initial conditions of the ActiveX
Control block.
• If the window contains a Simulink subsystem, the control must be
displayed on an ActiveX Control block contained in that subsystem. Specify
the path of the ActiveX Control block on which the control is to appear.
Block Parameters for the ActiveX Control Block
For example, if a model named my_model has a subsystem called
sub_disp_signals that contains an ActiveX Control block named signal1,
the path is
Using this feature is useful in a complex model that displays signals in
multiple subsystems on ActiveX Control blocks. If you feed the signals into
ActiveX Control blocks but display the controls themselves in a separate
system o r window, it is not necessary to have the subsystems open to see the
results. For more information, see Chapter 4, “Placing Controls in a Different
Window”.
my_model/sub_disp_signals/signal1.
Border
The Border check box determines whether the block displays a border
around the control.
Note Be careful when clearing this box, because the only way to move a
block is to drag it with the border. Clearing the Border box renders the
ActiveX Control block immovable.
3-27
3 Categories of Controls
3-28
PlacingControlsina
Different W indow
• “Placing Controls in a Different Model” on page 4-2
• “Placing Controls in a Subsystem” on page 4-7
• “Placing Controls in a Figure Window” on page 4-10
4
4 Placing Controls in a Different Window
Placing Controls in a Different Model
In this section...
“Example Overview” o n page 4-2
“Creating a Model Window Containing Gauges” on page 4-2
“Associating the Main Model with the Gauges” on page 4-4
Example Overview
This example modifies the Simulink demo, sldemo_bounce, by displaying the
position and velocity signals on Gauges Blockset blocks contained in another
model window.
To open the original demo model, enter
Command Window. To open the modified version, enter
modified version includes two ActiveX Control blocks on the signals that feed
into the Scope block, as in the figure below.
sldemo_bounce in the MATLAB
gauges_bounce.The
Creating a Model Window Containing Gauges
Create a new model called gauges_bounce_gui and copy the following G auges
Blockset blocks into it:
• The Generic Linear Gauge b lock from the Linear Gauges library. Change
the block’s name to
Position.
4-2
Placing Controls in a Different Model
• The Amp Meter block from the Angular Gauges library. Change the block’s
name to
Velocity.
Customizing the Gauges
Ifyouwanttocustomizethegauges,particularlytherangeofvaluesthat
they can display, then use this optional procedure:
1 Open the ActiveX Control Properties dialog box for the Position (Generic
Linear Gauge) block.
2 From the Scales panel, set ScaleMax to 30. This enables the gauge to
display values between 0 and 30.
3 From the Ticks panel, set StopValue to 30,setDeltaValue to 5,check
the Label On/Off check box, and set Width to
0.012. This creates labeled
major ticks.
4 Still on the Ticks panel, set Ticks to 2,setTickID to 1,setDeltaValue to
1,setInner to 0.4,andsetOuter to 0.75. This creates a set of unlabeled
minor ticks.
5 From the Pointers panel, click Color, choose the color that matches the
pointer on the Velocity (Amp Meter) block, and click OK.Also,setValue
to
0.
6 Click OK.
7 Open the ActiveX Control Properties dialog box for the Velocity (Amp
Meter) block.
8 From the Captions panel, set Captions to 0. This removes the word Amps.
4-3
4 Placing Controls in a Different Window
9 From the Annulars panel, set Annulars to 1. This removes the colored
shading of the annular region.
10 From the Needles panel, set Value to 0. This moves the needle so that
it points to zero.
11 From the Scales panel, set Min to -30,setMax to 30,selectBackward,
set Start to
between
12 Still on the Scales panel, set X to -1.06 and set Y to 0.04.Thishelps
center the control in the block.
13 From the Ticks panel, set DeltaValue to 5. This creates labeled major
ticks.
14 Still on the Ticks panel, set TickID to 1 and set DeltaValue to 1.This
creates unlabeled minor ticks.
15 Click OK.
10,andsetStop to 170.Thiscausestheblocktodisplayvalues
-30 and 30 along the right half of a circle.
4-4
You might also want to enlarge the blocks. They should now look like this.
Asso
Open
gau
int
mak
Con
ciating the Main Model with the Gauges
the original
ges_bounce
otheScopeblock. ToconnecttheActiveX Control blocks to the controls,
e these changes in the Block Parameters dialog box in each of the ActiveX
trol blocks:
sldemo_bounce model and save it in your working f older as
. Insert two ActiveX Control blocks on the signals that feed
Placing Controls in a Different Model
1 Clear the In-block control check box, because the signal is being
communicated between ActiveX Control blocks in one window and ActiveX
Control blocks in another window. When you clear the In-block control
check box, the number of fields on the dialog box changes.
2 In the Input property field, specify NeedleValue for the velocity display
and
PointerValue property for the position disp lay. This property controls
the current values of these gauges. Doing this passes the value of the input
signal to this property.
Note IfyouadaptthisexampletousetheStripChartcontrolinstead,
then set In put property to
Y. For other controls in this blockset, set
Input property to the value used in the corresponding parameter field
in the library block.
3 Specify the path of each gauge in the Handle location field. In this case,
the new model is named
gauges_bounce_gui.
The dialog box es should look like those in the following figures. Now, when
you simulate the main model window, the gauges in the auxiliary model
window reflect the velocity and position of the bouncing ball.
For Displaying the Velocity
4-5
4 Placing Controls in a Different Window
For Displaying the Position
4-6
Placing Controls in a Subsystem
In this section...
“Example Overview” o n page 4-7
“Creating a Subsystem Containing Gauges” on page 4-7
“Associating T op-Le vel Blocks with the Subsystem” on page 4-8
Example Overview
This example builds on the one described in “Placing Controls in a Different
Model” on page 4-2, but places the Gauges Blockset blocks in a subsystem
of the main model rather than a different model. This approach simplifies
operations such as saving and closing the system because the system involves
only a single
.mdl file.
Placing Controls in a Subsystem
To open a completed version of this example, enter
the MATLAB Command Window. Notice that the model includes a subsystem
called
gui in the lower right.
gauges_bounce_subsys in
Creating a Subsystem Containing Gauges
To create the subsystem, follow these steps:
1 Open the sldemo_bounce model and save it in your working folder as
gauges_bounce_subsys.
4-7
4 Placing Controls in a Different Window
2 Copy a Subsystem block from the Simulink Signals & Systems library into
the model window. Change the block’s name to
3 Double-click the subsystem to open it.
4 Copy a Generic Linear Gauge block from the Linear Gauges library into the
subsystem. Change the block’s name to
5 Copy an Amp Meter block f rom the Angular Gauges library into the
subsystem. Change the block’s name to
6 In the Block Parameters dialog box for each of the tw o gauge blocks, set
the Connections parameter to
edit field.
To customize the gauge blocks, see “Customizing the Gauges” on page 4-3.
Associating Top-Level Blocks with the Subsystem
The procedure for associating the top-level ActiveX Control blocks with
the gauge blocks that are inside the subsystem is similar to the procedure
described in “Associating the Main Model with the Gauges” on page 4-4. The
only difference is that the Handle location parameters have different values
for a subsyste m than for a separate model. The dialog boxes should look
like those in the following figures.
gui.
Position.
Velocity.
neither and clear the Input p roperty
4-8
For Displaying the Velocity
For Displaying the Position
Placing Controls in a Subsystem
4-9
4 Placing Controls in a Different Window
Placing Controls in a Figure Window
In this section...
“Example Overview” on page 4-10
“Creating Helper M-Files and Building the Model” on page 4-10
“Saving and Reopening the Model” on page 4-13
Example Overview
In this example, a simple model displays the simulation time on a control
located in a MATLAB figure window.
To open a completed copy of the model, enter
MATLAB Command Window. Alternatively, follow the instructions below
for building it yourself.
gauges_offblock in the
Creating Helper M-Files and Building the Model
1 Create and execute an M-file called gauges_gaugewindow that consists
of these statements.
f = figure;
h = actxcontrol('mwagauge.agaugectrl.1',[100 100 100 100],f);
This M-file creates a figure window containing a Generic Angular Gauge,
whose program ID is
like this (resized).
mwagauge.agaugectrl.1. The figure window looks
4-10
Placing Controls in a Figure Window
The M-file also specifies the position of the control in the figure window .
For more information about
2 Create an M-file called gauges_off_block that consists of these
actxcontrol, see its reference documentation.
statements.
function hactx = gauges_o ff_block
hactx = evalin('base','h');
The gauges_off_block function returns the handle of the control that is to
be connected to the ActiveX Control block.
3 In a new model window, connect a Clock block to an ActiveX Control block.
4 Open the ActiveX Control block to modify its parameters as follows:
a Clear the In-block control check box. The number of fields on the
dialog box changes as a result.
b In the Connections field, select input. When you apply this change
later, the outport on the ActiveX Control block will disappear.
c In the Inpu t property field, enter NeedleValue. During the simulation,
the Generic Angular Gauge (that is, the control referenced by the block)
4-11
4 Placing Controls in a Different Window
sets the NeedleValue property to the value of the signal at the ActiveX
Control block’s inport.
Note If you adapt this exa m ple to use the Strip Chart control instead,
then set Input property to
Input property to the value used in the corresponding parameter field
in the library block.
d In the Handle location field, enter gauge s_of f_block.
As a result of these changes, the Block Parameters dialog box looks like t his.
Y. For other controls in this blockset, set
4-12
5 Click O
of the
6 Run the simulation. Notice that the Generic Angular Gauge reflects the
K.The
control in the figure window.
gauges_off_block M-file executes and returns the handle
clock time.
Note If you accidentally close the figure window before you are finished
exploring the model, you can recreate it by executing
gauges_gaugewindow.
Placing Controls in a Figure Window
Saving and Reope
If you want to use
you must preserv
window and gaug
1 Save the model
2 If the model’s name is mymodel, then use these commands in the MATLAB
Command Window to preserve the commands that create the figure
window and gauge.
Now, opening mymodel automatically creates the figure that contains the
gauge.
this model in a different MATLAB software session, then
e both the model and the commands that create the figure
e. Here is an easy way to do this:
to give it a name.
ning the Model
4-13
4 Placing Controls in a Different Window
4-14
Block Reference
5
Angular Gauges
PurposeDisplay input value on arc
DescriptionBlocks in the Angular Gauges library show their input values
graphically on a scale that lies along an arc of a circle. If the input value
is greater than the scale’s maximum or less than the scale’s minimum,
then the block displays the maximum or minimum value, respectively.
To learn how to use and customize blocks in this library, see “Angular
Gauges” on page 3-2.
Note Blocks in this library can display multiple needles. The Stop
Watch and Analog Clock blocks display multiple needles b y default. To
learn h ow to control multiple needles simultaneously, see “Controlling
Multiple Graphical Elements” on page 2-18.
Blocks in the Library
The blocks in the Angular Gauges library are
5-2
• Amp Meter
• Analog Clock
• Compass
• Generic Angular Gauge
• Lower Left
• Lower Right
• Stop Watch
• Upper Left
• Upper Right
• Vacuum
• Volume
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.