Dials & Gauges Blockset ® For Use with Simulink Modeling Simulation Implementation User’s Guide Version 1
How to Contact The MathWorks: www.mathworks.com comp.soft-sys.matlab Web Newsgroup info@mathworks.com Technical support Product enhancement suggestions Bug reports Documentation error reports Order status, license renewals, passcodes Sales, pricing, and general information 508-647-7000 Phone 508-647-7001 Fax The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098 Mail support@mathworks.com suggest@mathworks.com bugs@mathworks.com doc@mathworks.com service@mathworks.
Contents Getting Started 1 What Is the Dials & Gauges Blockset? . . . . . . . . . . . . . . . . . . . 1-2 Related Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 External Mode Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 Real-Time Workshop Support . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5 Accessing the Preconfigured Blocks . . . . . . . . . . . . . . . . . . . . Using the dnglib Command . . . . . . . . . . . . . . . . . .
Using Instrumentation in a Model 2 Connecting Blocks in a Model . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 Modifying ActiveX Control Properties . . . . . . . . . . . . . . . . . . 2-4 Using Multiple Styles Within One Block . . . . . . . . . . . . . . . . . . 2-4 Understanding ID Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7 Displaying Text on a Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8 Controlling Values with the Mouse . . . . . . . . . . . . .
Numeric Displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19 Customizing Numeric Displays . . . . . . . . . . . . . . . . . . . . . . . . . 3-19 Customizing the Odometer Block . . . . . . . . . . . . . . . . . . . . . . . 3-20 Percent Indicators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21 Customizing Percent Indicators . . . . . . . . . . . . . . . . . . . . . . . . 3-21 Sliders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Placing ActiveX Controls in a Figure Window . . . . . . . . . . 4-10 Saving and Reopening the Model . . . . . . . . . . . . . . . . . . . . . . . 4-12 Library Reference 5 iv Contents Angular Gauges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3 Buttons & Switches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5 Knobs & Selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6 LEDs . . . . . . . . . . . . . . . . . . .
1 Getting Started What Is the Dials & Gauges Blockset? . . . . . . . . 1-2 Related Products . . . . . . . . . . . . . . . . . . 1-3 External Mode Support . . . . . . . . . . . . . . . . 1-4 Real-Time Workshop Support . . . . . . . . . . . . . 1-5 Accessing the Preconfigured Blocks Using the dnglib Command . . . . . Using the Simulink Library Browser . Configuring the Dials & Gauges Blockset Moving and Selecting Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1 Getting Started Getting Started11 What Is the Dials & Gauges Blockset? The Dials & Gauges Blockset is a collection of blocks that provides graphical instrumentation for monitoring and controlling signals and parameters in Simulink® models. Using the Dials & Gauges Blockset, you can set up realistic-looking instruments that are custom-designed for your Simulink model and visually representative of the environment that you are modeling.
Related Products Related Products The MathWorks provides several products that are especially relevant to the kinds of tasks you can perform with the Dials & Gauges Blockset. In particular, the Dials & Gauges Blockset requires these products: • MATLAB • Simulink For more information about any of these products, see either: • The online documentation for that product, if it is installed or if you are reading the documentation from the CD • The MathWorks Web site, at http://www.mathworks.
1 Getting Started Product Description Power System Blockset Simulink block libraries for the design, simulation, and prototyping of electrical power systems Real-Time Windows Target Tool that allows you to run Simulink models interactively and in real time on your PC under Windows Real-Time Workshop Tool that generates customizable C code from Simulink models and automatically builds programs that can run in real time in a variety of environments Simulink Interactive, graphical environment for mo
Related Products Real-Time Workshop Support You can use Real-Time Workshop® 4.0 or later to generate code from models that include Dials & Gauges Blockset blocks. For dials, the code you generate contains static values (that is, the value specified at the time of code generation). Gauges are ignored during code generation, except through the use of external mode (see below). If you want to manipulate dials and view the gauges, you can do so through the external mode in Real-Time Workshop.
1 Getting Started Accessing the Preconfigured Blocks The Dials & Gauges Blockset contains many preconfigured blocks, via the Global Majic ActiveX Library. To access these blocks, follow the procedures described in one of these two sections: • “Using the dnglib Command” • “Using the Simulink Library Browser” on page 1-7 Using the dnglib Command 1 Enter the dnglib command in the MATLAB Command Window, which causes the following window to appear.
Accessing the Preconfigured Blocks Each icon represents a different library of blocks. Double-click on an icon to access the blocks in the library. If they all say “ActiveX” and do not look like graphical instruments, then follow the instructions in “Configuring the Dials & Gauges Blockset” on page 1-9. Each library also includes a question-mark block that provides access to online help for the ActiveX controls in that library.
1 Getting Started 2 Open the Global Majic ActiveX Library to display its libraries of blocks. If you click on the name of a library, then the right pane of the Simulink Library Browser displays the library’s contents. You can also view the blocks as instruments in a library window by right-clicking on the library name, and then selecting the option that appears. For example, the figure below shows the context menu that appears when you right-click on the Angular Gauges listing. .
Accessing the Preconfigured Blocks Configuring the Dials & Gauges Blockset Normally, the installation process automatically registers the ActiveX controls associated with the Dials & Gauges Blockset. However, in exceptional cases you might see an error message referring to an .ocx component, similar to the following message: Copying Dials & Gauges Blockset files ads.
1 Getting Started • Enter dng_register_ocx in the MATLAB Command Window. • See Solution Number 24876 in the Support area of the MathWorks Web site (http://www.mathworks.com/support).
Moving and Selecting Blocks Moving and Selecting Blocks The way you move and select blocks from the Dials & Gauges Blockset is significantly different from how you move and select a Simulink block. Dials & Gauges Blockset blocks consist of an “active” area containing the actual control, and a border that surrounds that area.
1 Getting Started Building a Simple Model This section illustrates how to build and use a simple system, first using Simulink blocks alone, and then using blocks from the Dials & Gauges Blockset. By building the latter model, you can practice finding and using blocks from the Dials & Gauges Blockset. By comparing the two models, you can get a better sense of how graphical instruments might enhance the look, feel, and usability of your own models.
Building a Simple Model When you simulate this system, the Lower Right block displays the value of the signal at that instant. To change the value of the signal that feeds into the Gain block, you use your mouse to adjust the needle on the Generic Knob block. Building the Model To build the model described earlier, follow the steps below. Alternatively, type dng_simple in MATLAB to open a completed copy of the model. 1 Open the Simulink Library Browser and create a new model window.
1 Getting Started 6 Draw connection lines from the Generic Knob block to the Gain block, and from the Gain block to the Lower Right block. 7 From the model window’s Simulation menu, choose Simulation parameters. Set the Stop time parameter to Inf. Now you can run the model and watch how adjustments to the Generic Knob block affect the needle on the Lower Right block.
Working with a Model Working with a Model This section indicates how you can perform common tasks involving the model you built in the section “Building the Model” on page 1-13. This section includes: • “Running the Simulation” • “Saving the Model” • “Printing the Model” on page 1-16 Running the Simulation Run the simulation by choosing Start from the model window’s Simulation menu.
1 Getting Started The files with the .ax extension describe the Dials & Gauges Blockset blocks. Note that these files are not text files. They save the current state of the ActiveX control that is embedded in the block. If you delete the .ax files, then the corresponding blocks reinitialize themselves to the exact state in which they are stored in the library. Note The easiest way to rename a model is to open it in Simulink and use the Save As menu option. If, alternatively, you simply rename the .
Modifying Properties of Blocks Modifying Properties of Blocks This section describes how to view and modify properties of a preconfigured Dials & Gauges Blockset block using a dialog box. This section includes: • “Accessing the Properties” • “Example Modifying Properties” on page 1-18 • “Learning More About Properties” on page 1-19 Accessing the Properties You can view ActiveX control properties by using one of these procedures: • Double-click on the active area of the block that contains the control.
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. Example Modifying Properties Returning to the model that you built in the section “Building a Simple Model” on page 1-12, you can modify the range of possible input values by modifying the properties of the Generic Knob block.
Modifying Properties of Blocks 6 Set the DeltaValue parameter to 5. This prevents the knob block from looking too crowded. The figure shows how the model looks as a result. Notice that the knob can now register values between 0 and 25, and that it displays values in increments of 5. Learning More About Properties Dials & Gauges Blockset blocks have many properties. Changing the appearance of a block might require changing several properties and can be quite complex.
1 Getting Started 1-20
2 Using Instrumentation in a Model Connecting Blocks in a Model . . . . . . . . . . . . 2-3 Modifying ActiveX Control Properties Using Multiple Styles Within One Block . Understanding ID Properties . . . . . . Displaying Text on a Block . . . . . . . Controlling Values with the Mouse . . . Modifying the Displayed Range . . . . . Modifying Multiple Tick Marks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2 Using Instrumentation in a Model This chapter describes how to use instrumentation in the Dials & Gauges Blockset and includes these sections: • “Connecting Blocks in a Model” on page 2-3 describes how to determine which type(s) of connections a block can have. • “Modifying ActiveX Control Properties” on page 2-4 shows how to change various properties of a block using the ActiveX Control Properties dialog box.
Connecting Blocks in a Model Connecting Blocks in a Model Before you connect a Dials & Gauges Blockset block with other blocks, you should know whether it is meant to be an input device (with an output connection), or an output device (with an input connection). Dials & Gauges Blockset blocks are initially drawn with both an inport and an outport, but Simulink removes unused ports when the simulation starts running or when you update the block diagram.
2 Using Instrumentation in a Model Modifying ActiveX Control Properties You can modify many properties of a preconfigured Dials & Gauges Blockset block using its ActiveX Control Properties dialog box, introduced in “Accessing the Properties” on page 1-17. Modifying some properties is straightforward.
Modifying ActiveX Control Properties • The Volume block in the Angular Gauges library uses three adjacent annular regions, each with a different color. • The Thermometer block in the Sliders library uses two styles for ticks: one for numbered ticks every 10 degrees and another 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.
2 Using Instrumentation in a Model 1 Click 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 repeatedly on the up arrow next to the ID property to set it to its maximum value.
Modifying ActiveX Control Properties Once you have located a part of the dialog box where you can apply a style you previously created, simply 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 1. If you change the FontID property in the Captions panel to a different number, then you will probably notice a change in some text on the block.
2 Using Instrumentation in a Model 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.
Modifying ActiveX Control Properties of the block, as well as the part of the ActiveX Control Properties dialog box panel that defines the text. Some types of text apply only to certain blocks. Type of Text Part of Dialog Box That Defines or Enables Text Title appearing in block’s outline Title property on Background panel Numerical labels near tick marks Labels area on Ticks panel. On Strip Chart block, Labels properties on Tracks and X Axis panels.
2 Using Instrumentation in a Model Changing Fonts and Other Characteristics of Text Captions. To change the font of an existing text caption, you must create a numbered font style and then apply that style to the caption. Follow 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 maximum value. This is the index that corresponds to the newest font style.
Modifying ActiveX Control Properties Description of Mouse-Response Modes The table below describes how a control’s value responds to mouse events under different mouse-response modes. Mode Behavior None The control’s value does not respond to mouse events. Relative The change in the control’s value depends on the change in the mouse position when the mouse pointer is dragged. Snap To The control’s value becomes that of the current mouse position when the mouse button is released.
2 Using Instrumentation in a Model The table below indicates which categories of blocks and which dialog box panels have a MouseControl property. Category of Block Panel in Dialog Box Angular Gauges Needles Knobs & Selectors Knob Linear Gauges Pointers Percent Indicators Portions Sliders Knob In typical Simulink models, blocks acting as sources use the Relative or Snap To mode to enable mouse control, while blocks acting as sinks use the None mode to disable mouse control.
Modifying ActiveX Control Properties Changing the Scale Click on the Scales tab to display the scales properties page. This figure shows the default scale properties for the Generic Linear Gauge. To modify the scale range, change ScaleMax to 20 and ScaleMin to -20.
2 Using Instrumentation in a Model Displaying Labels Next to Tick Marks Click on the Ticks tab to display the tick mark properties page. This figure shows the default tick mark properties. To show tick mark labels, check the Label On/Off check box. To set the starting and ending tick marks so they mark the minimum and maximum scale settings, set StartValue to -20 and StopValue to 20. Change the DeltaValue property, which sets the spacing between tick marks.
Modifying ActiveX Control Properties The Value property indicates the current pointer value. Set the initial value to 0, halfway between the maximum and minimum scale values. Click on OK to accept the changes and close the dialog box. Modifying Multiple Tick Marks Some characteristics can be repeated in a block. For example, a single block can display multiple needles or tick marks. This example illustrates the use of multiple tick marks and the use of the ID property to manage them.
2 Using Instrumentation in a Model 5 1 4 2 3 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.
Modifying ActiveX Control Properties 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 located relative to the needle length, examine the needle length by selecting the Needles page. The needle length is 2.0. The Inner position is 1.70 and the Outer position is 2.00.
2 Using Instrumentation in a Model 1 4 2 3 The Position/Size properties, in the box labeled 2, are defined as follows: • The Inner position is 1.90 and the Outer position is 2.00. These tick marks are 0.10 units long, one-third the length of the longer tick marks. • The Width property of the tick marks is 0.00, the same as the longer tick marks. The Range properties, in the box labeled 3, are defined as follows. • StartValue for these tick marks is 0.
Saving and Reusing a Customized Control Saving and Reusing a Customized Control If you have modified settings in a block’s ActiveX Control Properties dialog box, then you might want to store the customized version of the block for later use or to share with other users.
2 Using Instrumentation in a Model 4 Enter a description in the text area and click on OK. 5 Select the directory in which to store the modified control by expanding the library hierarchy at the left. The new set of property settings is stored in the directory you select. Click on Store. 6 Click on OK to accept all the changes and close the dialog box.
Saving and Reusing a Customized Control The figure below shows the dialog box with fields filled in. The customized control is stored in the Linear Gauge directory. An alternative to this procedure is to export customized controls to .gms files. To do this, select a directory from the left side of the panel and click on Export. You can later access these controls by using the Import button, or share the controls by sharing the .gms files.
2 Using Instrumentation in a Model 2-22
3 Categories of ActiveX Controls Angular Gauges . . . . . . . . . . . . . . . . . . 3-3 Buttons & Switches . . . . . . . . . . . . . . . . . 3-6 Knobs & Selectors LEDs . . . . . . . . . . . . . . . . . 3-8 . . . . . . . . . . . . . . . . . . . . . . . 3-14 Linear Gauges . . . . . . . . . . . . . . . . . . . 3-16 Numeric Displays . . . . . . . . . . . . . . . . . 3-19 Percent Indicators . . . . . . . . . . . . . . . . . 3-21 Sliders . . . . . . . . . . . . . . . . . . . . . . 3-24 Strip Chart . . .
3 Categories of ActiveX Controls This chapter discusses various categories of instrumentation that you can use in your model.
Angular Gauges Angular Gauges The Angular Gauges library contains controls that reflect their input value graphically along an arc of a circle. Blocks 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. The next section describes how to customize angular gauges by making changes that are specific to the Angular Gauges library.
3 Categories of ActiveX Controls Task (Continued) Description (Continued) Change the appearance of a needle label On the Digital panel, first set NeedleID to the ID of the needle 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).
Angular Gauges input signal controls only one needle’s value. Unless you access the control directly as an ActiveX object, the remaining needles have static values. Task Description Add another needle to 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.
3 Categories of ActiveX Controls Buttons & Switches The Buttons & Switches library contains two-state controls that change their state when you click on them. The block output is 0 when the block’s state is “off” and -1 when the state is “on.” The blocks in this library differ in cosmetic ways, such as the image(s) shown on the block and the changes in the block’s appearance after you click on it.
Buttons & Switches Task (Continued) Description (Continued) Use beveling to make the button appear three-dimensional Use the BevelInner and BevelOuter properties on the Background panel. Change the way the button’s beveling (if visible) responds to a mouse click Use the Mode property on the General panel. Under the SingleState option, the bevels remain fixed. Under the TwoState option, the bevels toggle with each mouse click.
3 Categories of ActiveX Controls Knobs & Selectors The Knobs & Selectors library contains two dial blocks that you can control using the mouse: • The Generic Knob block assumes values in a continuum by default. You can also configure it to assume discrete values along a linear scale. For common customizations specific to this block, see “Customizing the Generic Knob Block” on page 3-9. • The Frequency Selector block assumes only values in a discrete set.
Knobs & Selectors Customizing the Generic Knob Block The table below lists some common customizations involving the ActiveX Control Properties dialog box of the Generic Knob block. Task Description Change the shape or size of the selector knob On the Knobs panel, use the KnobStyle property to choose the shape, and the KnobRadius property to determine the size. Display a mark on the knob to indicate the selected position more precisely On the Mark panel, choose a value for MarkStyle other than None.
3 Categories of ActiveX Controls Task (Continued) Description (Continued) Draw an annular region along the scale 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 On the Annulars panel, first set AnnularID to the ID of the annular region you want to change.
Knobs & Selectors Task (Continued) Description (Continued) Change the dial’s range of motion On the Auto panel, check the AutoAngleConfine check box and then use AutoStartAngle and AutoStopAngle to define the range of allowable angles. To allow the dial to move in a full circle, uncheck the AutoAngleConfine check box. Define a new selection (that is, new possible value for the knob) On the Selections panel, increase the Selections property.
3 Categories of ActiveX Controls 1 Copy the Frequency Selector block from the library into a new model. 2 From the model window, open the block’s ActiveX Control Properties dialog box. All other steps in this procedure refer to this dialog box. 3 Set up the block to configure selections and their captions automatically, by checking all of the check boxes on the Auto panel and setting AutoOffsetStyle to Vertical.
Knobs & Selectors SelectionID SelectionCaption 2 Half Rate 3 Full Rate 9 Change the color of the currently chosen value to red by setting HighlightColor to red. Manually Adjusting the Selections It is generally easier to let the block determine the positions of selections and their captions.
3 Categories of ActiveX Controls LEDs 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 LEDs 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 LED.
LEDs Task (Continued) Description (Continued) Display a binary representation of the (rounded) input Set the Mode property on the LEDs/General panel to Bitwise. The first LED corresponds to the least significant bit. Display decaying maximum value of the input, in addition to the current input Check the MaxDecay check box on the LEDs/General panel. The DecayRate value controls how quickly the displayed value decays from the maximum to the current input value.
3 Categories of ActiveX Controls Linear Gauges The Linear Gauges library contains controls that reflect their input value 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 next section describes how to customize linear gauges by making changes that are specific to the Linear Gauges library.
Linear Gauges Customizing Linear Gauges The table below lists some common customizations involving the ActiveX Control Properties dialog box that are specific to blocks in the Linear Gauges library. Task Description Change the shape or size of a pointer On the Pointers panel, set PointerID to the ID of the pointer you want to change (0 if there is exactly one pointer).
3 Categories of ActiveX Controls Combining Multiple Pointers in One Display If you want to display multiple pointers on a single block, then the customizations in the table below might be relevant. Note that the Simulink input signal controls only one pointer’s value. Unless you access the control directly as an ActiveX object, the remaining pointers have static values. 3-18 Task Description Add another pointer to the display On the Pointers panel, increase the Pointers property.
Numeric Displays Numeric Displays The Numeric Displays library contains controls that display the numerical value of their input signal. The Generic Numeric LED and PlusMinus XX.XXX blocks are probably the most useful blocks in this library. The next section describes how to customize them. The Odometer block differs from the other blocks in this library in its appearance and dialog box. You can also customize the Odometer block.
3 Categories of ActiveX Controls Customizing the Odometer Block The table below lists some common ways to customize the Odometer block, using the General panel of its ActiveX Control Properties dialog box. 3-20 Task Description Change the number of digits in the display 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.
Percent Indicators Percent Indicators 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 have them display an input value X between m and M as the percentage 100 * ((X - m) / (M - m)).
3 Categories of ActiveX Controls Task (Continued) Description (Continued) Change the direction in which a linear percentage scale increases 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 Forward, then a horizontal scale increases to the right and a vertical scale increases downward.
Percent Indicators input signal controls only one region. Unless you access the control directly as an ActiveX object, the remaining portions have static values. Task Description Add another region to 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.
3 Categories of ActiveX Controls Sliders The Sliders library contains controls that model a knob sliding along a bar and that output the numerical value corresponding to the knob’s position. Blocks in the library differ from each other in their numerical ranges and in their use of numerical labels, knob appearances, text captions, and tick marks. The next section describes how to customize sliders by making changes that are specific to the Sliders library.
Sliders Task (Continued) Description (Continued) Change the size or position of the bar 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.
3 Categories of ActiveX Controls 3-26 Task (Continued) Description (Continued) Move the knob label to a fixed position On the Digital panel, uncheck the Attach check box. Then use X Position and Y Position to set the fixed position for the label. Move the knob label to a position relative to the knob On the Digital panel, check the Attach check box. For a vertical (respectively, horizontal) linear scale, use X Position (respectively, Y Position) to set the independent coordinate for the label.
Strip Chart Strip Chart The interface to the Strip Chart block is different from the interface to the other preconfigured blocks in the Dials & Gauges Blockset. 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 invoke to call methods of ActiveX control blocks and pass arguments to those methods.
3 Categories of ActiveX Controls Using Your Own ActiveX Control To use your own ActiveX control in a Simulink model, you must associate it with the generic ActiveX Control block.
Using Your Own ActiveX Control Note Double-clicking on the border of a preconfigured block (supplied with the blockset) displays its ActiveX Control Properties dialog box, which lists properties in multiple tabbed panels. Double-clicking on a block that you created by customizing the generic ActiveX Control block displays its Block Parameters dialog box. Summary of Dialog Box Fields and Check Boxes Here is a summary of the Block Parameters dialog box fields and check boxes.
3 Categories of ActiveX Controls • Program ID — the name of the ActiveX Control block • Connections — whether the ActiveX Control block has an inport, an outport, both, or neither • Input property — the name of the property that is set when the ActiveX Control block receives a signal • Output property — the name of the property whose value is passed as the output signal • Event on which to output — the events that will cause the value of the output to be updated • Initialization command — the command that
Using Your Own ActiveX Control block that has an input connection stores the block’s current value in a property, as listed in the table below. Names of Input Properties Library Property Name Angular Gauges NeedleValue LEDs Value Linear Gauges BandStop (Min-Max Thermometer) PointerValue (Others) Numeric Displays Value (Generic Numeric LED, Odometer, PlusMinus XX.
3 Categories of ActiveX Controls events. The table below lists the events associated with the preconfigured blocks that use this parameter field. Events Associated With Each Block Block Associated Events Demo Joystick Control JoyMove Frequency Selector Change Generic Knob Turn, Click Generic Slider Slide, Change Generic Toggle Click Initialization Command The Initialization command parameter is a string that sets the initial conditions of the ActiveX Control block.
Using Your Own ActiveX Control In-Block Control The In-block control check box determines whether the ActiveX Control block displays an ActiveX Control block or is connected to an ActiveX Control block somewhere else. The ActiveX Control block can be in the same model window or in a different subsystem, model, or MATLAB figure. If checked, the control whose name is specified in the Program ID field appears on the ActiveX Control block.
3 Categories of ActiveX Controls Note Be careful when unchecking this box because the only way to move a block is to drag it with the border. Unchecking the Border box renders the ActiveX Control block unmovable. Notes on Third-Party ActiveX Control Blocks This section contains additional notes about third-party ActiveX control blocks. One note is about editing ActiveX Control blocks that ignore mouse events, while another concerns the colors of ActiveX control blocks.
Using Your Own ActiveX Control 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 will be the handle to the ActiveX control.
4 Placing ActiveX Controls in a Different Window Placing ActiveX Controls in a Different Model . . . . 4-3 Creating a Model Window Containing Gauges . . . . . . . 4-3 Associating the Main Model with the Gauges . . . . . . . 4-6 Placing ActiveX Controls in a Subsystem . . . . . . . 4-8 Creating a Subsystem Containing Gauges . . . . . . . . 4-8 Associating Top-Level Blocks with the Subsystem . . . . . 4-9 Placing ActiveX Controls in a Figure Window . . . . . 4-10 Saving and Reopening the Model . . . . . . . .
This chapter describes how to place Dials & Gauges Blockset blocks in their own window. By separating the controls from the computational blocks in the simulation, you can make your system look neater and more user-friendly. The sections are as follows: • “Placing ActiveX Controls in a Different Model” on page 4-3 describes how to use a control located in a different model. • “Placing ActiveX Controls in a Subsystem” on page 4-8 describes how to use a control located in a subsystem of a model.
4 Placing ActiveX Controls in a Different Window Placing ActiveX Controls in a Different Model This sample model modifies the Simulink bounce demo by displaying the position and velocity signals on Dials & Gauges Blockset blocks contained in another model window. To open the original demo model, type bounce in MATLAB. To open the modified version, type dng_bounce in MATLAB. The modified version includes two ActiveX Control blocks on the signals that feed into the Scope block, as in the figure below.
Placing ActiveX Controls in a Different Model • The Amp Meter block from the Angular Gauges library. Change the block’s name to Velocity. Customizing the Gauges If you want to customize the gauges, particularly the range of values that 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 allows the gauge to display values between 0 and 30.
4 Placing ActiveX Controls in a Different Window 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. 9 From the Annulars panel, set Annulars to 1. This removes the colored shading of the annular region. 10 From the Scales panel, set Min to -30, set Max to 30, select Backward, set Start to 10, and set Stop to 170.
Placing ActiveX Controls in a Different Model Associating the Main Model with the Gauges In the main model window, insert two ActiveX Control blocks on the signals that feed into the Scope block.
4 Placing ActiveX Controls in a Different Window For displaying the velocity 4-7 For displaying the position
Placing ActiveX Controls in a Subsystem Placing ActiveX Controls in a Subsystem This sample model builds on the one described in “Placing ActiveX Controls in a Different Model” on page 4-3, but places the Dials & 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.
4 Placing ActiveX Controls in a Different Window 2 Double-click on the subsystem to open it. 3 Copy a Generic Linear Gauge block from the Linear Gauges library into the subsystem. Change the block’s name to Position. 4 Copy an Amp Meter block from the Angular Gauges library into the subsystem. Change the block’s name to Velocity. 5 In the Block Parameters dialog box for each of the two gauge blocks, set the Connections parameter to neither and clear the Input property edit field.
Placing ActiveX Controls in a Figure Window Placing ActiveX Controls in a Figure Window In this example, a simple model displays the simulation time on an ActiveX Control block located in a figure window. You can open a completed copy of the model by typing dng_offblock in MATLAB, or you can follow the instructions below for building it yourself. The model looks like this. 1 Create and execute an M-file called dng_gaugewindow that consists of these statements. f = figure; h = actxcontrol('mwagauge.
4 Placing ActiveX Controls in a Different Window connected to the ActiveX Control block (the code appears below). With the fields filled in, the Block Parameters dialog box looks like this. 7 Click on OK. MATLAB executes the dng_off_block M-file, which returns the handle of the ActiveX Control block in the figure window. The figure window looks like this (resized). 8 Run the simulation. Notice that the clock time is passed to the Generic Angular Gauge.
Placing ActiveX Controls in a Figure Window Note In case you accidentally close the figure window before you are finished exploring the model, you can recreate it by executing dng_gaugewindow. Saving and Reopening the Model If you want to use this model in a different MATLAB session, then you must preserve both the model and the MATLAB commands that create the figure window and gauge. Here is an easy way to do this: 1 Save the model to give it a name.
4 Placing ActiveX Controls in a Different Window 4-13
5 Library Reference
5 Library Reference This chapter contains detailed descriptions of the categories of blocks in the Dials & Gauges Blockset. Each category corresponds to a library containing blocks that share many aspects of their functionality.
Angular Gauges Purpose 5Angular Gauges Description Blocks in the Angular Gauges library reflect their input value 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 mininum value, respectively. To learn how to use and customize blocks in this library, see “Angular Gauges” on page 3-3.
Angular Gauges Panel Purpose Library Refer to property settings as a named collection Needles Display one or more needles on the block (The Digital panel uses the NeedleID property to reference the needles defined here.) Scales Define the range(s) and locations of values displayed on the block (The Annulars, Hubs, Needles and Ticks panels use the ScaleID property to reference the ranges defined here.
Buttons & Switches Purpose 5Buttons & Switches Description Blocks in the Buttons & Switches library are two-state controls that change their state when you click on them. The block output is 0 when the block’s state is “off” and -1 when the state is “on.” To learn how to use and customize blocks in this library, see “Buttons & Switches” on page 3-6. Dialog Box The ActiveX Control Properties dialog box governs the appearance and functionality of the ActiveX control itself.
Knobs & Selectors Purpose 5Knobs & Selectors Description The Knobs & Selectors library has two blocks that behave differently: Select values in a discrete or continuous set using a mouse-controlled dial • The Generic Knob block displays a mouse-controlled dial that selects values on a continuous scale. The block’s output is the value to which the dial points. • The Frequency Selector block displays a mouse-controlled dial that selects values in a discrete set.
Knobs & Selectors Panel Purpose Mark Display a dot or other mark on the dial Selections Define the number and appearance of selectable values for the block The table below lists the panels of the ActiveX Control Properties dialog box for the Generic Knob block.
LEDs Purpose 5LEDs Description Blocks in the LEDs library 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 LEDs in the “on” state is the rounded value of the block’s input. If the rounded value is nonpositive, then all LEDs are in the “off” state, while if the rounded value exceeds the number of LEDs, then all LEDs are in the “on” state.
Linear Gauges Purpose 5Linear Gauges Description Blocks in the Linear Gauges library reflect their input value graphically on a scale that lies along a line. 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 mininum value, respectively. To learn how to use and customize blocks in this library, see “Linear Gauges” on page 3-16. Display input value on a line Note Blocks in this library can display multiple linear scales.
Linear Gauges Panel Purpose Pointers Display one or more pointers on the block (The Digital panel uses the PointerID property to reference the pointers defined here.) Scales Define the range(s) and locations of values displayed on the block (The Bands, Pointers and Ticks panels use the ScaleID property to reference the ranges defined here.
Numeric Displays Purpose 5Numeric Displays Description Blocks in the Numeric Displays library reflect the numerical value of their input using graphical elements that imitate either numerals composed of light-emitting diode (LED) segments, or numbered wheels. Display input value using LED digits or numbered wheels The Odometer block’s displays imitates the numbered wheels of a car’s odometer or tripometer.
Numeric Displays The Block Parameters dialog box governs the interaction between Simulink and the ActiveX control embedded in the block. See “Summary of Dialog Box Fields and Check Boxes” on page 3-29 for details.
Percent Indicators Purpose 5Percent Indicators Description Blocks in the Percent Indicators library convert their input value to a percentage or ratio. They display the percentage or ratio graphically as either a segment on a linear scale or a sector of a circle. To learn how to use and customize blocks in this library, see “Percent Indicators” on page 3-21.
Sliders Purpose 5Sliders Description Blocks in the Sliders library model a knob sliding along a bar. The block output is the numerical value corresponding to the knob’s position. To learn how to use and customize blocks in this library, see “Sliders” on page 3-24. Dialog Box The ActiveX Control Properties dialog box governs the appearance and functionality of the ActiveX control itself. The table below lists the panels of the ActiveX Control Properties dialog box.
Strip Chart Purpose 5Strip Chart Description The Strip Chart library contains a single block, the Strip Chart block. This block displays one or more signals while the simulation runs. It also enables you to zoom in or out. To learn how to use the Strip Chart block, see “Strip Chart” on page 3-27. Dialog Box The ActiveX Control Properties dialog box governs the appearance and functionality of the ActiveX control itself. The table below lists the panels of the ActiveX Control Properties dialog box.
Strip Chart Panel Purpose Variables Determine which variables appear in each individual plot and how each variable is displayed. X Axis Determine what the values along the X axis represent and how they are displayed The Block Parameters dialog box governs the interaction between Simulink and the ActiveX control embedded in the block. See “Summary of Dialog Box Fields and Check Boxes” on page 3-29 for details.
Index A active area 1-11 ActiveX Control blocks accessing from MATLAB 1-6 accessing from Simulink 1-7 accessing in a different model window 4-3 accessing in a figure window 4-10 active area 1-11 adding to a model 1-11 border 1-11 Border property 3-33 connecting to your own 3-28 Connections property 3-30 Event on which to output property 3-31 In-block control property 3-33 Input property 3-30 moving 1-11 Other events and handlers property 3-32 Output property 3-31 parameters 3-29 printing 1-16 Program ID pro
Index K R Knobs & Selectors library reference for 5-6 ranges 2-12 Real-Time Workshop support 1-5 running a simulation 1-15 L LEDs library reference for 5-8 Linear Gauges library reference for 5-9 M models adding ActiveX Control blocks 1-11 saving 1-15 modifying ActiveX control properties 2-4 S saving a model 1-15 simulation, running 1-15 Simulink Library Browser 1-7 Sliders library reference for 5-14 Strip Chart library reference for 5-15 T third-party ActiveX Control blocks 3-34 tick mark propertie