Real-Time Workshop User's Guide

Preface

Chapter Summary

Related Products

Installing the Real-Time Workshop

Third-Party Compiler Installation on Windows

Supported Compilers

Compiler Optimization Settings

Typographical Conventions

Introduction to the Real-Time Workshop

Product Summary

Getting Started: Basic Concepts and Tutorials

Tutorial 1: Building a Generic Real-Time Program

Tutorial 2: Data Logging

Tutorial 3: Code Validation

Tutorial 4: A First Look at Generated Code

Where to Find Information in This Manual

Technical Overview

The Rapid Prototyping Process

Key Aspects of Rapid Prototyping

Rapid Prototyping for Digital Signal Processing

Rapid Prototyping for Control Systems

Open Architecture of the Real-Time Workshop

Automatic Program Building

Steps in the Build Process

Code Generation and the Build Process

Introduction

Overview of the Real-Time Workshop User Interface

Using the Real-Time Workshop Page

Target Configuration Options

General Code Generation Options

Target Specific Code Generation Options

TLC Debugging Options

Real-Time Workshop Submenu

Simulation Parameters and Code Generation

Solver Options

Workspace I/O Options and Data Logging

Diagnostics Page Options

Advanced Options Page

Tracing Generated Code Back to Your
Simulink Model

Other Interactions Between Simulink
and the Real-Time Workshop

Selecting a Target Configuration

The System Target File Browser

Available Targets

Nonvirtual Subsystem Code Generation

Nonvirtual Subsystem Code Generation Options

Modularity of Subsystem Code

Generating Code and Executables from Subsystems

Parameters: Storage, Interfacing, and Tuning

Storage of Nontunable Parameters

Tunable Parameter Storage

Storage Classes of Tunable Parameters

Using the Model Parameter Configuration Dialog

Tunable Expressions

Tunability of Linear Block Parameters

Signals: Storage, Optimization, and Interfacing

Signal Storage Concepts

Signals with Auto Storage Class

Declaring Test Points

Interfacing Signals to External Code

Symbolic Naming Conventions for Signals
in Generated Code

Summary of Signal Storage Class Options

C API for Parameter Tuning and Signal Monitoring

Target Language Compiler API for Parameter
Tuning and Signal Monitoring

Parameter Tuning via MATLAB Commands

Simulink Data Objects and Code Generation

Overview

Parameter Objects

Signal Objects

Object Property Information in the model.rtw File

Configuring the Generated Code via TLC

Target Language Compiler Variables and Options

Making an Executable

Directories Used in the Build Process

Choosing and Configuring Your Compiler

Template Makefiles and Make Options

Compiler-Specific Template Makefiles

Template Makefile Structure

Generated Code Formats

Introduction

Choosing a Code Format for Your Application

Real-Time Code Format

Unsupported Blocks

System Target Files

Template Makefiles

Real-Time malloc Code Format

Unsupported Blocks

System Target Files

Template Makefiles

S-Function Code Format

Embedded C Code Format

External Mode

Introduction

Tutorial: Getting Started with External Mode Using GRT

Part 1: Setting Up the Model

Part 2: Building the Target Executable

Part 3: Running the External Mode Target Program

Part 4: Tuning Parameters

Using the External Mode User Interface

External Mode Related Menu and Toolbar Items

External Mode Control Panel

Connection and Start/Stop Controls

Target Interface Dialog Box

External Signal & Triggering Dialog Box

Data Archiving

Parameter Download Options

External Mode Compatible Blocks and Subsystems

Compatible Blocks

Signal Viewing Subsystems

Overview of External Mode Communications

The Download Mechanism

The TCP/IP Implementation

Overview

Using the TCP/IP Implementation

The External Interface MEX-File

External Mode Compatible Targets

Running the External Program

Error Conditions

Implementing an External Mode Protocol Layer

Limitations of External Mode

Program Architecture

Introduction

Model Execution

Program Timing

Program Execution

External Mode Communication

Data Logging In Single-
and Multitasking Model Execution

Rapid Prototyping and Embedded
Model Execution Differences

Rapid Prototyping Model Functions

Embedded Model Functions

Rapid Prototyping Program Framework

Rapid Prototyping Program Architecture

Rapid Prototyping System Dependent Components

Rapid Prototyping System Independent Components

Rapid Prototyping Application Components

Embedded Program Framework

Models with Multiple Sample Rates

Introduction

Single- Versus Multitasking Environments

Executing Multitasking Models

