M9Xx Getting Started
M9Xx Getting Started
TM
The MATRIXx products and related items have been purchased from Wind
River Systems, Inc. (formerly Integrated Systems, Inc.). These reformatted user
materials may contain references to those entities. Any trademark or copyright
notices to those entities are no longer valid and any references to those entities
as the licensor to the MATRIXx products and related items should now be
considered as referring to National Instruments Corporation.
National Instruments did not acquire RealSim hardware (AC-1000, AC-104,
PCI Pro) and does not plan to further develop or support RealSim software.
NI is directing users who wish to continue to use RealSim software and hardware
to third parties. The list of NI Alliance Members (third parties) that can provide
RealSim support and the parts list for RealSim hardware are available in our
online KnowledgeBase. You can access the KnowledgeBase at
[Link]/support.
Worldwide Offices
Australia 1800 300 800, Austria 43 0 662 45 79 90 0, Belgium 32 0 2 757 00 20, Brazil 55 11 3262 3599,
Canada (Calgary) 403 274 9391, Canada (Montreal) 514 288 5722, Canada (Ottawa) 613 233 5949,
Canada (Québec) 514 694 8521, Canada (Toronto) 905 785 0085, Canada (Vancouver) 514 685 7530,
China 86 21 6555 7838, Czech Republic 420 2 2423 5774, Denmark 45 45 76 26 00,
Finland 385 0 9 725 725 11, France 33 0 1 48 14 24 24, Germany 49 0 89 741 31 30, Greece 30 2 10 42 96 427,
India 91 80 51190000, Israel 972 0 3 6393737, Italy 39 02 413091, Japan 81 3 5472 2970,
Korea 82 02 3451 3400, Malaysia 603 9131 0918, Mexico 001 800 010 0793, Netherlands 31 0 348 433 466,
New Zealand 1800 300 800, Norway 47 0 66 90 76 60, Poland 48 0 22 3390 150, Portugal 351 210 311 210,
Russia 7 095 238 7139, Singapore 65 6226 5886, Slovenia 386 3 425 4200, South Africa 27 0 11 805 8197,
Spain 34 91 640 0085, Sweden 46 0 8 587 895 00, Switzerland 41 56 200 51 51, Taiwan 886 2 2528 7227,
Thailand 662 992 7519, United Kingdom 44 0 1635 523545
For further support information, refer to the Technical Support and Professional Services appendix. To comment
on the documentation, send email to techpubs@[Link].
Warranty
The media on which you receive National Instruments software are warranted not to fail to execute programming instructions, due to defects
in materials and workmanship, for a period of 90 days from date of shipment, as evidenced by receipts or other documentation. National
Instruments will, at its option, repair or replace software media that do not execute programming instructions if National Instruments receives
notice of such defects during the warranty period. National Instruments does not warrant that the operation of the software shall be
uninterrupted or error free.
A Return Material Authorization (RMA) number must be obtained from the factory and clearly marked on the outside of the package before
any equipment will be accepted for warranty work. National Instruments will pay the shipping costs of returning to the owner parts which are
covered by warranty.
National Instruments believes that the information in this document is accurate. The document has been carefully reviewed for technical
accuracy. In the event that technical or typographical errors exist, National Instruments reserves the right to make changes to subsequent
editions of this document without prior notice to holders of this edition. The reader should consult National Instruments if errors are suspected.
In no event shall National Instruments be liable for any damages arising out of or related to this document or the information contained in it.
EXCEPT AS SPECIFIED HEREIN, NATIONAL INSTRUMENTS MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AND SPECIFICALLY DISCLAIMS ANY WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. CUSTOMER’S RIGHT TO RECOVER DAMAGES CAUSED BY FAULT OR NEGLIGENCE ON THE PART OF
NATIONAL INSTRUMENTS SHALL BE LIMITED TO THE AMOUNT THERETOFORE PAID BY THE CUSTOMER. NATIONAL INSTRUMENTS WILL NOT BE LIABLE FOR
DAMAGES RESULTING FROM LOSS OF DATA, PROFITS, USE OF PRODUCTS, OR INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY
THEREOF. This limitation of the liability of National Instruments will apply regardless of the form of action, whether in contract or tort, including
negligence. Any action against National Instruments must be brought within one year after the cause of action accrues. National Instruments
shall not be liable for any delay in performance due to causes beyond its reasonable control. The warranty provided herein does not cover
damages, defects, malfunctions, or service failures caused by owner’s failure to follow the National Instruments installation, operation, or
maintenance instructions; owner’s modification of the product; owner’s abuse, misuse, or negligent acts; and power failure or surges, fire,
flood, accident, actions of third parties, or other events outside reasonable control.
Copyright
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying,
recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National
Instruments Corporation.
Trademarks
AutoCode™, DocumentIt™, LabVIEW™, MATRIXx™, National Instruments™, NI™, [Link]™, RealSim™, SystemBuild™, and Xmath™ are
trademarks of National Instruments Corporation.
Product and company names mentioned herein are trademarks or trade names of their respective companies.
Patents
For patents covering National Instruments products, refer to the appropriate location: Help»Patents in your software, the [Link] file
on your CD, or [Link]/patents.
Chapter 1
Introduction to the MATRIXx Product Family
Xmath.............................................................................................................................1-2
SystemBuild...................................................................................................................1-3
AutoCode .......................................................................................................................1-3
DocumentIt ....................................................................................................................1-4
Chapter 2
Available Publications
Installation Manuals.......................................................................................................2-1
Xmath Manuals..............................................................................................................2-1
SystemBuild Manuals ....................................................................................................2-2
AutoCode and DocumentIt Manuals .............................................................................2-3
Chapter 3
Xmath
Introduction to Xmath....................................................................................................3-1
Data Handling..................................................................................................3-1
Numerical Analysis .........................................................................................3-1
Architecture .....................................................................................................3-1
Getting Started in Xmath ...............................................................................................3-2
Directories Defined by Environment Variables ..............................................3-2
Setting Your Display Colors ...........................................................................3-3
Starting Xmath.................................................................................................3-3
Getting Acquainted with the Xmath Commands Window..............................3-4
Menu Choices ...................................................................................3-4
Command Modes ..............................................................................3-5
Running Demos ...............................................................................................3-5
Accessing Online Help ....................................................................................3-6
Chapter 4
SystemBuild
Introduction to SystemBuild.......................................................................................... 4-1
Key Terms....................................................................................................... 4-1
SystemBuild Catalog Browser ........................................................................ 4-2
SystemBuild Editor ......................................................................................... 4-3
SystemBuild Palette Browser.......................................................................... 4-4
SystemBuild Simulator ................................................................................... 4-5
Additional Functions....................................................................................... 4-6
Two- and Three-Button Pointing Devices ...................................................... 4-6
Specifying an ASCII Text Editor.................................................................... 4-6
SystemBuild Optional Module Overview....................................................... 4-7
State Transition Diagram Block ....................................................... 4-7
Fuzzy Logic Block............................................................................ 4-7
Neural Network Module ................................................................... 4-7
Starting and Exiting SystemBuild ................................................................................. 4-8
Starting SystemBuild ...................................................................................... 4-8
Exiting SystemBuild ....................................................................................... 4-8
Sample SystemBuild Tasks ........................................................................................... 4-8
Creating a New SuperBlock............................................................................ 4-8
Creating a New Block in a SuperBlock .......................................................... 4-10
Loading a Model File ...................................................................................... 4-11
Loading a File from the Xmath Command Area .............................. 4-11
Loading a File from the Xmath Commands Window ...................... 4-12
Loading a File from the Catalog Browser ........................................ 4-13
Opening a SuperBlock in the Editor ............................................................... 4-14
Simulating the Model from the Xmath Commands Window ......................... 4-15
Deleting a SuperBlock.....................................................................................4-17
Navigating a SuperBlock Hierarchy................................................................4-18
Navigating in the Catalog Browser ...................................................4-18
Navigating from the Editor Window ................................................4-20
Printing from the Editor Window....................................................................4-21
SystemBuild Tutorial .....................................................................................................4-21
Building a Block Diagram...............................................................................4-21
Creating a SuperBlock.....................................................................................4-22
Creating and Placing Blocks ...........................................................................4-23
Creating the First Block in Your SuperBlock...................................4-23
Creating the Remaining Blocks in the SuperBlock ..........................4-26
Connecting Blocks...........................................................................................4-28
Making Internal Connections on the Diagram ..................................4-28
Making External Connections on the Diagram.................................4-29
Saving the Tutorial Model...............................................................................4-31
Simulating the Model ......................................................................................4-32
Chapter 5
AutoCode
Generating Non-Customized Code ................................................................................5-1
Generating Customized Code ........................................................................................5-2
Chapter 6
DocumentIt
Generating Non-Customized Documentation................................................................6-1
Generating Customized Documentation ........................................................................6-3
EXAMPLE 6-1: Example of DocumentIt Output ...........................................6-3
Appendix A
Technical Support and Professional Services
This manual acquaints you with the MATRIXx Product Family software. It
provides an overview of each software component and provides tutorials to
assist you in learning the product.
This manual is for anyone who wants to learn how to use the MATRIXx
Product Family software.
Organization
This manual is organized as follows:
• Chapter 1, Introduction to the MATRIXx Product Family, introduces
each piece of software in the MATRIXx Product Family.
• Chapter 2, Available Publications, lists the MATRIXx Product Family
publications available.
• Chapter 3, Xmath, provides an overview of Xmath and the Xmath
modules and gives a tutorial.
• Chapter 4, SystemBuild, provides an overview of SystemBuild and the
SystemBuild modules and gives a tutorial. It also provides an overview
to Interactive Animation and gives a tutorial.
• Chapter 5, AutoCode, provides an overview of the AutoCode code
generator.
• Chapter 6, DocumentIt, provides an overview of the DocumentIt
document.
Conventions
This section describes the conventions used in this manual.
Font Conventions
This sentence is set in the default text font, Times. Times is used for general
text, menu selections, window names, and program names. Fonts other than
the standard text default have the following significance:
Courier Courier is used for command and function names, filenames, directory
paths, environment variables, messages and other system output, code and
program examples, system calls, prompt responses, and syntax examples.
bold Courier Bold Courier is used for user input (anything you are expected to
type in).
italic Italics are used in conjunction with the default font for emphasis, first
instances of terms, and publication titles.
Bold Helvetica narrow Bold Helvetica narrow font is used for buttons, fields, and icons in a graphical
user interface. Keyboard keys are also set in this font.
Mouse Conventions
This document assumes you have a standard, right-handed three-button
mouse. From left to right, the buttons are referred to as MB1, MB2, and
MB3. All instructions assume MB1 unless otherwise noted.
click Press and quickly release a mouse button. MB1 is assumed if click is used
without a button designation. For example, “click on the root window.”
drag Place the cursor over an object, then hold down MB1 while moving the
mouse. Release the button when the desired result is obtained.
Note Notes provide special considerations or details which are important to the
procedures or explanations presented.
Caution Cautions indicate actions that may result in possible loss of work performed and
associated data. An example might be a system crash that results in the loss of data for that
given session.
Warning Warnings indicate actions or circumstances that may result in file corruption,
irrecoverable data loss, data security risk, or damage to hardware.
Related Publications
NI provides a library of publications to support its products. Of special
interest to the users of this publication are the installation guides:
• MATRIXx System Administrator’s Guide (Windows Hosts)
• MATRIXx Product Family CD-ROM and booklet for each platform
Products Needed
Xmath SystemBuild AutoCode DocumentIt
Product SystemBuild X X — —
to Add
AutoCode X X X —
DocumentIt X X — X
Xmath
Xmath software provides a system analysis and visualization software
environment with over 700 predefined functions and commands,
interactive color graphics, and a programmable graphical user interface
(PGUI). The MathScript scripting language simplifies command and
function programming. Object-oriented design provides convenient data
SystemBuild
SystemBuild visual modeling and simulation software lets you model
many kinds of systems, from control loops to complex aerospace and
automotive applications. You can use SystemBuild to prepare models that
can be simulated with the SystemBuild simulator. Built-in simulation tools
let you interactively verify, test, and modify system models.
To create a model, you can use all of the SystemBuild standard and optional
features. The optional Interactive Animation (IA) module or the Altia
Design module adds the ability to control your model interactively during
simulation. With IA, the icons are put in one or more picture files (.pic)
while Altia images are stored in design files (.dsn).
AutoCode
AutoCode is an automatic code generator for SystemBuild models.
The AutoCode software processes SystemBuild model files you create and
outputs compilable ANSI C or Ada code.
DocumentIt
DocumentIt is an automated documentation generator for SystemBuild
models. This module integrates documentation with SystemBuild design
activity for easier and more accurate manuals and reports. Templates are
included for FrameMaker, Microsoft Word, and WordPerfect markup
formats. Using TPL, you can capture and tailor any part of the generated
document for special documentation standards or other needs.
Installation Manuals
The MATRIXx System Administrator’s Guide (Windows) describes proper
setup of a PC running Windows 2000/NT/XP/9x for the installation of the
MATRIXx core software products.
Xmath Manuals
The Xmath manuals consist of Xmath Basics and a number of other
manuals for Xmath modules.
• Xmath Basics—Describes Xmath structure and concepts. It provides
a tutorial, covers basic features for general Xmath use, and describes
advanced Xmath features such as creating a GUI, creating your own
MathScript commands, functions, or objects, and linking external
programs.
• Xmath Control Design Module—Explains the use of the Control
Design Module including Linear system representation, building
system connections, system analysis, classical feedback analysis, and
state-space design. It describes each function in the Control Design
Module.
• Xmath Interactive Control Design Module—Describes how to use
the Interactive Control Design Module (ICDM), which is a tool for
interactive design of continuous-time, single-input, linear
time-invariant controllers. ICDM uses the Xmath programmable
graphical user interface (PGUI or GUI).
SystemBuild Manuals
The SystemBuild manuals consist of the SystemBuild User’s Guide and a
number of other manuals for SystemBuild modules.
• SystemBuild User’s Guide—Describes how to use SystemBuild, the
graphical modeling and simulation environment, to construct a model
for a dynamic system. SystemBuild lets you create custom building
blocks, hierarchically organize model subsystems into SuperBlocks,
and run system simulations based on the models.
• Aerospace Libraries—Describes a library of SystemBuild models
that were written for the aerospace industry.
• HyperBuild User’s Guide—Describes how to decrease the computer
simulation time of medium and large SystemBuild models. The bigger
and more complex the SystemBuild model, the more significant the
increase in simulation speed. HyperBuild achieves this improvement
by converting a SystemBuild block diagram into highly optimized C
code (called HyperCode) that executes much faster in the simulation
engine, which normally interprets the model data. HyperBuild can be
used to generate code for continuous SuperBlocks only.
Introduction to Xmath
The following subsections introduce the Xmath tools and capabilities.
Data Handling
MathScript, the language of Xmath, allows you to define and manipulate
data in the form of numbers, objects, graphs, and text. Xmath provides a
graphical user interface to facilitate data management. You can save, load,
import, and export data.
Numerical Analysis
Xmath provides an extensive library of commands and basic functions
(more than 700), including mathematical functions, filter design functions,
and more. Xmath also provides a plotting facility that allows you to modify
plot appearance interactively. These are documented in the online Xmath
Help.
Each Xmath module includes online Help describing related functions and
commands, as well as online and printed versions of a usage manual.
Discussions of theory and examples are provided in the usage manual. See
the Xmath Manuals section of Chapter 2, Available Publications, for a list
of available manuals.
Architecture
Xmath’s programming language, MathScript, allows users to alter or
extend Xmath’s functionality. An interactive debugger and a full
complement of checking utilities simplify developing scripts to define
functions, commands, and objects.
SYSBLD, and CASE. If you do not know this pathname, you can determine
it by typing the following command within the Xmath command area:
oscmd("echo %variable%");
These variables are defined whether or not you purchase the entire product
line.
Note The environment variables discussed within this section are reserved for the
exclusive use of NI, and they are subject to change. Therefore, we recommend that you not
use them in your scripts.
Default colors for your display windows, borders, and other screen
components are established through the Appearance tab in the
Start»Programs»National Instruments»MATRIXx 6.3»Xmath
selection, just as in other Windows applications.
Starting Xmath
To start and run Xmath, select Start»Programs»MATRIXx»Xmath or
double-click the Xmath icon (after creating a shortcut with Explorer):
You can also enter the following command from either the Run dialog
(Start»Run) or from the DOS prompt:
ISIHOME\bin\xmath
Invoking Xmath from the DOS command line is convenient for calling
Xmath with special startup options, such as the User-Callable Interface
(UCI). (See Xmath Basics for details on the UCI.)
Any of the above methods brings up the Xmath Commands window (see
the Getting Acquainted with the Xmath Commands Window section).
You type commands in the bottom portion of the window (for example,
build to run SystemBuild). Function outputs, environment status, and
error messages are echoed to the messages and log area, the top portion of
the window.
Menu Choices
The menu choices available in the Xmath Commands window combine
Microsoft Windows and Xmath paradigms.
• The Edit menu displays commands for editing the Xmath command
area. Conventional windows selections are Undo, Cut, Copy, and
Paste. Xmath adds Clear Log, Clear Command, and Send Command.
• The View menu is reserved for expansion.
• The Options menu includes a Font menu item that allows you to set any
TrueType font installed on your Windows system to be used in your
Xmath displays. It also has a Format menu item for selecting the
format of numeric values displayed in the Xmath log window.
• The Window menu lets you bring up the Graphics or Palette window
or invoke SystemBuild.
Command Modes
Within the Commands window, there are two modes of operation:
single-line command mode and multiline command mode.
The key sequence <Shift-Return> turns multiline mode on and also toggles
the mode off. In multiline mode, the <Return> key adds a new line rather
than sending the command to Xmath. For example:
for i=1:10 Press <Shift-Return> at the end of the first line to turn
multiline mode on.
Note The above example is not valid for cutting and pasting from online format into
Xmath.
Running Demos
For a tutorial of Xmath’s basic features, see the Xmath Jumpstart section of
Xmath Basics. For an online demo, click in the command area, and then
type:
demo
Note Online Help requires Internet Explorer. (It does not work with Netscape.)
To access a topic, click the title in the Topics Hierarchy pane of the window
shown in Figure 3-2. The topic (MathScript in the figure) appears in the text
window. Use the scroll bar and various buttons and links to navigate from
one topic to another.
Figure 3-3 shows the second online Help window with a portion of the
online Help index on display. Double-click any item to bring up its online
Help topic.
You can also get the index for any particular letter by clicking that letter at
the top of the online Help window shown in Figure 3-2.
Stopping Xmath
• To exit from Xmath, type quit in the command area, or select
File»Exit from the Commands Window menu bar. Xmath prompts you
to save your workspace.
• If you want to stop a function from continuing, type <Ctrl-Break>. Note
that <Ctrl-Break> cannot interrupt a command in communication with
the operating system (load, save); this includes creating and
displaying windows.
• If the above methods do not work, you can enter <Ctrl-Alt-Delete> to
display the Task Manager; then select Xmath Commands and click the
<End Task> button.
In the sections below, inputs are shown in bold Courier. You can find a
description of the action, if applicable, and pertinent Help topics to the right
of each input, preceded by the Xmath comment symbol (#). You can also
see the Xmath Basics for a complete description of each feature used here.
We encourage you to try the examples provided below. You do not need to
type comments. Note that most commands and functions can be shortened
to as few as four characters.
See the Starting Xmath section for information on how to start Xmath.
Creating Data
Creating data is simple. Click in the command area to focus the pointer, and
then enter the following MathScript statements to save the variables
(comments are for your information):
# See "punctuation."
a=[1,2,2^2,3^3] # Define a variable. See "vector" and
"operators."
b=1:.1:5 # See "regular vector."
c=sin(b) # Call a function. See "functions."
We look at the variable later. To find out more, see the online Help topic
Graph Object under Xmath»Plotting.
If you look at the vector topic in the online Help, you see that vectors fall
in the numeric class. Nonnumeric, or complex, objects are strings or
mixtures of strings and numeric objects. Polynomials fall into this category:
d=makepoly(a,"d") # See "makepoly"
e=polynomial(1:3,"d") # See "polynomial"
Some functions accept only certain objects and return others. For example,
char accepts an integer and returns a string:
str=char(65)
For more on PDMs, see pdm and PDM object in online Help. For more on
the plot function, see plot in online Help and Xmath Basics.
Xmath saves all data to a file with the default name [Link] in the
current working directory. (You may want to specify a filename because
[Link] will be overwritten by the next save command.) The first of the
following two commands saves your variables to a file, and the second uses
a wildcard to save a subset of variables to a different file.
save "[Link]"
save "try_2.xmd" g* sys
You can use the Xmath operating system command oscmd to list the files
you saved:
oscmd("dir try*.*")
Retrieve the second file you saved and use the function who to list the
variables that you have:
load "try_2"
who
Graphics
Let’s use the variable sys again:
nyquist(sys)?
You now have three graph objects. You can display them similar to any
variable:
graph1
graph2
graph3
Printing Graphs
You can print the graph currently displayed in the Graphics window in one
of two ways:
• In the Graphics window, select File»Print and fill in the resulting
dialog.
• Type
hardcopy {color=0}
in the Commands window command area. The setting color=0
ensures that you receive a black and white rather than a color plot,
which is the default.
Note To use the hardcopy command to print directly, the environment variable
%XMATH_PRINT% must be defined. Check Control Panel»System and examine the
environment variables. If you need further help, see the Xmath Basics manual.
Alternatively, you can save your graphics to a .ps file and then submit the
file to the printer with a standard command. For example:
hardcopy graph3, file="[Link]", {color=0}
Using MathScript
MathScript, the language of Xmath, defines statements, constructs,
punctuation, functions (MSFs), commands (MSCs), and operators (MSOs).
You can use MathScript to create your own functions and commands. Open
a text editor, and create a file named [Link] (.msf corresponds to
MathScript function), with the contents shown in EXAMPLE 3-1: [Link].
else
error("positive integers only; try again","C")
endif
endfunction
Save your file in the current directory for Xmath, and return to Xmath.
Try calling cdown with good and bad inputs:
cdown(5)
cdown(2.2)
The debugger sets a break at the first line of executable code—in this case,
line 6. Now that a break point is set, let’s try the debugger:
cdown(2)
Look at the difference in the status bar at the bottom of the Xmath window.
You are now in debug mode, and the function that you are debugging
shows on the right side. You can step through the code and examine local
or global variables. Type next to continue until you reach the first line of
the loop. To watch the variable i, type:
set watch i
Continue to type next. Note that you travel through the for loop two times,
and the debugger notifies you when i is incremented.
You can examine variables local to the function. In the command area, type:
who
i?
When you fall out of the loop, type next, or go to run the function through
to the end. Figure 3-4 shows a debugging session similar to what you have
done.
While you are working through this chapter, remember that additional
sources of information are available to you. The SystemBuild User’s Guide
covers the SystemBuild Editor and Simulator in detail, including several
chapters on special SystemBuild topics. The extensive SystemBuild block
library and other technical subjects are covered in the SystemBuild online
Help.
Introduction to SystemBuild
This section introduces you to some of the SystemBuild tools and
functions. For additional information about specific features, see the
SystemBuild User’s Guide or the SystemBuild online Help.
Key Terms
Table 4-1 provides key terms and their definitions. These terms are used
throughout this guide and in other SystemBuild documentation.
Term Definition
SuperBlock The basic hierarchical object in SystemBuild,
which serves as a container blocks and defines
the environment in which they operate.
Block The basic functional element of SystemBuild.
A set of blocks are used to model a control or
real-time system.
Term Definition
Internal Connection Signals and data are passed between blocks
using connections that appear as lines in the
diagram within the Editor window. Internal
connections pass data between blocks within
the same SuperBlock.
External Connection Connections between the SuperBlocks of a
model and between the SuperBlocks and the
outside world.
For a guide to other terms, concepts, and keyboard and mouse actions, see
the SystemBuild User’s Guide.
SystemBuild Editor
The SystemBuild Editor (also known as the Editor window or Editor)
offers a user-friendly graphical model design/programming environment,
which allows you to construct continuous-time, discrete-time, and hybrid
systems of arbitrary complexity. You use the Editor window (see
Figure 4-2) to edit the contents of your model.
SystemBuild Simulator
The SystemBuild Simulator provides a means of simulating your block
diagram model under user-defined conditions. The Simulator provides
flexibility in algorithms for integration, data input methods, model timing,
and other areas. Both interactive and noninteractive simulation interfaces
are provided for maximum utility.
Simulation in an interactive mode lets you interact with the model and
monitor outputs of your blocks during simulation. You can debug your
models with interactive capabilities such as block stepping or time
stepping.
You can also change the values of block parameters during simulation by
using the Run-Time Variable Editor (RVE).
Additional Functions
SystemBuild has a large number of additional functions that are not
covered in this brief introduction. For example, the lin function performs
linearization of single-rate and multi-rate models, and the trim function
finds the trimmed input, state, and output values for equilibrium points of
a system.
The text editor for other tabs is controlled by the environment variable
%EDIT_COMMENT%; if you want to change the default editor, change the
environment variable.
You must restart Xmath before the new editor becomes available.
Starting SystemBuild
To start SystemBuild:
1. If you have not already started Xmath, select
Start»Programs»MATRIXx version, or enter the following
command from the Run dialog or Command Prompt window:
ISIHOME\bin\xmath
where ISIHOME is the location of the MATRIXx installation
directory (see the Starting Xmath section of Chapter 3, Xmath).
Note You can also double-click on the Xmath icon as described in he Starting Xmath
section of Chapter 3, Xmath.
2. When Xmath comes up, type the following in the command area of the
Xmath Commands window:
build
After a short time, SystemBuild is loaded; the Catalog Browser comes
on view and the Editor window is iconized.
Exiting SystemBuild
To exit SystemBuild:
1. Select File»Exit from the Catalog Browser.
2. SystemBuild asks if you want to save your work before exiting; if you
answer yes, the Save As dialog appears.
Note You might want to move your windows around so that both are visible.
Figure 4-6. Placing a New Block in a SuperBlock Using the Palette Browser
Note You can only load a model file from the Catalog Browser or Xmath.
Note The Xmath command line is the only place that can recognize environment
variables. For the other methods that follow, you must know the full pathname of the
SystemBuild directory. Note also that Xmath commands themselves use $env_var whereas
commands that go directly to the operating system, such as oscmd, use %env_var%.
Figure 4-8. Load File Dialog Available from the Xmath Commands Window
Note In this dialog, the default file types include all the standard extensions for catalog
files.
Note The default settings in this Load dialog include no Xmath data.
After the load completes, the Catalog Browser lists the contents of the
model (see Figure 4-7).
Note If you performed the simulation from the Xmath command line above and haven’t
deleted the variables, you can start at step 5.
Deleting a SuperBlock
Deleting a SuperBlock is an easy process. From the Catalog Browser
(either pane, provided the SuperBlock names appear), select a SuperBlock.
Then select Edit»Delete.
Before we get started, we need to start fresh. So, delete all of the
SuperBlocks you may have created, or just exit the Catalog Browser
(File»Exit), and then restart SystemBuild.
Next, load a model with some hierarchy in it. Following the instructions in
the Loading a Model File section, load the following file:
SYSBLD\demo\f14_demo\[Link]
Note This section does not simulate this model. If you are interested in this model, from
the Xmath command line, type demo, and then follow the subsequent dialogs to select the
SystemBuild demos.
After the f14 model is loaded, the Catalog Browser displays only the types
of catalog objects (SuperBlocks, State Diagrams, and so forth) in the left
pane (see Figure 4-13). Notice that the folder icon next to SuperBlocks is
open, indicating that the SuperBlocks are listed in the right pane.
Notice the expand/collapse indicator for the SuperBlocks folder in the left
pane. The indicator displays a plus (+), indicating that the folder is
collapsed.
3. To move down the hierarchy in the Editor window, select the desired
SuperBlock; then select Edit»Open.
The Editor now displays the selected SuperBlock.
SystemBuild Tutorial
Now that you have a basic understanding of Xmath and SystemBuild, you
are ready to build and simulate a model. This section presents a basic
tutorial to take you through the basic process from model conception to
model simulation.
In this tutorial, you build a simple spring-mass damper model and then
simulate it. This model has the following equations:
·· ·
F ( t ) = mx + cx + kx (4-1)
x → x1
·
x → x2
·
x 1 = x2
· 1
x 2 = ---- [ F ( t ) – cx 2 – kx 1 ]
m
Creating a SuperBlock
To create a new SuperBlock called simple.
1. Start Xmath as described in the Starting Xmath section of Chapter 3,
Xmath.
2. To invoke SystemBuild, at the Xmath command line, enter the
following command:
build
The SystemBuild Catalog Browser loads. If necessary, click on the bar
at the top of the window to move it to the front of the display.
3. In the Catalog Browser, create a new SuperBlock by clicking the New
SuperBlock toolbar button or selecting File»New»SuperBlock.
The SuperBlock Properties dialog appears (see Figure 4-16). Initially,
the Attributes tab is active in the dialog, and all of the properties of a
SuperBlock are set to their default values.
e. Click the Display tab (see Figure 4-19), and enable the Show
Output Labels check box.
Note The gain block is directed left to right. For a better layout of the diagram, we can
change its direction to be right to left. This is often needed on feedback paths in block
diagrams.
Palette Code
Name Block Type Parameters Tab Outputs Tab Display Tab Tab
Algebraic Gain (flip) Name: damping Output label: Show Output —
Gain %Var: c damping Labels: enabled
force
Algebraic Gain (flip) Name: stiffness Output label: Show Output —
Gain %Var: k spring force Labels: enabled
After creating all of those blocks, arrange your diagram so that it looks like
Figure 4-20. Note that the block IDs may be different, and that is expected.
Connecting Blocks
Connecting the blocks completes the process of building a SystemBuild
model. This section assumes you have successfully created the blocks in
the diagram and that your diagram looks like Figure 4-20.
In the Connection Editor, the FROM or source block (the ID of the first
block you clicked on) appears on the left side of the window while the
TO or destination block (the ID of the second block you clicked on)
appears on the right side.
• All of the source block’s outputs as well as all the destination
block’s inputs are listed; the number in each box represents the
channel number of the signal for that block
• Output labels and input names, if any, are displayed.
• The datatype of each signal is abbreviated; in this case F indicates
Float, the default datatype.
3. Click the appropriate channel of the source block and the appropriate
channel of the destination block, and then click Done.
SystemBuild makes the connection using the Add button selection,
which is the default.
4. Continue to connect the blocks as shown in Figure 4-15.
Note When connecting a block with one output to another with one input, SystemBuild
makes the connection automatically without displaying the Connection Editor.
The spring-mass damper model (see Figure 4-15) has one external input
and three external outputs in the tutorial. Figure 4-22 shows some of the
external I/O flags from this model. Notice that there is only one way to
represent an external input connection, while there are two possible ways
Note You can connect a single external input to as many block inputs as needed, but only
one signal can be connected to a single external output in each SuperBlock.
Note When there is only one external input, SystemBuild makes the connection
automatically without the use of the Connection Editor.
Note When there is only one external output, SystemBuild makes the connection
automatically without the use of the Connection Editor.
Note The filename extension of a SystemBuild save file is not predefined, meaning that
you can use any extension you want. Some common extensions include .cat, .sbd, .mdl,
and .dat.
6. Click OK.
After the simulation completes, you should see the results shown in
Figure 4-23.
You can generate code from the Catalog Browser in SystemBuild or use the
auto-code Xmath command. The generated code represents a complete
implementation of the model. The generated code can be targeted for and
run on other computers or an actual controller. The default target is a
stand-alone simulation that you can execute on your computer; you can
then load the results of the simulation back into Xmath for analysis.
Note The Xmath command line is the only place that can recognize environment
variables. For loading with other methods, you must know that full pathname of the
SystemBuild directory. Note also that Xmath commands themselves use $env_var whereas
commands that go directly to the operating system, such as oscmd, use %env_var%.
You can use the Advanced dialog from the AutoCode Code Generation
dialog or use keywords with the autocode Xmath command to customize
the generated code as follows:
• Specifying a template file on the Templates tab allows you to control
the formatting of the output of AutoCode to meet a variety of software
needs; you can modify the overall architecture of generated code,
customize the scheduler, modify data structures and external I/O calls,
add user code, and so forth. Using the Template Programming
Language (TPL), you can tailor any part of the code except the
hierarchy logic and the elementary blocks. Numerous templates are
available, including one to customize the generated code for the
pSOSystem real-time operating system. For more information on
templates, see the Template Programming Language User’s Guide.
• Formatting options (Formatting tab) let you set maximums, such as the
number of significant digits, the length of variable names, and columns
per row. From here, you can also specify indentation between levels,
as well as set a number of other parameters.
• The IALG (Integration Algorithms) Options tab lets you select an
algorithm such as Euler or Runge Kutta.
• The Multi-Processor tab lets you specify a processor, startup,
background, interrupt, skew, priority, or map file.
• The Optimization tab lets you make general, vectorization, and VAR
block settings that affect code size and efficiency (see the Autocode
Reference for details).
• The Miscellaneous tab lets you select an options file, the type of
scheduler, output scope control, and various other settings.
• The RTOS (real-time operating system) Options tab lets you specify a
configuration file and set additional options.
Once you have customized your settings, you click OK in the Advanced
dialog; then you generate code by clicking OK in the Generate Real-Time
Code dialog.
For information about compiling, executing, and using the generated code,
see the AutoCode User’s Guide. For information about autocode
keywords, see the Xmath online Help.
Note The Xmath command line is the only place that can recognize environment
variables. For loading with other methods, you must know that full pathname of the
SystemBuild directory. Note also that Xmath commands themselves use $env_var whereas
commands that go directly to the operating system, such as oscmd, use %env_var%.
See the Directories Defined by Environment Variables section of Chapter 3, Xmath, for
additional information.)
5. Choose a directory, and enter a name in the File name field or accept the
default, Discrete_Cruise_System.
6. Click OK to start the document generation process.
7. Raise the Xmath Commands window to monitor the progress of the
documentation generation.
8. Once the document generation is complete, look for a statement
similar to the following in the Xmath Log window:
Documentation generation complete.
Document generated and saved in file:
your_directory\Discrete_Cruise_System.doc.
Note The .doc file is in ASCII format. The current defaults also produce [Link] file,
which contains Microsoft Word markup commands.
Unlike AutoCode, DocumentIt does not have a dialog box for advanced
features.
*****************************************************************
Number of DataStores in this model = 1
---------------------------------------------------------
DataStore Desired Speed (#0)
---------------------------------------------------------
Description :
No. of Registers = 1
No. of Inputs = 1
No. of Outputs = 1
Name DataType UoM Limit/Range Accuracy
set speed DOUBLE 0.0-0.0 0.0
*****************************************************************
Number of SuperBlocks inputs this model = 6
SUPERBLOCK[0] = Discrete Cruise System
SUPERBLOCK[1] = Cruise Control System
SUPERBLOCK[2] = Set Speed
SUPERBLOCK[3] = Controller Logic
SUPERBLOCK[4] = mux3
SUPERBLOCK[5] = continuous automobile
Number of Unique SuperBlocks inputs this model = 6
SUPERBLOCK[0] = 0
SUPERBLOCK[1] = 1
SUPERBLOCK[2] = 2
SUPERBLOCK[3] = 3
SUPERBLOCK[4] = 4
SUPERBLOCK[5] = 5
---------------------------------------------------------
Top Level SuperBlock model is Discrete Cruise System
---------------------------------------------------------
LEVEL = 0
NUM_SB_IN_I = 6
NUM_SB_OUT_I = 3
SB_FREQ_R = 50.0
SB_SAMPLE_R = 0.02
SB_SKEW_R = 0.0
SB_ACTV_SIG_S = Parent
SB_OUT_POST_S =
SB_ATTR_S = Discrete
SB_HAS_IN_B = 1
SB_HAS_IN_DATA_B = 1
SB_IS_DSCR_B = 1
SB_IS_TRIG_B = 0
External Data Elements
----------------------
Discrete Cruise System External Inputs
------------------------------------------
ID Desc DType UoM Limit/Range Accuracy
set DOUBLE 0.0-0.0 0.0
resume DOUBLE 0.0-0.0 0.0
disengage DOUBLE 0.0-0.0 0.0
brake DOUBLE 0.0-0.0 0.0
manual throttle DOUBLE 0.0-0.0 0.0
incline DOUBLE 0.0-0.0 0.0
Discrete Cruise System External Outputs
------------------------------------------
ID Desc DType UoM Limit/Range Accuracy
Cruise Control On LOGICAL 0.0-0.0 0.0
throttle DOUBLE 0.0-0.0 0.0
auto speed DOUBLE 0.0-0.0 0.0
Internal Data Elements
----------------------
LEVEL = 1
Cruise Control System Inputs
---------------------------------
ID Desc DType UoM Limit/Range Accuracy
set DOUBLE 0.0-0.0 0.0
resume DOUBLE 0.0-0.0 0.0
disengage DOUBLE 0.0-0.0 0.0
If you searched [Link] and could not find the answers you need, contact
your local office or NI corporate headquarters. Phone numbers for our
worldwide offices are listed at the front of this manual. You also can visit
the Worldwide Offices section of [Link]/niglobal to access the branch
office Web sites, which provide up-to-date contact information, support
phone numbers, email addresses, and current events.