MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Guida Utente

Navigare online o scaricare Guida Utente per Software MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER. MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER User`s guide [en] Manuale Utente

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 386
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti

Sommario

Pagina 1 - Real-Time Workshop

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

Pagina 2 - How to Contact The MathWorks:

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

Pagina 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

Pagina 4

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

Pagina 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

Pagina 6

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

Pagina 7

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

Pagina 8

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

Pagina 9

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

Pagina 10

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

Pagina 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

Pagina 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

Pagina 13 - Real-Time Workshop Libraries

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

Pagina 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

Pagina 15 - Real-Time Workshop Ada Coder

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 24 - Installation

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

Pagina 25 - System,gototheEnvironment

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

Pagina 26

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

Pagina 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

Pagina 28

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

Pagina 29 - Introduction to the

3 Code Generation and the Build Process3-42

Pagina 30

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

Pagina 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

Pagina 32 - Types of Output

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

Pagina 33

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

Pagina 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

Pagina 35

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 40

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

Pagina 41

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

Pagina 42 - Make Utility

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

Pagina 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

Pagina 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

Pagina 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

Pagina 46

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

Pagina 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

Pagina 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

Pagina 49

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

Pagina 50

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

Pagina 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

Pagina 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

Pagina 53

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

Pagina 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

Pagina 55 - 4. Validating Generated Code

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

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

Pagina 57

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

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

Pagina 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

Pagina 61

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

Pagina 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

Pagina 63

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

Pagina 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

Pagina 65

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

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

Pagina 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

Pagina 68 - The UNIX Template Makefile

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

Pagina 69 - PC Template Makefiles

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

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

Pagina 71 - Nonlinear Blocks

5 Data Logging and Signal Monitoring5-10

Pagina 72

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

Pagina 73

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

Pagina 74

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

Pagina 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

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

Pagina 77

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

Pagina 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

Pagina 79 - PC chassisMonitor/keyboard

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

Pagina 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

Pagina 81

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

Pagina 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

Pagina 83 - Build Process

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

Pagina 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

Pagina 85 - Build button on the

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

Pagina 86

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

Pagina 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

Pagina 88

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

Pagina 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

Pagina 90

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

Pagina 91

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

Pagina 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

Pagina 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

Pagina 94

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

Pagina 95

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

Pagina 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

Pagina 97 - Options Button

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

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

Pagina 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

Pagina 100 - Tunable Parameters

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

Pagina 101 - Signal Properties

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

Pagina 102

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

Pagina 103

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

Pagina 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

Pagina 105 - Template Makefiles

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

Pagina 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

Pagina 107

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

Pagina 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

Pagina 109 - Parameters

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

Pagina 110

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

Pagina 111

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

Pagina 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

Pagina 113

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

Pagina 115

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

Pagina 116

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

Pagina 117

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

Pagina 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

Pagina 119

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

Pagina 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

Pagina 121

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

Pagina 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

Pagina 123

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

Pagina 124

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

Pagina 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

Pagina 126 - Introduction

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

Pagina 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

Pagina 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

Pagina 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

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

Pagina 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

Pagina 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

Pagina 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

Pagina 134 - External Mode Control Panel

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

Pagina 135 - Target Interface

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

Pagina 136

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

Pagina 137

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

Pagina 138

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

Pagina 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

Pagina 140

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

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

Pagina 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

Pagina 143

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

Pagina 144

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

Pagina 145

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

Pagina 146 - Interface

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

Pagina 147

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 152

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

Pagina 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

Pagina 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

Pagina 155

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

Pagina 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

Pagina 157

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

Pagina 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

Pagina 159

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

Pagina 160

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

Pagina 161

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

Pagina 162

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

Pagina 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

Pagina 164

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

Pagina 165

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

Pagina 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

Pagina 167

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

Pagina 168

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 174

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

Pagina 175

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

Pagina 176

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

Pagina 177

9 Targeting DOS for Real-Time Applications9-18

Pagina 178

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

Pagina 179

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

Pagina 180

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

Pagina 181

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

Pagina 182

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

Pagina 183

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

Pagina 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

Pagina 185

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

Pagina 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

Pagina 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

Pagina 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

Pagina 189 - Initialization

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

Pagina 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

Pagina 191

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

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

Pagina 193

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

Pagina 194 - The SimStruct Data Structure

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

Pagina 195 - — MdlInitializeSampleTimes

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

Pagina 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

Pagina 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

Pagina 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

Pagina 199

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

Pagina 200

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

Pagina 201 - Sample Rates

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

Pagina 202

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

Pagina 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

Pagina 204

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

Pagina 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

Pagina 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

Pagina 207

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

Pagina 208 - Singletasking

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

Pagina 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

Pagina 210 - Singletasking Operation

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

Pagina 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

Pagina 212 - T=2sT=1s

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

Pagina 213

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

Pagina 214

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

Pagina 215

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

Pagina 216

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

Pagina 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

Pagina 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

Pagina 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

Pagina 220

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

Pagina 221 - VxWorks Support library

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

Pagina 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

Pagina 223 - WindSh (the

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

Pagina 224

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

Pagina 225

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

Pagina 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

Pagina 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

Pagina 228

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

Pagina 229 - Implementation Overview

11 Real-Time Workshop Libraries11-26

Pagina 230

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

Pagina 231 - VxWorks Configuration

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

Pagina 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

Pagina 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

Pagina 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

Pagina 235

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

Pagina 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

Pagina 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

Pagina 238

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

Pagina 239

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

Pagina 240

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

Pagina 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

Pagina 242

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

Pagina 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

Pagina 244

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

Pagina 245

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 251

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

Pagina 252 - [-10 10] volts. Refer

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

Pagina 253

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

Pagina 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

Pagina 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

Pagina 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

Pagina 257

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

Pagina 258

12 Configuring Real-Time Workshop for Your Application12-26

Pagina 259 - Hardware

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

Pagina 260

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 268

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

Pagina 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

Pagina 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

Pagina 271

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

Pagina 272

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

Pagina 273 - Initializing Sample Times

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

Pagina 274 - Initializing the I/O Device

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

Pagina 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

Pagina 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

Pagina 277

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

Pagina 278

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

Pagina 279 - Libraries

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

Pagina 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

Pagina 281

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

Pagina 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

Pagina 283

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

Pagina 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

Pagina 285

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

Pagina 286

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

Pagina 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

Pagina 288

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

Pagina 289

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

Pagina 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

Pagina 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

Pagina 292

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

Pagina 293

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

Pagina 294

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

Pagina 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

Pagina 296

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

Pagina 297

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

Pagina 298

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

Pagina 299

14 Real-Time Workshop Ada Coder14-24

Pagina 300

AReal-Time WorkshopDirectory Tree

Pagina 301

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

Pagina 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

Pagina 303 - Library for Your System

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

Pagina 304

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

Pagina 305 - Application

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

Pagina 306

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

Pagina 307

BGlossary

Pagina 308

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

Pagina 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

Pagina 310

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

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

Pagina 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

Pagina 313

B GlossaryB-6

Pagina 314 - Real-Time Code Format

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

Pagina 315

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

Pagina 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

Pagina 317

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

Pagina 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

Pagina 319 - Local block outputs

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

Pagina 320 - System Target File

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

Pagina 321

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

Pagina 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

Pagina 323

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

Pagina 324 - Restrictions

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

Pagina 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

Pagina 326 - Simulation Parameters

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

Pagina 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

Pagina 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

Pagina 329 - Compiler Options

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

Pagina 330

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

Pagina 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

Pagina 332

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

Pagina 333

1 Introduction to the Real-Time Workshop1-22

Pagina 334 - File Browser

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

Pagina 335

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

Pagina 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

Pagina 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

Pagina 338

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

Pagina 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

Pagina 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

Pagina 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

Pagina 342

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

Pagina 343 - Simulation Performance

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 348

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

Pagina 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

Pagina 350 - Getting Started

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

Pagina 351

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

Pagina 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

Pagina 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

Pagina 354 - Parameters field blank)

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

Pagina 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

Pagina 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

Pagina 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

Pagina 358

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

Pagina 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

Pagina 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

Pagina 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

Pagina 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

Pagina 363

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

Pagina 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

Pagina 365 - Supported Blocks

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

Pagina 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

Pagina 367

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

Pagina 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

Pagina 369 - Directory Tree

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

Pagina 370

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

Pagina 371

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

Pagina 372

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

Pagina 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

Pagina 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

Pagina 375

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

Pagina 376

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

Pagina 377

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

Pagina 378 - B Glossary

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

Pagina 379

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

Pagina 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

Pagina 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

Pagina 382

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

Pagina 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

Pagina 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

Pagina 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

Pagina 386

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

Commenti su questo manuale

Nessun commento