Multitasking and Pseudomultitasking

Building the Program for Multitasking Execution

Singletasking

Building the Program for Singletasking Execution

Model Execution

Simulating Models with Simulink

Executing Models in Real Time

Sample Rate Transitions

Faster to Slower Transitions in Simulink

Faster to Slower Transitions in Real Time

Slower to Faster Transitions in Simulink

Slower to Faster Transitions in Real Time

Optimizing the Model for Code Generation

General Modeling Techniques

Block Diagram Performance Tuning

Look-Up Tables and Polynomials

Accumulators

Use of Data Types

Stateflow Optimizations

Simulation Parameters

Compiler Options

Real-Time Workshop Embedded Coder

Introduction

Real-Time Workshop Embedded Coder Demos

Data Structures and Code Modules

Real-Time Object

Code Modules

Program Execution

Overview

Main Program

rt_OneStep

Model Entry Points

Automatic S-Function Wrapper Generation

Optimizing the Generated Code

Basic Code Generation Options

Generating Code from Subsystems

Generating Block Comments

Generating a Code Generation Report

Controlling Stack Space Allocation

Advanced Code Generation Options

Create Simulink (S-Function) Block

Generate HTML Report

Generate ASAP2 File

Requirements and Restrictions

Unsupported Blocks

System Target File and Template Makefiles

The S-Function Target

Introduction

Intellectual Property Protection

Creating an S-Function Block from a Subsystem

Tunable Parameters in Generated S-Functions

Automated S-Function Generation

Restrictions

Unsupported Blocks

System Target File and Template Makefiles

System Target File

Template Makefiles

Real-Time Workshop Rapid Simulation Target

Introduction

Building for the Rapid Simulation Target

Running a Rapid Simulation

Simulation Performance

Batch and Monte Carlo Simulations

Limitations

Targeting Tornado for Real-Time Applications

Introduction

Confirming Your Tornado Setup Is Operational

VxWorks Library

Run-Time Architecture Overview

Parameter Tuning and Monitoring

Run-Time Structure

Implementation Overview

Adding Device Driver Blocks

Configuring the Template Makefile

Tool Locations

Building the Program

Downloading and Running the Executable
Interactively

Targeting DOS for Real-Time Applications

Introduction

DOS Device Drivers Library

Implementation Overview

System Configuration

Sample Rate Limits

Device Driver Blocks

Device Driver Block Library

Configuring Device Driver Blocks

Adding Device Driver Blocks to the Model

Building the Program

Running the Program

Custom Code Blocks

Introduction

Custom Code Library

Model Code Sublibrary

Subsystem Code Sublibrary

Asynchronous Support

Introduction

Interrupt Handling

Asynchronous Interrupt Block

Task Synchronization Block

Asynchronous Buffer Block

Rate Transition Block

Creating a Customized Asynchronous Library

Real-Time Workshop Ada Coder

Introduction

Real-Time Workshop Ada Coder Applications

Supported Compilers

Supported Targets

The Generated Code

Types of Output

Supported Blocks

Restrictions

Getting Started

Models with S-Functions

Configuring the Template Makefile

Data Logging

Generating Block Comments

Application Modules Required for the
Real-Time Program

Configuring and Interfacing Parameters and Signals

Model Parameter Configuration

Signal Properties

Code Validation

Analyzing Data with MATLAB

Supported Blocks

Targeting Real-Time Systems

Introduction

Components of a Custom Target Configuration

Code Components

User-Written Run-Time Interface Code

Run-Time Interface for Rapid Prototyping

Run-Time Interface for Embedded Targets

Control Files

Tutorial: Creating a Custom Target Configuration

Customizing the Build Process

System Target File Structure

Adding a Custom Target to the System Target
File Browser

Template Makefiles

Creating Device Drivers

Inlined and Noninlined Drivers

Device Driver Requirements and Limitations

Parameterizing Your Driver

Writing a Noninlined S-Function Device Driver

Writing an Inlined S-Function Device Driver

Building the MEX-File and the Driver Block

Source Code for Inlined ADC Driver

Interfacing Parameters and Signals

Signal Monitoring via Block Outputs

Parameter Tuning via model_pt.c

Target Language Compiler API for
Signals and Parameters

Creating an External Mode Communication Channel

The Design of External Mode

Overview of External Mode Communications

External Mode Source Files

Guidelines for Implementing the Transport Layer

Combining Multiple Models

DSP Processor Support

Blocks That Depend on Absolute Time


Glossary


 Preface