MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Betriebsanweisung

Stöbern Sie online oder laden Sie Betriebsanweisung nach Software MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER herunter. MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER User`s guide [en] Benutzerhandbuch

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 386
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen

Inhaltsverzeichnis

Seite 1 - Real-Time Workshop

ModelingSimulationImplementationReal-Time Workshop® For Use with SIMULINK ®User’s GuideVersion 3

Seite 2 - How to Contact The MathWorks:

viiiExecutingModelsinReal-Time ... 7-9MultitaskingOperation... 7-10SingletaskingOperation ...

Seite 3

3 Code Generation and the Build Process3-18Online Help. Placing your mouse over any of these field names or check boxesactivates a Help facility that

Seite 4

The Real-Time Workshop User Interface3-19The RTW Tunable Parameters dialog box supports the following features:• Parameter tuning — de-inline any mode

Seite 5

3 Code Generation and the Build Process3-20your Simulink model; then select Signal Properties under the Edit menu ofyour model. This opens theSignal P

Seite 6

The Real-Time Workshop User Interface3-21- Imported Extern — declares the signal as extern. It must then be declaredfrom outside the generated code.-

Seite 7

3 Code Generation and the Build Process3-22Configuring the Generated CodeAs an alternative to using the Code Generation Options dialog box, you cancon

Seite 8

Template Makefiles3-23Template MakefilesThis section contains a description of how to work with and modify thetemplate makefiles that are used with th

Seite 9

3 Code Generation and the Build Process3-24|>MEXEXT<|MEX-file extension. See the MATLABmexext command.|>MODEL_NAME<| Name of the Simulink

Seite 10

Template Makefiles3-25In addition target specific tokens defined via the Real-Time Workshop page oftheSimulation Parameters dialog box are expanded. I

Seite 11

3 Code Generation and the Build Process3-26Typically, build options are specified as a comment at the top of the templatemakefile you are using.You ne

Seite 12 - Targeting Custom Hardware

Template Makefiles3-27then the make command that will be invoked is:mymake −f model.mkHOST— What platform this template makefile is targeted for. This

Seite 13 - Real-Time Workshop Libraries

ixInteractively ... 8-19ConnectingtotheVxWorksTarget ... 8-19DownloadingtheReal-TimeProgram ...

Seite 14 - Contents

3 Code Generation and the Build Process3-28• The third section defines the tokens make_rtw expands.• The fourth section contains themake rules used in

Seite 15 - Real-Time Workshop Ada Coder

Template Makefiles3-29Figure 3-7: Structure of a Template Makefile#-- Section 1: Comments -------------------------------------------------------## D

Seite 16 - Glossary

3 Code Generation and the Build Process3-30Customizing and Creating Template MakefilesTo customize or create a new template makefile, you can copy an

Seite 17 - Foreword

Template Makefiles3-31You can use pattern matching expressions to make the dependency rules moregeneral. For example, using GNU Make you could have re

Seite 18 - Foreword

3 Code Generation and the Build Process3-32Generic Real-Time TemplatesThe Real-Time Workshop includes a set of built-in template makefiles that areset

Seite 19 - What Is MATLAB?

Generic Real-Time Templates3-33• USER_SRCS — Additional user sources, such as files needed by S-functions.For example, suppose you have an S-function

Seite 20 - What Is Simulink?

3 Code Generation and the Build Process3-34• USER_SRCS — Additional user sources, such as files needed by S-functions.For example, suppose you have an

Seite 21 - What Is Stateflow?

Generic Real-Time Templates3-35built with sfcn_lib1.c,andsfcn_lib2.c. (library routines for use withmany S-functions). You can build,my_sfcn.c using:m

Seite 22

3 Code Generation and the Build Process3-36• USER_OBJS — Additional object (.obj) files, which are to be created from usersources, such as files neede

Seite 23 - File menu

Generic Real-Time Templates3-37• OPTS — User-specific options, for example,make_rtw OPTS="−DMYDEFINE=1"• OPT_OPTS — grt_bc.tmf optimization

Seite 24 - Installation

x10Targeting Custom HardwareIntroduction ...10-2Run-Time Interface ...1

Seite 25 - System,gototheEnvironment

3 Code Generation and the Build Process3-38File and Function SplittingTo support compilers with file size limitations, the Real-Time Workshopprovides

Seite 26

File and Function Splitting3-39You must turn off the TLC variable ShowEliminatedStatements for filesplitting to work. This is required because the#if

Seite 27 - Where to Go from Here

3 Code Generation and the Build Process3-40Function SplittingSometimes a file may not be too large, but a single function contained in the filemight b

Seite 28

File and Function Splitting3-41incrementing by one each time the function is split. For example, if youroriginal function isMdlOutput, the split funct

Seite 29 - Introduction to the

3 Code Generation and the Build Process3-42

Seite 30

4External ModeIntroduction ...4-2ExternalMode...4-3Getting Started with External Mode Using grt ...4-4Setting Up th

Seite 31 - The Real-Time Workshop

4 External Mode4-2IntroductionExternal mode is a simulation mode provided by the Real-Time Workshop thatsupports on-the-fly parameter tuning in a real

Seite 32 - Types of Output

Introduction4-3External ModeSimulink external mode is a mechanism that manages communicationbetween Simulink and stand-alone programs built with the R

Seite 33

4 External Mode4-4Getting Started with External Mode Using grtThis section provides a step-by-step set of instructions for getting started withexterna

Seite 34 - The Rapid Prototyping Process

Getting Started with External Mode Using grt4-5the Stop Time set to its default value. Set the Decimation to 1 (nodecimation).3 On the Workspace I/O p

Seite 35

xi11Real-Time Workshop LibrariesIntroduction ...11-2Custom Code Library ...

Seite 36

4 External Mode4-6select External Mode Control Panel under the Tools menu. This dialog boxopens.The top four buttons for use after you have started yo

Seite 37 - Using External Mode

Getting Started with External Mode Using grt4-7To open the External Target Interface dialog box, click the Target Interfacebutton. The dialog box shou

Seite 38 - Modeling Systems in Simulink

4 External Mode4-8The dialog box should look like this when you’re finished.Prior to building your model, you must select values for gainsA and B.Thee

Seite 39 - Algorithm Design and Analysis

Getting Started with External Mode Using grt4-9Running External Mode on Your TargetTo run external mode, you must open an MS-DOS command prompt (on UN

Seite 40

4 External Mode4-10External Mode GUIThe Real-Time Workshop provides an extensive graphical user interface (GUI),which includes four separate windows,

Seite 41

External Mode GUI4-11Target InterfacePressing the Target Interface button activates the External Target Interfacedialog box.You must set the MEX-file

Seite 42 - Make Utility

4 External Mode4-12External Signal & TriggeringPressing the Signal & Triggering button activates the External Signal &Triggeringdialog box

Seite 43 - The Build Procedure

External Mode GUI4-13Trigger Signal Selection. You select a trigger signal by choosing it from the Signalselection list and pressing theTrigger signal

Seite 44

4 External Mode4-14If you have selected a trigger, the Trigger signal panel activates.By default, any element of the first input port of the specified

Seite 45 - Basic Features of example.rtw

External Mode GUI4-15Data ArchivingPressing the Data Archiving button opens the External Data Archivingdialog box.This panel supports various features

Seite 46

xii ContentsChoosingaTarget ... 12-7Real-Time Code Format ...12-10UnsupportedBlocks...

Seite 47 - Basic Features of example.c

4 External Mode4-16intermediate result. Since the trigger can fire at any time, writing intermediateresults to the workspace generally results in unpr

Seite 48 - Bundled Target Systems

External Mode GUI4-17This picture shows the External Data Archiving dialog box with enabledarchiving.Unless you selectEnable archiving, entries for th

Seite 49

4 External Mode4-18This picture shows the External Mode Control Panel with the batchdownload option activated:External Mode OperationWhen external mod

Seite 50

External Mode GUI4-19The Simulink side initiates the parameter download operation by calling aprocedure on the external program side. In the general t

Seite 51 - Getting Started with the

4 External Mode4-20LimitationsIn general, you cannot change a parameter if doing so results in a change in thestructure of the model. For example, you

Seite 52

External Mode GUI4-21The following section discusses how to use external mode with real-timeprograms on a UNIX or PC system. Chapter 8, “Targeting Tor

Seite 53

4 External Mode4-22Using the TCP ImplementationThis section describes how to use the TCP-based client/server implementationprovided with the Real-Time

Seite 54 - 2. Customizing Generated Code

Using the TCP Implementation4-23Figure 4-2: TCP-based Client/Server Implementation for External ModeThe following sections discuss the details of how

Seite 55 - 4. Validating Generated Code

4 External Mode4-24The External Interface MEX-FileYoumustspecifythenameoftheexternalinterfaceMEX-fileintheExternalTarget Interfacedialog box:You may b

Seite 56 - 10. Parameter Tuning

Using the TCP Implementation4-25You must specify these options in order. For example, if you want to specify theverbosity level (the second argument),

Seite 57

xiii13Real-Time Workshop Rapid Simulation TargetIntroduction ...13-2Building for the Rapid Simulation Targe

Seite 58 - Simulation Parameters dialog

4 External Mode4-26Enabling External ModeTo enable external mode, display the Simulink block diagram and selectExternal from the Simulation menu:Next,

Seite 59 - The Build Process

Using the TCP Implementation4-27Creating an External Mode Communication ChannelThe Real-Time Workshop provides support for TCP/IP through ext_comm.Whe

Seite 61

5Data Logging and SignalMonitoringMAT-File Data Logging ...5-2Singletasking versus MultitaskingMAT-FileLogging...5-3C API for

Seite 62 - The Simulink Model

5 Data Logging and Signal Monitoring5-2MAT-File Data LoggingFor the Real-Time Workshop targets that have access to a disk, you can useMAT-file logging

Seite 63

MAT-File Data Logging5-3Singletasking versus Multitasking MAT-File LoggingWhen logging data you will notice differences in the logging of:• Noncontinu

Seite 64 - Setting Program Parameters

5 Data Logging and Signal Monitoring5-4C API for Signal MonitoringSignal monitoring provides a second method for accessing block outputs in anexternal

Seite 65

Using BlockIOSignals to Obtain Block Outputs5-5Using BlockIOSignals to Obtain Block OutputsThe BlockIOSignals data structure is declared as follows:ty

Seite 66 - Inline parameters check

5 Data Logging and Signal Monitoring5-6The model code file model.bio defines an array of BlockIOSignals structures,for example:#include "bio_sig.

Seite 67 - Data Logging

Using BlockIOSignals to Obtain Block Outputs5-7You must then write code that walks through the rtBIOSignals array andchooses the signals to be monitor

Seite 68 - The UNIX Template Makefile

xiv ContentsGetting Started ... 14-6SettingOptionsforAdaCodeGeneration ... 14-7GeneratingAdaCode...

Seite 69 - PC Template Makefiles

5 Data Logging and Signal Monitoring5-8continue; } } /*install/remove the signals*/ for (w = 0; w < blockInfo->signalWidth; w++) {

Seite 70 - Generic Real-Time Modules

Using BlockIOSignals to Obtain Block Outputs5-9Below is an excerpt from an example routine that collects signals taken fromthe main simulation loop:/*

Seite 71 - Nonlinear Blocks

5 Data Logging and Signal Monitoring5-10

Seite 72

6Program ArchitectureIntroduction ...6-2Model Execution ...6-4ProgramTiming...6-13ProgramExecution...

Seite 73

6 Program Architecture6-2IntroductionThe Real-Time Workshop generates two styles of code. One code style issuitable for rapid prototyping (and simulat

Seite 74

Introduction6-3Third-party vendors supply additional targets for the Real-Time Workshop.Generally, these can be classified as rapid prototyping target

Seite 75

6 Program Architecture6-4Model ExecutionBefore looking at the two styles of generated code, you need to have a high-levelunderstanding of how the gene

Seite 76 - Tracing Generated Code Back

Model Execution6-5a given simulation time step. In minor time steps, the run-time interfaceintegrates the derivatives to update the continuous states.

Seite 77

6 Program Architecture6-6During the ModelOutputs and ModelUpdate phases of model execution, onlyblocks that have hit the current point in time execute

Seite 78 - Targeting dSPACE

Model Execution6-7Note that the multitasking execution assumes that all tasks are multiples ofthe base rate. Simulink enforces this when you have crea

Seite 79 - PC chassisMonitor/keyboard

ForewordRelated Products and Documentation ...xviRequirements...xviHow to Use This Guide ...xxiTypographicalConventi

Seite 80 - Real-Time Interface (RTI)

6 Program Architecture6-8The pseudocode below shows the execution of a model in a real-timesingletasking system where the model is run at interrupt le

Seite 81

Model Execution6-9continuous blocks, then the integration step size determines the base samplerate.For example, if the model code is a controller oper

Seite 82

6 Program Architecture6-10This code shows how a model executes in a real-time multitasking system(where the model is run at interrupt level).rtOneStep

Seite 83 - Build Process

Model Execution6-11Running models at interrupt level in real-time multitasking environment isvery similar to the previous singletasking environment, e

Seite 84

6 Program Architecture6-12occurs. The clock tick gives a clockSem (clock semaphore) to the model task(tSingleRate). The model task will wait for the s

Seite 85 - Build button on the

Model Execution6-13EndMainLoop}main(){InitializationStart/spawn task "tSingleRate".Start clock that does a "semGive" on a clockSem

Seite 86

6 Program Architecture6-14The following diagram illustrates interrupt timing.Figure 6-2: Task TimingThesampleintervalmustbelongenoughtoallowmodelcode

Seite 87

Model Execution6-15Program ExecutionAs the previous section indicates, a real-time program may not require 100% ofthe CPU’s time. This provides an opp

Seite 88

6 Program Architecture6-16that have a task identifier of 0. This results in differences in the logged valuesbetween singletasking and multitasking log

Seite 89

Model Execution6-17name, parameter and signal storage class are included as part of the API forthe embedded style of code.The single largest differenc

Seite 90

ForewordxviRelated Products and DocumentationRequirementsThe Real-Time Workshop®is a multiplatform product, running on MicrosoftWindows 95, Windows 9

Seite 91

6 Program Architecture6-18model.reg), execute, the run-time interface starts execution by callingMdlStart. This routine is called once at start-up.The

Seite 92 - Inline Parameters

Model Execution6-19• MdlTerminate(void) — MdlTerminate contains any block shutdown code.MdlTerminate is called by the run-time interface, as part of t

Seite 93 - Make Command

6 Program Architecture6-20The general content of the rapid prototyping style of code for C is shown in thefollowing figure.Figure 6-3: Content of Mod

Seite 94

Model Execution6-21A flow chart describing the execution of the rapid prototyping generated codeis shown below.Figure 6-4: Rapid Prototyping Executio

Seite 95

6 Program Architecture6-22Block outputs can also go to the external output structure (rtY). The followingfigure shows the general mapping between thes

Seite 96

Model Execution6-23The states structure has two sections: the first is for the continuous states;the second is for the discrete states.• Block Paramet

Seite 97 - Options Button

6 Program Architecture6-24When compared with the rapid prototyping environment, these functions arevery similar.

Seite 98 - System Target File Browser

Rapid Prototyping Program Framework6-25Rapid Prototyping Program FrameworkGenerating code for a Simulink model results in at least four files — model.

Seite 99 - S3 in the generated

6 Program Architecture6-26Figure 6-6: The Rapid Prototyping Program ArchitectureThe Real-Time Workshop architecture consists of three parts. The firs

Seite 100 - Tunable Parameters

Rapid Prototyping Program Framework6-27modules that implement the functions carried out by the system dependent,system independent, and application co

Seite 101 - Signal Properties

Related Products and DocumentationxviiWhat Is MATLAB?MATLAB is a high-performance language for technical computing. Itintegrates computation, visualiz

Seite 102

6 Program Architecture6-28Model Execution• Execute a background task, for example, communicate with the host duringexternal mode simulation or introdu

Seite 103

Rapid Prototyping Program Framework6-29Model ExecutionAt each sample interval, the main program passes control to the modelexecution function, which e

Seite 104 - .tlc) files. These files are

6 Program Architecture6-30Integration of Continuous States The real-time program calculates the next values for the continuous statesbased on the deri

Seite 105 - Template Makefiles

Rapid Prototyping Program Framework6-31Application Modules for System Independent ComponentsThe system independent components include these modules:•

Seite 106

6 Program Architecture6-32• Initialize a vector of sample times and sample time offsets and store thisvector in theSimStruct.• Store the values of the

Seite 107

Rapid Prototyping Program Framework6-33Figure 6-8: Execution of the Model CodeThis diagram shows what functions are defined in the generated code and

Seite 108 - Make Utilities

6 Program Architecture6-34automatically incorporates your non-inlined C code S-functions into theprogram if they adhere to the S-function API describe

Seite 109 - Parameters

Rapid Prototyping Program Framework6-35Application Modules for Application ComponentsWhen the Real-Time Workshop generates code, it produces the follo

Seite 110

6 Program Architecture6-36Embedded Program FrameworkThe embedded program framework and architecture is outlined by thefollowing figure.Figure 6-9: Th

Seite 111

Embedded Program Framework6-37Note the similarity between this architecture and the rapid prototypingarchitecture on page 6-26. The main difference is

Seite 112

How to Contact The MathWorks:508-647-7000 Phone508-647-7001 FaxThe MathWorks, Inc. Mail24 Prime Park WayNatick, MA 01760-1500http://www.mathworks.com

Seite 113

ForewordxviiiWhat Is Simulink?Simulink is a software package for modeling, simulating, and analyzingdynamic systems. It supports linear and nonlinear

Seite 115

7Models with MultipleSample RatesIntroduction ...7-2Single Versus Multitasking Environments ...7-3ExecutingMultitaskingModels...

Seite 116

7 Models with Multiple Sample Rates7-2IntroductionEvery Simulink block can be classified according to its sample time as constant,continuous-time, dis

Seite 117

Single- Versus Multitasking Environments7-3Single- Versus Multitasking EnvironmentsThere are two basic ways in which you can execute a fixed-step Simu

Seite 118

7 Models with Multiple Sample Rates7-4Figure 7-1: Real-Time Program ExecutionThis chapter focuses on when and how the run-time interface executes you

Seite 119

Single- Versus Multitasking Environments7-5Executing Multitasking ModelsIn cases where the continuous part of a model executes at a rate that isdiffer

Seite 120 - File and Function Splitting

7 Models with Multiple Sample Rates7-6The following diagrams illustrate how mixed-rate systems are handled by theReal-Time Workshop in these two envir

Seite 121

Single- Versus Multitasking Environments7-7Figure 7-3: Pseudomultitasking Using Overlapped InterruptsThis diagram illustrates how overlapped interrup

Seite 122 - Function Split Threshold

7 Models with Multiple Sample Rates7-8SingletaskingIt is possible to execute the model code in a strictly singletasking manner.While this method is le

Seite 123

Single- Versus Multitasking Environments7-9Simulating Models with SimulinkBefore Simulink simulates a model, it orders all of the blocks based upon th

Seite 124

Related Products and DocumentationxixStateflow machine. This S-function is the agent Simulink interacts with forsimulation and analysis.The control be

Seite 125 - External Mode

7 Models with Multiple Sample Rates7-10See “Multitasking and Pseudomultitasking” on page 7–5 for a description ofhow this works. It is important to un

Seite 126 - Introduction

Sample Rate Transitions7-11Sample Rate TransitionsThere are two possible sample rate transitions that can exist within a model:• A faster block drivin

Seite 127

7 Models with Multiple Sample Rates7-12In transitioning from slower to faster blocks, you must add Unit Delay blocksbetween slow to fast transitions a

Seite 128

Sample Rate Transitions7-13Simulink does not execute in real-time, which means that it is not bound byreal-time constraints. Simulink waits for, or mo

Seite 129

7 Models with Multiple Sample Rates7-14The sample time of the Zero Order Hold block must be set to 2 sec (i.e., thesample time of the slower block).Th

Seite 130 - 4 External Mode

Sample Rate Transitions7-15As you can see from the preceding diagrams, Simulink can simulate modelswith multiple sample rates in an efficient manner.

Seite 131 - Signals & Triggering

7 Models with Multiple Sample Rates7-16This timing diagram illustrates two problems:1 Execution of the slower block is split over more than one faster

Seite 132

Sample Rate Transitions7-17Three key points about this diagram:1 Unit delay output runs in 1 sec task, but only at its rate (2 sec). The outputof the

Seite 133 - A and B.WithA=2 and B=3,the

7 Models with Multiple Sample Rates7-18Note Inserting a Unit Delay block changes the model. The output of theslower block is now delayed by one time

Seite 134 - External Mode Control Panel

8Targeting Tornado forReal-Time ApplicationsIntroduction ...8-2Confirming Your Tornado Setup Is Operational . . . . . . 8-2VxWorksLib

Seite 135 - Target Interface

Forewordxxdiagrams. Stateflow brings system specification and design closer together. Itis easy to create designs, consider various scenarios, and it

Seite 136

8 Targeting Tornado for Real-Time Applications8-2IntroductionThis chapter describes how to create real-time programs for execution underVxWorks, which

Seite 137

Introduction8-3for additional information about installation and operation of VxWorks andTornado products.VxWorks LibrarySelecting VxWorks Support und

Seite 138

8 Targeting Tornado for Real-Time Applications8-4There is a second sublibrary, the IO Devices library, that contains support forthese drivers:• Matrix

Seite 139 - Data Archiving

Run-time Architecture Overview8-5Run-time Architecture OverviewIn a typical VxWorks-based real-time system, the hardware consists of a UNIXor PC host

Seite 140

8 Targeting Tornado for Real-Time Applications8-6External ModeSimulink external mode provides a mechanism to download new parametervalues to the execu

Seite 141

Run-time Architecture Overview8-7Note You may need to enter a routing table entry into VxWorks if your hostis not on the same local network (subnet)

Seite 142 - Update Diagram

8 Targeting Tornado for Real-Time Applications8-8StethoScopeWith StethoScope, you can access the output of any block in the model (in thereal-time pro

Seite 143

Run-time Architecture Overview8-9The program creates VxWorks tasks to run on the real-time system: onecommunicates with Simulink, the others execute t

Seite 144

8 Targeting Tornado for Real-Time Applications8-10Multitasking. Optionally, the model can run as multiple tasks, one for eachsample rate in the model.

Seite 145

Implementation Overview8-11Implementation OverviewTo implement and run a VxWorks-based real-time program using theReal-Time Workshop, you must:• Desig

Seite 146 - Interface

How to Use This GuidexxiHow to Use This GuideTypographical ConventionsTo Indicate... This Guide Uses... ExampleNew terms Italics An array is an ordere

Seite 147

8 Targeting Tornado for Real-Time Applications8-12Figure 8-3: Source Modules Used to Build the VxWorks Real-Time ProgramThis diagram illustrates the

Seite 148 - MEX-File Optional Arguments

Implementation Overview8-13Adding Device Driver BlocksThe real-time program communicates with the I/O devices installed in theVxWorks target chassis v

Seite 149 - Options on the Real-Time

8 Targeting Tornado for Real-Time Applications8-14Edit the following lines to reflect your setup.VX_TARGET_TYPE = 68kCPU_TYPE = MC68040Downloading Con

Seite 150 - Possible Error Conditions

Implementation Overview8-15Specifying the Real-Time Build OptionsSet the real-time build options using the Solver and Real-Time Workshoppages of theSi

Seite 151

8 Targeting Tornado for Real-Time Applications8-16Next, use the System Target File Browser to select the correct Real-TimeWorkshop page settings for T

Seite 152

Implementation Overview8-17Build Command Options. You can specify build command options on the CodeGeneration Optionsdialog box. Click the Options but

Seite 153 - Monitoring

8 Targeting Tornado for Real-Time Applications8-18• MATLAB MAT-file — to enable data logging during program execution,checkMAT-file logging. The progr

Seite 154 - To File Block MAT-Files

Implementation Overview8-19Downloading and Running the Executable InteractivelyIf automatic downloading is disabled, you must use the Tornado tools to

Seite 155

8 Targeting Tornado for Real-Time Applications8-20external mode during the build procedure.) It also initializes StethoScope if youselected this optio

Seite 156 - C API for Signal Monitoring

Implementation Overview8-21The following table lists the arguments to this SimStruct.Table 8-1: Arguments to the rt_main SimStruct modelA pointer to

Seite 157

ForewordxxiiInstallationYour platform-specific MATLAB Installation Guide provides essentially all ofthe information you need to install the Real-Time

Seite 158

8 Targeting Tornado for Real-Time Applications8-22Calling rt_main. To begin program execution, call rt_main from WindSh.Forexample,sp(rt_main, vx_equa

Seite 159

9Targeting DOS forReal-Time ApplicationsIntroduction ...9-2DOSDeviceDriversLibrary...9-3Implementation Overview ...

Seite 160

9 Targeting DOS for Real-Time Applications9-2IntroductionThis chapter provides information that pertains specifically to using theReal-Time Workshop i

Seite 161

Introduction9-3DOS Device Drivers LibrarySelecting DOS Device Drivers under the Real-Time Workshop library in theSimulink Library Browser opens the DO

Seite 162

9 Targeting DOS for Real-Time Applications9-4Implementation OverviewThe Real-Time Workshop includes DOS run-time interface modules designedto implemen

Seite 163 - Program Architecture

Implementation Overview9-5This diagram illustrates the code modules that are used to build a DOSreal-time program.To execute the code in real time, th

Seite 164

9 Targeting DOS for Real-Time Applications9-6Hardware RequirementsThe hardware needed to develop and run a real-time program includes:• A workstation

Seite 165

Implementation Overview9-7source code of the device drivers for the Keithley Metrabyte DAS 1600/1400Series I/O boards. See the “Device Driver Blocks”

Seite 166 - Model Execution

9 Targeting DOS for Real-Time Applications9-8The fastest sample rate you can define is determined by the minimum valuefrom which the counter can count

Seite 167

Device Driver Blocks9-9Device Driver BlocksThe real-time program communicates with external hardware via a set ofdevice drivers. These device drivers

Seite 168

InstallationxxiiiIf you experience installation difficulties and have Web access, connect to TheMathWorkshomepage(http://www.mathworks.com). Look for

Seite 169

9 Targeting DOS for Real-Time Applications9-10To access the device driver blocks, double-click on the sublibrary icon.The blocks in the library contai

Seite 170

Device Driver Blocks9-11Analog Input (ADC) Block Parameters• Base I/O Address —Thebeginning of the I/O address spaceassigned to the board. The valuesp

Seite 171

9 Targeting DOS for Real-Time Applications9-12• Sample Time (sec) — Device drivers are discrete blocks that require you tospecify a sample time. In th

Seite 172

Device Driver Blocks9-13• Number of Channels — Number of DAC channels enabled. The DAS-1600Series I/O boards have two 12-bit DAC channels. The DAS-140

Seite 173

9 Targeting DOS for Real-Time Applications9-14Digital Output Block Parameters• Base I/O Address —Thebeginning of the I/O address spaceassigned to the

Seite 174

Device Driver Blocks9-15executed at the specified rate. Specifically, when the digital output block isexecuted, it causes corresponding boolean values

Seite 175

9 Targeting DOS for Real-Time Applications9-16Building the ProgramOnce you have created your Simulink model and added the appropriate devicedriver blo

Seite 176

Building the Program9-17workstation. You can verify this by checking the environment variable,WATCOM, which correctly points to the directory where th

Seite 177

9 Targeting DOS for Real-Time Applications9-18

Seite 178

10Targeting CustomHardwareIntroduction ...10-2Run-Time Interface ...10-4Creating System Target Files and Template Makef

Seite 179

ForewordxxivMicrosoft Visual C/C++Define the environment variable MSDevDir to beMSDevDir=<path to compiler> for Visual C/C++ 4.2MSDevDir=<p

Seite 180

10 Targeting Custom Hardware10-2IntroductionThis chapter contains information on targeting custom hardware andimplementing device driver blocks. By im

Seite 181

Introduction10-3Note For examples of device drivers, see the S-functions supplied inmatlabroot/rtw/c/tornado/devices and matlabroot/rtw/c/dos/devices

Seite 182

10 Targeting Custom Hardware10-4Run-Time InterfaceThere are two ways to target custom hardware:• Rapid prototyping• Embedded real-timeRapid prototypin

Seite 183

Creating System Target Files and Template Makefiles10-5Creating System Target Files and Template MakefilesAssuming that you’ve created the directory/a

Seite 184

10 Targeting Custom Hardware10-6Clicking the Build button causes the Real-Time Workshop to generate code asdictated bymytarget.tlc and compile it as d

Seite 185

Implementing Device Drivers10-7Implementing Device DriversS-functions can be built into MEX-files or compiled and linked with other codeto become part

Seite 186

10 Targeting Custom Hardware10-8You can add your own blocks to a device driver library by writing S-functionsthat implement device drivers for your pa

Seite 187 - SimStruct,but

Implementing Device Drivers10-9- Reading values from an I/O device and assigning these values to theblock’s output vectory (ifitisanADC)- Writing valu

Seite 188

10 Targeting Custom Hardware10-10Figure 10-1: Format of a Device Driver S-Function #define S_FUNCTION_NAME filenameDefine a name for the entry point

Seite 189 - Initialization

Implementing Device Drivers10-11S_FUNCTION_NAME DefinitionThe statement#define S_FUNCTION_NAME namedefines the name of the function that is the entry

Seite 190 - Components

Where to Go from HerexxvWhere to Go from HereChapter 1, “Introduction to the Real-Time Workshop,” is a quick introductionto the rapid prototyping proc

Seite 191

10 Targeting Custom Hardware10-12Conditional CompilationsIn general, you can use an S-function in these environments:• Simulink• Real-TimeWhen you use

Seite 192

Implementing Device Drivers10-13Next define a variable used to store the integer (which is the number ofchannels in this example):uint_T num_channels;

Seite 193

10 Targeting Custom Hardware10-14This list describes the function of each macro in mdlInitializeSizes:• ssSetNumSFcnParams — The number of input param

Seite 194 - The SimStruct Data Structure

Implementing Device Drivers10-15The following example illustrates the definition of mdlInitializeSizes for aDAC:static void mdlInitializeSizes(SimStru

Seite 195 - — MdlInitializeSampleTimes

10 Targeting Custom Hardware10-16Initializing the I/O DeviceDevice driver S-functions use the mdlInitializeConditions function to:• Read parameters fr

Seite 196 - Inlining S-Functions

Implementing Device Drivers10-17All S-functions call the mdlOutputs function to calculate block outputs. For adevice driver block, this function conta

Seite 197

10 Targeting Custom Hardware10-18The Termination FunctionThe final required function is typically used only in DACs to zero the output atthe end of th

Seite 198 - Embedded Program Framework

Implementing Device Drivers10-19The Public Registration FunctionThe include file cg_sfun.h defines a function that is the entry point for theS-functio

Seite 199

10 Targeting Custom Hardware10-20Setting the MATLAB PathThe device driver blocks in a library can automatically change your MATLABpath to ensure that

Seite 200

11Real-Time WorkshopLibrariesIntroduction ...11-2Custom Code Library ...11-4CustomModelCode ...11-4CustomS

Seite 201 - Sample Rates

ForewordxxviChapter 12, “Configuring Real-Time Workshop for Your Application,”compares and contrasts various targets, including the generic real-time

Seite 202

11 Real-Time Workshop Libraries11-2IntroductionThe Real-Time Workshop provides a library of functions that allow you greatflexibility in constructing

Seite 203 - Solver options pull-down

Introduction11-3• S-Function Target — This block is intended for use in conjunction with theReal Time W S-function code format. See “S-Function Code F

Seite 204

11 Real-Time Workshop Libraries11-4Custom Code LibraryThe Real-Time Workshop also provides a Custom Code library containingblocks that allow you to pl

Seite 205 - Executing Multitasking Models

Custom Code Library11-5• model.h — Header File block•model.prm — Parameter File block•model.c — Source File block•model.reg — Registration File blockT

Seite 206 - Highest Priority

11 Real-Time Workshop Libraries11-6Double clicking the Model Start Function block opens a the MdlStartFunction Custom Codedialog box.You can insert cu

Seite 207

Custom Code Library11-7The code below is the MdlStart function for this example (mymodel).void MdlStart(void){ /* user code (Start function Header) *

Seite 208 - Singletasking

11 Real-Time Workshop Libraries11-8• Subsystem Enable• Subsystem Disable• Subsystem Outputs• Subsystem Update• Subsystem DerivativesThe location of th

Seite 209 - Executing Models in Real-Time

Interrupt Handling11-9Interrupt HandlingThe Real-Time Workshop provides blocks in the Interrupt Template librarythat allow you to model synchronous/as

Seite 210 - Singletasking Operation

11 Real-Time Workshop Libraries11-10subsystem (or Stateflow Chart). The Asynchronous Interrupt block theninstalls the Task Synchronization block as th

Seite 211 - Sample Rate Transitions

Interrupt Handling11-11concept:Figure 11-1: Using the Asynchronous Interrupt Block with Simulink’s Library Feature in the Rapid Prototyping Process B

Seite 212 - T=2sT=1s

1Introduction to theReal-Time WorkshopIntroduction ...1-2The Real-Time Workshop ...1-3Real-TimeWorkshopApplications...

Seite 213

11 Real-Time Workshop Libraries11-12generation on the board. You must match the interrupt level and vectorspecified in the Asynchronous Interrupt bloc

Seite 214

Interrupt Handling11-13• VME Interrupt Offset Number(s) — the Real-Time Workshop uses thisnumber in the call tointConnect(INUM_TO_IVEC(#),...). You sh

Seite 215

11 Real-Time Workshop Libraries11-14Asynchronous Interrupt Block Example - Simulation ModeThis example shows how the Asynchronous Interrupt block work

Seite 216

Interrupt Handling11-15Asynchronous Interrupt Block Example - RTW ModeThis example shows the Asynchronous Interrupt block in RTW mode:Note that the si

Seite 217

11 Real-Time Workshop Libraries11-16Locking and Unlocking ISRs. It is possible to lock ISRs so that they are notpreempted by a higher priority interru

Seite 218 - Unit Delay

Interrupt Handling11-17• A semaphore is created to synchronize the downstream system to theexecution of the Task Synchronization block.• Code is added

Seite 219 - Real-Time Applications

11 Real-Time Workshop Libraries11-18VxWorks system. In particular, the default priority of the model code is 30and, when multitasking is enabled, the

Seite 220

Interrupt Handling11-19creates and initializes the synchronization semaphore. It also spawns thefunction-call subsystem as an independent task./* Crea

Seite 221 - VxWorks Support library

11 Real-Time Workshop Libraries11-20Asynchronous Buffer BlockTheVxWorksDoubleBufferblocksaremeanttobeusedtointerfacesignalstoasynchronous function-cal

Seite 222 - Help button on the

Interrupt Handling11-21Asynchronous Buffer Block ParametersThere are two kinds of Asynchronous Buffer blocks, a reader and a writer. Thepicture below

Seite 223 - WindSh (the

iContentsForewordRelated Products and Documentation ... xviRequirements... xviWhatIsMATLAB? ...

Seite 224

1 Introduction to the Real-Time Workshop1-2IntroductionThe Real-Time Workshop, for use with MATLAB and Simulink, produces codedirectly from Simulink m

Seite 225

11 Real-Time Workshop Libraries11-22Asynchronous Buffer Block ExampleThis example shows how you might use the Asynchronous Buffer block tocontrol the

Seite 226 - StethoScope

Interrupt Handling11-23This will cause blocks up- or downstream from it, which would otherwiseinherit from the function-call subsystem, to use the sam

Seite 227 - VxWorks Tasks

11 Real-Time Workshop Libraries11-24Rate Transition Block ExampleThis picture shows a sample application of the Rate Transition block in an ISR:In thi

Seite 228

Creating a Customized Asynchronous Library for Your System11-25Creating a Customized Asynchronous Library for Your SystemYou can use the Real-Time Wor

Seite 229 - Implementation Overview

11 Real-Time Workshop Libraries11-26

Seite 230

12Configuring Real-TimeWorkshop for YourApplicationIntroduction ...12-2Interaction between SimulinkandtheReal-TimeWorkshop ...

Seite 231 - VxWorks Configuration

12 Configuring Real-Time Workshop for Your Application12-2IntroductionThis chapter discusses how Simulink interacts with the Real-Time Workshopand als

Seite 232 - Downloading Configuration

Introduction12-3One of the key components of Simulink is its engine, which propagates datafrom one block to the next along signal lines. The data prop

Seite 233 - Step Size

12 Configuring Real-Time Workshop for Your Application12-4This figure shows the propagation of the signal attributes associated with theInport block t

Seite 234

Introduction12-5start time and Tfis the simulation stop time. If Tfis infinity, the defaultsample time is set to 0.2.To ensure a completely determinis

Seite 235

The Real-Time Workshop1-3The Real-Time WorkshopThe Real-Time Workshop provides a real-time development environment thatfeatures:• A rapid and direct p

Seite 236 - Initiating the Build

12 Configuring Real-Time Workshop for Your Application12-6generator to properly specify the rate at which f() should be executed as shownin theconnect

Seite 237 - Running the Program

Introduction12-7target throughout development. The real-time format is the mostcomprehensive code format and supports almost all the built-in blocks.I

Seite 238

12 Configuring Real-Time Workshop for Your Application12-8Table 12-1: Features Supported by Real-Time Workshop Targets and Code Formats Real-TimeReal

Seite 239

Introduction12-9Executes inhardreal-timeXX X XNonreal-timeexecutableincludedXX X XMultipleinstantiationof one model(provided noStateflowblocks are iny

Seite 240

12 Configuring Real-Time Workshop for Your Application12-10Real-Time Code FormatThe real-time code format (corresponding to the generic real-time targ

Seite 241 - Targeting DOS for

Real-Time Code Format12-11Template Makefiles• drt.tmf• grt- grt_bc.tmf —BorlandC-grt_vc.tmf —VisualC-grt_watc.tmf —WatcomC-grt_unix.tmf —UNIXhost•osek

Seite 242

12 Configuring Real-Time Workshop for Your Application12-12Real-Time malloc Code FormatThe real-time malloc code format (corresponding to the generic

Seite 243

Real-Time malloc Code Format12-13Template Makefiles• grt_malloc- grt_malloc_bc.tmf — Borland C-grt_malloc_vc.tmf —VisualC-grt_malloc_watc.tmf —WatcomC

Seite 244

12 Configuring Real-Time Workshop for Your Application12-14Embedded-C Code FormatThe embedded-C code format (corresponding to the embedded real-time t

Seite 245

Embedded-C Code Format12-15• Select the Single output/update function check box. Combining the outputand update functions allows the Real-Time Worksho

Seite 246 - Device Drivers

1 Introduction to the Real-Time Workshop1-4• High-speed stand-alone simulations.• Generation of portable C code for export to other simulation program

Seite 247 - Simulink Host

12 Configuring Real-Time Workshop for Your Application12-16Unsupported BlocksThe embedded-C format does not support the following built-in blocks:• Co

Seite 248 - Modifying Program Timing

Embedded-C Code Format12-17Template Makefiles• ert_bc.tmf —BorlandC•ert_vc.tmf —VisualC•ert_watc.tmf —WatcomC•ert_unix.tmf — UNIX host

Seite 249 - Device Driver Blocks

12 Configuring Real-Time Workshop for Your Application12-18S-Function Code FormatThe S-function code format (corresponding to the RTW S-function targe

Seite 250

S-Function Code Format12-19functionality of the sfun model. The picture below shows the sfun_sf blockembedded in a new model.After you have placed the

Seite 251

12 Configuring Real-Time Workshop for Your Application12-20Restrictions• Hand-written S-functions without corresponding TLC files must containexceptio

Seite 252 - [-10 10] volts. Refer

Optimizations Common to All Code Formats12-21Optimizations Common to All Code FormatsGeneral Modeling TechniquesThe following are techniques that you

Seite 253

12 Configuring Real-Time Workshop for Your Application12-22Stateflow OptimizationsIf your model contains Stateflow blocks, select the Use Strong Data

Seite 254 - [lo hi],for

Optimizations Common to All Code Formats12-23Diagnostic Page• Deselect the Disable optimized block I/O storage check box. Disablingoptimized block I/O

Seite 255 - Including Device Driver Code

12 Configuring Real-Time Workshop for Your Application12-24vector. Note that you can override the inlining of individual parameter byusing theTunable

Seite 256 - Building the Program

Optimizations Common to All Code Formats12-25• Select the Inline invariant signals check box. The Real-Time Workshop willnot generate code for blocks

Seite 257

The Real-Time Workshop1-5a fixed, user-specified sample rate. Continuous time models are incorporatedinto this code with the simple provision that the

Seite 258

12 Configuring Real-Time Workshop for Your Application12-26

Seite 259 - Hardware

13Real-Time WorkshopRapid Simulation TargetIntroduction ...13-2Building for the Rapid Simulation Target ...13-4RunningaRapidSimula

Seite 260

13 Real-Time Workshop Rapid Simulation Target13-2IntroductionThe Real-Time Workshop rapid simulation target (rsim) consists of a set oftarget files fo

Seite 261

Introduction13-3you can easily write simple scripts that will run a set of simulations insequence while using new data sets. These scripts can be writ

Seite 262 - Run-Time Interface

13 Real-Time Workshop Rapid Simulation Target13-4Building for the Rapid Simulation TargetBy specifying the system target file (rsim.tlc)andthetemplate

Seite 263

Building for the Rapid Simulation Target13-5real-time target, on the other hand, is a starting point for targeting a newprocessor.A single build of yo

Seite 264

13 Real-Time Workshop Rapid Simulation Target13-6at the MATLAB prompt. Typew = 100;zeta = 0.5;to set parameters. Copy a test data file by typing!matla

Seite 265 - Implementing Device Drivers

Building for the Rapid Simulation Target13-7Replacing Input Signal Data. New data for a From File block can be placed in astandard MATLAB MAT-file. As

Seite 266

13 Real-Time Workshop Rapid Simulation Target13-8This picture shows the resulting plot.As a result the new data file is read and the simulation progre

Seite 267 - Required Functions

Building for the Rapid Simulation Target13-9<-o> Specifying a New Output Filename for the SimulationIf you have specified Save to Workspace opti

Seite 268

1 Introduction to the Real-Time Workshop1-6The Rapid Prototyping ProcessThe Real Time Workshop allows you to do rapid prototyping, a process thatallow

Seite 269 - Defining the SimStruct

13 Real-Time Workshop Rapid Simulation Target13-10incorrect simulation results. In this case, where model structure has changed,you must regenerate th

Seite 270

Building for the Rapid Simulation Target13-11<-s> Specifying a New Stop Time for an rsim SimulationIf a new stop time is not provided, the simul

Seite 271

13 Real-Time Workshop Rapid Simulation Target13-12From Workspace data must be contained in a structure variable with thefollowing fields:var.timevar.s

Seite 272

Building for the Rapid Simulation Target13-13Simulation PerformanceIt is not possible to predict accurately the simulation speed-up of an rsimsimulati

Seite 273 - Initializing Sample Times

13 Real-Time Workshop Rapid Simulation Target13-14demonstrate how rsim canbecalledrepeatedlywithinanM-fileforMonteCarlo simulations.

Seite 274 - Initializing the I/O Device

14Real-Time WorkshopAda CoderIntroduction ...14-2Real-Time Workshop Ada Coder Applications . . . . . . . 14-3SupportedCompilers...

Seite 275 - DAC Outputs

14 Real-Time Workshop Ada Coder14-2IntroductionThis chapter presents an introduction to the Real-Time Workshop Ada Coder.It compares and contrasts the

Seite 276 - The Termination Function

Introduction14-3Real-Time Workshop Ada Coder ApplicationsLike the Real-Time Workshop, the Real-Time Workshop Ada Coder supports avariety of real-time

Seite 277

14 Real-Time Workshop Ada Coder14-4All Simulink blocks are automatically converted to code, with the exception of:• MATLAB function blocks• Any contin

Seite 278

Introduction14-5generation. You can, however, perform explicit upcasting using the DataType Conversion block in Simulink.S-FunctionsS-functions provid

Seite 279 - Libraries

The Rapid Prototyping Process1-7The traditional approach to real-time design and implementation typicallyinvolves multiple teams of engineers, includi

Seite 280

14 Real-Time Workshop Ada Coder14-6Getting Started This section illustrates, through a simple example, how to transform aSimulink model into a stand-a

Seite 281

Getting Started14-7Setting Options for Ada Code GenerationYou must specify the correct options before you generate Ada code from thismodel. These are

Seite 282 - Custom Code Library

14 Real-Time Workshop Ada Coder14-8Alternatively, you can specify the settings on the Real-Time Workshop pagemanually by following these steps:1 Selec

Seite 283

Getting Started14-9Generated FilesThis table lists the Ada files generated by the Real-Time Workshop Ada Coderfrom the counter demonstration (counters

Seite 284 - Function Custom Code

14 Real-Time Workshop Ada Coder14-10Create model times2 using these blocks:• Sine Wave (sample time = 0.1)•timestwo S-function (provided in the matlab

Seite 285

Getting Started14-11The times2 model contains a simple S-function, called timestwo,thattakestheinput sine wave signal and doubles its amplitude. The T

Seite 286

14 Real-Time Workshop Ada Coder14-12Configuring the Template MakefileTemplate makefiles specify the compiler, link, and make directives native tothe t

Seite 287 - Interrupt Handling

Getting Started14-13Application Modules Required for the Real-Time ProgramBuilding the real-time program requires a number of support files in additio

Seite 288

14 Real-Time Workshop Ada Coder14-14Tunable ParametersIf you select Inline parameters on the Real-Time Workshop page, the Tunableparametersbutton acti

Seite 289

Getting Started14-15- ImportedExtern — the variable is assumed to be declared in the packagespecification entered in theStorage Type Qualifier field.

Seite 290

1 Introduction to the Real-Time Workshop1-8The figure below shows the rapid prototyping process in more detail.Figure 1-2: The Rapid Prototyping Deve

Seite 291

14 Real-Time Workshop Ada Coder14-16To change the storage class of a signal, select it in your Simulink model; thenselectSignal Properties under the E

Seite 292

Getting Started14-17specification. The generated code accesses this signal asRT_U.Signal_Name.- ExportedGlobal — declares the signal as a global varia

Seite 293

14 Real-Time Workshop Ada Coder14-18Code ValidationAfter completing the build process, the stand-alone version of thecountersdemo model is ready for c

Seite 294

Code Validation14-19The “!” character passes the command that follows it to the operating system.This command, therefore, runs the stand-alone version

Seite 295

14 Real-Time Workshop Ada Coder14-20Analyzing Data with MATLABPoints to consider when data logging:• The Ada Coder only supports data logging to a mat

Seite 296

Supported Blocks14-21Supported BlocksThe Real-Time Workshop Ada Coder supports the following Simulink blocks.Discrete BlocksDiscrete-Time Integrator D

Seite 297

14 Real-Time Workshop Ada Coder14-22Nonlinear BlocksBacklash QuantizerCoulomb & Viscous Friction RelayDeadZone SaturationManual Switch (must Break

Seite 298

Supported Blocks14-23SinksDisplay — no code is generated forthis blockTo FileScope — matrix data logging only(double arrays)To Workspace — matrix data

Seite 299

14 Real-Time Workshop Ada Coder14-24

Seite 300

AReal-Time WorkshopDirectory Tree

Seite 301

The Rapid Prototyping Process1-9This highly productive development cycle is possible because the Real-TimeWorkshop is closely tied to MATLAB and Simul

Seite 302 - Rate Transition Block Example

A Real-Time Workshop Directory TreeA-2Real-Time Workshop Directory TreeThe files provided to implement real-time and generic real-time applicationsres

Seite 303 - Library for Your System

Real-Time Workshop Directory TreeA-3The matlabroot/rtw/c Directorymatlabroot/rtw/ctlcgrtdostornadolibsrctoolssrcrtwsfcnertgrt_mallocwindowsosek_leorsi

Seite 304

A Real-Time Workshop Directory TreeA-4Directory Purposematlabroot/rtw/c/dosFiles for targeting DOSmatlabroot/rtw/c/ertFiles for targeting embedded C c

Seite 305 - Application

Real-Time Workshop Directory TreeA-5The matlabroot/simulink DirectoryThe matlabroot/toolbox DirectoryDirectory Purposematlabroot/simulink/includeInclu

Seite 306

A Real-Time Workshop Directory TreeA-6The matlabroot/extern DirectoryDirectory Purposematlabroot/extern/includeInclude files used to build the targetm

Seite 307

BGlossary

Seite 308

B GlossaryB-2Application Modules − With respect to Real-Time Workshop programarchitecture, these are collections of programs that implement functionsc

Seite 309

B-3Generic Real-Time − An environment where model code is generated for areal-time system, and the resulting code is simulated on your workstation.(No

Seite 310

B GlossaryB-4Makefiles − Files that contain a collection of commands that allow groups ofprograms, object files, libraries, etc. to interact. Makefile

Seite 311

B-5Target File − A file that is compiled and executed by the Target LanguageCompiler. A combination of these files describes how to transform theReal-

Seite 312

1 Introduction to the Real-Time Workshop1-10You can monitor signals using Scope blocks while running external mode.Simply connect Scope blocks to sign

Seite 313

B GlossaryB-6

Seite 314 - Real-Time Code Format

I-1IndexAapplication modulesapplication specific layer 6-35common layer 6-31definition of 6-25Asynchronous Buffer block 11-20Asynchronous Interrupt bl

Seite 315

IndexI-2device driver blocks 9-9adding to model 9-15device drivers 9-6digital input block parameters 9-13digital output block parameters 9-14hardware

Seite 316 - Real-Time malloc Code Format

IndexI-3under DOS 7-3under VxWorks 7-3interrupt service routine (ISR) 9-5locking and unlocking 11-16interrupt templates library 11-9LlibraryCustom Cod

Seite 317

IndexI-4program buildingDOSreal-time 9-16VxWorksbuild command options 8-17real-time options 8-14setting step size 8-15program executiondata logging fu

Seite 318 - Embedded-C Code Format

IndexI-5sample tiime overlaps 7-15S-functionsAPI 6-34device driver 10-9format of 10-8inlining 1-4, 10-7locating source code for 6-34models containing

Seite 319 - Local block outputs

IndexI-6UUNIX 2-18template makefiles 2-18Vvirtual blocks 1-18VxWorksapplication overview 8-5build command options 8-17configuringfor external mode (so

Seite 320 - System Target File

The Rapid Prototyping Process1-11Algorithm Design and AnalysisFrom the block diagrams developed during the modeling stage, you can extractstate-space

Seite 321

iiThe Rapid Prototyping Process ... 1-6KeyAspectsofRapidPrototyping... 1-6RapidPrototypingforDigitalSigna

Seite 322 - S-Function Code Format

1 Introduction to the Real-Time Workshop1-12Open Architecture of the Real-Time WorkshopThe Real-Time Workshop is an open and extensible system designe

Seite 323

Open Architecture of the Real-Time Workshop1-13Figure 1-3: The Real-Time Workshop’s Open ArchitectureMATLABSimulinkReal-Time Workshop BuildTargetLang

Seite 324 - Restrictions

1 Introduction to the Real-Time Workshop1-14Target Language CompilerTo generate code, the Real-Time Workshop invokes the Target LanguageCompiler (TLC)

Seite 325 - General Modeling Techniques

Open Architecture of the Real-Time Workshop1-15S-FunctionsS-functions allow you to add custom code to your Simulink model. You canembed the code direc

Seite 326 - Simulation Parameters

1 Introduction to the Real-Time Workshop1-16options, and additional information for the destination (target) of thegenerated executable.Themodel.mk fi

Seite 327 - Real-Time Workshop Page

Open Architecture of the Real-Time Workshop1-17A First Look at Real-Time Workshop FilesAn example of a Simulink model is this block diagram:Figure 1-4

Seite 328

1 Introduction to the Real-Time Workshop1-18example.rtw,whichisthe.rtw file associated with “A Simple Simulink Model”on page 1-17:Note thatmodel.rtw f

Seite 329 - Compiler Options

Open Architecture of the Real-Time Workshop1-19Language Compiler Reference Guide, which contains detailed descriptions ofthe contents ofmodel.rtw file

Seite 330

1 Introduction to the Real-Time Workshop1-20assigning buffers to each input and output. Compare this to the MdlOutputsfunction generated with buffer o

Seite 331 - Rapid Simulation Target

Open Architecture of the Real-Time Workshop1-21Using Stateflow and Blocksets with the Real-Time WorkshopStateflow is a graphical design and developmen

Seite 332

iii4.ValidatingGeneratedCode ... 2-55. Incorporating Generated Code into Legacy Code . . . . . . . . . . 2-56.IncorporatingLeg

Seite 333

1 Introduction to the Real-Time Workshop1-22

Seite 334 - File Browser

2Getting Started with theReal-Time WorkshopIntroduction ...2-2Where to Find Information in This Manual ...2-3Basic Concepts in the

Seite 335

2 Getting Started with the Real-Time Workshop2-2IntroductionThis chapter begins a discussion of basic concepts used in real-timedevelopment and relate

Seite 336 - Build buttonontheReal-Time

Where to Find Information in This Manual2-3Where to Find Information in This ManualThis section discusses typical requirements for producing real-time

Seite 337

2 Getting Started with the Real-Time Workshop2-4• Write a harness program (i.e., main)• Install a C compilerA bundled harness program is supplied for

Seite 338

Where to Find Information in This Manual2-5LibMdlRegCustomCode, LibSystemInitializeCustomCode, LibSystemOutputCustomCode, LibSystemUpdateCustomCode, L

Seite 339

2 Getting Started with the Real-Time Workshop2-66. Incorporating Legacy Code into Generated CodeLegacy code, or hand-written code, is existing code th

Seite 340

Where to Find Information in This Manual2-7• External mode — you can tune parameters from Simulink while running thegenerated code on a target process

Seite 341

2 Getting Started with the Real-Time Workshop2-8Basic Concepts in the Real-Time WorkshopBefore going through a step-by-step example of how to target s

Seite 342

Basic Concepts in the Real-Time Workshop2-9target environments and the system target files and template makefilesassociated with each example environm

Seite 343 - Simulation Performance

ivTargeting dSPACE ... 2-28Real-TimeInterface(RTI) ... 2-30Building a Real-Time Executable

Seite 344 - Carlo simulations

2 Getting Started with the Real-Time Workshop2-10the Real-Time Workshop page. Finally, if the host on which you are runningmatches theHOST macro speci

Seite 345 - Ada Coder

Basic Concepts in the Real-Time Workshop2-11and program building. Therefore, before you generate code and build aprogram, you must verify that the mod

Seite 346

2 Getting Started with the Real-Time Workshop2-12Building Generic Real-Time ProgramsThis example describes how to generate C code from a Simulink mode

Seite 347

Building Generic Real-Time Programs2-13This is the Simulink model that appears:Figure 2-1: Simulink Model of an F14 AircraftThe model employs a Signa

Seite 348

2 Getting Started with the Real-Time Workshop2-14Setting Program ParametersAfter displaying the f14 model, select Parameters from the Simulationpull-d

Seite 349

Building Generic Real-Time Programs2-15Note Alternatively, you can select RTW Options from the Tools pull-downmenu. This brings you directly to the R

Seite 350 - Getting Started

2 Getting Started with the Real-Time Workshop2-16WhenyouclickontheBuild button in the Simulation Parameters dialog box,the Real-Time Workshop invokes

Seite 351

Building Generic Real-Time Programs2-17substitute the numerical values of the model parameters in place of thevariable names. It also instructs Simuli

Seite 352 - Generating Ada Code

2 Getting Started with the Real-Time Workshop2-18a MATLAB MAT-file. You can load this data into MATLAB for analysis. See“Blocks That Depend on Absolut

Seite 353 - Generated Files

Building Generic Real-Time Programs2-19grt_unix.tmf is designed to be used by GNU Make, which is located inmatlabroot/bin/arch/make (except for Linux

Seite 354 - Parameters field blank)

vFile and Function Splitting ... 3-38FileSplitting ... 3-38FunctionSplitting ...

Seite 355 - Generating the Ada Code

2 Getting Started with the Real-Time Workshop2-20Generic Real-Time ModulesThese source modules are automatically linked by the makefile, model.mk.Them

Seite 356

Blocks That Depend on Absolute Time2-21Blocks That Depend on Absolute TimeSome Simulink blocks use the value of absolute time (i.e., the time from the

Seite 357

2 Getting Started with the Real-Time Workshop2-22In addition, data logging time (in the Workspace I/O page of the SimulationParametersdialog box) also

Seite 358

Code Validation2-23Code ValidationAfter completing the build process, the stand-alone version of the f14 model isready for comparison with the Simulin

Seite 359

2 Getting Started with the Real-Time Workshop2-24Then look at the workspace variables:whoYour variables are:rt_Pilot_G_force rt_tout rt_Angle_of_attac

Seite 360 - Signal_Name is declared in

Code Validation2-25Comparing Simulation and Generic Real-Time ResultsYour Simulink simulations and generic real-time code should produce nearlyidentic

Seite 361

2 Getting Started with the Real-Time Workshop2-26Comparing Pilot_G_force to rt_Pilot_G_force produces:max(abs(rt_Pilot_G_force-Pilot_G_force))ans = 1

Seite 362 - Code Validation

Code Validation2-27Use the MATLAB open_system command to trace the generated code back tothe model. For example,open_system('<S3>') op

Seite 363

2 Getting Started with the Real-Time Workshop2-28Targeting dSPACEdSPACE, a company that specializes in real-time hardware and softwareproducts, market

Seite 364

Targeting dSPACE2-29Figure 2-3: A PC Setup Including a Target SystemFigure 2-4: The dSPACE PHS BusMotherboard “host”Embedded cards(target system)PC

Seite 365 - Supported Blocks

viCreating an External Mode Communication Channel . . . . . . 4-27Rebuildingtheext_commMEX-file ... 4-275Data Logging and Signal Mon

Seite 366

2 Getting Started with the Real-Time Workshop2-30Real-Time Interface (RTI)When using the Real-Time Workshop with dSPACE hardware, you mustgenerate tar

Seite 367

Targeting dSPACE2-31system target file and template makefile. For the current example, in theReal-Time Workshop page of the dialog box, specify:• Syst

Seite 368

2 Getting Started with the Real-Time Workshop2-32This picture shows the Control Desk Control Panel and a sample of ControlDesk plots:Figure 2-5: The

Seite 369 - Directory Tree

3Code Generation and theBuild ProcessIntroduction ...3-2Automatic Program Building ...3-3The Real-Time Workshop User Interfa

Seite 370

3 Code Generation and the Build Process3-2IntroductionThe Real-Time Workshop simplifies the process of building applicationprograms. One of the Real-T

Seite 371

Automatic Program Building3-3Automatic Program BuildingThe Real-Time Workshop automates the task of building a stand-aloneprogram from your Simulink m

Seite 372

3 Code Generation and the Build Process3-4Theshadedboxinthefigurebelowoutlinesthesesteps:Figure 3-1: The Build ProcessThe task of creating a stand-al

Seite 373

Automatic Program Building3-5When you click the Build button on the Real-Time Workshop page on theSimulation Parameters dialog box, these steps are ca

Seite 374 - Directory Purpose

3 Code Generation and the Build Process3-6The Real-Time Workshop User InterfaceYou work with the Real-Time Workshop by interacting with and modifyingf

Seite 375

The Real-Time Workshop User Interface3-7System Target FileUse the System target file fieldtospecifythetypeofcodeandtargetforwhichyou are generating co

Seite 376

viiRapid Prototyping System Dependent Components . . . . . . . . 6-27ThemainFunction ... 6-27Initialization ...

Seite 377

3 Code Generation and the Build Process3-8This table lists the options available.Table 3-2: Target Language Compiler Optional Variables Variable Desc

Seite 378 - B Glossary

The Real-Time Workshop User Interface3-9−aFunctionInlineType="mode"Controls how functions are inlined. Thereare two modes:•CodeInsertion• Pr

Seite 379

3 Code Generation and the Build Process3-10Inline ParametersInlining parameters refers to a mode where blocks with a constant sample timeare removed f

Seite 380

The Real-Time Workshop User Interface3-11Retaining the model.rtw FileWhen modifying the target files, you will need to look at the model.rtw file. Top

Seite 381

3 Code Generation and the Build Process3-12select the target appropriate to your application. This is a picture of thebrowser with the generic real-ti

Seite 382

The Real-Time Workshop User Interface3-13Table 3-3: Targets Available from the System Target File BrowserTarget/Code Format System Target FileTemplat

Seite 383

3 Code Generation and the Build Process3-14Generic Real-Timefor UNIXgrt.tlc grt_unix.tmf make_rtw 3and12Generic Real-Time(dynamic) for PC/UNIXgrt_mall

Seite 384 - See Rsim 13-2

The Real-Time Workshop User Interface3-15Options ButtonThere is an Options button on the Real-Time Workshop page of theSimulation Parameters dialog bo

Seite 385 - SimStruct data structure

3 Code Generation and the Build Process3-16Generation Options dialog box that varies depending on which system targetfile configuration you selected i

Seite 386

The Real-Time Workshop User Interface3-17Verbose builds. This feature forces command line display of code generationstages and compiler output.Invaria

Kommentare zu diesen Handbüchern

Keine Kommentare