ModelingSimulationImplementationReal-Time Workshop® For Use with SIMULINK ®User’s GuideVersion 3
viiiExecutingModelsinReal-Time ... 7-9MultitaskingOperation... 7-10SingletaskingOperation ...
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
The Real-Time Workshop User Interface3-19The RTW Tunable Parameters dialog box supports the following features:• Parameter tuning — de-inline any mode
3 Code Generation and the Build Process3-20your Simulink model; then select Signal Properties under the Edit menu ofyour model. This opens theSignal P
The Real-Time Workshop User Interface3-21- Imported Extern — declares the signal as extern. It must then be declaredfrom outside the generated code.-
3 Code Generation and the Build Process3-22Configuring the Generated CodeAs an alternative to using the Code Generation Options dialog box, you cancon
Template Makefiles3-23Template MakefilesThis section contains a description of how to work with and modify thetemplate makefiles that are used with th
3 Code Generation and the Build Process3-24|>MEXEXT<|MEX-file extension. See the MATLABmexext command.|>MODEL_NAME<| Name of the Simulink
Template Makefiles3-25In addition target specific tokens defined via the Real-Time Workshop page oftheSimulation Parameters dialog box are expanded. I
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
Template Makefiles3-27then the make command that will be invoked is:mymake −f model.mkHOST— What platform this template makefile is targeted for. This
ixInteractively ... 8-19ConnectingtotheVxWorksTarget ... 8-19DownloadingtheReal-TimeProgram ...
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
Template Makefiles3-29Figure 3-7: Structure of a Template Makefile#-- Section 1: Comments -------------------------------------------------------## D
3 Code Generation and the Build Process3-30Customizing and Creating Template MakefilesTo customize or create a new template makefile, you can copy an
Template Makefiles3-31You can use pattern matching expressions to make the dependency rules moregeneral. For example, using GNU Make you could have re
3 Code Generation and the Build Process3-32Generic Real-Time TemplatesThe Real-Time Workshop includes a set of built-in template makefiles that areset
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
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
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
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
Generic Real-Time Templates3-37• OPTS — User-specific options, for example,make_rtw OPTS="−DMYDEFINE=1"• OPT_OPTS — grt_bc.tmf optimization
x10Targeting Custom HardwareIntroduction ...10-2Run-Time Interface ...1
3 Code Generation and the Build Process3-38File and Function SplittingTo support compilers with file size limitations, the Real-Time Workshopprovides
File and Function Splitting3-39You must turn off the TLC variable ShowEliminatedStatements for filesplitting to work. This is required because the#if
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
File and Function Splitting3-41incrementing by one each time the function is split. For example, if youroriginal function isMdlOutput, the split funct
3 Code Generation and the Build Process3-42
4External ModeIntroduction ...4-2ExternalMode...4-3Getting Started with External Mode Using grt ...4-4Setting Up th
4 External Mode4-2IntroductionExternal mode is a simulation mode provided by the Real-Time Workshop thatsupports on-the-fly parameter tuning in a real
Introduction4-3External ModeSimulink external mode is a mechanism that manages communicationbetween Simulink and stand-alone programs built with the R
4 External Mode4-4Getting Started with External Mode Using grtThis section provides a step-by-step set of instructions for getting started withexterna
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
xi11Real-Time Workshop LibrariesIntroduction ...11-2Custom Code Library ...
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
Getting Started with External Mode Using grt4-7To open the External Target Interface dialog box, click the Target Interfacebutton. The dialog box shou
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
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
4 External Mode4-10External Mode GUIThe Real-Time Workshop provides an extensive graphical user interface (GUI),which includes four separate windows,
External Mode GUI4-11Target InterfacePressing the Target Interface button activates the External Target Interfacedialog box.You must set the MEX-file
4 External Mode4-12External Signal & TriggeringPressing the Signal & Triggering button activates the External Signal &Triggeringdialog box
External Mode GUI4-13Trigger Signal Selection. You select a trigger signal by choosing it from the Signalselection list and pressing theTrigger signal
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
External Mode GUI4-15Data ArchivingPressing the Data Archiving button opens the External Data Archivingdialog box.This panel supports various features
xii ContentsChoosingaTarget ... 12-7Real-Time Code Format ...12-10UnsupportedBlocks...
4 External Mode4-16intermediate result. Since the trigger can fire at any time, writing intermediateresults to the workspace generally results in unpr
External Mode GUI4-17This picture shows the External Data Archiving dialog box with enabledarchiving.Unless you selectEnable archiving, entries for th
4 External Mode4-18This picture shows the External Mode Control Panel with the batchdownload option activated:External Mode OperationWhen external mod
External Mode GUI4-19The Simulink side initiates the parameter download operation by calling aprocedure on the external program side. In the general t
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
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
4 External Mode4-22Using the TCP ImplementationThis section describes how to use the TCP-based client/server implementationprovided with the Real-Time
Using the TCP Implementation4-23Figure 4-2: TCP-based Client/Server Implementation for External ModeThe following sections discuss the details of how
4 External Mode4-24The External Interface MEX-FileYoumustspecifythenameoftheexternalinterfaceMEX-fileintheExternalTarget Interfacedialog box:You may b
Using the TCP Implementation4-25You must specify these options in order. For example, if you want to specify theverbosity level (the second argument),
xiii13Real-Time Workshop Rapid Simulation TargetIntroduction ...13-2Building for the Rapid Simulation Targe
4 External Mode4-26Enabling External ModeTo enable external mode, display the Simulink block diagram and selectExternal from the Simulation menu:Next,
Using the TCP Implementation4-27Creating an External Mode Communication ChannelThe Real-Time Workshop provides support for TCP/IP through ext_comm.Whe
4 External Mode4-28
5Data Logging and SignalMonitoringMAT-File Data Logging ...5-2Singletasking versus MultitaskingMAT-FileLogging...5-3C API for
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
MAT-File Data Logging5-3Singletasking versus Multitasking MAT-File LoggingWhen logging data you will notice differences in the logging of:• Noncontinu
5 Data Logging and Signal Monitoring5-4C API for Signal MonitoringSignal monitoring provides a second method for accessing block outputs in anexternal
Using BlockIOSignals to Obtain Block Outputs5-5Using BlockIOSignals to Obtain Block OutputsThe BlockIOSignals data structure is declared as follows:ty
5 Data Logging and Signal Monitoring5-6The model code file model.bio defines an array of BlockIOSignals structures,for example:#include "bio_sig.
Using BlockIOSignals to Obtain Block Outputs5-7You must then write code that walks through the rtBIOSignals array andchooses the signals to be monitor
xiv ContentsGetting Started ... 14-6SettingOptionsforAdaCodeGeneration ... 14-7GeneratingAdaCode...
5 Data Logging and Signal Monitoring5-8continue; } } /*install/remove the signals*/ for (w = 0; w < blockInfo->signalWidth; w++) {
Using BlockIOSignals to Obtain Block Outputs5-9Below is an excerpt from an example routine that collects signals taken fromthe main simulation loop:/*
5 Data Logging and Signal Monitoring5-10
6Program ArchitectureIntroduction ...6-2Model Execution ...6-4ProgramTiming...6-13ProgramExecution...
6 Program Architecture6-2IntroductionThe Real-Time Workshop generates two styles of code. One code style issuitable for rapid prototyping (and simulat
Introduction6-3Third-party vendors supply additional targets for the Real-Time Workshop.Generally, these can be classified as rapid prototyping target
6 Program Architecture6-4Model ExecutionBefore looking at the two styles of generated code, you need to have a high-levelunderstanding of how the gene
Model Execution6-5a given simulation time step. In minor time steps, the run-time interfaceintegrates the derivatives to update the continuous states.
6 Program Architecture6-6During the ModelOutputs and ModelUpdate phases of model execution, onlyblocks that have hit the current point in time execute
Model Execution6-7Note that the multitasking execution assumes that all tasks are multiples ofthe base rate. Simulink enforces this when you have crea
ForewordRelated Products and Documentation ...xviRequirements...xviHow to Use This Guide ...xxiTypographicalConventi
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
Model Execution6-9continuous blocks, then the integration step size determines the base samplerate.For example, if the model code is a controller oper
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
Model Execution6-11Running models at interrupt level in real-time multitasking environment isvery similar to the previous singletasking environment, e
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
Model Execution6-13EndMainLoop}main(){InitializationStart/spawn task "tSingleRate".Start clock that does a "semGive" on a clockSem
6 Program Architecture6-14The following diagram illustrates interrupt timing.Figure 6-2: Task TimingThesampleintervalmustbelongenoughtoallowmodelcode
Model Execution6-15Program ExecutionAs the previous section indicates, a real-time program may not require 100% ofthe CPU’s time. This provides an opp
6 Program Architecture6-16that have a task identifier of 0. This results in differences in the logged valuesbetween singletasking and multitasking log
Model Execution6-17name, parameter and signal storage class are included as part of the API forthe embedded style of code.The single largest differenc
ForewordxviRelated Products and DocumentationRequirementsThe Real-Time Workshop®is a multiplatform product, running on MicrosoftWindows 95, Windows 9
6 Program Architecture6-18model.reg), execute, the run-time interface starts execution by callingMdlStart. This routine is called once at start-up.The
Model Execution6-19• MdlTerminate(void) — MdlTerminate contains any block shutdown code.MdlTerminate is called by the run-time interface, as part of t
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
Model Execution6-21A flow chart describing the execution of the rapid prototyping generated codeis shown below.Figure 6-4: Rapid Prototyping Executio
6 Program Architecture6-22Block outputs can also go to the external output structure (rtY). The followingfigure shows the general mapping between thes
Model Execution6-23The states structure has two sections: the first is for the continuous states;the second is for the discrete states.• Block Paramet
6 Program Architecture6-24When compared with the rapid prototyping environment, these functions arevery similar.
Rapid Prototyping Program Framework6-25Rapid Prototyping Program FrameworkGenerating code for a Simulink model results in at least four files — model.
6 Program Architecture6-26Figure 6-6: The Rapid Prototyping Program ArchitectureThe Real-Time Workshop architecture consists of three parts. The firs
Rapid Prototyping Program Framework6-27modules that implement the functions carried out by the system dependent,system independent, and application co
Related Products and DocumentationxviiWhat Is MATLAB?MATLAB is a high-performance language for technical computing. Itintegrates computation, visualiz
6 Program Architecture6-28Model Execution• Execute a background task, for example, communicate with the host duringexternal mode simulation or introdu
Rapid Prototyping Program Framework6-29Model ExecutionAt each sample interval, the main program passes control to the modelexecution function, which e
6 Program Architecture6-30Integration of Continuous States The real-time program calculates the next values for the continuous statesbased on the deri
Rapid Prototyping Program Framework6-31Application Modules for System Independent ComponentsThe system independent components include these modules:•
6 Program Architecture6-32• Initialize a vector of sample times and sample time offsets and store thisvector in theSimStruct.• Store the values of the
Rapid Prototyping Program Framework6-33Figure 6-8: Execution of the Model CodeThis diagram shows what functions are defined in the generated code and
6 Program Architecture6-34automatically incorporates your non-inlined C code S-functions into theprogram if they adhere to the S-function API describe
Rapid Prototyping Program Framework6-35Application Modules for Application ComponentsWhen the Real-Time Workshop generates code, it produces the follo
6 Program Architecture6-36Embedded Program FrameworkThe embedded program framework and architecture is outlined by thefollowing figure.Figure 6-9: Th
Embedded Program Framework6-37Note the similarity between this architecture and the rapid prototypingarchitecture on page 6-26. The main difference is
How to Contact The MathWorks:508-647-7000 Phone508-647-7001 FaxThe MathWorks, Inc. Mail24 Prime Park WayNatick, MA 01760-1500http://www.mathworks.com
ForewordxviiiWhat Is Simulink?Simulink is a software package for modeling, simulating, and analyzingdynamic systems. It supports linear and nonlinear
6 Program Architecture6-38
7Models with MultipleSample RatesIntroduction ...7-2Single Versus Multitasking Environments ...7-3ExecutingMultitaskingModels...
7 Models with Multiple Sample Rates7-2IntroductionEvery Simulink block can be classified according to its sample time as constant,continuous-time, dis
Single- Versus Multitasking Environments7-3Single- Versus Multitasking EnvironmentsThere are two basic ways in which you can execute a fixed-step Simu
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
Single- Versus Multitasking Environments7-5Executing Multitasking ModelsIn cases where the continuous part of a model executes at a rate that isdiffer
7 Models with Multiple Sample Rates7-6The following diagrams illustrate how mixed-rate systems are handled by theReal-Time Workshop in these two envir
Single- Versus Multitasking Environments7-7Figure 7-3: Pseudomultitasking Using Overlapped InterruptsThis diagram illustrates how overlapped interrup
7 Models with Multiple Sample Rates7-8SingletaskingIt is possible to execute the model code in a strictly singletasking manner.While this method is le
Single- Versus Multitasking Environments7-9Simulating Models with SimulinkBefore Simulink simulates a model, it orders all of the blocks based upon th
Related Products and DocumentationxixStateflow machine. This S-function is the agent Simulink interacts with forsimulation and analysis.The control be
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
Sample Rate Transitions7-11Sample Rate TransitionsThere are two possible sample rate transitions that can exist within a model:• A faster block drivin
7 Models with Multiple Sample Rates7-12In transitioning from slower to faster blocks, you must add Unit Delay blocksbetween slow to fast transitions a
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
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
Sample Rate Transitions7-15As you can see from the preceding diagrams, Simulink can simulate modelswith multiple sample rates in an efficient manner.
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
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
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
8Targeting Tornado forReal-Time ApplicationsIntroduction ...8-2Confirming Your Tornado Setup Is Operational . . . . . . 8-2VxWorksLib
Forewordxxdiagrams. Stateflow brings system specification and design closer together. Itis easy to create designs, consider various scenarios, and it
8 Targeting Tornado for Real-Time Applications8-2IntroductionThis chapter describes how to create real-time programs for execution underVxWorks, which
Introduction8-3for additional information about installation and operation of VxWorks andTornado products.VxWorks LibrarySelecting VxWorks Support und
8 Targeting Tornado for Real-Time Applications8-4There is a second sublibrary, the IO Devices library, that contains support forthese drivers:• Matrix
Run-time Architecture Overview8-5Run-time Architecture OverviewIn a typical VxWorks-based real-time system, the hardware consists of a UNIXor PC host
8 Targeting Tornado for Real-Time Applications8-6External ModeSimulink external mode provides a mechanism to download new parametervalues to the execu
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)
8 Targeting Tornado for Real-Time Applications8-8StethoScopeWith StethoScope, you can access the output of any block in the model (in thereal-time pro
Run-time Architecture Overview8-9The program creates VxWorks tasks to run on the real-time system: onecommunicates with Simulink, the others execute t
8 Targeting Tornado for Real-Time Applications8-10Multitasking. Optionally, the model can run as multiple tasks, one for eachsample rate in the model.
Implementation Overview8-11Implementation OverviewTo implement and run a VxWorks-based real-time program using theReal-Time Workshop, you must:• Desig
How to Use This GuidexxiHow to Use This GuideTypographical ConventionsTo Indicate... This Guide Uses... ExampleNew terms Italics An array is an ordere
8 Targeting Tornado for Real-Time Applications8-12Figure 8-3: Source Modules Used to Build the VxWorks Real-Time ProgramThis diagram illustrates the
Implementation Overview8-13Adding Device Driver BlocksThe real-time program communicates with the I/O devices installed in theVxWorks target chassis v
8 Targeting Tornado for Real-Time Applications8-14Edit the following lines to reflect your setup.VX_TARGET_TYPE = 68kCPU_TYPE = MC68040Downloading Con
Implementation Overview8-15Specifying the Real-Time Build OptionsSet the real-time build options using the Solver and Real-Time Workshoppages of theSi
8 Targeting Tornado for Real-Time Applications8-16Next, use the System Target File Browser to select the correct Real-TimeWorkshop page settings for T
Implementation Overview8-17Build Command Options. You can specify build command options on the CodeGeneration Optionsdialog box. Click the Options but
8 Targeting Tornado for Real-Time Applications8-18• MATLAB MAT-file — to enable data logging during program execution,checkMAT-file logging. The progr
Implementation Overview8-19Downloading and Running the Executable InteractivelyIf automatic downloading is disabled, you must use the Tornado tools to
8 Targeting Tornado for Real-Time Applications8-20external mode during the build procedure.) It also initializes StethoScope if youselected this optio
Implementation Overview8-21The following table lists the arguments to this SimStruct.Table 8-1: Arguments to the rt_main SimStruct modelA pointer to
ForewordxxiiInstallationYour platform-specific MATLAB Installation Guide provides essentially all ofthe information you need to install the Real-Time
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
9Targeting DOS forReal-Time ApplicationsIntroduction ...9-2DOSDeviceDriversLibrary...9-3Implementation Overview ...
9 Targeting DOS for Real-Time Applications9-2IntroductionThis chapter provides information that pertains specifically to using theReal-Time Workshop i
Introduction9-3DOS Device Drivers LibrarySelecting DOS Device Drivers under the Real-Time Workshop library in theSimulink Library Browser opens the DO
9 Targeting DOS for Real-Time Applications9-4Implementation OverviewThe Real-Time Workshop includes DOS run-time interface modules designedto implemen
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
9 Targeting DOS for Real-Time Applications9-6Hardware RequirementsThe hardware needed to develop and run a real-time program includes:• A workstation
Implementation Overview9-7source code of the device drivers for the Keithley Metrabyte DAS 1600/1400Series I/O boards. See the “Device Driver Blocks”
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
Device Driver Blocks9-9Device Driver BlocksThe real-time program communicates with external hardware via a set ofdevice drivers. These device drivers
InstallationxxiiiIf you experience installation difficulties and have Web access, connect to TheMathWorkshomepage(http://www.mathworks.com). Look for
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
Device Driver Blocks9-11Analog Input (ADC) Block Parameters• Base I/O Address —Thebeginning of the I/O address spaceassigned to the board. The valuesp
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
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
9 Targeting DOS for Real-Time Applications9-14Digital Output Block Parameters• Base I/O Address —Thebeginning of the I/O address spaceassigned to the
Device Driver Blocks9-15executed at the specified rate. Specifically, when the digital output block isexecuted, it causes corresponding boolean values
9 Targeting DOS for Real-Time Applications9-16Building the ProgramOnce you have created your Simulink model and added the appropriate devicedriver blo
Building the Program9-17workstation. You can verify this by checking the environment variable,WATCOM, which correctly points to the directory where th
9 Targeting DOS for Real-Time Applications9-18
10Targeting CustomHardwareIntroduction ...10-2Run-Time Interface ...10-4Creating System Target Files and Template Makef
ForewordxxivMicrosoft Visual C/C++Define the environment variable MSDevDir to beMSDevDir=<path to compiler> for Visual C/C++ 4.2MSDevDir=<p
10 Targeting Custom Hardware10-2IntroductionThis chapter contains information on targeting custom hardware andimplementing device driver blocks. By im
Introduction10-3Note For examples of device drivers, see the S-functions supplied inmatlabroot/rtw/c/tornado/devices and matlabroot/rtw/c/dos/devices
10 Targeting Custom Hardware10-4Run-Time InterfaceThere are two ways to target custom hardware:• Rapid prototyping• Embedded real-timeRapid prototypin
Creating System Target Files and Template Makefiles10-5Creating System Target Files and Template MakefilesAssuming that you’ve created the directory/a
10 Targeting Custom Hardware10-6Clicking the Build button causes the Real-Time Workshop to generate code asdictated bymytarget.tlc and compile it as d
Implementing Device Drivers10-7Implementing Device DriversS-functions can be built into MEX-files or compiled and linked with other codeto become part
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
Implementing Device Drivers10-9- Reading values from an I/O device and assigning these values to theblock’s output vectory (ifitisanADC)- Writing valu
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
Implementing Device Drivers10-11S_FUNCTION_NAME DefinitionThe statement#define S_FUNCTION_NAME namedefines the name of the function that is the entry
Where to Go from HerexxvWhere to Go from HereChapter 1, “Introduction to the Real-Time Workshop,” is a quick introductionto the rapid prototyping proc
10 Targeting Custom Hardware10-12Conditional CompilationsIn general, you can use an S-function in these environments:• Simulink• Real-TimeWhen you use
Implementing Device Drivers10-13Next define a variable used to store the integer (which is the number ofchannels in this example):uint_T num_channels;
10 Targeting Custom Hardware10-14This list describes the function of each macro in mdlInitializeSizes:• ssSetNumSFcnParams — The number of input param
Implementing Device Drivers10-15The following example illustrates the definition of mdlInitializeSizes for aDAC:static void mdlInitializeSizes(SimStru
10 Targeting Custom Hardware10-16Initializing the I/O DeviceDevice driver S-functions use the mdlInitializeConditions function to:• Read parameters fr
Implementing Device Drivers10-17All S-functions call the mdlOutputs function to calculate block outputs. For adevice driver block, this function conta
10 Targeting Custom Hardware10-18The Termination FunctionThe final required function is typically used only in DACs to zero the output atthe end of th
Implementing Device Drivers10-19The Public Registration FunctionThe include file cg_sfun.h defines a function that is the entry point for theS-functio
10 Targeting Custom Hardware10-20Setting the MATLAB PathThe device driver blocks in a library can automatically change your MATLABpath to ensure that
11Real-Time WorkshopLibrariesIntroduction ...11-2Custom Code Library ...11-4CustomModelCode ...11-4CustomS
ForewordxxviChapter 12, “Configuring Real-Time Workshop for Your Application,”compares and contrasts various targets, including the generic real-time
11 Real-Time Workshop Libraries11-2IntroductionThe Real-Time Workshop provides a library of functions that allow you greatflexibility in constructing
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
11 Real-Time Workshop Libraries11-4Custom Code LibraryThe Real-Time Workshop also provides a Custom Code library containingblocks that allow you to pl
Custom Code Library11-5• model.h — Header File block•model.prm — Parameter File block•model.c — Source File block•model.reg — Registration File blockT
11 Real-Time Workshop Libraries11-6Double clicking the Model Start Function block opens a the MdlStartFunction Custom Codedialog box.You can insert cu
Custom Code Library11-7The code below is the MdlStart function for this example (mymodel).void MdlStart(void){ /* user code (Start function Header) *
11 Real-Time Workshop Libraries11-8• Subsystem Enable• Subsystem Disable• Subsystem Outputs• Subsystem Update• Subsystem DerivativesThe location of th
Interrupt Handling11-9Interrupt HandlingThe Real-Time Workshop provides blocks in the Interrupt Template librarythat allow you to model synchronous/as
11 Real-Time Workshop Libraries11-10subsystem (or Stateflow Chart). The Asynchronous Interrupt block theninstalls the Task Synchronization block as th
Interrupt Handling11-11concept:Figure 11-1: Using the Asynchronous Interrupt Block with Simulink’s Library Feature in the Rapid Prototyping Process B
1Introduction to theReal-Time WorkshopIntroduction ...1-2The Real-Time Workshop ...1-3Real-TimeWorkshopApplications...
11 Real-Time Workshop Libraries11-12generation on the board. You must match the interrupt level and vectorspecified in the Asynchronous Interrupt bloc
Interrupt Handling11-13• VME Interrupt Offset Number(s) — the Real-Time Workshop uses thisnumber in the call tointConnect(INUM_TO_IVEC(#),...). You sh
11 Real-Time Workshop Libraries11-14Asynchronous Interrupt Block Example - Simulation ModeThis example shows how the Asynchronous Interrupt block work
Interrupt Handling11-15Asynchronous Interrupt Block Example - RTW ModeThis example shows the Asynchronous Interrupt block in RTW mode:Note that the si
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
Interrupt Handling11-17• A semaphore is created to synchronize the downstream system to theexecution of the Task Synchronization block.• Code is added
11 Real-Time Workshop Libraries11-18VxWorks system. In particular, the default priority of the model code is 30and, when multitasking is enabled, the
Interrupt Handling11-19creates and initializes the synchronization semaphore. It also spawns thefunction-call subsystem as an independent task./* Crea
11 Real-Time Workshop Libraries11-20Asynchronous Buffer BlockTheVxWorksDoubleBufferblocksaremeanttobeusedtointerfacesignalstoasynchronous function-cal
Interrupt Handling11-21Asynchronous Buffer Block ParametersThere are two kinds of Asynchronous Buffer blocks, a reader and a writer. Thepicture below
iContentsForewordRelated Products and Documentation ... xviRequirements... xviWhatIsMATLAB? ...
1 Introduction to the Real-Time Workshop1-2IntroductionThe Real-Time Workshop, for use with MATLAB and Simulink, produces codedirectly from Simulink m
11 Real-Time Workshop Libraries11-22Asynchronous Buffer Block ExampleThis example shows how you might use the Asynchronous Buffer block tocontrol the
Interrupt Handling11-23This will cause blocks up- or downstream from it, which would otherwiseinherit from the function-call subsystem, to use the sam
11 Real-Time Workshop Libraries11-24Rate Transition Block ExampleThis picture shows a sample application of the Rate Transition block in an ISR:In thi
Creating a Customized Asynchronous Library for Your System11-25Creating a Customized Asynchronous Library for Your SystemYou can use the Real-Time Wor
11 Real-Time Workshop Libraries11-26
12Configuring Real-TimeWorkshop for YourApplicationIntroduction ...12-2Interaction between SimulinkandtheReal-TimeWorkshop ...
12 Configuring Real-Time Workshop for Your Application12-2IntroductionThis chapter discusses how Simulink interacts with the Real-Time Workshopand als
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
12 Configuring Real-Time Workshop for Your Application12-4This figure shows the propagation of the signal attributes associated with theInport block t
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
The Real-Time Workshop1-3The Real-Time WorkshopThe Real-Time Workshop provides a real-time development environment thatfeatures:• A rapid and direct p
12 Configuring Real-Time Workshop for Your Application12-6generator to properly specify the rate at which f() should be executed as shownin theconnect
Introduction12-7target throughout development. The real-time format is the mostcomprehensive code format and supports almost all the built-in blocks.I
12 Configuring Real-Time Workshop for Your Application12-8Table 12-1: Features Supported by Real-Time Workshop Targets and Code Formats Real-TimeReal
Introduction12-9Executes inhardreal-timeXX X XNonreal-timeexecutableincludedXX X XMultipleinstantiationof one model(provided noStateflowblocks are iny
12 Configuring Real-Time Workshop for Your Application12-10Real-Time Code FormatThe real-time code format (corresponding to the generic real-time targ
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
12 Configuring Real-Time Workshop for Your Application12-12Real-Time malloc Code FormatThe real-time malloc code format (corresponding to the generic
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
12 Configuring Real-Time Workshop for Your Application12-14Embedded-C Code FormatThe embedded-C code format (corresponding to the embedded real-time t
Embedded-C Code Format12-15• Select the Single output/update function check box. Combining the outputand update functions allows the Real-Time Worksho
1 Introduction to the Real-Time Workshop1-4• High-speed stand-alone simulations.• Generation of portable C code for export to other simulation program
12 Configuring Real-Time Workshop for Your Application12-16Unsupported BlocksThe embedded-C format does not support the following built-in blocks:• Co
Embedded-C Code Format12-17Template Makefiles• ert_bc.tmf —BorlandC•ert_vc.tmf —VisualC•ert_watc.tmf —WatcomC•ert_unix.tmf — UNIX host
12 Configuring Real-Time Workshop for Your Application12-18S-Function Code FormatThe S-function code format (corresponding to the RTW S-function targe
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
12 Configuring Real-Time Workshop for Your Application12-20Restrictions• Hand-written S-functions without corresponding TLC files must containexceptio
Optimizations Common to All Code Formats12-21Optimizations Common to All Code FormatsGeneral Modeling TechniquesThe following are techniques that you
12 Configuring Real-Time Workshop for Your Application12-22Stateflow OptimizationsIf your model contains Stateflow blocks, select the Use Strong Data
Optimizations Common to All Code Formats12-23Diagnostic Page• Deselect the Disable optimized block I/O storage check box. Disablingoptimized block I/O
12 Configuring Real-Time Workshop for Your Application12-24vector. Note that you can override the inlining of individual parameter byusing theTunable
Optimizations Common to All Code Formats12-25• Select the Inline invariant signals check box. The Real-Time Workshop willnot generate code for blocks
The Real-Time Workshop1-5a fixed, user-specified sample rate. Continuous time models are incorporatedinto this code with the simple provision that the
12 Configuring Real-Time Workshop for Your Application12-26
13Real-Time WorkshopRapid Simulation TargetIntroduction ...13-2Building for the Rapid Simulation Target ...13-4RunningaRapidSimula
13 Real-Time Workshop Rapid Simulation Target13-2IntroductionThe Real-Time Workshop rapid simulation target (rsim) consists of a set oftarget files fo
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
13 Real-Time Workshop Rapid Simulation Target13-4Building for the Rapid Simulation TargetBy specifying the system target file (rsim.tlc)andthetemplate
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
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
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
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
Building for the Rapid Simulation Target13-9<-o> Specifying a New Output Filename for the SimulationIf you have specified Save to Workspace opti
1 Introduction to the Real-Time Workshop1-6The Rapid Prototyping ProcessThe Real Time Workshop allows you to do rapid prototyping, a process thatallow
13 Real-Time Workshop Rapid Simulation Target13-10incorrect simulation results. In this case, where model structure has changed,you must regenerate th
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
13 Real-Time Workshop Rapid Simulation Target13-12From Workspace data must be contained in a structure variable with thefollowing fields:var.timevar.s
Building for the Rapid Simulation Target13-13Simulation PerformanceIt is not possible to predict accurately the simulation speed-up of an rsimsimulati
13 Real-Time Workshop Rapid Simulation Target13-14demonstrate how rsim canbecalledrepeatedlywithinanM-fileforMonteCarlo simulations.
14Real-Time WorkshopAda CoderIntroduction ...14-2Real-Time Workshop Ada Coder Applications . . . . . . . 14-3SupportedCompilers...
14 Real-Time Workshop Ada Coder14-2IntroductionThis chapter presents an introduction to the Real-Time Workshop Ada Coder.It compares and contrasts the
Introduction14-3Real-Time Workshop Ada Coder ApplicationsLike the Real-Time Workshop, the Real-Time Workshop Ada Coder supports avariety of real-time
14 Real-Time Workshop Ada Coder14-4All Simulink blocks are automatically converted to code, with the exception of:• MATLAB function blocks• Any contin
Introduction14-5generation. You can, however, perform explicit upcasting using the DataType Conversion block in Simulink.S-FunctionsS-functions provid
The Rapid Prototyping Process1-7The traditional approach to real-time design and implementation typicallyinvolves multiple teams of engineers, includi
14 Real-Time Workshop Ada Coder14-6Getting Started This section illustrates, through a simple example, how to transform aSimulink model into a stand-a
Getting Started14-7Setting Options for Ada Code GenerationYou must specify the correct options before you generate Ada code from thismodel. These are
14 Real-Time Workshop Ada Coder14-8Alternatively, you can specify the settings on the Real-Time Workshop pagemanually by following these steps:1 Selec
Getting Started14-9Generated FilesThis table lists the Ada files generated by the Real-Time Workshop Ada Coderfrom the counter demonstration (counters
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
Getting Started14-11The times2 model contains a simple S-function, called timestwo,thattakestheinput sine wave signal and doubles its amplitude. The T
14 Real-Time Workshop Ada Coder14-12Configuring the Template MakefileTemplate makefiles specify the compiler, link, and make directives native tothe t
Getting Started14-13Application Modules Required for the Real-Time ProgramBuilding the real-time program requires a number of support files in additio
14 Real-Time Workshop Ada Coder14-14Tunable ParametersIf you select Inline parameters on the Real-Time Workshop page, the Tunableparametersbutton acti
Getting Started14-15- ImportedExtern — the variable is assumed to be declared in the packagespecification entered in theStorage Type Qualifier field.
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
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
Getting Started14-17specification. The generated code accesses this signal asRT_U.Signal_Name.- ExportedGlobal — declares the signal as a global varia
14 Real-Time Workshop Ada Coder14-18Code ValidationAfter completing the build process, the stand-alone version of thecountersdemo model is ready for c
Code Validation14-19The “!” character passes the command that follows it to the operating system.This command, therefore, runs the stand-alone version
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
Supported Blocks14-21Supported BlocksThe Real-Time Workshop Ada Coder supports the following Simulink blocks.Discrete BlocksDiscrete-Time Integrator D
14 Real-Time Workshop Ada Coder14-22Nonlinear BlocksBacklash QuantizerCoulomb & Viscous Friction RelayDeadZone SaturationManual Switch (must Break
Supported Blocks14-23SinksDisplay — no code is generated forthis blockTo FileScope — matrix data logging only(double arrays)To Workspace — matrix data
14 Real-Time Workshop Ada Coder14-24
AReal-Time WorkshopDirectory Tree
The Rapid Prototyping Process1-9This highly productive development cycle is possible because the Real-TimeWorkshop is closely tied to MATLAB and Simul
A Real-Time Workshop Directory TreeA-2Real-Time Workshop Directory TreeThe files provided to implement real-time and generic real-time applicationsres
Real-Time Workshop Directory TreeA-3The matlabroot/rtw/c Directorymatlabroot/rtw/ctlcgrtdostornadolibsrctoolssrcrtwsfcnertgrt_mallocwindowsosek_leorsi
A Real-Time Workshop Directory TreeA-4Directory Purposematlabroot/rtw/c/dosFiles for targeting DOSmatlabroot/rtw/c/ertFiles for targeting embedded C c
Real-Time Workshop Directory TreeA-5The matlabroot/simulink DirectoryThe matlabroot/toolbox DirectoryDirectory Purposematlabroot/simulink/includeInclu
A Real-Time Workshop Directory TreeA-6The matlabroot/extern DirectoryDirectory Purposematlabroot/extern/includeInclude files used to build the targetm
BGlossary
B GlossaryB-2Application Modules − With respect to Real-Time Workshop programarchitecture, these are collections of programs that implement functionsc
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
B GlossaryB-4Makefiles − Files that contain a collection of commands that allow groups ofprograms, object files, libraries, etc. to interact. Makefile
B-5Target File − A file that is compiled and executed by the Target LanguageCompiler. A combination of these files describes how to transform theReal-
1 Introduction to the Real-Time Workshop1-10You can monitor signals using Scope blocks while running external mode.Simply connect Scope blocks to sign
B GlossaryB-6
I-1IndexAapplication modulesapplication specific layer 6-35common layer 6-31definition of 6-25Asynchronous Buffer block 11-20Asynchronous Interrupt bl
IndexI-2device driver blocks 9-9adding to model 9-15device drivers 9-6digital input block parameters 9-13digital output block parameters 9-14hardware
IndexI-3under DOS 7-3under VxWorks 7-3interrupt service routine (ISR) 9-5locking and unlocking 11-16interrupt templates library 11-9LlibraryCustom Cod
IndexI-4program buildingDOSreal-time 9-16VxWorksbuild command options 8-17real-time options 8-14setting step size 8-15program executiondata logging fu
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
IndexI-6UUNIX 2-18template makefiles 2-18Vvirtual blocks 1-18VxWorksapplication overview 8-5build command options 8-17configuringfor external mode (so
The Rapid Prototyping Process1-11Algorithm Design and AnalysisFrom the block diagrams developed during the modeling stage, you can extractstate-space
iiThe Rapid Prototyping Process ... 1-6KeyAspectsofRapidPrototyping... 1-6RapidPrototypingforDigitalSigna
1 Introduction to the Real-Time Workshop1-12Open Architecture of the Real-Time WorkshopThe Real-Time Workshop is an open and extensible system designe
Open Architecture of the Real-Time Workshop1-13Figure 1-3: The Real-Time Workshop’s Open ArchitectureMATLABSimulinkReal-Time Workshop BuildTargetLang
1 Introduction to the Real-Time Workshop1-14Target Language CompilerTo generate code, the Real-Time Workshop invokes the Target LanguageCompiler (TLC)
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
1 Introduction to the Real-Time Workshop1-16options, and additional information for the destination (target) of thegenerated executable.Themodel.mk fi
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
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
Open Architecture of the Real-Time Workshop1-19Language Compiler Reference Guide, which contains detailed descriptions ofthe contents ofmodel.rtw file
1 Introduction to the Real-Time Workshop1-20assigning buffers to each input and output. Compare this to the MdlOutputsfunction generated with buffer o
Open Architecture of the Real-Time Workshop1-21Using Stateflow and Blocksets with the Real-Time WorkshopStateflow is a graphical design and developmen
iii4.ValidatingGeneratedCode ... 2-55. Incorporating Generated Code into Legacy Code . . . . . . . . . . 2-56.IncorporatingLeg
1 Introduction to the Real-Time Workshop1-22
2Getting Started with theReal-Time WorkshopIntroduction ...2-2Where to Find Information in This Manual ...2-3Basic Concepts in the
2 Getting Started with the Real-Time Workshop2-2IntroductionThis chapter begins a discussion of basic concepts used in real-timedevelopment and relate
Where to Find Information in This Manual2-3Where to Find Information in This ManualThis section discusses typical requirements for producing real-time
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
Where to Find Information in This Manual2-5LibMdlRegCustomCode, LibSystemInitializeCustomCode, LibSystemOutputCustomCode, LibSystemUpdateCustomCode, L
2 Getting Started with the Real-Time Workshop2-66. Incorporating Legacy Code into Generated CodeLegacy code, or hand-written code, is existing code th
Where to Find Information in This Manual2-7• External mode — you can tune parameters from Simulink while running thegenerated code on a target process
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
Basic Concepts in the Real-Time Workshop2-9target environments and the system target files and template makefilesassociated with each example environm
ivTargeting dSPACE ... 2-28Real-TimeInterface(RTI) ... 2-30Building a Real-Time Executable
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
Basic Concepts in the Real-Time Workshop2-11and program building. Therefore, before you generate code and build aprogram, you must verify that the mod
2 Getting Started with the Real-Time Workshop2-12Building Generic Real-Time ProgramsThis example describes how to generate C code from a Simulink mode
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
2 Getting Started with the Real-Time Workshop2-14Setting Program ParametersAfter displaying the f14 model, select Parameters from the Simulationpull-d
Building Generic Real-Time Programs2-15Note Alternatively, you can select RTW Options from the Tools pull-downmenu. This brings you directly to the R
2 Getting Started with the Real-Time Workshop2-16WhenyouclickontheBuild button in the Simulation Parameters dialog box,the Real-Time Workshop invokes
Building Generic Real-Time Programs2-17substitute the numerical values of the model parameters in place of thevariable names. It also instructs Simuli
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
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
vFile and Function Splitting ... 3-38FileSplitting ... 3-38FunctionSplitting ...
2 Getting Started with the Real-Time Workshop2-20Generic Real-Time ModulesThese source modules are automatically linked by the makefile, model.mk.Them
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
2 Getting Started with the Real-Time Workshop2-22In addition, data logging time (in the Workspace I/O page of the SimulationParametersdialog box) also
Code Validation2-23Code ValidationAfter completing the build process, the stand-alone version of the f14 model isready for comparison with the Simulin
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
Code Validation2-25Comparing Simulation and Generic Real-Time ResultsYour Simulink simulations and generic real-time code should produce nearlyidentic
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
Code Validation2-27Use the MATLAB open_system command to trace the generated code back tothe model. For example,open_system('<S3>') op
2 Getting Started with the Real-Time Workshop2-28Targeting dSPACEdSPACE, a company that specializes in real-time hardware and softwareproducts, market
Targeting dSPACE2-29Figure 2-3: A PC Setup Including a Target SystemFigure 2-4: The dSPACE PHS BusMotherboard “host”Embedded cards(target system)PC
viCreating an External Mode Communication Channel . . . . . . 4-27Rebuildingtheext_commMEX-file ... 4-275Data Logging and Signal Mon
2 Getting Started with the Real-Time Workshop2-30Real-Time Interface (RTI)When using the Real-Time Workshop with dSPACE hardware, you mustgenerate tar
Targeting dSPACE2-31system target file and template makefile. For the current example, in theReal-Time Workshop page of the dialog box, specify:• Syst
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
3Code Generation and theBuild ProcessIntroduction ...3-2Automatic Program Building ...3-3The Real-Time Workshop User Interfa
3 Code Generation and the Build Process3-2IntroductionThe Real-Time Workshop simplifies the process of building applicationprograms. One of the Real-T
Automatic Program Building3-3Automatic Program BuildingThe Real-Time Workshop automates the task of building a stand-aloneprogram from your Simulink m
3 Code Generation and the Build Process3-4Theshadedboxinthefigurebelowoutlinesthesesteps:Figure 3-1: The Build ProcessThe task of creating a stand-al
Automatic Program Building3-5When you click the Build button on the Real-Time Workshop page on theSimulation Parameters dialog box, these steps are ca
3 Code Generation and the Build Process3-6The Real-Time Workshop User InterfaceYou work with the Real-Time Workshop by interacting with and modifyingf
The Real-Time Workshop User Interface3-7System Target FileUse the System target file fieldtospecifythetypeofcodeandtargetforwhichyou are generating co
viiRapid Prototyping System Dependent Components . . . . . . . . 6-27ThemainFunction ... 6-27Initialization ...
3 Code Generation and the Build Process3-8This table lists the options available.Table 3-2: Target Language Compiler Optional Variables Variable Desc
The Real-Time Workshop User Interface3-9−aFunctionInlineType="mode"Controls how functions are inlined. Thereare two modes:•CodeInsertion• Pr
3 Code Generation and the Build Process3-10Inline ParametersInlining parameters refers to a mode where blocks with a constant sample timeare removed f
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
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
The Real-Time Workshop User Interface3-13Table 3-3: Targets Available from the System Target File BrowserTarget/Code Format System Target FileTemplat
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
The Real-Time Workshop User Interface3-15Options ButtonThere is an Options button on the Real-Time Workshop page of theSimulation Parameters dialog bo
3 Code Generation and the Build Process3-16Generation Options dialog box that varies depending on which system targetfile configuration you selected i
The Real-Time Workshop User Interface3-17Verbose builds. This feature forces command line display of code generationstages and compiler output.Invaria
Komentarze do niniejszej Instrukcji