MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Podręcznik Użytkownika

Przeglądaj online lub pobierz Podręcznik Użytkownika dla Oprogramowanie MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER. MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER User`s guide Instrukcja obsługi

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 130
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów

Podsumowanie treści

Strona 1 - Real-Time Workshop

Real-Time Workshop® For Use with Simulink ®Getting StartedVersion 6

Strona 2 - How to Contact The MathWorks:

1 What Is Real-Time Workshop?1-4- The flexible scripting capabilities of the Target Language Compiler enable you to fully customize generated code.- E

Strona 3 - Contents

3 Working with Real-Time Workshop3-44External mode supports communication via TCP/IP, serial, and custom transport protocols. The MEX-file name field

Strona 4

Quick Start Tutorials3-457 Click Apply to save the Interface settings.8 Save the model.9 In the Real-Time Workshop pane, click Build to generate code

Strona 5

3 Working with Real-Time Workshop3-46The top three buttons are for use after the target program has started. The two lower buttons open separate dialo

Strona 6

Quick Start Tutorials3-474 Make sure that the External Signal & Triggering dialog is set to the defaults as shown:-Select all check box is selecte

Strona 7 - Workshop?

3 Working with Real-Time Workshop3-48Click Close, and then close the External Mode Control Panel.For information on the options mentioned above, see “

Strona 8

Quick Start Tutorials3-496 Open Scope blocks A and B. At this point, no signals are visible on the scopes. When you connect Simulink to the target pro

Strona 9 - Capabilities and Benefits

3 Working with Real-Time Workshop3-50Part 4: Tuning ParametersYou can change the gain factor of either Gain block by assigning a new value to the vari

Strona 10 - 1 What Is Real-Time Workshop?

Quick Start Tutorials3-51Tutorial 6: Generating Code for a Referenced ModelThe Model block, introduced in Version 6 of Simulink, enables an existing S

Strona 11 - Extensible make process

3 Working with Real-Time Workshop3-524 Right-click any of the three highlighted blocks and select Create Subsystem from the pop-up context menu. You c

Strona 12

Quick Start Tutorials3-53The border of the vdpmult subsystem thickens to indicate that it is now atomic. An atomic subsystem executes as a unit rather

Strona 13 - VERIFICATION

Introducing Real-Time Workshop1-5• Target support- Turnkey solutions for rapid prototyping substantially reduce design cycles, allowing for fast turna

Strona 14

3 Working with Real-Time Workshop3-548 Open the Configuration Parameters dialog from the Simulation menu or by typing Ctrl+E.The next four steps bypas

Strona 15 - Toolboxes

Quick Start Tutorials3-55In this exercise you only supply the first two calling arguments (a model name and a target directory) and no return argument

Strona 16

3 Working with Real-Time Workshop3-56Code for model reference simulation targets is placed in the slprj/sim subdirectory. Generated code for GRT, ERT,

Strona 17 - Installing Real-Time Workshop

Quick Start Tutorials3-57This instructs the vdptop_converted model (and later its executable) to log time and output data to MAT-files for each time s

Strona 18

3 Working with Real-Time Workshop3-586 Use the Model Explorer to inspect the newly created build directory, vdptop_converted_grt_rtw, in your current

Strona 19 - Microsoft Visual C/C++

Quick Start Tutorials3-59To view a model’s generated code in Model Explorer, the model must be open. To open a file in a text editor, click a filename

Strona 20

3 Working with Real-Time Workshop3-6011 A Model Explorer node named Code for vdpmult also appears under the node Code for vdptop_converted. Expand thi

Strona 21

Quick Start Tutorials3-61/* Output and update for referenced model: 'vdpmult'*/void mr_vdpmult(const real_T *rtu_0, const real_T *rtu_1, rea

Strona 22

3 Working with Real-Time Workshop3-62Working with Project DirectoriesWhen you view generated code in Model Explorer, the files listed in the Contents

Strona 23 - Help and Documentation

Quick Start Tutorials3-63

Strona 24

1 What Is Real-Time Workshop?1-6• Annotation of the generated code using the Description block property.• Control over naming and storage class for pa

Strona 25

3 Working with Real-Time Workshop3-64

Strona 26

Glossary-1 Glossaryapplication modulesWith respect to Real-Time Workshop program architecture, these are collections of programs that implement functi

Strona 27 - Building an Application

Glossary-2expression foldingCode optimization technique that minimizes the computation of intermediate results at block outputs and the storage of su

Strona 28 - 2 Building an Application

GlossaryGlossary-3host system Computer system on which you create and may compile your real-time application. Also referred to as emulation hardware.i

Strona 29 - Real-Time Workshop Workflow

Glossary-4part of a Simulink model, it is by default noninlined unless you write your own .tlc file that inlines it.nonreal-time Simulation environme

Strona 30

GlossaryGlossary-5simulation targetSet of code files generated for a model which is referenced by a Model block. Simulation target code is generated i

Strona 31

Glossary-6virtual block Connection or graphical block, for example a Mux block, that has no algorithmic functionality. Virtual blocks incur no real-t

Strona 32

Index-1IndexBblock target file 2-17build directorycontents of 2-27f14 example 3-18naming convention 2-26build processsteps in 2-15Ccode formatdefiniti

Strona 33

IndexIndex-2subsystem.c 2-24subsystem.h 2-24generic real-time (GRT) target 3-4tutorial 3-9Hhostand target 3-3Mmake utility 2-13components 3-3MAT-files

Strona 34

IndexIndex-3system target file 3-4TLC scripts 2-17template makefileintroduction to 3-5tutorialsbuilding generic real-time program 3-9code generation 3

Strona 35 - Generating Code

Introducing Real-Time Workshop1-7Spiral Design ProcessWhen you work with tools from The MathWorks, your model represents your understanding of your sy

Strona 36

IndexIndex-4

Strona 37 - Save the Model Configuration

1 What Is Real-Time Workshop?1-8can verify that an algorithm works on a real-world rapid prototyping system. The spiral process lends itself naturally

Strona 38

Introducing Real-Time Workshop1-9Roles of MathWorks Products in Software DevelopmentEarly in the design process, you use MATLAB and Simulink to help y

Strona 39 - Automatic Program Building

1 What Is Real-Time Workshop?1-10Real-Time Windows Target or the xPC Target. With a rapid prototyping target, you connect your model to your physical

Strona 40

Installing Real-Time Workshop1-11Installing Real-Time WorkshopYour platform-specific MATLAB installation documentation provides all the information yo

Strona 41 - The Build Process

1 What Is Real-Time Workshop?1-12Third-Party Compiler Installation on WindowsMost Real-Time Workshop targets create an executable that runs on your wo

Strona 42

Installing Real-Time Workshop1-13• Replace %INTELC71% with the root directory of the Intel Compiler installation.LCCThe freeware LCC C compiler is shi

Strona 43 - Code Generation

How to Contact The MathWorks:www.mathworks.com Webcomp.soft-sys.matlab [email protected] Technical [email protected] Product

Strona 44

1 What Is Real-Time Workshop?1-14If the WATCOM environment variable is not defined, you must define it to point to where you installed your Watcom com

Strona 45

Installing Real-Time Workshop1-15On UNIX. On UNIX, the Real-Time Workshop build process uses the default compiler. The cc compiler is the default on a

Strona 46

1 What Is Real-Time Workshop?1-16Real-Time Workshop DemosA good way to familiarize yourself with Real-Time Workshop is by browsing through its suite o

Strona 47

Help and Documentation1-17Help and DocumentationReal-Time Workshop software is shipped with this Getting Started guide. Users of this book should be f

Strona 48

1 What Is Real-Time Workshop?1-181 In the MATLAB window, click Desktop -> Help, Help -> Full product family help, or click the ? icon on the too

Strona 49

Help and Documentation1-19You can customize output from Real-Time Workshop at the block, target, and makefile levels. For advanced uses, you may have

Strona 50

1 What Is Real-Time Workshop?1-20

Strona 51

2Building an ApplicationThis chapter expands the high-level discussion of code generation and the build process given in Chapter 1, “What Is Real-Tim

Strona 52

2 Building an Application2-2Real-Time Workshop WorkflowThe typical workflow for applying Real-Time Workshop to the application development process inv

Strona 53

Real-Time Workshop Workflow2-3ConfigurationNo YesDoneAdjust Configuration SettingsRun Model Advisor RequiresTuning?Generate CodeCode OK? Map Applicat

Strona 54

iContents1What Is Real-Time Workshop?Introducing Real-Time Workshop . . . . . . . . . . . . . . . . . . . . . . 1-2Components and Features . . .

Strona 55

2 Building an Application2-4Mapping Application Requirements to Configuration OptionsThe first step to applying Real-Time Workshop to the application

Strona 56

Real-Time Workshop Workflow2-5• What is the highest priority for your application — traceability, efficiency, extra safety precaution, or some other c

Strona 57 - Workshop

2 Building an Application2-6OptimizationBlock reduction optimizationClear Clear Set No impact SetImplement logic signals as Boolean data (vs. double)N

Strona 58

Real-Time Workshop Workflow2-7Hardware ImplementationNumber of bitsNo impact No impact Target specificNo impact 8, 16, 32, 32Real-Time WorkshopGenerat

Strona 59 - Code Formats

2 Building an Application2-8* Backward compatibility with previous release.Setting Configuration OptionsOnce you have mapped your application requirem

Strona 60 - The Generic Real-Time Target

Real-Time Workshop Workflow2-9Although you can use the Model Advisor to improve model simulation, it is particularly useful for identifying aspects of

Strona 61 - Template Makefiles

2 Building an Application2-10• You want to inspect the generated code. Is Real-Time Workshop generating what you expect?• You need to integrate custom

Strona 62 - Configuration Parameters

Real-Time Workshop Workflow2-11For a more detailed discussion of the build process, see “Automatic Program Building” on page 2-13 and “The Build Proce

Strona 63

2 Building an Application2-125 Click Apply.The name of the active configuration in the Model Hierarchy pane changes to the name you typed.6 Save the m

Strona 64 - The f14 Demonstration Model

Automatic Program Building2-13Automatic Program BuildingReal-Time Workshop builds programs automatically for real-time applications in a variety of ho

Strona 65 - Working and Build Directories

ii ContentsThe Build Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15Model Compilation . . . . . . . . . . . .

Strona 66 - Setting Program Parameters

2 Building an Application2-14A high-level M-file command controls the Real-Time Workshop build process. By default, Real-Time Workshop issues the comm

Strona 67 - SingleTasking

The Build Process2-15The Build ProcessReal-Time Workshop generates C code only or generates the C code and produces an executable image, depending on

Strona 68

2 Building an Application2-16report contents vary depending on the target, but all reports feature clickable links to generated source files. The foll

Strona 69

The Build Process2-17• Computes work vector sizes, such as those used by S-functions. (For more information about work vectors, refer to the Simulink

Strona 70

2 Building an Application2-18Note Real-Time Workshop executes all user-written S-function target files, but optionally executes block target files fo

Strona 71

The Build Process2-19During the final stage of processing, Real-Time Workshop invokes the generated make file, model.mk, which in turn compiles and li

Strona 72

2 Building an Application2-20This stage is optional, as illustrated by the control logic in the preceding figure. You might choose to omit this stage,

Strona 73

The Build Process2-21How Automatic Program Building Is ControlledCustomGenerateMakefileClick BuildButtonCreateExecutable?No InvokeYesGenerateCodeTempl

Strona 74

2 Building an Application2-22Files and Directories Created by the Build ProcessThe following sections discuss• “Files Created During Build Process” on

Strona 75 - Tutorial 2: Data Logging

The Build Process2-23| rt_nonfinite.c| modelsources.txt| f14_dt.h|+---tlc| This directory contains TLC files generated during the build| process. Thes

Strona 76

iiiIndex

Strona 77

2 Building an Application2-24- Exported Stateflow machine parented data- Model data structures, including rtM- Model entry point functions•model_priva

Strona 78

The Build Process2-25• model.exe (on PC) or model (on UNIX), generated in current directory, not in build directoryExecutable program file created und

Strona 79

2 Building an Application2-26• model_dt.hC header file used for supporting External Mode. Declares structures that contain data type and data type tra

Strona 80 - Build button, type

The Build Process2-27• Project directory—slprjA subdirectory within your working directory. When models referenced via Model blocks are built for simu

Strona 81 - Tutorial 3: Code Verification

2 Building an Application2-28Shared Utilities Directory in the Build Process” in the Real-Time Workshop User’s Guide documentation.

Strona 83

2 Building an Application2-30

Strona 84

3Working with Real-Time WorkshopThis chapter provides an overview of the ideas and technology behind Real-Time Workshop, and hands-on exercises to he

Strona 85

3 Working with Real-Time Workshop3-2Basic Real-Time Workshop ConceptsEven if you have experience in building real-time systems, you may find it helpfu

Strona 86 - Setting Up the Model

Basic Real-Time Workshop Concepts3-3Target and HostA target is an environment—hardware or operating system—on which your generated code will run. The

Strona 88 - Click Apply

3 Working with Real-Time Workshop3-4The Generic Real-Time TargetReal-Time Workshop provides a generic real-time development target. The GRT target pro

Strona 89

Basic Real-Time Workshop Concepts3-5Template MakefilesReal-Time Workshop uses template makefiles to build an executable from the generated code. The R

Strona 90

3 Working with Real-Time Workshop3-64 Finally, make is invoked. make compiles and links a program from the generated code, as instructed in the genera

Strona 91

Quick Start Tutorials3-7Quick Start TutorialsThis section provides hands-on experience with the code generation, program building, data logging, code

Strona 92 - 3 Click Apply

3 Working with Real-Time Workshop3-8Compilers” on page 1-14 for more information on supported compilers and compiler installation.The f14 Demonstratio

Strona 93 - HTML Code Generation Reports

Quick Start Tutorials3-9Tutorial 1: Building a Generic Real-Time ProgramThis tutorial walks through the process of generating C code and building an e

Strona 94

3 Working with Real-Time Workshop3-10Note When a model contains Model blocks (which enable one Simulink model to include others), special project dir

Strona 95

Quick Start Tutorials3-11Mode: SingleTaskingThe Solver pane with the modified parameter settings is shown below. Note the tan background color of the

Strona 96 - Part 1: Setting Up the Model

3 Working with Real-Time Workshop3-12Selecting the Target ConfigurationNote The steps in this section do not require you to make changes. They are in

Strona 97

Quick Start Tutorials3-134 From the list of available configurations, select Generic Real-Time Target (as shown above) and then click OK.Note The Sys

Strona 98 - Fixed-step, and

1What Is Real-Time Workshop?This guide begins with a high-level overview of Real-Time Workshop®, describing its purpose, its component parts, its maj

Strona 99

3 Working with Real-Time Workshop3-145 Select the Debug tab of the Real-Time Workshop dialog. The options displayed here control build verbosity and d

Strona 100 - MEX-file arguments

Quick Start Tutorials3-156 Select the Symbols tab of the Real-Time Workshop dialog. The options on this pane control the look and feel of generated co

Strona 101 - 8 Save the model

3 Working with Real-Time Workshop3-167 Select the Comments tab of the Real-Time Workshop dialog. The options displayed here control the types of comme

Strona 102

Quick Start Tutorials3-178 Make sure that the Generate code only option is not selected, and save the model.Building and Running the ProgramThe Real-T

Strona 103 - X in the Block column

3 Working with Real-Time Workshop3-18The content of many of the succeeding messages depends on your compiler and operating system. The final message i

Strona 104 - Return

Quick Start Tutorials3-19f14rtw_grt_rtw contains these generated source files:The build directory also contains other files used in the build process,

Strona 105 - A = 2 and B = 3

3 Working with Real-Time Workshop3-20To configure data logging, you use the Data Import/Export pane of the Configuration Parameters dialog. The proces

Strona 106 - Part 4: Tuning Parameters

Quick Start Tutorials3-21enables Real-Time Workshop to generate code that logs the simulation time to the MAT-file with a related name, as you will se

Strona 107 - Quick Start Tutorials

3 Working with Real-Time Workshop3-228 Verify that the simulation time and outputs have been saved to the workspace.whos *out Name Size

Strona 108

Quick Start Tutorials3-23Part 2: Data Logging from Generated CodeIn the second part of the exercise, you build and run a Real-Time Workshop executable

Strona 109

1 What Is Real-Time Workshop?1-2Introducing Real-Time WorkshopReal-Time Workshop® is an extension of capabilities of Simulink® and MATLAB® that automa

Strona 110

3 Working with Real-Time Workshop3-244 Click Apply to register your changes.5 Generate code and build an executable: Click the Build button, type Ctrl

Strona 111

Quick Start Tutorials3-25Tutorial 3: Code VerificationIn this tutorial, you verify the answers computed by code generated from the f14rtw model by com

Strona 112

3 Working with Real-Time Workshop3-26The Stick Input signal to the scope block is logged to the array Stick_input during simulation. The generated cod

Strona 113

Quick Start Tutorials3-273 Use the whos command to observe that the array variables Stick_input, Pilot_G_force, and Angle_of_attack have been saved to

Strona 114

3 Working with Real-Time Workshop3-28!f14rtwThe executing program writes the following messages to the console.** starting the model ** ** created f14

Strona 115 - Dialog pane

Quick Start Tutorials3-29Comparing Numerical Results of the Simulation and the Generated ProgramYour Simulink simulations and the generated code shoul

Strona 116

3 Working with Real-Time Workshop3-30Tutorial 4: A First Look at Generated CodeIn this tutorial, you examine code generated from a simple model to obs

Strona 117

Quick Start Tutorials3-315 Click the Solver tab and enter the following parameter values on the Solver pane:Solver options: set Type to Fixed-step. Se

Strona 118

3 Working with Real-Time Workshop3-322 Click Apply.3 Click the Real-Time Workshop node and click the Generate code button.4 Because the Generate code

Strona 119

Quick Start Tutorials3-335 The generated code is in the build directory, example_grt_rtw. The file example_grt_rtw\example.c contains the output compu

Strona 120

Introducing Real-Time Workshop1-3embedded target products extend and tailor Real-Time Workshop code to run in a growing suite of microprocessor enviro

Strona 121 - Glossary

3 Working with Real-Time Workshop3-34 example_P.SineWave_Phase) + example_P.SineWave_Bias; example_B.gain_out = example_B.sin_out * example_P.Gain

Strona 122 - Glossary-2

Quick Start Tutorials3-35You will observe the effects of expression folding later in this tutorial. Not performing expression folding allows you to se

Strona 123 - Glossary-3

3 Working with Real-Time Workshop3-36 sin(example_P.SineWave_Freq * example_M->Timing.t[0] + example_P.SineWave_Phase) + example_P.SineWave_B

Strona 124 - Glossary-4

Quick Start Tutorials3-374 Click the Generate code button.5 As before, Real-Time Workshop generates code in the example_grt_rtw directory.6 Edit examp

Strona 125 - Glossary-5

3 Working with Real-Time Workshop3-38Enabling this option causes Real-Time Workshop to produce an HTML file for each generated source file, plus a sum

Strona 126 - Glossary-6

Quick Start Tutorials3-39you can navigate to identify the settings of every option in place at the time that the HTML report was generated.You can ref

Strona 127

3 Working with Real-Time Workshop3-40The example presented uses the generic real-time target, and does not require any hardware other than the compute

Strona 128

Quick Start Tutorials3-414 Define and assign two variables A and B in the MATLAB workspace as follows:A = 2; B = 3;5 Open Gain block A and set its Gai

Strona 129

3 Working with Real-Time Workshop3-428 From the File menu, choose Save As. Save the model as ext_example.mdl.Part 2: Building the Target ExecutableIn

Strona 130

Quick Start Tutorials3-432 Click the Data Import/Export tab, and clear the Time and Output check boxes. In this exercise, data is not logged to the wo

Komentarze do niniejszej Instrukcji

Brak uwag