Products & Services Solutions Academia Support User Community Company

Learn more about xPC Target   

Introduction

xPC Target Drivers

The xPC Target™ software provides device drivers for a variety of third-party boards. xPC Target users access these drivers as Simulink® blocks from the xPC Target library (xpclib). If you have a board for which the xPC Target software does not supply a driver, you can write your own. This guide provides guidelines for writing custom xPC Target device drivers.

The xPC Target driver library contains drivers that support third-party boards with many I/O capabilities and applications. This includes drivers for different types of I/O boards, including

Analog-to-digital
Digital-to-analog
Audio
Counters
Shared memory

There are also drivers that support particular protocols, including

RS-232, RS-422, RS-485
GPIB
CAN
UDP
ARINC 429
MIL-1553

When to Write Your Own Drivers

Consider writing your own device drivers for the xPC Target block library if:

Restrictions on Customizing xPC Target Drivers

The xPC Target software has its own kernel, and you will be writing device drivers aimed at that kernel. An xPC Target driver is therefore different from a driver for another environment, such as Microsoft Windows. The xPC Target kernel is optimized and small, and does not have the operating system layers that traditional kernels do.

The xPC Target software installs its own kernel on the target PC. This kernel runs to the exclusion of any other operating system. When writing your own driver:

Expected Background

This guide assumes that you are already knowledgeable about writing device drivers. It describes the steps specific to writing device drivers for the xPC Target environment. To write your own device drivers for the xPC Target system, you need the following background:

Resources for Customizing xPC Target Drivers

This section lists the resources that are available to you from The MathWorks.

References

The following MathWorks documentation provides information that you can refer to when customizing xPC Target drivers:

See...For...
Simulink User's GuideOverall description of the Simulink environment and how the Simulink software performs simulations.
MATLAB External InterfacesHow to write MATLAB® MEX-files.
Writing S-FunctionsHow to write MATLAB C-MEX S-functions (noninlined S-functions). Note the following references in this guide:
  • S-Function Callback Methods — Alphabetical List the Simulink software invokes these methods when simulating a model with S-functions. Real-Time Workshop uses the same methods in generated real-time applications.

  • SimStruct Functions — Alphabetical List Contains detailed descriptions of the functions that access the fields of an S-function's simulation data structure (SimStruct). S-function callback methods use these functions to store and retrieve information about an S-function.

Real-Time Workshop Target Language CompilerHow to write target language compiler (TLC) files to inline S-function drivers. This is an optional reference and depends on whether or not you choose to inline your driver.
Real-Time Workshop User's GuideOverall description of Real-Time Workshop fundamentals, and guidelines on understanding I/O boards and low-level programming for drivers for those boards.

MathWorks Consulting

You can alternatively contact the MathWorks Consulting Services Group about the fee-based creation of a driver for your board.

Source Code

You can examine the source code for existing xPC Target device drivers as a reference for your custom drivers. Refer to the following directory:

matlabroot\toolbox\rtw\targets\xpc\target\build\xpcblocks

xPC Target Exported Functions

The xPC Target software provides kernel functions that you can use when writing your device drivers. These functions enable you to input and output data, configure PCI devices, and specify time-out intervals. Use only the functions documented in this guide. The guidelines in this document are not applicable if you are using an xPC Target software version prior to xPC Target software version 3.2 (R2007a). See I/O Functions — Alphabetical List, for a description of these functions.

Third-Party Directory

The xPC Target software provides the following directory to help you integrate your custom driver.

matlabroot\toolbox\rtw\targets\xpc\target\build\xpcblocks\thirdpartydrivers

This directory provides template files that you copy and customize for your drivers. Place all files that support your drivers in this directory.

What Makes Up an xPC Target Driver?

An xPC Target device driver is an S-function with functions that access an I/O board.

Like any device driver, an xPC Target driver interfaces between the user and an I/O device. Unlike typical device drivers, xPC Target device drivers:

Anatomy of an xPC Target Driver

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS