MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Uživatelská příručka

Procházejte online nebo si stáhněte Uživatelská příručka pro Software MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER. MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER User`s guide [en] Uživatelská příručka

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 386
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků

Shrnutí obsahu

Strany 1 - Real-Time Workshop

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

Strany 2 - How to Contact The MathWorks:

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

Strany 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

Strany 4

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

Strany 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

Strany 6

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

Strany 7

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

Strany 8

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

Strany 9

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

Strany 10

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

Strany 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

Strany 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

Strany 13 - Real-Time Workshop Libraries

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

Strany 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

Strany 15 - Real-Time Workshop Ada Coder

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 24 - Installation

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

Strany 25 - System,gototheEnvironment

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

Strany 26

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

Strany 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

Strany 28

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

Strany 29 - Introduction to the

3 Code Generation and the Build Process3-42

Strany 30

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

Strany 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

Strany 32 - Types of Output

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

Strany 33

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

Strany 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

Strany 35

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 40

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

Strany 41

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

Strany 42 - Make Utility

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

Strany 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

Strany 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

Strany 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

Strany 46

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

Strany 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

Strany 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

Strany 49

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

Strany 50

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

Strany 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

Strany 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

Strany 53

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

Strany 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

Strany 55 - 4. Validating Generated Code

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

Strany 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),

Strany 57

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

Strany 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,

Strany 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

Strany 61

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

Strany 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

Strany 63

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

Strany 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

Strany 65

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

Strany 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.

Strany 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

Strany 68 - The UNIX Template Makefile

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

Strany 69 - PC Template Makefiles

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

Strany 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:/*

Strany 71 - Nonlinear Blocks

5 Data Logging and Signal Monitoring5-10

Strany 72

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

Strany 73

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

Strany 74

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

Strany 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

Strany 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.

Strany 77

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

Strany 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

Strany 79 - PC chassisMonitor/keyboard

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

Strany 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

Strany 81

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

Strany 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

Strany 83 - Build Process

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

Strany 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

Strany 85 - Build button on the

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

Strany 86

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

Strany 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

Strany 88

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

Strany 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

Strany 90

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

Strany 91

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

Strany 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

Strany 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

Strany 94

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

Strany 95

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

Strany 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

Strany 97 - Options Button

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

Strany 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.

Strany 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

Strany 100 - Tunable Parameters

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

Strany 101 - Signal Properties

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

Strany 102

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

Strany 103

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

Strany 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

Strany 105 - Template Makefiles

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

Strany 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

Strany 107

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

Strany 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

Strany 109 - Parameters

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

Strany 110

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

Strany 111

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

Strany 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

Strany 113

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

Strany 115

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

Strany 116

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

Strany 117

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

Strany 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

Strany 119

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

Strany 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

Strany 121

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

Strany 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

Strany 123

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

Strany 124

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

Strany 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

Strany 126 - Introduction

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

Strany 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

Strany 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

Strany 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

Strany 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.

Strany 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

Strany 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

Strany 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

Strany 134 - External Mode Control Panel

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

Strany 135 - Target Interface

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

Strany 136

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

Strany 137

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

Strany 138

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

Strany 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

Strany 140

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

Strany 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)

Strany 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

Strany 143

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

Strany 144

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

Strany 145

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

Strany 146 - Interface

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

Strany 147

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 152

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

Strany 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

Strany 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

Strany 155

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

Strany 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

Strany 157

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

Strany 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

Strany 159

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

Strany 160

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

Strany 161

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

Strany 162

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

Strany 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

Strany 164

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

Strany 165

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

Strany 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

Strany 167

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

Strany 168

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 174

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

Strany 175

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

Strany 176

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

Strany 177

9 Targeting DOS for Real-Time Applications9-18

Strany 178

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

Strany 179

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

Strany 180

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

Strany 181

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

Strany 182

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

Strany 183

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

Strany 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

Strany 185

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

Strany 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

Strany 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

Strany 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

Strany 189 - Initialization

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

Strany 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

Strany 191

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

Strany 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;

Strany 193

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

Strany 194 - The SimStruct Data Structure

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

Strany 195 - — MdlInitializeSampleTimes

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

Strany 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

Strany 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

Strany 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

Strany 199

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

Strany 200

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

Strany 201 - Sample Rates

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

Strany 202

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

Strany 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

Strany 204

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

Strany 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

Strany 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

Strany 207

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

Strany 208 - Singletasking

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

Strany 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

Strany 210 - Singletasking Operation

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

Strany 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

Strany 212 - T=2sT=1s

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

Strany 213

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

Strany 214

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

Strany 215

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

Strany 216

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

Strany 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

Strany 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

Strany 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

Strany 220

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

Strany 221 - VxWorks Support library

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

Strany 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

Strany 223 - WindSh (the

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

Strany 224

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

Strany 225

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

Strany 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

Strany 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

Strany 228

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

Strany 229 - Implementation Overview

11 Real-Time Workshop Libraries11-26

Strany 230

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

Strany 231 - VxWorks Configuration

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

Strany 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

Strany 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

Strany 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

Strany 235

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

Strany 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

Strany 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

Strany 238

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

Strany 239

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

Strany 240

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

Strany 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

Strany 242

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

Strany 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

Strany 244

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

Strany 245

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 251

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

Strany 252 - [-10 10] volts. Refer

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

Strany 253

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

Strany 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

Strany 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

Strany 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

Strany 257

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

Strany 258

12 Configuring Real-Time Workshop for Your Application12-26

Strany 259 - Hardware

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

Strany 260

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 268

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

Strany 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

Strany 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

Strany 271

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

Strany 272

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

Strany 273 - Initializing Sample Times

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

Strany 274 - Initializing the I/O Device

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

Strany 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

Strany 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

Strany 277

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

Strany 278

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

Strany 279 - Libraries

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

Strany 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

Strany 281

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

Strany 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

Strany 283

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

Strany 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

Strany 285

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

Strany 286

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

Strany 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

Strany 288

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

Strany 289

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

Strany 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

Strany 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

Strany 292

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

Strany 293

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

Strany 294

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

Strany 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

Strany 296

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

Strany 297

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

Strany 298

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

Strany 299

14 Real-Time Workshop Ada Coder14-24

Strany 300

AReal-Time WorkshopDirectory Tree

Strany 301

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

Strany 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

Strany 303 - Library for Your System

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

Strany 304

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

Strany 305 - Application

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

Strany 306

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

Strany 307

BGlossary

Strany 308

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

Strany 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

Strany 310

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

Strany 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-

Strany 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

Strany 313

B GlossaryB-6

Strany 314 - Real-Time Code Format

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

Strany 315

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

Strany 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

Strany 317

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

Strany 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

Strany 319 - Local block outputs

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

Strany 320 - System Target File

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

Strany 321

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

Strany 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

Strany 323

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

Strany 324 - Restrictions

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

Strany 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

Strany 326 - Simulation Parameters

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

Strany 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

Strany 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

Strany 329 - Compiler Options

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

Strany 330

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

Strany 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

Strany 332

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

Strany 333

1 Introduction to the Real-Time Workshop1-22

Strany 334 - File Browser

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

Strany 335

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

Strany 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

Strany 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

Strany 338

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

Strany 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

Strany 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

Strany 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

Strany 342

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

Strany 343 - Simulation Performance

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 348

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

Strany 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

Strany 350 - Getting Started

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

Strany 351

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

Strany 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

Strany 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

Strany 354 - Parameters field blank)

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

Strany 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

Strany 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

Strany 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

Strany 358

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 363

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

Strany 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

Strany 365 - Supported Blocks

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

Strany 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

Strany 367

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

Strany 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

Strany 369 - Directory Tree

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

Strany 370

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

Strany 371

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

Strany 372

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

Strany 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

Strany 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

Strany 375

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

Strany 376

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

Strany 377

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

Strany 378 - B Glossary

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

Strany 379

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

Strany 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

Strany 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

Strany 382

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

Strany 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

Strany 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

Strany 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

Strany 386

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

Komentáře k této Příručce

Žádné komentáře