User’s GuideVersion 2For Use with Real-Time Workshop®Real-Time Windows Target
1 Getting Started1-2What Is the Real-Time Windows Target?The Real-Time Windows Target is a PC solution for prototyping and testing real-time systems.
4 Advanced Procedures4-2I/O BoardsTypically I/O boards are preset from the factory for certain base addresses, voltage levels, and unipolar or bipolar
I/O Boards4-3After you add an I/O driver block to your Simulink model, you can select and configure the I/O board installed in your computer. This pro
4 Advanced Procedures4-44 Click the Test button.The Real-Time Windows Target tries to connect to the selected board, and if successful, displays the f
I/O Boards4-5PCI Bus BoardYou do not have to set a base address with a PCI board. The plug-and-play feature of Microsoft Windows assigns a PCI slot nu
4 Advanced Procedures4-6We recommend that before you use a PCI or PCMCIA board, you install the drivers supplied by the board manufacturer. The Real-T
I/O Driver Blocks4-7I/O Driver BlocksThe Analog Input, Analog Output, Digital Input, Digital Output, Counter Input, and Encoder Input blocks provide a
4 Advanced Procedures4-8After you create a Simulink model, you can add an I/O block. This procedure adds an Analog Input block and uses the Simulink m
I/O Driver Blocks4-92 Click and drag the Analog Input block to your Simulink model. Remove the Signal Generator block and connect the Analog Input blo
4 Advanced Procedures4-102 In the left column, double-click Real-Time Windows Target. Click and drag the Analog Input block to your Simulink model. Re
I/O Driver Blocks4-113 In the Input channels box, enter a channel vector that selects the analog input channels you are using on this board. The vecto
What Is the Real-Time Windows Target?1-3Expected UserTo benefit from reading this book, you should be familiar with• Using Simulink and Stateflow to c
4 Advanced Procedures4-126 Select one of the following:- Click the Apply button to apply the changes to your model and leave the dialog box open.- Cli
I/O Driver Blocks4-132 In the Sample time box, enter the same value you entered in the Fixed step size box from the Configuration Parameters dialog bo
4 Advanced Procedures4-147 Enter a final value for each analog channel you entered in the Output channels box. For example, if you entered [1,2] in th
I/O Driver Blocks4-15Digital Input BlockThe Real-Time Windows Target I/O blocks allow you to select and connect specific digital lines or digital chan
4 Advanced Procedures4-164 From the Channel mode list, choose one of the following options:-Bit — Returns a value of 0 or 1.-Byte — Groups eight digit
I/O Driver Blocks4-17After you have added a Digital Output block to your Simulink model, you can enter the parameters for this I/O driver. This proced
4 Advanced Procedures4-185 Enter the initial values for each digital output line or channel you entered in the Output channels box. For example, if yo
I/O Driver Blocks4-19If you chose Bit, your dialog box will look similar to the figure shown below.7 Do one of the following:- Click Apply to apply th
4 Advanced Procedures4-201 Double-click the Counter Input block.The Block Parameters: Counter Input dialog box opens.2 In the Sample time box, enter t
I/O Driver Blocks4-215 From Clock input active edge, which determines which clock edge should increment the counter, select-rising — Low to high trans
1 Getting Started1-4FeaturesThe Real-Time Windows Target software environment includes many features to help you prototype and test real-time applicat
4 Advanced Procedures4-22- latch & reset on falling edge — The count of the counter is remembered and then the counter is reset when high to low t
I/O Driver Blocks4-23- double — Counts the rising edges from both stripe sets-single — Counts the rising edges from one stripe set-quadruple — Counts
4 Advanced Procedures4-24Output Signals from an I/O BlockI/O driver blocks output multiple signals as a vector instead of individual channels or lines
I/O Driver Blocks4-255 Finish making connections and selecting display options.- Connect the Analog Input block to the Demux block input. - Connect ea
4 Advanced Procedures4-26Variations with Channel SelectionFor a better understanding of how to specify device settings when using both analog and digi
I/O Driver Blocks4-27Input vector with single-ended analog — Now, assume your DAS-1601 board is configured to be single-ended analog input. In this ca
4 Advanced Procedures4-28This illustration shows the block implementation.Depending on the board and the number of channels used, I/O conversion time
Using Analog I/O Drivers4-29Using Analog I/O DriversControl systems have unique requirements for I/O devices that the Real-Time Windows Target support
4 Advanced Procedures4-30Normalized Scaling for Analog InputsThe Real-Time Windows Target allows you to normalize I/O signals internal to the block di
Using Analog I/O Drivers4-31In your block diagram, you can do this as follows.0 to +5 Volts and Normalized UnipolarFrom the Input range list, choose 0
Features1-5• Scheduler — The timer interrupt clocks a simple scheduler that runs the executable. The number of tasks is equal to the number of samplin
4 Advanced Procedures4-32In your block diagram, you can do this as follows.-10 to +10 Volts and Normalized UnipolarFrom the Input range list, choose -
Using Analog I/O Drivers4-33A voltage range on the D/A converter is set to -10 to +10 volts, and the Block input signal is chosen as Normalized bipola
4 Advanced Procedures4-34
5TroubleshootingSolutions have been worked out for some common errors and problems that can occur when you are using the Real-Time Windows Target.Bui
5 Troubleshooting5-2Building Older ModelsIf you are building an older model for Real-Time Windows Target, you might get a message like the following:&
Plots Not Visible in Simulink Scope Block5-3Plots Not Visible in Simulink Scope BlockFor data to plot correctly in a Simulink Scope block, you must sp
5 Troubleshooting5-4Failure to Connect to TargetPossible Problem — When trying to connect to the target, the Simulation Errors dialog box displays Che
Sample Time Too Fast5-5Sample Time Too FastDuring a run, you might not see any output in the Scope window. This could indicate that the sample time is
5 Troubleshooting5-6S-Functions Using Math FunctionsPossible problem — When you create your own S-functions that include math functions, the S-functio
ASupported I/O Boards ReferenceThe Real-Time Windows Target includes support for more than 200 I/O boards. Multiple boards can be used as I/O for a m
1 Getting Started1-6• Relation to the kernel — The executable must be loaded and executed directly by the Real-Time Windows Target kernel. It cannot b
A Supported I/O Boards ReferenceA-2IntroductionThis appendix includes the following topics:• “ISA Bus” on page A-2• “PCMCIA Bus” on page A-10• “PCI Bu
IntroductionA-3PCL-714PCL-722PCL-724PCL-725PCL-726PCL-727PCL-728PCL-730PCL-731PCL-733PCL-734PCL-735PCL-812PCL-812PGPCL-814BPCL-816PCL-818PCL-818HPCL-8
A Supported I/O Boards ReferenceA-4Analog Devices RTI-800RTI-815Axiom AX5032IOAX5064IAX50640AX5215HAX5244HAX5412-HAX5412-LAX5611C-HAX5611C-LData Trans
IntroductionA-5Humusoft AD512MC101-CE150MF604Intelligent Instrumentation PCI-20377WKeithley-Metrabyte ADC-16DAC-02DAS-1201DAS-1202DAS-1401DAS-1402DAS-
A Supported I/O Boards ReferenceA-6PIO-32INPIO-32IOPIO-32OUTPIO-96PIO-HVREL-16Measurement Computing CIO-DAC02CIO-DAC02/16CIO-DAC08CIO-DAC08/16CIO-DAC1
IntroductionA-7CIO-DAS08-PGLCIO-DAS08-PGMCIO-DAS-1401/12CIO-DAS-1402/12CIO-DAS-1402/16CIO-DAS16CIO-DAS16/330CIO-DAS16/FCIO-DAS16/JrCIO-DAS16Jr/16CIO-D
A Supported I/O Boards ReferenceA-8CIO-DIO24CIO-DIO24HCIO-DIO48CIO-DIO48HCIO-DIO96CIO-DIO192CIO-DISO48CIO-DO24DDCIO-DO48DDCIO-DO48HCIO-DO96HCIO-DO192H
IntroductionA-9National Instruments AT-MIO-16E-1AT-MIO-16E-2AT-MIO-64E-3AT-MIO-16E-10AT-MIO-16DE-10AT-AI-16XE-10AT-MIO-16XE-10AT-MIO-16XE-50Lab-PCLab-
A Supported I/O Boards ReferenceA-10PCMCIA BusThis table lists the PCMCIA bus I/O boards supported by the Real-Time Windows Target.PCMCIA Bus Supporte
IntroductionA-11PCI BusThis table lists the PCI bus I/O boards supported by the Real-Time Windows Target.DAQCard-AI-16XE-50DAQCard-DIO-24PCI Bus Suppo
Features1-7For more information, see “Signal Logging to the MATLAB Workspace” on page 3-30 and “Signal Logging to a Disk Drive” on page 3-38.Parameter
A Supported I/O Boards ReferenceA-12Measurement Computing PCI-DAS08 PCI-DAS1000PCI-DAS1001PCI-DAS1002 PCI-DAS1200PCI-DAS1200/JrPCI-DAS1602/12PCI-DAS16
IntroductionA-13PCI-6023EPCI-6024EPCI-6025EPCI-6031EPCI-6032EPCI-6033EPCI-6034EPCI-6035EPCI-6036EPCI-6052EPCI-6071EPCI-6703PCI-6704PCI-MIO-16E-1PCI-MI
A Supported I/O Boards ReferenceA-14Compact PCIThis table lists the compact PCI I/O boards supported by the Real-Time Windows Target.PXI BusThis table
IntroductionA-15PC/104 BusThis table lists PC/104 bus I/O devices supported by the Real-Time Windows Target.PC/104 Bus Supported I/O Boards Manufactur
A Supported I/O Boards ReferenceA-16Standard DevicesThis table lists standard I/O devices supported by the Real-Time Windows Target.Standard Supported
BCustom I/O Driver Blocks ReferenceCustom I/O device drivers can be used in combination with the Real-Time Windows Target. We do not recommend using
B Custom I/O Driver Blocks ReferenceB-2I/O Register Access from S-Functions LimitationFor Windows NT, Windows 2000, and Windows XP, drivers can access
I/O Register Access from S-Functions LimitationB-3Incompatibility with Win32 API CallsThe Real-Time Windows Target kernel intercepts the interrupt fro
B Custom I/O Driver Blocks ReferenceB-4Unsupported C FunctionsIf you create your own custom I/O driver blocks, you should first check for C functions
Unsupported C FunctionsB-5Supported C FunctionsYou can use ANSI C functions that do not use the Windows operating system in your custom blocks or I/O
1 Getting Started1-8Hardware EnvironmentThe hardware environment consists of a PC-compatible computer and I/O boards.This section includes the followi
B Custom I/O Driver Blocks ReferenceB-6
Index-1IndexAaddingAnalog Input block 4-7I/O driver blocks 4-7input blocks 4-7analog inputnormalized scaling 4-30Analog Input blockconfiguring 4-10Ana
IndexIndex-2Demux blockseparating I/O signals 4-24descriptionSimulink external mode 1-12device driverschannel selection 4-26custom I/O 4-33writing cus
IndexIndex-3system target 2-11system target file 2-12template makefile 2-12working directory 2-11Fixed-Point Blocksetcompatible software 1-4Hhardwares
IndexIndex-4Llicensesgetting or updating 2-8system requirements 2-8listsupported I/O boards A-1loggingdata to disk drive 3-44data to workspace 3-30Mma
IndexIndex-5plottinglogged data from disk 3-46logged data from workspace 3-35Rreal-timecontrol 1-2execution 1-10hardware-in-the-loop 1-2signal process
IndexIndex-6settinginitial working directory 2-13working directory 2-13signal and triggeringentering properties 3-32properties 3-41signal archivingSee
IndexIndex-7supported I/O boardscompact PCI bus A-14ISA bus A-2list A-1PC/104 bus A-15PCI bus A-11PCMCIA bus A-10PXI bus A-14system conceptsdata buffe
IndexIndex-8
Hardware Environment1-9I/O driver block library — The Real-Time Windows Target provides a custom Simulink block library. The I/O driver block library
1 Getting Started1-10Software EnvironmentThe software environment is a place to design, build, and test an application in nonreal time and real time.T
Software Environment1-11Real-time execution — The Real-Time Windows Target provides the necessary software that uses the real-time resources on your c
How to Contact The MathWorks:www.mathworks.com Webcomp.soft-sys.matlab [email protected] Technical [email protected] Product
1 Getting Started1-12System ConceptsA more detailed understanding of Real-Time Workshop and the Real-Time Windows Target can help you when creating an
System Concepts1-13Data Buffers and Transferring DataAt each sample interval of the real-time application, Simulink stores contiguous data points in m
1 Getting Started1-14
2Installation and ConfigurationThe Real-Time Windows Target requires the installation of MATLAB, Simulink, Real-Time Workshop, and the Real-Time Wind
2 Installation and Configuration2-2Required ProductsThe Real-Time Windows Target is a self-targeting system where the host and the target computer are
Required Products2-3SimulinkSimulink provides an environment where you model your physical system and controller as a block diagram. You create the bl
2 Installation and Configuration2-4Real-Time WorkshopReal-Time Workshop provides the utilities to convert your Simulink models into C code, and then,
Related Products2-5Related ProductsThe MathWorks provides several products that are especially relevant to the kinds of tasks you can perform with the
2 Installation and Configuration2-6System RequirementsThe Real-Time Windows Target requires a PC-compatible computer.This section includes the followi
System Requirements2-7Software RequirementsThe Real-Time Windows Target 2.5 has certain product prerequisites that must be met for proper installation
iContents1Getting StartedWhat Is the Real-Time Windows Target? . . . . . . . . . . . . . . . . 1-2Expected User . . . . . . . . . . . . . . . . .
2 Installation and Configuration2-8Real-Time Windows TargetThe Real-Time Windows Target (Version 2.5) is available on CD or as a Web downloadable.If y
Real-Time Windows Target2-9Installing from a CDReal-Time Windows Target (Version 2.5) is distributed on the MathWorks Release 14 CD with the general i
2 Installation and Configuration2-103 Under Access Login Users, select download products.The Access Login page opens.4 Enter your E-mail Address and P
Real-Time Windows Target2-11Files on Your ComputerWhen using the Real-Time Windows Target, you may find it helpful to know where files are located:• M
2 Installation and Configuration2-12The Real-Time Windows Target provides files to help Real-Time Workshop generate C code from your Simulink model an
Initial Working Directory2-13Initial Working DirectorySet your MATLAB working directory outside the MATLAB root directory. The default MATLAB root dir
2 Installation and Configuration2-14Real-Time Windows Target KernelA key component of the Real-Time Windows Target is a real-time kernel that interfac
Real-Time Windows Target Kernel2-153 Check that the kernel was correctly installed. TypertwhoMATLAB should display a message similar toReal-Time Windo
2 Installation and Configuration2-16Uninstalling the KernelIf you encounter any problems with the Real-Time Windows Target, you can uninstall the kern
Real-Time Windows Target Kernel2-17To uninstall the kernel, click the MATLAB Start button, and select Simulink->Real-Time Windows Target->Uninst
ii ContentsSystem Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6Hardware Requirements . . . . . . . . . . . .
2 Installation and Configuration2-18Testing the InstallationThe Real-Time Widows Target includes several demo models. You can use one of the demo mode
Testing the Installation2-19The Simulink model rtvdp.mdl window opens.2 From the Tools menu, point to Real-Time Workshop, and then click Build Model.
2 Installation and Configuration2-204 From Simulation menu, click Start Real-Time Code.The Scope window displays the output signals. If your Scope win
Testing the Installation2-21Displaying Status InformationThe Real-Time Windows Target provides the command rtwho for accessing the kernel and displayi
2 Installation and Configuration2-22Detecting Excessive Sample RatesIf your specified sample rate is too fast, the Real-Time Windows Target detects an
Testing the Installation2-232 Double-click a demo block to open the model.
2 Installation and Configuration2-24
3Basic ProceduresThe basic procedures explain how to create a Simulink or real-time application, and how to run a simulation or execution.Simulink Mo
3 Basic Procedures3-2Simulink ModelA Simulink model is a graphical representation of your physical system. You create a Simulink model for a non-real-
Simulink Model3-3An empty Simulink window opens. With the toolbar and status bar disabled, the window looks like the following.3 In the Simulink Libra
iiiReal-Time Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15Entering Simulation Parameters for Real-Time Workshop
3 Basic Procedures3-45 Double-click the Transfer Fcn block. The Block Parameters dialog box opens. In the Numerator text box, enter[10000]In the Denom
Simulink Model3-51In the Frequency text box, enter20From the Units list, select rad/sec.Your Block Parameters dialog box will look similar to the figu
3 Basic Procedures3-69 From the File menu, click Save As. The Save As dialog box opens. In the File name text box, enter a filename for your Simulink
Simulink Model3-71 In the Simulink window, and from the Simulation menu, click Configuration Parameters. In the Configuration Parameters dialog box, c
3 Basic Procedures3-8Your Solver pane will look similar to the figure shown below.7 Do one of the following:- Click Apply to apply the changes to your
Simulink Model3-9Entering Scope Parameters for Signal TracingYou enter or change scope parameters to specify the x-axis and y-axis in a Scope window.
3 Basic Procedures3-104 Do one of the following:- Click Apply to apply the changes to your model and leave the dialog box open.- Click OK to apply the
Simulink Model3-116 From the pop-up menu, click Axes Properties.7 The Scope properties: axis 1 dialog box opens. In the Y-min and Y-max text boxes, en
3 Basic Procedures3-12Simulink runs the simulation and plots the signal data in the Scope window.During the simulation, the Scope window displays the
Simulink Model3-133 Do one of the following:- Let the simulation run to the stop time.- From the Simulation menu, click Stop. The simulation stops. MA
iv ContentsI/O Driver Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7Real-Time Windows Target Library . . . .
3 Basic Procedures3-14See “Creating a Real-Time Application” on page 3-21 for a description of how to build your Real-Time Windows Target application.
Real-Time Application3-15Real-Time ApplicationYou create a real-time application to let your system run while synchronized to a real-time clock. This
3 Basic Procedures3-163 From the Device type list, choose 32-bit Real-Time Windows Target.1 Click the Real-Time Workshop node.The Real-Time Workshop p
Real-Time Application3-17Although not visible in the Real-Time Workshop pane, the external target interface MEX file rtwinext is also configured after
3 Basic Procedures3-18Entering Scope Parameters for Signal TracingYou enter or change scope parameters to format the x-axis and y-axis in a Scope wind
Real-Time Application3-194 Do one of the following:- Click Apply to apply the changes to your model and leave the dialog box open.- Click OK to apply
3 Basic Procedures3-206 In the Y-min and Y-max text boxes enter the range for the y-axis in the Scope window. For example, enter -2 and 2.7 Do one of
Real-Time Application3-21Creating a Real-Time ApplicationReal-Time Workshop generates C code from your Simulink model, then the Open Watcom C/C++ comp
3 Basic Procedures3-22Entering Additional Scope Parameters for Signal TracingSimulink external mode connects your Simulink model to your real-time app
Real-Time Application3-234 Click OK.5 In the Simulation window, and from the Tools menu, click External Mode Control Panel.The External Mode Control P
vASupported I/O Boards ReferenceIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2ISA Bus . . . . .
3 Basic Procedures3-246 Click the Signal & Triggering button.The External Signal & Triggering dialog box opens.7 Select the Select all check b
Real-Time Application3-2510 Do one of the following:- Click Apply to apply the changes to your model and leave the dialog box open.- Click Close to ap
3 Basic Procedures3-26Running a Real-Time ApplicationYou run your real-time application to observe the behavior of your model in real time with the ge
Real-Time Application3-272 In the Simulation window, and from the Simulation menu, click Start Real-Time Code. You can also start the execution from t
3 Basic Procedures3-283 Do one of the following:- Let the execution run until it reaches the stop time.- From the Simulation menu, click Stop Real-tim
Real-Time Application3-29Running a Real-Time Application from the MATLAB Command LineYou can use the MATLAB command-line interface as an alternative t
3 Basic Procedures3-30Signal Logging to the MATLAB WorkspaceSignal logging is the process of saving (logging) data to a variable in your MATLAB worksp
Signal Logging to the MATLAB Workspace3-312 On the toolbar, click the Parameters button.A Scope parameters dialog box opens.3 Click the Data history t
3 Basic Procedures3-327 Do one of the following:- Click Apply to apply the changes to your model and leave the dialog box open.- Click OK to apply the
Signal Logging to the MATLAB Workspace3-33After you create a Simulink model and add a Scope block, you can enter the signal and triggering properties
vi Contents
3 Basic Procedures3-34The Duration value specifies the number of contiguous points of data to be collected in each buffer of data. We recommend that y
Signal Logging to the MATLAB Workspace3-355 Do one of the following:- Click Apply to apply the changes to your model and leave the dialog box open.- C
3 Basic Procedures3-36MATLAB lists the structure of the variable ScopeData.signals. This structure contains one or more vectors of signal data dependi
Signal Logging to the MATLAB Workspace3-373 The variable ScopeData is not automatically saved to your hard disk. To save the variable ScopeData, types
3 Basic Procedures3-38Signal Logging to a Disk DriveSignal logging is the process of saving (logging) data to a variable in your MATLAB workspace and
Signal Logging to a Disk Drive3-391 In the Simulink window, double-click the Scope block.A Scope window opens.2 On the toolbar, click the Parameters b
3 Basic Procedures3-40The Scope parameters dialog box is related to the Data Archiving dialog box. In the Scope parameters dialog box, you must select
Signal Logging to a Disk Drive3-417 Do one of the following:- Click Apply to apply the changes to your model and leave the dialog box open.- Click OK
3 Basic Procedures3-424 In the Duration box, enter the number of sample points in a data buffer. For example, if you have a sample rate of 1000 sample
Signal Logging to a Disk Drive3-435 Do one of the following:- Click Apply to apply the changes to your model and leave the dialog box open.- Click Clo
1Getting StartedThe Real-Time Windows Target has many features. An introduction to these features and the Real-Time Windows Target software environme
3 Basic Procedures3-44Entering Data Archiving ParametersThe Data Archiving dialog box is related to the Scope parameters dialog box. In the Scope para
Signal Logging to a Disk Drive3-452 Click the Data archiving button.The External Data Archiving dialog box opens. This dialog box allows you to specif
3 Basic Procedures3-466 Select the Append file suffix to variable names check box.Within each MAT-file, a variable is saved with the same name you ent
Signal Logging to a Disk Drive3-471 In the MATLAB window, typeScopeDataMATLAB lists the structure of the variable ScopeData. The variable ScopeData is
3 Basic Procedures3-48
Parameter Tuning3-49Parameter TuningSimulink external mode connects your Simulink model to your real-time application. The block diagram becomes a gra
3 Basic Procedures3-50Changing Model ParametersYou must use Simulink external mode to change model parameters. While external mode is running, you can
Parameter Tuning3-513 In the Denominator box, change 70 to 30. Click OK. The effect of changing a block parameter is shown in the Scope window.
3 Basic Procedures3-52
4Advanced ProceduresThe Real-Time Windows Target provides driver blocks for more than 200 I/O boards. These driver blocks connect the physical world
Komentarze do niniejszej Instrukcji