Mathworks XPC TARGET 4 Installation Guide

xPC Target™ 4
Getting Started Guide
How to Contact The MathWorks
www.mathworks. comp.soft-sys.matlab Newsgroup www.mathworks.com/contact_TS.html Technical Support
com
rks.com
rks.com
Web
Bug reports
Sales, prici
ng, and general information
508-647-7000 (Phone)
508-647-7001 (Fax)
The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site.
xPC Target™ Getting Started Guide
© COPYRIGHT 2000–20 10 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written consent from The MathW orks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through the federal government of the United States. By accepting delivery of the Program or Documentation, the government hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand Documentation by the federal government (or other entity acquiring for or through the federal government) and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the government’s needs or is inconsistent in any respect with federal procurement law, the government agrees to return the Program and Docu mentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
The MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
November 2000 First printing New for Version 1 (Release 12) June 2001 Online only Revised for Version 1.2 (Release 12.1) September 2001 Online only Revised for Version 1.3 (Release 12.1+) July 2002 Second printing Revised for Version 2 (Release 13) September 2003 Online only Revised for Version 2.0.1 (Release 13SP1) June 2004 Third printing Revised for Version 2.5 (Release 14) August 2004 Online only Revised for Version 2.6 (Release 14+) October 2004 Fourth printing Revised for Version 2.6.1 (Release 14SP1) November 2004 Online only Revised for Version 2.7 (Release 14SP1+) March 2005 Online only Revised for Version 2.7.2 (Release 14SP2) September 2005 Online only Revised for Version 2.8 (Release 14SP3) March 2006 Online only Revised for Version 2.9 (Release 2006a) May 2006 Fifth printing Revised for Version 3.0 (Release 2006a+) September 2006 Online only Revised for Version 3.1 (Release 2006b) March 2007 Online only Revised for Version 3.2 (Release 2007a) September 2007 Online only Revised for Version 3.3 (Release 2007b) March 2008 Online only Revised for Version 3.4 (Release 2008a) October 2008 Sixth printing Revised for Version 4.0 (Release 2008b) March 2009 Online only Revised for Version 4.1 (Release 2009a) September 2009 Online only Revised for Version 4.2 (Release 2009b) March 2010 Online only Revised for Version 4.3 (Release 2010a)
Introduction
1
Product Overview ................................. 1-2
Contents
Expected Background
xPC Target Features
Real-Time Kernel Real-Time Application Signal Acquisition Parameter Tuning Fixed-Point Support MATLAB
Hardware Environment
Introduction Host PC Target PC Host-Target Connection I/O Driver Support
Software Environment
Introduction Host-Target Communication Rapid Prototyping Process The xPC Target Em be dded Option Product
®
Compiler Support ........................ 1-10
...................................... 1-11
......................................... 1-11
........................................ 1-12
...................................... 1-18
.............................. 1-4
............................... 1-5
................................. 1-5
............................. 1-7
................................. 1-7
................................. 1-8
............................... 1-10
............................ 1-11
............................ 1-13
................................ 1-15
............................. 1-18
........................ 1-18
.......................... 1-19
............ 1-21
User Interaction
Introduction xPC T a rget Explorer MATLAB Command-Line Interface Simulink External Mode Interface Simulink with xPC Target Scope Blocks Target PC Command-Line Interface Web B row ser Interface
................................... 1-23
...................................... 1-23
............................... 1-24
............................. 1-29
................... 1-25
.................... 1-27
............... 1-28
.................. 1-28
v
Custom GUI with xPC Target API for M icrosoft .NET
Framework Custom GUI with xPC Target API Custom GUI with xPC Target COM API
.................................... 1-29
.................... 1-30
............... 1-30
Installation and Configuration
2
Required Products ................................. 2-2
MATLAB Simulink Real-Time Workshop CCompiler xPC Target Embedded Option Product
........................................ 2-2
........................................ 2-3
............................... 2-4
....................................... 2-4
................ 2-6
Related Products
System Requirements
Introduction Host PC Requirements Target PC Requirements
Installation on the Host PC
Overview License Requirements Files on the Host PC Computer Setting Your Initial Working Folder Running MATLAB Remotely Configuring the xPC Target Host PC for Your C
Compiler
xPC Target Explorer
Introducing xPC Target Explorer The xPC Target Product and Default Target PCs
Network Communication
Network Communication Overview Hardware for Network Communication
........................................ 2-15
.................................. 2-7
.............................. 2-8
...................................... 2-8
............................. 2-8
........................... 2-10
......................... 2-15
.............................. 2-15
...................... 2-16
.................. 2-16
........................ 2-18
...................................... 2-19
............................... 2-21
..................... 2-21
........................... 2-25
.................. 2-25
............... 2-25
........ 2-23
vi Contents
Ethernet Card Provided with the xPC Target Product .... 2-26
Ethernet Card for a PCI Bus Ethernet Card for an ISA Bus Environment Properties for Network Communication
........................ 2-27
....................... 2-28
.... 2-30
Serial Communication
Serial Communication Overview Hardware for Serial Communication Environment Properties for Serial Communication
xPC Target Boot Options
Introduction Booting Targ et PCs from CD or DVD Booting Target PCs from Boot Floppy Disk Booting Target PCs Within a Dedicated Network
Testing and Troubleshooting the Installation
Testing the Installation from a Boot Disk or Boot CD Test 1, Ping Target System Standard Ping Test 2, Ping Target System xPC T arget Ping Test 3, Reboot Target Using Direct C all Test 4, Build and Download Application If You Need More Help
Exporting and Importing xPC Target Explorer
Environments
...................................... 2-44
................................... 2-69
............................. 2-37
..................... 2-37
.................. 2-37
........................... 2-44
................. 2-46
............. 2-52
............. 2-64
........... 2-66
............... 2-67
............... 2-67
............................. 2-68
...... 2-38
....... 2-55
........ 2-62
.... 2-62
Basic Tutorial
3
Simulink Model ................................... 3-2
Creating a Simple Simulink Model Entering Parameters for the Scope Block Adding a Simulink Outport Block Entering Parameters for the Outport Blocks Adding an xPC Target Scope Block Entering Param eters for an xPC Target Scope Block
................... 3-2
.............. 3-6
.................... 3-10
........... 3-13
................... 3-17
..... 3-22
vii
Simulating the Model .............................. 3-38
Simulating the Model with Simulink Simulating the Model from MATLAB
.................. 3-38
................. 3-40
xPC Target Application
Booting the Target PC Troubleshooting the Boot Process Entering the Real-Time Workshop Parameters Building and Downloading the Target Application Troubleshooting the Build Process Increasing the Time-Out Value xPC Target Options
Running the Target Application
Introduction Control with xPC Target Explorer Control with MATLAB Commands Control with Simulink External Mode
Menu Bar and Toolbar Contents and Shortcut Keys
...................................... 3-60
............................ 3-44
............................. 3-44
.................... 3-45
......... 3-46
....... 3-50
.................... 3-52
...................... 3-53
................................ 3-54
.................... 3-60
.................... 3-60
................... 3-70
................. 3-72
.. 3-74
Glossary
viii Contents
Index
Introduction
“Product Overview” on page 1-2
“Expected Background” on p age 1-4
“xPC Target Features” on page 1-5
“Hardware Environment” on page 1-11
“Software Environment” on page 1-18
“User Interaction” on page 1-23
1
1 Introduction
Product Overview
The xPC Target™ product is a solution for prototyping, testing, and deploying real-time systems using standard PC hardware. It is an environment that uses a target PC, separate from a host PC, for running real-time applications. The xPC Target software environment includes many features to help you prototype, test, and deploy real-time systems.
In this environment you use your desktop computer as a host PC with MATLAB
®
, Simulink®,andStateflow®(optional) softw are, to create a model using Simulink blocks and Stateflow charts. After creating your model, you can run simulations in nonreal time.
xPC Target software lets you add I/O blocks to your model and then use the host PC with Real-Time Workshop Coder™ (optional), Stateflow
®
Coder™ (optional) software, and a C/C++
®
, Real-Time Workshop®Embedded
compiler to create executable code. Theexecutablecodeisdownloadedfrom the host PC to the target PC running the xPC Target real-time kernel. After downloading the executable code, you can run and test your target application in real time.
Hardware requirements — The xPC Target software requires a host PC,
target PC, and, for I/O, the target PC m ust also have I/O boards supported by the xPC Target product. However, the target PC can be a desktop PC, industrial PC, PC/104, PC/104+, o r CompactPCI computer.
Software requirements — The xPC Target software requires either a
Microsoft
®
Visual C/C++ compiler or an Open Watcom C/C++ compiler. In addition, the xPC Target software requires MATLAB, Simulink, and Real-Time Workshop software.
1-2
Product Overview
xPC Target Embedded Option™ requirements — The xPC Target
Embedded Option product is separate from the xPC Target product. It requires an additional license from The MathWorks. With this additional license, you can deploy an unlimited number of real-time applications for stand-alone operation. This option allows you to
- Create stand-alone applications for the target PC, independent from the
host PC , that can boot from a floppy drive or an alternate device.
- Deploy stand-alone GUI applications running on the host PC to control,
change parameters, and acquire signal data from a target application. This feature uses: the xPC Target API with any programming environment; the xPC Target COM API with any programming environment, such as Microsoft objects; the xPC Target API for Microsoft .NET Framework. Without the xPC Target Embe dded Option product, you can create, but not deploy, stand-alone GUI applications running on a host PC that does not contain your licensed copy of the xPC Target software, to control, change parameters, and acquire signal data from a target application.
Documentation and help — The xPC T arget software ships with the xPC
Target™ Getting Started Guide on page 1. This guide and the remaining documentation are available online through the MATLAB Help browser window,orasPDFfilesthatyoucanviewonlineorprint.
®
Visual Basic®, that can use COM
For additional information on using the xPC Target product, see the following MathWorks Web site resources:
MATLAB Central File Exchange for xPC Target Product.
MathWorks Support xPC Target Web site
(
http://www.mathworks.com/support/product/XP). The xPC Target
documentation is also available from this site.
1-3
1 Introduction
Expected Background
Users who read this book should be familiar with
Using the Simulink and Stateflow products to create models as block
diagrams, and simulating those models in Simulink
The concepts and use of Real-Time Workshop software to generate
executable code
When using the Real-Time Workshop and xPC Target products, you do not need to program in C or other programming languages to create, test, and deploy real-time systems.
If you are a new user — Begin with Chapter 1, “Introduction”. This chapter gives yo u an overview of the xPC Target features and xPC Target environment. Next, read and try the examples in Chapter 3, “Basic Tutorial”.
If you are an experienced user — After you are familiar with using the xPC Target software, read or browse the following chapters in the xPC Target User’s Guide: “Software Environment and D emos” and “Targets and Scopes in the MATLAB Interface” for more detailed information about the commands in the xPC Target software.
1-4
xPC Target Features
In this section...
“Real-Time Kernel” on page 1-5
“Real-Time Application” on page 1-7
“Signal Acquisition” on page 1-7
“Parameter Tuning” on page 1-8
“Fixed-Point Support” on page 1-10
“MATLAB®Compiler Support” on page 1-10
Real-Time Kernel
The xPC Target software does not require Microsoft DOS, Microsoft Windows you boot the target PC with boot media that includes the xPC Target kernel.
®
, Linux®, or any another operating system on the target PC. Instead,
xPC Target™ Features
However, the xPC Target Embedded Option product requires DOS and a DOS license at boot time. For more information, see “Embedded Option” in the xPC Target User’s Guide.
Target Boot Disk
The boot disk eliminates the need to install software, modify existing software configurations, or access the hard disk on the target PC. This arrangement allowsyoutousethetargetPCfortesting real-time applications, and then when you are finished with your te sts, you can use the target PC again as a desktop computer. Software is not permanently installed on the target PC unless y ou deliberately install a stand-alone application on the hard disk or flash memory using the xPC Target Embedded Option software. A target boot diskcanbeeitheraCDora3.5-inchfloppydisk. Noteyoucanalsoboota target PC from a boot image across a dedicated network.
Target PC BIOS
Selecting a current BIOS allows you to customize settings for better control over the real-time behavior of the system. For example, you can suppress checking for a keyboard and switch off any power save features.
1-5
1 Introduction
The xPC Target kernel runs only on a PC-compatible system, and a key component of every PC-compatible system is the BIOS. The BIOS is the only software component that is needed by the xPC Target kernel.
After the BIOS is loaded, it searches the targetbootdiskordedicatednetwork for a bootable image (executable). This bootable image includes a 16-bit part and a 32-bit part. The 16-bit part runs first because the CPU is still in real m ode. It prepares the descriptor tables and, in addition to other things, switches the CPU to protected mode. Next, the 32-bit part runs. It prepares the target PC environment for running the kernel and finally starts the kernel.
After loading the kernel, the target PC does not make calls to the BIOS or DOS functions. The resources on the CPU motherboard (for example, interrupt controller, UART, and counters) are addressed entirely through I/O addresses.
Real-Time Kernel
After the kernel starts running, it displays a welcome message with information about the host-target connection. The kernel activates the application loader and waits to d ownload a target application from the host PC. The loader receives the code, copies the different code sections to their designated addresses, and sets the target application ready to start. You can now use xPC Target functions and other utilities to communicate with the target application.
1-6
ItisimportanttonotethataftertheCPUswitches to protected mode (32-bit), none of the xPC Target components switches the CPU back to real mode (16-bit).
The generated real-time application and the real-time kernel are compiled as Microsoft Windows NT provides full 32-bit power without time-consuming 16-bit segment switching and Microsoft DOS extenders.
®
applications with a flat memory model. This
xPC Target™ Features
Real-Time Appli
The Real-Time Wo Coder, and xPC Ta application (t applications c run in real tim
The target app following ch
Memory model
applicatio to an image s 32-bit powe extenders system.
Task execu
real-tim time as fa hardware
For more Applica
aracteristics:
e task execution. A small block diagram can run with a sample
information on creating a target application, see “xPC Target
tion” on page 3-44.
rkshop, Real-Time Workshop Embedded Coder, Stateflow
rget products, and a C compiler, create a real-time
arget application) from a Simulink and Stateflow model. Target
reated with the Real-T ime Workshop and xPC Target software
e on a standard PC without using a Windows operating system.
lication runs in real time on the target PC and has the
— The target application is compiled as a Windows NT
n with the flat memory model. This executable is then converted
uitable for the xPC Target software, and it provides full
r w ithout time-consuming 16-bit segment switching and DOS
. It also does not rely on DOS or any other Microsoft operating
tion time — The target application is capable of high-speed,
st as 20 µs (50 kHz). Model size, complexity, and target PC affect maximum speed (minimal sample time ) of execution.
cation
Signal
The xPC in RAM real­you ca prod
Sign
time mor bac not
Fo yo
Acquisition
Target real-time kernel stores signal data from the target application
on the target PC. Alternatively, you can have the xPC Target
time kernel store signal data in a file on the target PC. In either case,
n use this signal data to analyze and visualize signals. The xPC Target
uct supports the following types of signal acquisition:
al monitoring — This is the process of acquiring signal data without
information. In this mode, you can g et the current values of one or
e signals. The data is not acquired in the real-time task but in the
kground task. The advantage of this process is that collecting data does
add any computational load to running the real-time application.
r example, if you have a LED gauge in a Simulink model on the host PC,
u could use signal moni t ori ng to display the status of the signal.
1-7
1 Introduction
Signal logging — This is the process of acquiring signal data while a target
application is running, and then visualizing the collected data after the target application stops running. The data is collected in the real-time task and acquired samples are associated with a time stamp. After the run finishes or you manually stop the run, the host PC makes a request to upload data from the target PC. You can then visualize signals by plotting data on the host PC, or you can save data to a disk.
Signal tracing — This is the process of acquiring and visualizing signal
data while a target application is running. The data is collected in the real-time task and acquired samples are associated with a time stamp. It allows you to acquire signal data and visualize it on the target PC or to upload the signal data and visualize it on the host PC while the target application is running. The flex ibility of this a c quisition type is very similar to the behavior of a digital oscilloscope.
For information on acquiring signal data with the xPC Target software, see “User Interaction” on page 1-23 in the xPC Target™ Getting Started Guide on page 1 and “Signal Monitoring with the MATLAB Interface”, “Signal Logging” and “Signal Tracing” in the xPC Target User’s Guide documentation.
1-8
Parameter Tuning
Most Simulink blocks have parameters (such as the amplitude and frequency of a sine wave) that you can change before or while your target application is running:
Interactive — The xPC Target software supports tuning of parameters
while the target application is running in real time.
Note Opening a dialog box for a source block causes Simulink to pause. While Simulink is paused, you can edit the parameter values. You must close the dialog box to hav e the changes take effect and allow S imu link to continue.
Scripts and batch procedures — The xPC Target software also includes
commands to change parameters during a run or between runs. By writing a script that incrementally changes a parameter and monitors a signal
xPC Target™ Features
output and running it on the host PC, you can optimize the value of that parameter.
For information on tuning parameters with the xPC Target software, see “User Interaction” on page 1-23 and “Parameter Tuning and Inlining Parameters” in the xPC Target User’s Guide.
1-9
1 Introduction
Fixed-Point Sup
The xPC Target so you to
Monitor and log
Tune paramete
For more infor Point”.
MATLAB Comp
The xPC Targ capability and genera Target fun
Stand-al followin
No MATLA
Target l
No xPC Ta
suppor
, you can use the MATLAB Compiler to take MATLAB files as input
te redistributable, stand-alone applications that include xPC
ctionality.
one applications that include xPC Target functionality have the
g limitations:
ibrary (
t.
ftware supports Simulink fixed-point data. This enables
signals of fixed-point data types
rs of fixed-point data types
mation on using fixed-point data, see the “Simulink Fixed
iler Support
et software supports the MATLAB
B Compiler support, which results in no access to the xPC
xpclib).
rget Explorer, or other xPC Target graphical us er interface
port
®
Compiler™. With this
1-10
No code
To use comma the MA
these features, create a file that uses the MATLAB Compiler
nd-line interface for the xPC Target software (for example, then use
TLAB Compiler).
generation functionality.
Hardware Environment
In this section...
“Introduction” on page 1-11
“Host PC” on page 1-11
“Target PC” on page 1-12
“Host-Target Connection” on page 1-13
“I/O Driver Support” on page 1-15
Introduction
The hardware environment consists of a host computer, target computer, I/O boards in the target computer, and a serial or network connection betw een the host and target computers. Knowing the different types of computers and I/O supported by the xPC Target software will help y ou to set up a development environment that mee ts your needs.
Hardware Environment
Host PC
You can use any PC that runs a Windows platform supported by The MathWorksasthehostPC.Itmustalsocontainafreeserialportoran Ethernet adapter card. In addition, the host PC must contain at least a
3.5–inch floppy disk drive, CD drive, or ability to belong to a d edicated network.
The host PC can be one of the following:
Desktop PC
Notebook PC
For more details on the requirements of the host PC, see “Host PC Requirements” on page 2-8.
1-11
1 Introduction
Target PC
The xPC Target so PC can be almost a processor (386 an Ethernet ada a3.5–inchflo network. Usin files from the alaptopPCas
compatible or higher). It must also contain a free serial port or
pter card. In addition, the target PC must contain at least
ppy disk drive, CD drive, or ability to belong to a dedicated
g the xPC Target Embedded Option software, you can transfer
3.5-inch disk or CD to a hard disk or flash memory. Do not use atargetPC.
ftware supports up to 64 target PCs w ith one host. A target
ny PC compatible system with a 32-bit Intel
®
or AMD
®
AtargetPCca
Desktop PC —
network boo
When you bo image, the RAM, and se already s
After you reboot yo and resu
Industr
networ from a h
When us Compac
You do be a fu cont
For m Requ
not need any special target hardware. However, the target PC must
lly PC-compatible system and contain a serial port or an Ethernet
roller compatible with the xPC Target software.
ore details on the requirements of the target PC, see “Target PC
irements” on page 2-10.
nbeoneofthefollowing:
This computer is booted fro m a special target boot disk or
t image created by the xPC Target software.
ot the target PC from the target boot disk or network boot
xPC Target software u ses the resources on the target PC (CPU,
rial port or network adapter) without changing the files
tored on the hard drive.
are done using your desktop computer as a target PC, you can
ur compute r without the target boot disk or network boot image
me normal use of your desktop computer.
ial PC — This computer is booted from a special target boot disk or
k b oot image, or, using the xPC Target Embedded Option software,
ard disk or flash memory.
ing an industrial target PC, you can select PC/104, PC/104+,
tPCI, or single-board computer (SBC) hardware.
1-12
Hardware Environment
Host-Target Connection
The xPC Target product supports two connection and communication protocols b etw een the host PC and the target PC: serial and network.
Serial — The host and target computers are connected directly with a serial cable using their RS-232 ports. This cable is wired as a null modem link that can be up to 5 meters long and with a transfer rate between 1200 and 115200 baud. A null modem cable is provided with the xPC Target software.
Host PC
Serial
port
For detailed information on setting up the hardware and software for serial communication, see “Serial Communication” on page 2-37.
Network — The h ost and target computers are connected through a network. The network can b e a LAN, the Internet, or a direct connection using a crossover Ethernet cable. Both the host and target computers are connected to the network with Ethernet adapter cards using the TCP/IP protocol for communication.
RS-232
serial connection
Target PC
Serial
port
1-13
1 Introduction
When using a network connection, the target P C can use the Ethernet adapter card provided with the xPC Target product or one of the supported cards. The data transfer rate can be 10 megabits/second, 100 megabits/second, or 1 gigabit/second. For a list of supported cards, see “Hardware for Network Communication” on page 2-25.
Host PC
network
card
Target PC
network
card
TCP/IP
network connection
For detailed information on setting up the hardware and software for network communication, see “Network Communication” on page 2-25.
Advantages of Netwo rk Communication
A host-to-target connection using network TCP/IP communication has advantages over serial RS-232 communication:
Higher data throughput — Network communication using Ethernet can
transfer data up to 100 Mbit/second instead of the maximum data transfer rate of 115 kBaud with serial communication.
Longer distances between host and target computer — By using repeaters
and gateways you do not restrict the distance between your host and target computers to the length of a serial cable. Communication over the Internet is also possible.
1-14
This manual does not include information for installing network cards or the TCP/IP protocol on your host computer. For correct installation and setup of your network cards and the TCP/IP protocol, contact your system administrator.
Hardware Environment
I/O Driver Suppo
The xPC Target pr The list of suppo CompactPCI har Your interacti parameter dia
Note You are r safeguards w arealsosole
ly responsible for the content of your models that controls such
hardware.
I/O board l xPC Target connect I/ standard
I/O suppo boards. industr PMC carr I/O func
ibrary — The I/O board librar y contains Simulink blocks for the
product. You drag and drop blocks from the I/O library and O drivers to your model the same way you would connect any Simulink block.
rt — The I/O device library supports approximately 300 standard
I/O boards plug into the target PC expansion bus, PC/104 stack, or
ial PC chassis. There is also support for modules that plug into IP or
ier boards. The xPC Target block library supports the following
tions:
oduct supports a wide range of third-party I/O boards. rted I/O boards includes ISA, PCI, PC/104, PC/104+, and dware. The drivers are represented by Simulink blocks.
on with the drivers is through these Simulink blocks and the log boxes. The MathWorks does not manufacture the se boards.
esponsible for taking necessary precautions and implementing
hen interfacing hardware with the xPC Target product. You
rt
Analog
actuat
Digit
commu
RS-23
comm RS-4 See “
CAN
boa wit thr an
input (A/D) and analog output (D/A) — Connect sensors and
ors to your target application.
al input and output — Connect to switches, on/off devices, and
nicate information in parallel.
2/422/485 support — Use the COM1 or COM2 ports for serial unication with external devices. You can also access multiple RS-232,
22, and RS-485 serial ports using Quatech
®
and Commtech devices.
Serial Comm unications Support” in the xPC Target I/O Reference.
support — You can use CAN-AC2, CAN-AC2-PCI, and CAN-AC2-104
rds from Softing
®
GmbH AG with xPC Target CAN blocks to interface h a CAN field bus network. This interface provides communication ough a CAN network between target applications and remote sensors
d actuators.
1-15
1 Introduction
The xPC Target CAN blocks are compatible with CAN specifications 2.0A and 2.0B and use dynamic object mode. See “CAN I/O Support” and “CAN I/O Support for FIFO” in the xPC Target I/O Reference.
GPIB support — Special RS-232 drivers support communication with a
GPIB control module from National Instruments a GPIB connector. See “GPIB I/O Support” in the xPC Target I/O R eference.
UDP support — Communicate with another system using the standard
UDP/IP network protocol. See “UDP I/O Support” in the xPC Target I/O Reference.
Counter-Timers — Use the counter-timer blocks for measuring pulse and
frequency with modulation applications.
Watchdog — Monitor an interrupt or memory location, and reset the
computer if an application does not respond. See “Access” and “Versalogic” in the xPC Target I/O Reference.
Incremental encoder — Change motion into numerical information for
determining position, direction of rotation, and velocity.
Shared memory — Use shared memory blocks with multiprocessing
applications.
LVDT — Use the North Atlantic Industries, Inc. 73LD3, 76CL1, 76LD1,
and 76CL1 boards with xPC Target LVDT blocks to work w ith LVDT applications.
ARINC-429 — Use the Condor Engineering CEI-X20 boards with xPC
Target ARINC-429 blocks to interface with the ARINC 429 data bus.
MIL-STD-1553 — Use the Condor Engineering PCI-1553 and Q PCI-1553
series boards with xPC Target MIL-STD-1553 blocks to interface with the MIL-STD-1553 data bus.
®
to external devices with
1-16
Audio — Use the audio blocks to work with audio applications. See Ge n e ra l
Standards PM C66-16AO16 and General Standards PMC-24DSI12 in the xPC Target I/O Reference.
Thermocouple — Use the Measurement Computing™ PCI-DAS-TC
board with xPC Target thermocouple blocks to work with thermocouple applications.
Hardware Environment
For information on using specific I/O driver blocks and advanced I/O support, see the xPC Target I/O Reference.
1-17
1 Introduction
Software Environment
In this section...
“Introduction” on page 1-18
“Host-Target Communication” on page 1-18
“Rapid Prototyping Process” on page 1-19
“The xPC Target Embedded Option Product” on page 1-21
Introduction
The software environment is a place to design, build, and test a target application in nonreal time and real time. It also includes communication between the host and target computers.
Host-Target Communication
Whether using a serial connection (RS-232) or a network connection (TCP/IP), i nformation is exchanged betw een the ho st PC and target PC. This information includes
1-18
Target application — Download a target application from the host to the
target computer.
Control — Change properties and control the target application. This
includes starting and stopping the target application, ch anging sample and stop times, and getting information about the performance of the target application and CPU.
Signal data — Upload signal data from the target computer for analysis
after the target application is finished running, or view signal data during the run.
Parameter values — Download parameter values to the target computer
between runs or during a run.
Software Environment
Rapid Prototypi
Design and build target applicat the target appl while running i
Note Opening a Simulink is p dialog box to
The rapid pr
1 Create a Simulink or Stateflow model — You create block diagram s in
Simulink using simple drag-and-drop operations, and then you enter values for the block parameters and select sample rates. If you use continuous-time components, you also need to select an integration algorithm.
2 Simulate the model in nonreal time — Simulink uses a computed time
vector to step the model. After the outputs are computed for a given time value, Simulink immediately repeats the computations for the next time value. This process is repeated until it reaches the stop time.
ion on a target PC. xPC Target functions include control of
ication, acquisition of signal data, and tuning of pa ra meters
n real time.
aused, you can edit the param et er values. You must close the
have the changes take effect and allow Simulink to continue.
ototyping process includes the following tasks:
ng Process
a target application on a host PC, and then run and test the
dialog box for a source block causes Simulink to pause. While
Note Because this computed time vector is not connected to a hardware clock, the outputs are calculated in nonreal time as fast as your computer can run. The time to run a simulation can differ significantly from real time.
3 Create an executable target application — The Real-Time Workshop,
Stateflow Coder, xPC Target products, and a C compiler, create the target application that runs on the target PC. This real- time application uses the initial parameters from the Simulink model that were available at thetimeofcodegeneration.
cutethetargetapplicationinrealtime—ThetargetPCisbootedusing
4 Exe
xPC Target boot disk or network boot image that loads the xPC Target
an
1-19
1 Introduction
real-time kernel. After booting the target PC, you can build and download a real-time application.
The xPC Target software uses real-time resources on the target PC hardware. Based on your selected sample rate, the xPC Target software uses interrupts to step the model at the proper rate. With each new interrupt, the target application computes all the block outputs from your model.
5 Acquire signals — Acquire signal data using xPC Target scopes. xPC
Target software supports 10 scopes for scopes of type type
file, and an infinite number of scopes of type host,aslongasthe
target PC resources can support them.
Scopes created by xPC T arget Scope blocks acquire data according to Simulink sample time rules. This includes non-regular e xecution, such as if the scope is in an enabled or triggered subsystem. Note that scopes created dynamically(fromtheMATLABCommandWindowortheAPI)sampleat thebaserate,irrespectiveofthesampletimeoftheirsignals.
target, 8 scopes of
1-20
You can create xPC T arget scopes and acquire data from the target application by
xPC Target — Use the xPC Target Remote Control Tool and Scope
Manager windows to create scopes, and use the Simulink viewer to add signals.
MATLAB — Enter commands in the MATLAB Command Window.
Simulink — Add xPC Target Scope blocks to your Simulink model.
Note xPC Target software does not support normal Simulink Scope
blocks in external mode. Instead, use xPC Target Scope blocks.
Target PC — Use commands in the target PC command window.
Web browser — Use the xPC Target Web browser interface.
Software Environment
Simulink GUI — Add blocks to a Simulink user interface model with
xPC Target From blocks. See “Graphical U ser Interfaces” in the xPC Target User’s Guide documentation for details.
6 Tune parameters — You can tune parameters by
xPC Target GUI — Use the xPC Target Remote Control Tool and
Simulink viewer to change parameters.
MATLAB interface — Enter commands in the MATLAB window.
Simulink interface —- Use your Simulink model with external mode.
Target PC — Use commands in the target PC command window.
Web browser — Use the xPC Target Web browser interface.
Simulink GUI —- Add blocks to a Simulink user interface model with
xPC Target To blocks. See “Graphical User Interfaces” in the xPC Target User’s Guide for details.
The xPC Target Embedded Option Product
Often, control system and digital signal processing applications are developed for use in production where a limited number of deployed systems is re quired. Whether you deploy one or a hundred systems, the xPC Target Embedded Option software provides a convenient approach that allows you to implement your system on low-cost PC hardware.
When you have completed developing and testing, y ou can use the target application as a real-time system that runs on a dedicated target PC without needing to connect to the h ost computer.
The xPC Target Embedded Option product has one mode of operation, StandAlone. In this case, the target PC boots into the Microsoft DOS environment, starts the DOS program then starts the kernel from
xpcboot.com:
xpcboot.com from autoexec.bat,and
When using Boot Floppy or CD Boot, you do not need DOS environment to load and run the xPC Target kernel. boots the target PC into DOS, starts the DOS program
autoexec.bat, and then starts the kernel from xpcboot.com.
DOSLoader mode, like StandAlone mode,
xpcboot.com from
1-21
1 Introduction
Note The xPC Target Embedded Option software is a separate product that
requires an additional license from The MathWorks. With this additional license you can deploy an unlimited number of real-time applications for stand-alone o peration.
For more information on the xPC Target Embedded Option product, see “Embedded Option” in the xPC Target User’s Guide.
StandAlone Mode
StandAlone mode combines the target application with the kernel and boots
them together on the target PC from a hard disk drive or flash memory. The host PC does not have to be connected to the target PC.
1 Select StandAlone mode from the Con figuration node in the xPC Target
Hierarchy pane of the xPC Target Explorer tool.
2 Build a kernel/target application.
1-22
3 Copy DOS system files, util ities, kernel/application files, and helper files to
the target PC hard drive or flash memory.
4 Boot the target PC.
When you boot the target PC, the target PC loads DOS environment, which then calls the xPC Target (
*.rtb) and associated target application. If you set up the boot device to
run the xPC Target
autoexec.bat file to start the xPC Target k ern el
autoexec.bat file upon startup, thetargetapplication
starts executing as soon as possible. The xPC Target application e xe cute s entirely in protected mode using the 32-bit flat memory model.
For more information on the xPC Target Embedded Option product, see “Embedded Option” in the xPC Target User’s Guide.
User Interaction
In this section...
“Introduction” on page 1-23
“xPC Target Explorer” on page 1-24
“MATLAB Command-Line Interface” on page 1-25
“Simulink External Mode Interface” on page 1-27
“Simulink with xPC Target Scope B l ocks” on page 1-28
“TargetPCCommand-LineInterface”onpage1-28
“Web Browser I nte rface” on page 1-29
“Custom GUI with xPC Target API for Microsoft .NET Framework” on page 1-29
“Custom GUI with xPC Target API” on page 1-30
“Custom GUI with xPC Target COM API” on page 1-30
User Interaction
Introduction
The xPC Target environment has a modifiable interface to the target PC. You can use this interface from MATLAB or Simulink, and you can use other development environments to create stand-alone client applications independent of MATLAB. Because of this open environment, there are several ways to interact with your target application from the host and target PCs.
Note Some blocks (see “Blocks Whose Outputs Depend on Inherited Sample Time” in the Simulink User’s Guide) cannot p roperly handle sample time changes at run-time. For models that contain these blocks, change the sample time in the model first, then build that model. Although the xPC Target product allows you to change sample times at run-time, changing them at run-time for these blocks might cause incorrect results.
The following table compares the interfaces supported by the xPC Target product.
1-23
1 Introduction
Interface
“xPC Target Explorer” on page 1-24
“MATLAB Command-Line Interface” on page 1-25
“Simulink External Mode Interface” on page 1-27
“Simulink with xPC Target Scope Blocks” on page 1-28
“Target PC Command-Line Interface” on page 1-28
“Web Browser Interface” on page 1-29
“Custom GUI with xPC Target API for Microsoft .NET Framework” on page 1-29
“Custom GUI with xPC Target API” on page 1-30
“Custom GUI with xPC Target COM API” on page 1-30
Environment Properties Control
XXXX
XXXX
XX
XX X
XX X
XX X
XX X
XX X
Signal Acquisition
X
Parameter Tuning
1-24
xPC Target Explorer
The xPC Target software offers a graphical user interface (GUI) for configuring the host and target PCs and interacting with a target application. To open the xPC Target GUI, in the MATLAB Command Window, type
The xPC Target Explorer is an all-in-one user interface that includes the following functionality.
Environment — Use the xPC Target Explorer to change properties in the
xPC Target environment.
xpcexplr.
User Interaction
For more information on environment properties, see
- “Serial Communication” on page 2-37 and “Network Communication”
on page 2-25
- “Working with Target PC Environments” in the xPC Target User’s Guide
- The getxpcenv function in the xPC Target User’s Guide
Control — Use the xPC Target Explorer to download a model. After the
target application is d ow nloaded to the target PC, you can use xPC Target Explorer to run it. Use xPC Target Explorer to change stop time and sample times without regenerating code, and get statistical performance information during or after the last run.
Signal acquisition — Use the xPC Target Explorer
to interactively add scopes of type remove signals.
For more information on using scopes with the xPC Target Explorer, see “Signals and Parameters” in the xPC Target User’s Guide.
Parameter tuning — Use the xPC Target Explorer
to change tunable parameters in your target application.
For more information, see “Signals and Parameters” in the xPC Target User’s Guide.
host, target,orfile,andaddor
Model Hierarchy node
Model Hierarchy node
MATLAB Command-Line Interface
You can interact with the xPC Target environment through the MATLAB command-line interface. Enter xPC Target functions in the MATLAB window on the host PC. You can also write your own MATLAB scripts that use xPC Target functions for batch processing.
The xPC Target software has more than 90 MATLAB functions for controlling the target application from the host computer. These functions define, at the most basic level, what you can do with the xPC Target environment.
The GUIs provided with the xPC Target product are for completing the most common tasks. They use the xPC Target functions but do not extend their functionality. The command-line interface provides an interactive environment that you can extend.
1-25
1 Introduction
The MATLAB command-line interface includes the following functions:
Environment — Create a boot disk or network boot image and directly
change the environment properties without using a graphical interface.
For more information on environment properties, see “Creating a 3.5-Inch Target Boot Disk w ith a Command-Line Interface” on page 2-54, and “Software Environment and Demos” in the xPC Target U ser’s Guide.
Control — Reboot the target PC, download a target application, start
andstoptargetapplications,andchangestartandsampletimeswithout regenerating code. Get statistical performance information during or after the last run. Add and remove scopes, add/remove signals to scopes, and define triggers for scope display.
For more information, see “Control with MATLAB Commands” on page 3-70 in xPC Target™ Getting Started Guide on page 1 and “Software Environment and Demos” in the xPC Target User’s Guide.
Signal acquisition — Trace signals for viewing while the target application
is running and monitor signal values without time information. Transfer logged signal data to the MATLAB workspace by uploading from the target PC to the host PC between runs. For stand-alone target PCs, if you write signal data to a file, use the
ftp utility to transfer that file to a remote PC.
1-26
For more information, see “Signal Monitoring with the MATLAB Interface” “Signal Tracing with the MATLAB Interface” and “Signal Logging in the MATLAB Interface”, and “Targets and Scopes in the MATLAB Interface” in the xPC Target User’s Guide.
Parameter tuning — Change parameters while the target application is
running, and use xPC Target functions to change parameters in between runs.
For more information, see “Parameter Tuning with the MA TLAB Interface” and “Targets and Scopes in the MATLAB Interface” in the xPC Target User’s Guide.
User Interaction
Simulink External Mode Interface
Use Simulink in external mode to connect your Simulink block diagram to your target application. The block diagram becomes a graphical user interface to the target application running in real time. By changing parameters in the Simulink blocks, you also change parameters in the target application.
The Simulink external mode interface includes the following functions:
Control — Control is limited to connecting the Simulink block diagram to
the target application, and starting and stopping the target application.
For more information, see “Signal Tracing with Simulink External Mode” in the xPC Target User’s Guide.
Signal acquisition — You can use Simulink external mode to establish a
communication channel between your Simulink block diagram and your target application. The block diagram becomes a graphical user interface to your target applica t ion and Simulink scopes can acquire signal data from the target application. For more information, see “Signal Tracing with Simulink External Mode” in the xPC Target User’s Guide.
Parameter tuning — Select external mode, and change parameters in the
target application by changing parameters in the Block Parameters dialog boxes. Once you change a value and click OK, the new value is downloaded tothetargetPCandreplacestheexistingparameterwhilethetarget application continues to run. For more information, see “Parameter Tuning with Simulink External Mode”.
Note Opening a dialog box for a source block causes Simulink to pause. While Simulink is paused, you can edit the parameter values. You must close the dialog box to h av e the ch ang es take e ffect and allow Simulink to continue.
For more information, see “Parameter Tuning with Simulink External Mode” in the xPC Target User’s Guide.
1-27
1 Introduction
Simulink with xP
An alternative t Target Scope blo these blocks cr application. Y PC. You can als file in the tar
Signal acqui blocks to you the scope mod
For informa “Adding an x an xPC Targ Target Sco Scope Bloc
Target PC
You can i command This int to the ho
nteract with the xPC Target environment through the target PC
erface is useful with stand-alone applications that are not connected
st PC.
o interactively adding scopes to the target PC is to add xP C
cks to your Simulink model. After the download process,
eate scopes on the target PC during initialization of the target
ou can choose to display data on either the host PC or target
ochoosetosavesignaldata(logreal-timedatastream)toa
get PC file system and transfer that file to another PC.
sition — Add scopes to the target PC by adding xPC Target Scope
r Simulink model. In the Block Parameters dialog box, select
eandsetthetrigger.
tion on acquiring signal data with the xPC Target product, see
PC Target Scope Block” on page 3-17, “Entering Parameters for
et Scope Block” o n page 3-22, “Entering Parameters for an xPC pe of Type File” on page 3-32, and “Signal Tracing with xPC Target ks” in the xPC Target User’s Guide.
Command-Line Interface
window. Enter commands in the command line on the target PC.
C Target Scope Blocks
1-28
The tar
Contr
Sign
Par
get PC command-line interface includes the following functions:
ol — Start and stop the target application, and change the stop time
and sa
For mo in th
trac
mple time.
re info rm ation, see “Using the Target PC Command-Line Interface”
e xPC Target User’s Guide.
al acquisition — Acquirin g signal data is limited to viewing signal
es and signal monitoring on the target PC screen.
ameter tuning — You can change only scalar parameters in your model.
User Interaction
Web Browser Interface
If the target PC is connected to a network (TCP/IP), you can use a Web browser to interact with the target application from any computer connected to the network. If the target PC is connected to the hos t PC with an RS-232 cable, and is using the TCP/IP to RS-232 gateway, you can use a Web browser on the host PC.
The Web browser interface includes the following functions:
Control — Start and stop the target application, and change the stop time
and sample time.
For mo re information, see “xPC Target Web Browser Interface” in the xPC Target User’s Guide.
Signal acquisition — Signal tracing is limited to viewing a snapshot of a
screen captured from the target PC screen. Add scopes of type targ et, add or remove signals, and set triggering modes. You can also monitor signal values.
For more information, see “Signal Logging with a Web Browser” in the xPC Target User’s Guide.
Parameter tuning — Change parameters in an HTML form, and then
submit that form to make the changes in your target application.
For more i nformation, see “Parameter Tuning with a Web Browser” in the xPC Target User’s Guide.
Custom GUI with xPC Target API for Microsoft .NET Framework
Use the .NET API xPC Target framework to develop solutions (applications, human-machine interface (HMI) software, batch runs) that use the xPC Target software. The xPC Target .NET object model provides objects that you can interact with. The xPC Target software arranges the xPC Target .NET objects in a hierarchical order. Each of these objects has methods and properties that allow you to manipulate and interact with it. This document presents this referenceusingtheC#language.
For more information, see “xPC Target API for Microsoft .NET Framework”.
1-29
1 Introduction
Custom GUI with x
Create a GUI appl development env
Use the GUI appl acquire signa host PC and com RS-232 or TCP/ Windows appl
For more info
Custom GUI w
Create a GU Visual Bas objects. T paramete target ap Target ap
1 Create a Simulink model.
2 Optionally, tag parameters and signals in the Simulink model.
®
ic
hese COM o bjects connect graphic elements to parameters for
r tuning, and they connect signals for acquiring data from your
plication. To create a custom GUI application connected to an xPC
plication, use the following process:
ication interface to a target application using any
ironment that can link in a DLL.
ication to control the application, tune parameters, and
l data from a target application. The custom GUI runs on the
municates with the target application on the target PC using
IP communication. A GUI application can be a console or
ication using ActiveX
rmation, see the xPC Target API Guide.
ith xPC Target COM API
I application that interfaces with a target application using
or any development environment that can incorporate COM
PC Target API
®
components.
1-30
3 Build t
4 If you tag parameters and signals, build the model-specific COM library.
5 Create a GUI application that references the COM library.
For more information, see the xPC Target API Guide.
he target application.
Installation and Configuration
The software environment for xPC Target uses two separate computers. Because of this complexity, installation and configuration are more involved. This chapter includes the following sections:
“Required Products” on page 2-2
“Related Products” on page 2-7
“System Requirements” on page 2-8
2
“Installation on the Host PC” on page 2-15
“xPC Target Explorer” on page 2-21
“Network Communication” on page 2-25
“Serial Communication” on pag e 2-37
“xPC Target Boot Options” on page 2-44
“Testing and Troubleshooting the Installation” on page 2-62
“Exporting and Importing xPC Target Explorer Environments” on page
2-69
2 Installation and Configuration
Required Products
In this section...
“MATLAB” on page 2-2
“Simulink” on page 2-3
“Real-Time Workshop” on page 2-4
“C Compiler” on page 2-4
“xPC Target Embedded Option Product” on page 2-6
MATLAB
MATLAB provides a command-line interface for the xPC Target product.
With the xPC Target software, you have full control of the target computer and target application using xPC Target functions and the command-line interface or MATLAB scripts. You u se the xP C Target functions for
2-2
Real-time application control — Download,start,andstopthetarget
application.
Signal acquisition and analysis — Save signal data while the target
application is running and analyze the data after the application has completed running, or display signal data while the target application is running in real time.
Parameter tuning — Change parameters while the target application is
running in real time.
Note xPC Target Version 4.3 requires MATLAB V ersion 7.10.
MATLAB documentation — For information on using MATLAB and its
functions, see the online MATLAB documentation.
Simulink
Simulink provid system and contr using a mouse to
Required Products
es an environment where you model your dynamic physical
oller as a block diagram. You create the block diagram by connect blocks and a keyboard to edit block parameters.
You can use the discrete-tim system and gen fixed-step i
xPC Target I/ system with you can repl xPC Target I drivers be
come available, you can download updates from the MathWorks™
xPC Target product with most Sim u link blocks, including
e and continuous-time systems. When you use a continuous-time
erate code with Real-Time Workshop, you must use a
ntegration algorithm.
O driver blocks — You can replace the model of your physical
I/O driver blocks connected to the actual physical system, or
ace the model of your controller with the actual controller. The
/O library supports more than 400 driver blocks. As additional
Web site at
http://w productn
The I/O d
Note xPC
Simuli Simul and ch block
ww.mathworks.com/support/product/XP/productnews/ ews.html
evice drivers are written as Simulink C code S-functions.
Target Version 4.3 requires Simulink Version 7.5.
nk documentation — For information on using Simulink, see the online
ink documentation. It explains how to connect blocks to build models
ange block parameters. It also provides a reference that describes each
in the standard Simulink library.
2-3
2 Installation and Configuration
Real-Time Works
Real-Time Works into C code and th into a real-tim
Features of Re well as loop-r code for size a download you command in Re
Note xPC Tar
Real-Time see the onl
ine Real-Time Workshop documentation.
CCompile
The C com Real-Ti product applica
piler creates executable code from the C code generated from
me Workshop and the C code S-functions you create. The xPC Target
uses this executable code to create an executable image (target
tion) that runs with the xPC Target kernel on the target computer.
hop provides the utilities to convert your Simulink models
en, with a third-party C/C++ compiler, compile the code
e executable.
al-Time Workshop include support for multirate systems, as
olling and S-function inlining, which allow you to optimize your
nd efficiency. With the xPC Target product, you can build and
r target application to the target computer using the
al-Time Workshop.
get Version 4.3 requires Real-Time Workshop Version 7.5.
Workshop documentation — For information on code generation,
r
hop
build
2-4
Note To Targe CComp compi
configure your C compiler for the xPC Target software, use the xPC
t Explorer interface (see “Configu ring the xPC Target Host PC for Your
iler”onpage2-19).Donotusethe
ler for the xPC Target product.
mex -setup command to set the C
In addition to the products from The MathWorks, you need to install a C compiler. The Real-Time Workshop and xPC Target products support the C compilers listed here:
http://www.mathworks.com/support/compilers/current_release/
Required Products
2-5
2 Installation and Configuration
xPC Target Embed
You do not need th license, you can
Boot the target
DVD, or networ
Deploy a stand
Target C, COM, Embedded Opt application acquire sig
The xPC Targ an addition Embedded O
Note xPC T Version 4
al license from The MathWorks. Information about the xPC Target
.3.
is product for rapid prototyping, but with this additional
PC from an alternate device other than a floppy disk , CD, k boot image, such as a hard disk drive or flash memory.
-alone GUI application that you create with the xPC or .NET Framework API. Without the xPC Target
ion product, you can create, but not deploy, stand-alone GUI
s running on the host PC to control, change parameters, and
nal data from a target application.
et Embedded Option product is a separate entity that requires
ption product is included with the xPC Target documentation.
arget Version 4.3 works with xPC Target Embedded Option
ded Option Product
2-6
Related Products
The MathWorks provides several products that are relevant to the kinds of tasks you can perform with the xPC Target software.
For more information about any of these products, see either
The online documentation for that product if it is installed on your system
The MathWorks Web site at
http://www.mathworks.com/products/xpctarget/related.jsp.
Related Products
2-7
2 Installation and Configuration
System Requirements
In this section...
“Introduction” on page 2-8
“Host PC Requirements” on page 2-8
“Target PC Requirements” on page 2-10
Introduction
The hard w are and software requirements are different for the host and target computers.
Note that the BIOS settings of a PC system can affect how the PC works with the xPC Target software. If you experience problems using the xPC Target pro duct with the target or host PC, you should check the system BIOS settings. These settings are beyond the control o f the xPC Target software. Refer to “Target PC BIOS” in the xPC Target User’s Guide for guidelines on BIOS settings.
2-8
Host PC Requirements
The host PC is usually your desktop com puter where you install the M ATLA B, Simulink, Stateflow, Stateflow Coder, Real-Time Workshop, xPC Target, and xPC Target Embedded Option products. A notebook computer is also aviablehostPC.
Software Requirements for the Host PC
The following table lists the minimum software the xPC Target product requires on your host PC. For a list of optional software products related to the xPC Target product, see
http://www.mathworks.com/products/xpctarget/related.jsp.
tware
Sof
32-bit operating system
TLAB Product
MA
cription
Des
ndows platform supported by The MathWorks
Wi
TLAB Version 7.10
MA
Software Description
Simulink Product Simulink Version 7.5
System Requirements
Real-Time Workshop
Real-Time Workshop Version 7.5
Product
C language compilers
http://www.mathworks.com/support/­compilers/current_release/
xPC Target Product xPC Target Version 4.3
Hardware Requirements for the Host PC
The following table lists the minimum resources the xPC Target product requires on the host PC.
Hardware Description
Communication Select one of the following methods to
communicate with the target PC:
One supported Ethernet card connected to a
network (see “Network Communication” on page 2-25) for supported Ethernet cards and chip sets)
One free serial port (COM1 or COM2) with a
9-pin or 25-pin D-sub connector (see “Serial Communication” on page 2-37 for details)
CPU Pentium, Athlon, or later
Peripherals
Hard disk drive with 60 MB of free space
One 3.5-inch floppy disk drive
One CD-RW or DVD-RW drive
RAM
128 MB or more
2-9
2 Installation and Configuration
Target PC Requirements
The target PC must be a 32- or 64-bit PC-compatible system. For example, you can use a second desktop computer or an industrial system like a PC/104 or CompactPCI as the target computer.
Note For target PCs, 64-bit systems run in 32-bit mode.
Software Requirements for the Target PC
The following table lists the minimum software the xPC Target product requires on your target PC system.
Software Descriptio
Operating
BIOS PC compat
system
None. The x operating
n
PC Target kernel has no effect on any
system installed on the target PC.
ible
2-10
System Requirements
Hardware Requirements for t he Target PC
The following table lists the minimum resources the xPC Target product requires on the target PC system.
Note Do not use a laptop PC as a target PC.
Hardware Description
Chip set PC compatible with UA RT, programmable
interrupt controller, keyboard controller, and counter
Communication Select one of the following methods to
communicate with the host PC:
One supported Ethernet card connected to a
network (see “Network Communication” on page 2-25 for supported Ethernet cards and chip sets). Note, the xPC Target product includes an approved E the rnet card for the target PC.
Onefreeserialport(COM1orCOM2)witha
9-pin or 25-pin D-sub connector (see “Serial Communication” on page 2-37 for details). The xPC Target software includes a serial null modemcableforthetargetPC.
CPU Intel 386/486/Pentium or AMD K5/K6/Athlon
with or without a floating-point coproce ssor
Keyboard
Needed to control the target PC when you create stand-alone applications
Note that if a keyboard is not connected, the BIOS might display an error message (keyboard failure). With a current BIOS, you can use the BIOSsetuptoskipthekeyboardtest.
2-11
2 Installation and Configuration
Hardware Description
Monitor The MathWorks recommends using a monitor,
but it is not necessary. You can get all the target information using xPC Target functions on the host PC.
Peripheral
RAM
Random Access Memory (RAM) — The xPC Target product works with PC-compatible computers that use inexpensive dynamic RAM, unlike many non-PC-compatible target computers that use expensive static RAM. You can acquire several megabytes of data during a run depending on how much memory you install in the target PC.
One 3.5-inch floppy disk or CD/DVD drive. A hard disk drive is not required unless you want to accessthetargetPCfilesystem(forfilescopes).
Notes:
If you install the xPC Target Embedded Option
product, you can co py files to a hard disk or flash memory and boot from that device.
If you have a hard disk drive, and you want to
access the target PC file system on that drive, see “Working with Target PC Files and File Systems” in the xPC Target User’s Guide.The xPC Target product supports file systems of type FAT-12, FAT-16, or FAT-32.
The hard drive must b e a parallel ATA
(PATA)/Integrated Device Electronics (IDE) or serial ATA (SATA) drive. For best performance, configure this drive as a primary master.
Ensure that the hard d rive is not cable-selected.
8MBormore
2-12
System Requirements
PC-compatible target computers — The xPC Target p roduct supports the following PC-compatible hardware (form factors):
PC ISA
PC PCI
PC/104 and PC/104+
CompactPCI
I/O boards — You can install inexpensive I/O boards in the PCI or ISA slots of the target PC. These boards provide a direct interface to the sensors, actuators, or other devices for real-time control or signal processing applications.
The xPC Target software supports the I/O functionality listed in “I/O Driver Support” on page 1-15.
The xPC Target Software and the Target PC BIOS
The B IOS settings of a PC system can affect how the PC works with the xPC Target software. As a general rule, ensure that the host and target PC BIOS have at least the following settings:
RS-232 communication — If you are using RS-232 communications, ensure
that COM ports are enabled for both host and target PCs. Also, ensure through the BIOS that COM1 has a base address of COM2 must have a base address of
2F8 and an IRQ of 3. These are the
3F8 and an IRQ of 4.
defaultbaseaddressvalues. Donotchangethesevalues.
Plug-and-Play (PnP) operating system — Disable this feature to ensure
that the PCI BIOS sets up the plugged-in PCI cards properly. The xPC Target kernel is not a PnP operating sys tem; you must ensure that this feature is disabled or PCI devices will not work on the xPC Target product.
Power Saving modes — D isable all power saving modes.
USB support —- Disable all USB support, including general USB and
USB keyboard support. Failure to do this will cause occasional long task execution times (TET).
2-13
2 Installation and Configuration
PCI boards — Do not detect PCI boards with class code 0xff in the target
Hyper-threading — If your target PC supports hyper-threading capabilities,
In addition, check the boot up order for the target PC BIOS. You can boot up the target PC using the following methods:
Boot floppy disk
CD/DVD bootable ROM
Dedicated network boot
Configure your target PC BIOS to use your preferred boot order.
xPC Target Software and Multicore Support
If yo ur target PC has multicore processors, the xPC Target software enables youtotakeadvantageofthem. CheckthetargetPCBIOStoseeifithas multicore processors.
PC BIO S . Set this option to all boards.
do not enable these capabilities. Enabling hyper-threading can degrade the performance of the target PC .
Off to enable the BIOS to detect and configure
2-14
If the target PC has multicore processors, you can configure the xPC
Target software to take advantage of them. See “Configuring Environment Parameters for Target PCs” in the xPC Target User’s Guide.
To take advantage of multicore processors, be sure to disable hyper-threading in the target PC BIOS.
If the target PC has only single core processors, you cannot use the
multicore capabilities of the xPC Target software.
Installation on the Host PC
In this section...
“Overview” on page 2-15
“License Requirements” on pag e 2-15
“Files on the Host PC Computer” on page 2-16
“Setting Your Initial Working Folder” on page 2-16
“Running MATLAB Remotely” on page 2-18
“Configuring the xPC Target Host PC for Your C Compiler” on page 2-19
Overview
You install the xPC Target software entirely on the host PC. Installing software on the target PC is not necessary. The xPC Target software is distributed on a DVD or as a file you download from the Web.
Installation on the Host PC
Note Before you start, ensure that the xPC Target and xPC Target Embedded Option products are not already installed on your host PC. Uninstall both before proceeding if necessary.
After you install the product, you will need to set u p the xPC Target environment for either serial or network communication. See “Serial Communication” on page 2-37 or “Network Communication” on page 2-25.
License Requirements
Before you install the xPC Target or the xPC Target Embedded Option products, you must have a valid File Installation Key and License File. The File Installation Key identifies the products you purchased from The MathWorks and are permitted to install and use. The License File activates the installation.
If you have not received either of these, go to the License Center at the MathWorks Web site.
2-15
2 Installation and Configuration
The xPC Target family of software includes options that you can purchase and add later to the xPC Target environment.
xPC Target Embedded Option product — With the xPC Target Embedded Option product, you can boot the target PC from a device other than a floppy disk or CD/DVD and deploy stand-alone target applications separate from the host PC.
Files on the Host PC Computer
When using the xPC Target software, you might find it helpful to know where files are located:
MATLAB working folder — Simulink models (
applications (
Select a working folder outside the MATLAB root. See “Setting Your Initial Working Folder” on page 2-16.
Real-Time Workshop Build folder — The Real-Time Workshop C code files
(
model.c, model.h) are in a subfolder called modelname_xpc_rtw.
The xPC Target software uses the directories and files located in
matlabroot\toolbox\rtw\targets\xpc\
target — Files and functions related to the xPC Target kernel and build
process, including drivers to support I/O blocks
xpc — H o st PC functions related to all of the xPC Target software, methods
for target objects, and methods for scope objects
xpcdemos — Simulink models and MATLAB code demos
model.dlm)
model.mdl), xPC Target
Setting Your Initial Working Folder
You should set your MATLAB working folder outside the MATLAB root folder. The default MATLAB root folder is
If your MATLAB working folder is below or inside the MATLAB root, files created by Simulink and Re al-Time Workshop are mixed with the MATLAB directories. This mixing of files couldcausefilemanagementproblems.
c:\matlab.
2-16
Installation on the Host PC
From the Desktop Icon
Your initial working folder is specified in the shortcut file you use to start MATLAB. To change this initial folder, use the following procedure:
1 Right-click the MATLAB desktop icon or, from the program menu,
right-click the MATLAB shortcut.
2 Click Properties.IntheStart in text box, enter the folder path you
want MATLAB to use initially. Make sure you choose a folder outside the MATLAB root folder.
3 Click OK, and then start MATLAB. To check your w orking folder, in the
MATLAB Command W indow, type
pwd
From Within MATLAB
To temporarily set your MATLAB working folder, use the following procedure:
1 In the MATLAB Command Window, type
cd c:\<MATLAB working folder>
2 To check your working folder, type
pwd or cd
To permanently set your working folder, see “From the Desktop Icon” on page 2-17.
2-17
2 Installation and Configuration
Running MATLAB R
If you are runnin register A ctive
1 In the MATLAB Command Window, type
xpc_register_ocx
This function registers the Active X controllers that xPC Target Explorer requires.
2 Close xPC Target Explorer.
3 Close MATLA
4 Restart MATLAB.
5 Restart xPC Target Explorer.
You are now ready to start xPC Target Explorer.
g MATLAB remotely (accessing MATLAB over the network),
X controls before you start xPC Target Explorer.
B.
emotely
2-18
Installation on the Host PC
Configuring the xPC Target Host PC for Your C Compiler
To configure the host PC for your compiler, use xPC Target Explorer.
Note Do not use the mex -setup command to set the C compiler for the xPC Target software.
1 If xPC Target Explorer is not already open, in the MATLAB Command
Window, type
xpcexplr
The xPC Target Explorer window appears .
C Target Explorer always has a default target PC node in its
xP
nfiguration. The default target PC node is always boldfa ced. In a
co
2-19
2 Installation and Configuration
2 In the xPC Target Explorer window, select the Compiler(s)
3 At the Select C Compiler drop-down list, select the compiler you have
4 Enterthepath(orbrowse)tothecompilerforCompiler Path.For
multitarget environment, this visual aid helps you easily identify the defaulttargetPC.
Configuration
node.
In the right pane, the compiler parameters appear.
installed on the host PC. The examples in this chapter use
VisualC.
example,
C:\Application\Microsoft Visual Studio
2-20
5 Click Apply to apply the changes.
Note xPC Target Explorer dialogs highlight a field and enable the Revert
and Apply buttons when you make changes. To apply changes, click Apply. A prompt is displayed if you leave a dialog without first saving changes. If you want the original entry tobedisplayed,clicktheRevert button and do not click the A pply button. If you click Apply, you cannot retrieve the original entries.
xPC Target Explorer
In this section...
“Introducing xPC Target Explorer” on page 2-21
“The xP C Target Product and Default Target PCs” o n page 2-23
Introducing xPC Target Explorer
xPC Target Explorer is a graphical user interface for the xPC Target product. It provides a single point of contact for almost all interactions. Through xPC Target Explorer, you can perform basic operations, such as
Configure the host PC for the xPC Target software
Add and configure target PCs for the xPC Target software, up to 64 target
PCs
Create boot disks for particular target PCs
xPC Target™ Explorer
Connect the target PCs for your xPC Target system to the host PC
Download a prebuilt target application, DLM, to a target PC
Start and stop the application that has been downloaded to the target
Add host, target, or file scopes to the downloaded target application
Monitor signals
Add signals to xPC Target scopes and remove them
Start and stop scopes
Adjust parameter values for the signals while the target application is
running
The xPC Target Explorer GUI runs on your xPC Target system host machine.
You can interact w ith xPC Target Explorer through menus or a toolbar. You can also right-click objects and select actions from the context menu for those objects. The tutorials in the xPC Target documentation des cribe procedures using mouse operations.
2-21
2 Installation and Configuration
xPC Target Hierarchy
1 In the MATLAB Command Window, type
xpcexplr
The xPC Target Explorer window opens.
2-22
You can also start xPC Target Explorer from the Simulink model window (Tools > Real-Time Workshop > xPC Target Explorer).
You can dock or undock the xPC Target Explorer window using the arrow in the upper-right corner. Note the contents of the left pane of the xPC Target Explo rer. This is the xPC Target Hierarchy pane. If you resize or move the window, the xPC Target software remembers the new size and location in subsequent restarts of xPC Target Explorer.
xPC Target™ Explorer
This pane contains all the objects in your xPC Target hierarchy. As you add objects to your system, xPC Target Explorer adds corresponding nodes to the xPC Target Hierarchy pane. T he foremost node is the
node. It represents the host PC. The right pane displays information
Root
that reflects an item selected in the left pane.
Note that, by d efault, xPC Target Explorer starts with two target PC objects. The first target PC object is highlighted as the default.
Host PC
The xPC Target Product and Default Target PCs
The following are notes on default target PCs:
When you first start xPC Target Ex plore r, it has a default node,
You configure this node for a target PC, then connect the node to the target PC. If you later build a target application from a Simulink model, the xPC Target software builds and downloads that application for the default target PC. You can add other target PC nodes and designate one of them as the default target PC instead of the first one. To set a target PC node as the default, right-click that node and select Set As Default from the context-sensitive menu. The default target PC node is always boldfaced. In a multitarget environment, this visual aid h elps you easily see the target PC you are working with.
If you delete a default target PC node, the target PC node preceding it becomesthedefaulttargetPCnode. ThelasttargetPCnodeisalwaysthe default target PC node and cannot be deleted.
If you want to use the xPC Target command-line interface to work with the
target PC, you must indicate which target PC the command is interacting with. If you do not identify a particular target PC, the xPC Target software expects xPC Target Explorer to contain this information.
The xPC Target product provides a default target PC to help you work
with the MATLAB command-line interface, maintain compatibility with previous releases, and w ork with Simulink external mode, as follows:
TargetPC1.
- When you define a default target PC, the MATLAB command-line
interface works as in prior releases. For example, when you instantiate the target object constructor
tg=xpc) the constructor uses the environment properties of the default
target PC to communicate with the appropriate target PC.
xpc without any arguments (for example,
2-23
2 Installation and Configuration
- The target PC environment object, xpctarget.targets ,manages
collective and individual target PC environments. See “Working with Target PC Environments” in the xPC Target user’s guide documentation for details.
- The target PC commands getxpcenv and se txpcenv get and set
environment properties of the default target PC.
2-24
Network Communication
In this section...
“Network Communication Overview ” on page 2-25
“Hardware for Network Communication” on page 2-25
“Ethernet Card Provided with the xPC Target Product” on page 2-26
“Ethernet Card for a PCI Bus” on page 2-27
“Ethernet Card for an ISA Bus” on page 2-28
“Environment Properties for Netw ork Communication” on page 2-30
Network Communication Overview
This topic describes the establishment of communication between the host PC and target PC using network communications (TCP/IP). For serial communication, see “Serial Communication” on page 2-37.
Network Communication
Hardware for Network Communication
You must install the following hardware before you install the xPC Target software and configure it for network comm unication:
Network (Ethernet) adapter card — When using the product with TCP/IP,
you must have a network (Ethernet) adapter card correctly installed on both the host PC and the target PC. Be sure to:
- Connect the host and target computers with an unshielded twisted pair
(UTP) cable to your (LAN).
- Assign a static IP address to the target PC network adapter card.
For the most current network communications requirements, see
http://www.mathworks.com/products/xpctarget/­xPC_Target_Supported_Ethernet_Chipsets.pdf
You can also see “Ethernet Card Provided with the xPC Target Product” on page 2-26 for information on the Ethernet card that ships with your product.
2-25
2 Installation and Configuration
I/O boards — If you use I/O boards on your target PC, you need to install
Ethernet Card Provided with the xPC Target Product
The MathWorks supplies a PCI bus Ethernet card with the xPC Target software for you to u se in a desktop target PC. The following tab le will help to identify the card that was shipped with your software and the parameter you need to select in the xPC Target Explorer. Both cards support a data transfer rate of 100 megabits per second (Mb/s). Note that these cards are functionally the same.
The host PC network adapter card can have a Dynamic Host Configuration Protocol (DHCP) address. The host PC can be any computer on the network. When using the product with TCP/IP, you must configure the DHCP server to reserve all static IP addresses to prevent these addresses from being assigned to other systems.
You can also directly connect your computers. Use a crossover UTP cable with RJ45 connectors to connect them. Both computers must have static IP addresses. If the host PC has a second network adapter card, that card can have a DH CP address.
the boards correctly.
2-26
Board Identification Setup Parameter
Intel Pro/100 M Intel Pro/100 M or Desktop
Adapter
Intel Pro/100 S Intel Pro/100 S or Desktop Adapter
To configure xPC Target to work with the supplied card:
1 If xPC Target Explorer is not already started, in the MATLAB Command
Window, type
xpcexplr
The xPC Target Explorer window opens.
2 In the xPC Target Explorer xPC Target Hierarchy pane, select the
Communication node of the target PC for which you want to check the boot
disk. For example, sele ct the
Communication node for TargetPC1.
I82559
I82559
Network Communication
3 From the Host target communication list, select TCP/IP.
4 From the TCP/IP target driver list, select I82559.
If you cannot use the Ethernet card provided with the xPC Target product, youcanselectyourownEthernetcard,see
http://www.mathworks.com/products/xpctarget/­xPC_Target_Supported_Ethernet_Chipsets.pdf
The following are cas es where you might not be able to use the Ethernet card provided with the xPC Target product:
You do not have an available PCI slot in your target PC.
YoudonothaveaPCIbusinyourtargetPC.
You need to use an Ethernet card other than the card provided with the
xPC Target product.
Ethernet Card for a PCI Bus
If your target PC has a PCI bus, The MathWorks recommends that you use an Ethernet card for the PCI bus. The PCI bus has a faster data transfer rate and requires minimal effort to configure. The MathWorks also supplies one PCI bus Ethernet card with the xPC Target software for your target PC.
To install the PCI bus Ethernet card supplied with the xPC Target software, use the following procedure:
1 Turn off your target PC.
2 If the target PC already has an unsupported Ethernet card, remove the
card.
3 Plug the Ethernet card from The MathWorks into a free PCI bus slot.
4 Connect your target PC Ethernet card to your LAN using an unshielded
twisted-pair cable.
2-27
2 Installation and Configuration
Your next task is to set up the xPC Target environment for network communication. See “Environment Properties for Network Communication” on page 2-30.
Ethernet Card for an ISA Bus
Your target PC might not have an available PCI bus slot, or your target PC might not contain a PCI bus (older motherboards, passive ISA backplanes, or PC/104 computers). In these cases, you can use an Ethernet card for an ISA bus.
If you are using an ISA bus, you need to reserve, from the BIOS, an interrupt for this board.
The MathWorks does not provide an ISA b us board. For a list of known compatible network adapter chip families, see
http://www.mathworks.com/products/xpctarget/­xPC_Target_Supported_Ethernet_Chipsets.pdf
2-28
Network Communication
To install an ISA bus Ethernet card, u se the following proced ure:
1 Turn off your target PC.
2 On your ISA bus card, assign an IRQ and I/O-port base address by moving
the jumpers or switches on the card. Write down these settings, because you need to enter them in the xPC Target Explorer.
You should set the IRQ line to
0x300. If one of these hardware settings would lead to a conflict in your
11 and the I/O-port base address to around
target PC, select another IRQ or I/O-port base address.
Note If your ISA bus card does not contain jumpers to set the IRQ line and the base address, use the utility on the installation disk supplied with your card to manually assign the IRQ line and base address. Do not configure the card as a PnP-ISA device.
3 If the target PC already has an unsupported Ethernet card, remove the
card. Plug the compatible network card into a free ISA bus slot.
4 Connect the target PC network card to your local area network (LAN) using
a coaxial cable or an unshielded twisted-pair cable.
If you use an Ethernet card for an ISA bus within a target PC that has a PCI bus, you must reserve the chosen IRQ line number for the Ethernet card in the PCI BIOS. Refer to your BIOS setup documentation to set up the PCI BIOS.
Your next task is to set up the xPC Target environment for network communication. See “Environment Properties for Network Communication” on page 2-30.
2-29
2 Installation and Configuration
Environment Properties for Network Communication
The xPC Target environment is defined by a group of properties. These properties give xPC Target information about the software and hardware that it works with. You might change some of these properties often, while others you will rarely want to change.
After you have installed the xPC Target software, you can specify the environment properties for the host and target computers. Note that you must specify these properties before you can build and download a target application.
1 If xPC Target Explorer is not already started, in the MATLAB Command
Window, type
xpcexplr
The xPC Target Explorer window opens.
xPC Target Explorer associates network comm unication environment properties with the target PC.
2-30
2 In the xPC Target Explorer, right-click the Host PC node.
3 Select Add Target.
A target PC node named Hierarchy, at the same level as the
TargetPC1 appears in the xPC Target
Host PC node. It appears with the icon
(note the X to denote that the host PC is not connected to the target PC).
4 As necessary, repeat and for each additional target PC you want to add
to your system.
Additional target PC nodes appear in the xPC Target Hierarchy.As you add other target PCs, the PC number is incremented. T he following figure illustrates two target PC nodes.
Network Communication
5 In the xP
A
Config
Setting
groupe
6 Select Communication.
C Target Explorer, expand a target PC node.
uration
s
,andAppearance. The parameters for the target PC node are
node appears. Under this are nodes for Communication,
d in these categories.
The Communication Component pane appears to the right.
7 From the Host target communication list, select TcpIp.
The pane changes to one that contains only those parameters pertinent to network communication.
8 You
must enter the network properties with the correct values according
our LAN environment. Ask your system administrator for values for
to y
se settings.
the
2-31
2 Installation and Configuration
Target PC IP address —ThisistheIPaddressforyourtargetPC.An
example of an IP address is
LAN subnet mask address — This is the subnet mask address of your
LAN. An example of a subnet mask a ddress is
Alternatively, you can obtain the LAN subnet mask address from the Network Connections dialog box on your host PC. Depending on your Windows platform, you can access this dialog box in a number of ways. For example, on a Windows XP Professional system, y ou can use this sequence:
1 Select Start > Settings > Control Panel,thendouble-click
Network Connections.
2 Right-click Local Area Connection, then select Properties.
3 Select Internet Protocol (TCP/IP),thenclickProperties.
If your computers connect with a crossover cable, you might have a dialog box like the following. You can obtain your subnet mask address and TCP/IP gateway address from this dialog box.
192.168.0.10.
255.255.255.0.
2-32
Note The TCP/IP address is for your host PC, not your target PC. You stillneedtogetthetargetPCTCP/IPaddressforyourtargetPCfrom your system administrator.
The default gateway address is blank in this dialog box. However, in the xPC Target Explorer, you must enter value in the TCP/IP gateway address property.
255.255.255.255 for the gateway
Network Communication
Host PC TCP/IP address
LAN subnet mask address
9 Optionally, enter the following properties, depending on your specific
circumstances:
TCP/IP target port — This property is set by default to
22222.This
value should not cause any problems, because this number is higher than the reserved area (
telnet, ftp, ...) and it is only relevant on the
target PC. If necessary, you can change this property value to any value higher than
20000 and less than 65536.
TCP/IP g ateway address — This property is set by default to
255.255.255.255. This means that you do not use a gateway to connect
2-33
2 Installation and Configuration
10 Enter the following properties specific to the Ethernet card on your target
to your target PC. If you connect your computers with a crossover cable, leave this property as
255.255.255.255.
If you communicate with the target PC from within your LAN, you might not need to define a gateway and change this setting.
If you communicate from a host PC located in a LAN different from your target PC, you need to define a gateway and enter its IP address. This is especially true if you want to work over the Internet. Ask your system administrator for the IP address of the appropriate gateway.
PC:
TCP/IP target driver — From the list, select
I82559, RTLANCE, R8139, 3C90x, NS83815,orI8254x. This property is set
by default to
NE2000. For a crossover cable connection, select I82559.
NE2000, SMC91C9X,
Note To allow the software to determ ine your TCP/IP target driver,
select
Auto. If not supported Ethernet card exists in your target PC, the
software returns an error.
TCP/IP target bus type — This property is set by default to PCI. If TCP/IP target bus type is set to PCI, then the properties TCP/IP target ISA memory port and TCP/IP target ISA IRQ number have
no effect on TCP/IP communication and are disabled (grayed out). If you are using an ISA bus Ethernet card, set TCP/IP target bus type to and enter values for T CP/IP ISA memory port and TCP/IP target ISA IRQ number.
TCP/IP target ISA memory port and TCP/IP target ISA IRQ
number — If y ou are using an ISA bus Ethernet card, you must enter values for the properties TCP/IP target ISA memory port and TCP/IP target ISA IRQ number . The values of these properties must
correspond to the jumper settings or ROM settings on your ISA bus Ethernet card.
ISA
2-34
Network Communication
11 If the target PC has multiple Ethernet cards, type the following command
to specify which card to use:
setxpcenv(`EthernetIndex', '#')
indicates a single digit to specify the index number for the Ethernet card.
#
This command ensures that upon booting the target, the kernel selects the appropriate Ethernet card instead of selecting the default card with index number 0 as the target PC card.
For example,
setxpcenv('EthernetIndex','2') selects the Ethernet card
with index number 2 as the target PC card.
12 Repeat step 5 to 10 for any target PC for which you have a network
connection between the host PC and target PC.
The xPC Target software updates the environment with new properties as you enter them.
2-35
2 Installation and Configuration
The following fig ure illustrates the Communica t ion Component pane for a network connection.
2-36
For more information on the xPC Target environment, see “Software Environment and Demos” in the xPC Target User’s Guide.
Your next task is to create a target boot disk. S e e “Booting Target PCs from Boot Floppy Disk” on page 2-52.
Serial Communication
In this section...
“Serial Communication Overview” on page 2-37
“Hardware for Serial Communication” on page 2-37
“Environment Properties for Se rial Communication” on page 2-38
Serial Communication Overview
This topic describes the establishment of communication between the host PC and target PC using serial communications (RS-232). For network communication, see “Network Communication” on page 2-25.
Hardware for Serial Communication
Before you install the xPC Target software and confi gure it for serial communication, you must install the following hardware:
Serial Communication
Nullmodemcable—Connectthehostand target computers with the null
modem cable supplied by The MathWorks with the xPC Target software. You can use either the COM1 or COM2 port.
I/O boards — If you use I/O boards on the target PC, you need to install
the boards correctly. See the manufacturer’s literature for installation instructions.
2-37
2 Installation and Configuration
Null Modem Cable Wiring
xPC Target software ships with a null modem cable that you can use to connect the host a nd target computers for serial communications. The following diagram illustrates the wiring for this cable for a 9-pin DB9 connector.
1
6
2
7
3
8
4
9
5
DB9 Female DB9 Female
5
9
4
8
3
7
2
6
1
Environment Properties for Se rial Communication
The xPC Target environment is defined by a group of properties. These properties give to the xPC Target software information about the software and hardware products that it works with. You might change some of these properties often, while others you will rarely want to change.
After you have installed the xPC Target product, you can specify the environment properties for the host and target computers. Note that you must specify these properties before you can build and download a target application.
The following procedure describes how to set up serial communication environment properties through the xPC Target Explorer.
2-38
Serial Communication
Note the following:
If you h av e a serial connection between your host PC and target PC, and
you use a baud rate that is less than the maximum possible baud rate, you might experience communication failures. If you do experience these failures, use a baud rate greater than 19200.
If you have an RS-232 connection, you might not want to use host scopes
and a scope viewer on the host PC (Host Scope View er) to acquire and display large blocks of data. The slowness of the RS-232 connection causes large delays in performance for large blocks of data.
1 If xPC Target Explorer is not already started, in the MATLAB Command
Window, type
xpcexplr
The xPC Target Explorer window opens. Note that x PC Target Explorer automatically provides a defaulttargetPCnode,
TargetPC1.
xPC Target Explorer associates serial communication environment properties with the target PC.
2 In the xPC Target Explorer, right-click the Host PC node.
3 Select Add Target.
AtargetPCnode,named Hierarchy, at the same level as the
TargetPC2,appearsinthexPC Target
Host PC node. It appears with the icon
(note the X to denote that the host PC is not connected to the target PC).
4 As necessary, repeat step 2 and step 3 for each additional target PC you
want to add to your system.
Additional target PC nodes appear in the xPC Target Hierarchy.As you add other target PCs, the PC number is incremented. T he following figure illustrates two target PC nodes.
2-39
2 Installation and Configuration
2-40
5 In the xP
Configu
with the PC. The
PCI Dev
proced
Under and thes
6 Select Communication.
C Target Explorer, expand a target PC node.
ration
Configuration node to configure the target PC node for a target
File System node contains the contents of a target PC file system.
ices
ure, you work with the
the
pearance
Ap
, File System,andPCI Devices nodes appear. You work
lists all PCI devices detected on the target PC. In this
Configuration node.
Configuration node are nodes for Communication, Settings,
. The parameters for the target PC node are grouped in
e categories. These nodes make up the target environment settings.
The Communication Component pane appears to the right.
Serial Communication
Note When you first select a subnode under a target PC node, the target PC node becomes boldfaced. In a multitarget environment, this visual aid helps you easily see the target PC you are working w ith.
7 From the Host target communication list, select RS232.
The pane changes to one that contains only those parameters pertinent to serial communication.
8 From the Host port list, select either COM1 or COM2 for the connection on
the host PC. The xPC Target software determines the COM port you use on the target PC automatically.
9 From the Baud rate list, select the baud rate for the serial connection
between the host PC and this target PC. The default is
115200.Notethat
for optimal performance, you should select the highest possible serial connection baud rate for the xPC Target software.
10 Repeat step 5 to step 9 for any target PC for which you have a serial
connection between the host PC and target PC.
2-41
2 Installation and Configuration
The following figure illustrates the xPC Target Explorer settings for the serial connection of one target P C.
2-42
You do not have to exit and restart MATLAB after making changes to the xPC Target environment, even if you change the communication between the host an d target from RS-232 to TCP/IP. However, you do have to recreate the target boot disk and rebuild the target application from the Simulink model.
For more information on the xPC Target environment, see “Software Environment and Demos” in the xPC Target User’s Guide.
Serial Communication
Your next task is to create a target boot disk. S e e “Booting Target PCs from Boot Floppy Disk” on page 2-52.
2-43
2 Installation and Configuration
xPC Target Boot Options
In this section...
“Introduction” on page 2-44
“Booting Target PCs from CD or D VD” on page 2-46
“Booting Target PCs from Boot Floppy Disk” on page 2-52
“Booting Targ et PCs Within a Dedicated Network” on page 2-55
Introduction
You can boot your target PC with the xPC Target kernel using one of the following ways from the xPC Target Explorer:
CD Boot — Boot the target PC with a CD/DVD bootable ROM
Boot Floppy — Boot the target PC with a 3.5-inch floppy.
Network Boot — Boot the target PC from a dedicated network boot image.
2-44
Target boot disks and boot images include the xPC Target kernel specific foreitherserialornetworkcommunication. IfyouinstalledthexPCTarget Embedded Option, and you select stand-alone mode, the target boot files include the target application (see “Embedded Option” in the xPC Target User’s Guide). If you want to boot from a device other than a CD, DVD,
3.5-inch disk, or dedicated network boot image, see “Booting from a DOS Device” in the xPC Target User’s Guide.
Note Before you create a target boot disk, ensure that you have write permission for your current working folder. You cannot create a boot disk otherwise.
Before You Boot
Ensure that you have appropriately configured your xPC Target system before you create your boot disk or boot image. At a minimum, ensure that you have performed the following configurations. You can optionally set the
xPC Target™ Boot Options
other xPC Target Explorer configuration options; however, their default values should suffice.
Confirm that the boot tab on the
boot mode:
Configuration pane is set to your desired
- CD Boot
- Boot Floppy
- Network Boot
For information on other boot modes, see the following topics in the xPC Target User’s Guide:
- “Booting from a DOS Device”, for DOSLoader mode
- “Embedded Option”, for StandAlone mode
Check the C compiler specification (see “Configuring the xPC Target Host
PC for Your C Compiler” on page 2-19).
If you are using TCP/IP communication, check that your network
connections are correct. Also check the xPC Target Explorer settings (see “Network Communication” on page 2-25). Your xPC Target system shipped with a supported Ethernet card.
If you are using serial communication, check that your physical connections
are correct. Also check the xPC Target Explorer settings (see “Serial Communication” on page 2-37).
Check your target PC BIOS settings (see “The xPC Target Software and
the Target PC BIOS” on page 2-13 in this chapter and “BIOS Settings”).
2-45
2 Installation and Configuration
Booting Target PCs from CD or DVD
“Creating a Boot CD/DVD with xPC Target Explorer” on page 2-46
“Creating a Boot CD/DVD with a Command-Line Interface” on page 2-49
You use the target boot CD or DVD to load and run the xPC Target kernel. After you make changes to the xPC Target environment properties, you must create a target boot CD o r DVD. This to pic assumes you are using default environment parameter settings for the boot CD or DVD creation. If this is not the case, see “Configuring Environment Parameters for Target PCs” in the xPC Target User’s Guide for further details.
Creating a Boot CD/DVD with xPC Target Explorer
Use the following procedure to create a boot CD or DVD for the current xPC Target env ironment. This procedure describes how to create a target boot CD for the target TargetPC1. Before you start:
Ensure that you have an empty, writable CD or DVD.
2-46
Ensure that you have a CD/DVD-RW drive.
Ensure that you can create a boot CD or DVD. You can create a boot CD or
DVD in o ne of the following ways:
- The xPC Target Explorer Create CD Boot Image can create a boot CD
or DVD for you. To use this capability, your host PC must have one of the following Windows systems:
Microsoft Windows Vista™
Microsoft Windows XP Service Pack 2 or 3 with
Image Mastering API v2.0 (IMAPIv2.0), available at
http://support.microsoft.com/kb/KB932716.
- You can use third-party CD/DVD writing software to write ISO image
files. Use this method if you do not have Microsoft Windows Vista or Microsoft Windows XP Service Pack 2 or 3.
Note Standard Microsoft Windows software (such as Windows Explorer or Windows Media Player) does not write ISO image files to CD/DVD.
xPC Target™ Boot Options
Warning WritingtheCDISOimagetoaCDorDVDisnotthesame as copying the ISO image to a CD or DVD. When you write an ISO image to a CD or DVD, you create a bootable CD or DVD from the ISO image by burning the image to the CD or D VD. When you copy the ISO image, you just copy the ISO image to the CD or DVD as data; you cannot use a copied CD or DVD as a boot disk.
1 Insert the empty CD or DVD in the host PC.
2 If the xPC Target Explorer is not open, open it now. At the MATLAB
Command Window, type
xpcexplr
3 In the xPC Target Explorer xPC Target Hierarchy pane, select a target
PC
Configuration node. For example, select the Configurati on node
for
TargetPC1.
A TargetPC1 Configuration pane appears in the rightmost pane. This pane contains a series of tabs.
4 Select the CD Boot tab.
5 In the location parameter, enter a path in which you want xPC Target
Explorer to write the xPC Target CD/DVD boot ISO i mage. For example, enter
C:\Work\matlab.
2-47
2 Installation and Configuration
6 Click the Apply button.
2-48
7 Click the
The softw locatio
8 Perform one of the following depending on your software:
Create CD Boot Image button.
are creates a CD/DVD image file named
n.
cdboot.iso in this
If you have Microsoft Windows Vista or Microsoft Windows XP Service
Pack 2 or 3 with Image Mastering API v2.0 (IMAPIv2.0), xPC Target Explorer prompts you to insert a CD/DVD.
xPC Target™ Boot Options
Select the appropriate drive, insert the CD or DV D, then click Burn Disk.
If you d o not have Microsoft Windows Vista or Microsoft Windows XP
Service Pack 2 or 3 with Image Mastering API v2.0 (IMAPIv2.0), use your third-party CD creation software to write the the empty CD/DVD.
cdboot.iso image to
9 Insert the bootable CD/DVD into your target PC CD/DVD drive and reboot
that PC.
Your next task is to install the software on the target PC and test your installation. See “Testing and Troubleshooting the Installation” on page 2-62.
Creating a Boot CD/DVD with a Command-Line Interface
You use the boot CD/DVD to load and run the xPC Target kernel. After you make changes to the xPC Target environment properties, you must create a CD/DVD bootable ROM. Before you start:
Ensure that you have an empty, writable CD or DVD.
Ensure that you have a CD/DVD-RW drive.
Ensure that you can create a bootable CD or DVD. You can create a boot
CD or DVD in one of the following ways:
- The xPC Target software can create a boot CD or DVD for you. To use
this capability, your host PC must have one of the following Windows systems:
2-49
2 Installation and Configuration
To create a boot CD/DVD for the current xPC Target environment:
1 Insert the empty CD or DVD in the host PC.
2 In the MATLAB Command Window, type
Microsoft Windows Vista
Microsoft Windows XP Service Pack 2 or 3 with
Image Mastering API v2.0 (IMAPIv2.0), available at
http://support.microsoft.com/kb/KB932716.
- Third-party CD/DVD writing software can write ISO image files for you.
Use this method if you do not have Microsoft Windows Vista or Microsoft Windows XP Service Pack 2 or 3.
Note Standard Microsoft Windows software (such as Windows Explorer or Windows Media Player) does not write ISO image files to CD/DVD.
2-50
getxpcenv
3 Ensure that the following xPC Target properties are set as follows:
TargetBoot CDBoot
CDBootImageLocation — Your host PC CD/DVD disk drive location
4 If these properties are not set with the correct values, use the setxpcenv
function to set them. For example:
setxpcenv('TargetBoot','CDBoot') setxpcenv(CDBootImageLocation,'c:\work\xpc\cdimage') updatexpcenv
5 In the MATLAB Command Window, type
xpcbootdisk
The xPC Target software displays the following message and creates the CD/DVD boot ISO image.
xPC Target™ Boot Options
Current boot mode: CDBoot CD boot image is successfully created
6 Perform one of the following, depending on your software:
If you have Microsoft Windows Vista or Microsoft Windows XP Service
Pack 2 or 3 with Image Mastering API v2.0 (IMAPIv2.0),
xpcbootdisk
prompts you to insert a CD/DVD.
Insert an empty CD/DVD. A vail able drives:
[1] z:\ [0] Cancel Burn
Select the appropriate drive, insert the CD or DVD, then press the Enter key.
If you d o not have Microsoft Windows Vista or Microsoft Windows XP
Service Pack 2 or 3 with Image Mastering API v2.0 (IMAPIv2.0), use your third-party software to write the
cdboot.iso image to the empty
CD/DVD.
7 When the CD/DVD drive stops, rem ove the CD/DVD.
8 Insert the bootable CD/DVD into your target PC CD/DVD drive and reboot
that PC.
Your next task is to install the software on the target PC and test your installation. See “Testing and Troubleshooting the Installation” on page 2-62.
2-51
2 Installation and Configuration
Booting Target PCs from Boot Floppy Disk
Youusethe3.5-inchtargetbootdisktoload and run the xPC Target kernel. After you make changes to the xPC Target environment properties, you need to create or update a 3.5-inch boot disk. Note that this topic assumes you are using default environment parameter settings for the target boot disk creation. If this is not the case, s ee “Configuring Environment Parameters for Target PCs” in the xPC Target User’s Guide for further details.
Creating a Target Boot Disk with xPC Target Explorer
To create a target boot disk for the current xPC Target environment, use the following procedure. This procedure describes how to create a target boot disk for the target TargetPC 2. Alternatively, see “Creating a 3.5-Inch Target Boot Disk with a Command-Line Interface” on page 2-54.
1 If the xPC Target Explorer is not open, open it now. At the MATLAB
Command Window, type
xpcexplr
2-52
2 In the xPC Target Explorer xPC Target Hierarchy pane, select a target
PC
Configuration node. For example, select the Configurati on node
for
TargetPC2.
A configuration pane for that target PC appears in the rightmost pane.
xPC Target™ Boot Options
3 From the tab list, select the Boot Floppy tab.
4 As necessary, change the drive letter of the 3.5-inch drive to a valid floppy
drive. It is
5 Click the Apply button.
6 Click the Create boot disk button.
a: by default.
The following message box opens.
7 Insert a formatted 3.5-inch floppy disk into the host PC disk drive, and
then click OK.
All data on the disk is erased as the xPC Target software writes the xPC Target kernel and other required files to the 3.5-inch disk.
The xPC Target software displays the following dialog box while creating the boot disk. The process takes about 1 to 2 minutes.
2-53
2 Installation and Configuration
8 When the disk drive stops, remove the disk.
9 Insert the boot disk into your target PC disk drive and reboot that PC.
Your next task is to install the software on the target PC and test your installation. See “Testing and Troubleshooting the Installation” on page 2-62.
Creating a 3.5-Inch Target Boot Disk with a Command-Line Interface
You use the target boot disk to load and run the xPC Target kernel. After you make changes to the xPC Target environment properties, you need to create or update a boot disk.
2-54
To create a target boot disk for the current xPC Target environment, use the following procedure:
1 In the MATLAB Command Window, type
getxpcenv
2 Ensure that the following xPC Target properties are set as follows:
TargetBoot BootFloppy
BootFloppyLocation — Your host PC 3.5-inch disk drive location
3 If these properties are not set with the correct values, use the setxpcenv
function to set them. For example:
setxpcenv('TargetBoot','BootFloppy') setxpcenv('BootFloppyLocation','a:') updatexpcenv
xPC Target™ Boot Options
4 In the MATLAB Command Window, type
xpcbootdisk
The xPC Target software displays the following message.
Current boot mode: BootFloppy Insert a formatted floppy disk into your host PC's disk drive and press a key to continue
5 Insert a formatted floppy d isk into the host PC disk drive, and then press
any key.
The write procedure starts and, while creating the boot disk, the MATLAB Command Window displays the following status information.
Creating xPC Target boot disk ... Please wait xPC Target boot disk succe ssf ully created.
Your next task is to install the software on the target PC and test your installation. See “Testing and Troubleshooting the Installation” on page 2-62.
Booting Target PCs Within a Dedicated Network
This topic describes how to boot target PCs on a dedicated network. You do not n ee d a boot disk. You do need to set up the host PC and target PC. This topic assumes that you know how to:
Set up a dedicated network.
UsethexPCTargetExplorertoconfigurethetargetPCandhost
environments. You should be familiar with the following sections:
- “Configuring the xPC Target Host PC for Y our C Compiler” on page 2-19
- “xPC Target Explorer” on page 2-21
- “Network Communication” on page 2-25
- “Booting Target PCs from Boot Floppy Disk” on page 2-52
2-55
2 Installation and Configuration
Caution Do not boot a target PC on a corporate or nondedicated network.
Doing so might interfere with dynamic host configuration protocol (DHCP) servers, which will cause problems with the network.
Setting Up the Target PC
1 Identify the target PC that you want to boot over the dedicated network.
2 Perform one of the following for your target PC:
Install the Ethernet card supplied with the xPC Target product.
Use your own Ethernet card. If you choose this, ensure that:
The xPC Target product supports your Ethernet card (see “Hardware
for Network Communication” on page 2-25).
– Your Ethernet card must have a boot ROM that is compatible with
the Preboot eXecution Environment (PXE) specification.
2-56
3 Connect the host P C and the target PCs within the dedicated network. For
example, connect one end of a crossover cable to the dedicated network card of the host PC and connect the other end of this cable to the dedicated network card of the target PC.
4 Turn on the target PC.
5 Enter BIOS and set up the target PC for a LAN or network boot. If there
is a boot order, consider setting the boot order so that the removable/boot floppy disk is the first option and the LAN is the second. Doing so ensures that if there is no xPC Target boot disk in the target PC, you can still boot the target PC from a kernel on the netw ork.
Configuring for Network Booting
This procedure is similar to configuring a target boot disk. If you have previously created a ta r g et boot disk, you might not need to perform this procedure. However, you should still read the following instructions to ensure that your configuration is appropriate for booting a target PC in the dedicated network. You can configure multiple target PCs for your network.
xPC Target™ Boot Options
1 Ensure that the host PC has a network card available for the dedicated
network. As necessary, insert a second network card and configure that card for the dedicated network. This step includes assigning the host PC a unique IP address (for example, 10.10.10.10) in the same subnet as the target PC.
2 If the xPC Target Explorer is not open, open it now. A t the MATLAB
Command Window, type
xpcexplr
3 Add a target PC, fo r example, TargetPC3 (if necessary).
4 In the Communication Component pane for TargetPC3,
a In the Host target communication field, select TCP/IP.
b Ente r a target PC IP address in the dedicated network, for example,
10.10.10.11. Ensure that the subnet of this IP address is the same as
thehostPC,otherwiseNetworkBootwillfail.
c Enter appropriate values for the remaining fields.
d Click the Apply button.
5 In the TargetPC3 Configuration pane, select Network Boot.
2-57
2 Installation and Configuration
2-58
The Target PC Ethernet Configuration section of the configuration pane allows you to either associate a physical target PC MAC address with the xPC Target Explorer target PC name, or allow the software to automatically find target PC MAC addresses. If you want to associate your physical target PC MAC address,
a Click Manual.
b In the six fields, enter the physical target PC MAC address (in
hexadecimal).
6 Click the Create Network Boot Image button.
xPC Target™ Boot Options
The software creates and starts a network boot server process on the host PC. You will boot the target PC using this process .
A minimized icon (
) representing the network boot server process
appears on the bottom right host PC system tray.
Booting the Target PC
1 Reboot the target P C.
The host PC network boot server displays a pop-up from the system tray indicating that the boot server is being downlo aded to the target PC.
If the xP C Target Explorer target PC is not already associated with a physical target PC MAC address, the first time that the network boot server process detects a viable target PC, it displays a dialog that con ta ins the x PC Target Explorer target PC namesandtheIPaddressesforthose names. From this list, select the physical target PC you want to associate with the target PC name.
2-59
2 Installation and Configuration
2-60
2 Select the target PC name with which you want to associate the physical
target PC.
The target PC receives the xPC Target kernel and boots with this kernel.
xPC Target™ Boot Options
If you click the Cancel button instead of selecting a target PC name, the next time you try to boot the target PC across the network, the kernel will ignore the target PC b oo t request for 90 seconds.
Note the following behavior:
If the target PC name has a MAC address, and there is a physical target
PC whose MAC address matches the target PC n ame MAC address, the software matches the two and the xPC Target Network Boot dialog does not display.
If the connection between the target PC and host PC is an RS-232 one, you
cannot boot the target PC across the network.
IftheStandAlonemodeisenabled,you cannot boot the target PC across
the network.
2-61
2 Installation and Configuration
Testing and Troubleshooting the Installation
In this section...
“Testing the Installation from a Boot Disk or Boot CD ” on page 2-62
“Test 1, Ping Target System Standard Ping” on page 2-64
“Test 2, Ping Target System xPC Target Ping” on page 2 -66
“Test 3, Reboot Target Using Direct Call” on page 2-67
“Test 4, Build and Download Application” on page 2-67
“If You Need More Help” on page 2-68
Testing the Installation from a Boot Disk or Boot CD
This topic describes how to install software on a target PC, boot that PC, and test the installation and connection between the host PC and the target PC. The xPC Target software uses a test script to test the entire installation. After you install the software, set the environment settings, and create a target boot disk, you can test your installation. This procedure assumes that you have set environment se ttings with xPC Target Explorer. See “Environment Properties for Serial Communication” on page 2-38 or “Environment Properties for Network Communication” on page 2-30.
2-62
1 Insert your target boot disk into a target PC disk drive or CD drive. This
target boot disk contains the software to run a target PC.
2 To re
boot the target PC, press the reset button on the PC.
r loading the BIOS, the software boots the kernel and displays the
Afte
lowing on the target PC monitor.
fol
Loading...