xPC Target For Use with Real-Time Workshop Modeling Simulation Implementation User’s Guide Version 1 ®
How to Contact The MathWorks: www.mathworks.com comp.soft-sys.matlab Web Newsgroup info@mathworks.com Technical support Product enhancement suggestions Bug reports Documentation error reports Order status, license renewals, passcodes Sales, pricing, and general information 508-647-7000 Phone 508-647-7001 Fax The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098 Mail support@mathworks.com suggest@mathworks.com bugs@mathworks.com doc@mathworks.com service@mathworks.
Contents Introduction 1 What Is xPC Target? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 Advanced Procedures 2 I/O Driver Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 xPC Target I/O Driver Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 Adding I/O Blocks with the xPC Target Library . . . . . . . . . . . . 2-4 Adding I/O Blocks with the Simulink Library Browser . . . . . . 2-7 Defining I/O Block Parameters . . . . . . . .
Network Communication 3 Web Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3 Connecting the Web Interface through TCP/IP . . . . . . . . . . . . . 3-3 Connecting the Web Interface through RS232 . . . . . . . . . . . . . . 3-4 Syntax for the xpctcp2ser Command . . . . . . . . . . . . . . . . . . . . . 3-6 Using the Main Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8 Changing WWW Properties . . . . . . . . . . . . . . . . . . . . .
DOS Loader Target Applications . . . . . . . . . . . . . . . . . . . . . . 4-12 Creating a Target Boot Disk for DOS Loader . . . . . . . . . . . . . 4-12 Creating a Target Application for DOS Loader . . . . . . . . . . . . 4-13 Stand-Alone Target Applications . . . . . . . . . . . . . . . . . . . . . . Creating a Target Application for Stand-Alone . . . . . . . . . . . . Creating a Target Boot Disk for Stand-Alone . . . . . . . . . . . . . Using Target Scope Blocks with Stand-Alone . . . . . . . . . . . . .
Target Object Reference 6 Target Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3 What is a Target Object? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3 Target Object Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 Target Object Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9 Target PC Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11 Using Target Objects . .
1 Introduction What Is xPC Target? . . . . . . . . . . . . . . . . . . . .
1 Introduction xPC Target has many features. An introduction to these features and the xPC Target software environment will help you develop a model for working with xPC Target.
What Is xPC Target? What Is xPC Target? xPC Target is a host-target solution for prototyping, testing, and deploying real-time systems using standard PC hardware. It is an environment that uses a target PC, separate from the host PC, for running real-time applications. In this environment you use the desktop computer as a host PC with MATLAB®, Simulink®, and Stateflow® (optional) to create models using Simulink blocks and Stateflow diagrams.
1 Introduction 1-4
2 Advanced Procedures I/O Driver Blocks . . . . . . . . . . . . . . xPC Target I/O Driver Blocks . . . . . . . . . . Adding I/O Blocks with the xPC Target Library . . . Adding I/O Blocks with the Simulink Library Browser Defining I/O Block Parameters . . . . . . . . . . xPC Target Scope Blocks . . . . . . . . xPC Target Scope Blocks . . . . . . . . . Adding xPC Target Scope Blocks . . . . . . Defining xPC Target Scope Block Parameters . . . . . . . . . Target PC Command Line Interface . . . .
2 Advanced Procedures After learning the basic procedures for creating and running a target application, signal acquisition and parameter tuning, you can try some od the special and advanced procedures with xPC Target. This chapter includes the following sections: • “I/O Driver Blocks” — Adding I/O driver blocks to your Simulink model connects your model to sensors and actuators.
I/O Driver Blocks I/O Driver Blocks You add I/O driver blocks to your Simulink model to connect your model to physical I/O boards. These I/O boards then connect to the sensors and actuators in the physical system.
2 Advanced Procedures Adding I/O Blocks with the xPC Target Library xPC Target contains an I/O driver library with Simulink blocks. You can drag-and-drop these blocks from the library to your Simulink model. Alternately, you can access the I/O driver library with the Simulink Library Browser. See “Adding I/O Blocks with the Simulink Library Browser” on page 2-7. The highest hierarchy level in the library is grouped by I/O function.
I/O Driver Blocks The manufacturer level opens. Within each manufacturer group are the blocks for a single function. 3 Open a manufacturer group. For example, to open the A/D driver blocks from ComputerBoards, double-click the group marked ComputerBoards. The window with the A/D driver blocks for ComputerBoards opens. 4 In the Simulink window, type xpcosc The Simulink block diagram opens for the model xpcosc.mdl.
2 Advanced Procedures 5 From the block library, click-and-drag the name of an A/D board to the Simulink block diagram. Likewise, click-and-drag the name of a D/A board to your model. Simulink adds the new I/O blocks to your model. 6 Remove the signal generator block and add the analog input block in its place. Remove the scope block and add the analog output block in its place. The demo model xpcosc should look like the figure shown below. Your next task is to define the I/O block parameters.
I/O Driver Blocks Adding I/O Blocks with the Simulink Library Browser You can access the xPC Target driver blocks using the Simulink Library Browser. You drag-and-drop these blocks from the library to your Simulink model. Alternately, you can access driver blocks using the xPC Target I/O driver library, See “Adding I/O Blocks with the xPC Target Library” on page 2-4. The highest hierarchy level in the library is grouped by I/O function.
2 Advanced Procedures You can access the xPC Target I/O library by right-clicking xPC Target, and then clicking Open the xPC Target Library. 3 Double-click xPC Target. A list of I/O functions opens.
I/O Driver Blocks 4 Open a function group. For example, to open the A/D group for ComputerBoards, double-click A/D, and then double-click ComputerBoards. A list with the A/D driver blocks for ComputerBoards opens. 5 From the block library, click-and-drag the name of an A/D board to the Simulink block diagram. Likewise, click-and-drag the name of a D/A board to your model Simulink adds the new I/O blocks to your model. 6 Remove the signal generator block and add the analog input block in its place.
2 Advanced Procedures Your next task is to define the I/O block parameters. See “Defining I/O Block Parameters”. Defining I/O Block Parameters The I/O block parameters define values for your physical I/O boards. For example, I/O block parameters include channel numbers for multichannel boards, input and output voltage ranges, and sample time. This procedure uses the Simulink model xpcosc.mdl as an example, and assumes you have added an analog input and an analog output block to your model.
I/O Driver Blocks 3 In the Simulink window, double-click the output block labeled Analog Output. The dialog box for the D/A converter opens. 4 Fill in the dialog box. For example, for one channel enter [1] in the Channel Vector box, for an ouptut level of ±10 V enter the code [-10] in the Range Vector box. Enter the same sample time you entered for the step size in the Simulation Parameters dialog box. Enter the base address for this ISA-bus board.
2 Advanced Procedures The Block Parameters dialog box should look similar to the figure shown below. If you change the sample time by changing the target object property SampleTime, the step size you entered in the Simulation Parameters dialog box, as well as the sample times you entered in both of the I/O blocks are set to the new value. Your next task is to build and run the target application, see “Creating the Target Application” on page 3-7.
xPC Target Scope Blocks xPC Target Scope Blocks Usually scope objects are defined using xPC Target functions or the graphical interface after downloading your target application. An alternative is for you to add special xPC Target scope blocks to you Simulink model. These blocks should not be confused with standard Simulink scope blocks. The xPC Target scope blocks have unique capabilities when used with xPC Target.
2 Advanced Procedures You can drag an xPC Target scope block into any Simulink model, and the input to the scope can be connected to any block output. If you want to trace more than one signal, add a multiplexer block to your model, and connect the scope block to the multiplexer output. The following procedure uses the Simulink model xpcosc.mdl as an example to show how to connect an xPC Target scope block to your model.
xPC Target Scope Blocks 4 Double-click Misc. A list of miscellaneous group blocks opens. 5 Click-and-drag Scope (xPC) to your Simulink block diagram. Simulink adds a new scope block to your model with a scope identifier of 1.
2 Advanced Procedures 6 Connect the xPC Target scope block with the Simulink scope block. The model xpcosc should look like the figure shown below. Your next task is to define the xPC Target scope block parameters. See “Defining xPC Target Scope Block Parameters”. Defining xPC Target Scope Block Parameters Scope block parameters define the signals to trace on the scope, trigger modes, and the axis range. This procedure uses the Simulink model xpcosc.
xPC Target Scope Blocks 2 In the Scope Number box, enter a unique number to identify the scope. This number is used to identify the xPC Target scope block and the scope screen on the host or target computers. 3 From the Scope Type list, choose either Host or Target. 4 From the Scope Mode list, choose either Numerical, Graphical (redraw), Graphical (sliding), or Graphical (rolling). If you selected Host for the Scope Type, then you can only choose either Numerical or Graphical (redraw) for the Scope Mode.
2 Advanced Procedures 6 In the Y-axis Limits box, enter a row vector with two elements where the first element is the lower limit of the y-axis and the second element is the upper limit. If you enter 0 for both elements, then the scaling is set to auto. 7 Select the Start Scope after download check box, to start a scope when the target application is downloaded. With a target scope, the scope window open automatically. With a host scope, you need to open the window by typing xpcscope.
Target PC Command Line Interface Target PC Command Line Interface You can interact with the xPC Target environment through the target PC command window. This interface is useful with stand-alone applications that are not connected to the host PC.
2 Advanced Procedures Target Object Methods When using the target PC command line interface, target object methods are limited to starting and stopping the target application. The following table lists the syntax for the target commands that you can use on the target PC. The MATLAB equivalent syntax is shown in the right column, and the target object name tg is used as an example for the MATLAB methods. Target PC MATLAB start tg.start or +tg stop tg.stop or -tg reboot tg.
Target PC Command Line Interface Target PC MATLAB parameter_name (P0, P1, . . .) parameter_name = number tg.parameter_name tg.parameter_name = number signal_name (S0, S1, . . .) tg.S# Scope Object Methods When using the target PC command line interface, you use scope object methods to start a scope, and add signal traces. Notice the methods addscope and remscope are target object methods on the host PC, and notice the difference between a signal index (0, 1, . . .) and a signal name (S0, S1, . . .
2 Advanced Procedures Target PC MATLAB viewmode scope_index or left click the scope window viewmode all or right click any scope window Press function key for scope, and then press V to toggle viewmode ylimit scope_index ylimit scope_index = auto ylimit scope_index = num1, num2 grid scope_index on grid scope_index off Scope Object Properties When using the target PC command line interface, scope object properties are limited to those shown in the following table.
Target PC Command Line Interface Target PC MATLAB scopemode scope_index = 0 or numerical, 1 or redraw, 2 or sliding, 3 or rolling sc.Mode = ’numerical’, ’redraw’, ’sliding’, ’rolling’ triggermode scope_index = 0, freerun, 1 software, 2, signal, 3, scope sc.TriggerMode = ’freerun’, ’software’, ’signal’, ’scope’ numprepostsamples scope_index = number sc.NumPrePostSamples = number triggersignal scope_index = signal_index sc.TriggerSignal = signal_index triggerlever scope_index = number sc.
2 Advanced Procedures Using Variables on the Target PC Use variables to tag unfamiliar commands, parameter indices, and signal indexes with more descriptive names. After you have created and downloaded a target application to the target PC, you can create target PC variables. 1 On the target PC, press C. The target PC command window is activated, and a command line opens. 2 In the Cmd box, type a variable command.
3 Network Communication Web Interface . . . . . . . . . . . . . . . . . . Connecting the Web Interface through TCP/IP . . . . . Connecting the Web Interface through RS232 . . . . . . Syntax for the xpctcp2ser Command . . . . . . . . . . Using the Main Page . . . . . . . . . . . . . . . . Changing WWW Properties . . . . . . . . . . . . . Viewing Signals with the Web Browser . . . . . . . . . Using Scopes with the Web Browser . . . . . . . . . .
3 Network Communication xPC Target provides support for TCP/IP and UDP/IP communication protocols. This chapter includes the following sections: • “Web Interface” — Connect a target application to any computer connected to the network. • User Datagram Protocol (UDP) — Send and receive messages from a target application using UDP packets.
Web Interface Web Interface xPC Target has a Web server build in the TCP/IP mode to the kernel that allows you to interact your target application using a Web browser. If the target PC is connected to a network, you can use a Web browser to interact with the target application from any computer connected to a network Currently this feature is limited to Microsoft Internet Explorer (version 4.0 or later) and Netscape Navigator (version 4.5 or later) are the supported browsers.
3 Network Communication xpcwwwenable MATLAB is disconnected from the target PC, and the connection is reset for connecting to another client. If you do not use this command, your Web browser may not be able to connect to the target PC. 2 Open a Web browser. In the address box, enter the IP address and port number you entered in the xPC Target Setup window. For example, if the target computer IP address is 192.168.0.1 and the port is 22222, type http://192.168.0.
Web Interface c:\MATLABR12\toolbox\rtw\targets\xpc\xpc\bin\xpctcp2ser -v -t 22222 -c 1 The TCP/IP to RS232 gateway starts running, and the DOS command window displays the message *--------------------------------------------------------------* * xPC Target TCP/IP to RS232 gateway * * Copyright 2001 The MathWorks * *--------------------------------------------------------------* Connecting COM to TCP port 22222 Waiting to connect If you did not close the MATLAB to target application connection, then DOS d
3 Network Communication xpc MATLAB reconnects to the target application and lists the properties of the target object. If you did not close the gateway application, then MATLAB displays the message Error in ==> C:\MATLABR12\toolbox\rtw\targets\xpc\xpc\@xpc\xpc.m On line 31 ==> sync(xpcObj); To correct this problem, you must close MATLAB and then restart it.
Web Interface Command line option Description -t tcpPort Uses TCP port tcpPort. Default t is 22222. For example, to connect to port 20010, type -t 20010. -h Prints a help message. -c comPort Uses COM port comPort (1 <= comPort <= 4), Default is 1.
3 Network Communication 7 In the MATLAB window, type !c:\MATLABR12\toolbox\rtw\targets\xpc\xpc\bin\xpctcp2ser -h Alternatively, you can open a DOS command window and enter c:\MATLABR12\toolbox\rtw\targets\xpc\xpc\bin\xpctcp2ser -h MATLAB displays the following Usage: xpctcp2ser [-v] [-n] [-t tcpPort] [-c comPort] xpctcp2ser -h The command line options are as follows: -v : Verbose output.
Web Interface 2 Click the Start Execution button. The target application begins running on the target PC, the Status line is changed from Stopped to Running, and the Start Execution button text changes to Stop Execution. 3 Update the execution time and average task execution time (TET). Click the Refresh button. To stop the target application, click the Stop Execution button. 4 Enter new values in the Stop Time and Sample Time boxes, and then click the Apply button.
3 Network Communication The new property values are downloaded to the target application. Notice, the sample time box is visible only when the target application is stopped. You cannot change the sample time while a target application is running. 5 Select scopes to view on the target PC. From the ViewMode list choose one or all of the scopes to view. Note the ViewMode button is visible only if you add two or more scopes to the target PC.
Web Interface 2 In the Refresh Interval box, enter a value greater than 10. For example, enter 20. The signal page updates automatically every 20 seconds. Entering -1 or Inf does not automatically refresh the page. Sometimes, both of the frames try to update simultaneously, or the auto refresh starts before the previous load has finished. This problem may happen with slow network connections. In this case, increase the refresh interval or manually refresh the browser (Set the Refresh Interval = Inf).
3 Network Communication Using Scopes with the Web Browser The Web browser interface allows you to visualize data using an interactive graphical interface. After you connect a Web browser to the target PC you can use the Scopes page to add, remove and control scopes on the target PC. 1 In the left frame, click the Scopes button. The Scopes List page is loaded into the right frame. 2 Click the Add Scope button. A scope of type target is created and displayed on the target PC.
Web Interface Viewing and Changing Parameters with the Web Interface The parameters page displays a list of all the tunable parameters in your model. Row and column indices for vector/matrix parameters are also shown. After you connect a Web browser to the target PC you can use the Parameters page to change parameters in your target application while it is running in real time. 1 In the left frame, click the Parameters button. The Parameter List page is loaded into the right frame.
3 Network Communication Changing Access Levels to the Web Browser The Web browser interface allows you to set access levels to the target application. The different levels limit access to the target application. The highest level, 0, is the default level and allows full access. The lowest level 4, only allows signal monitoring and tracing with your target application. 1 In the Simulink window, click Simulation Parameters. On the Simulation Parameter dialog box, click the Real-Time Workshop tab.
User Datagram Protocol (UDP) User Datagram Protocol (UDP) xPC Target supports communication with another system using User Datagram Protocol (UDP) packets. UDP is a transport protocol similar to TCP. However, unlike TCP, UDP provides a direct method to send and receive packets over an IP network. UDP uses this direct method at the expense of reliability by limiting error checking and recovery.
3 Network Communication packets while the stack at the other end is responsible for reassembling the packets into a data stream using information in the packet headers. UDP, on the other hand, is a packet-oriented protocol where the application itself divides the data into packets and sends them to the other end. The other end does not have to reassemble the data into a stream. Note, some applications may indeed present the data as a stream when the underlying protocol is UDP.
User Datagram Protocol (UDP) Note Unreliable is used in the sense of “not guaranteed to succeed” as opposed to “will fail a lot of the time.” In practice, UDP is quite reliable as long as the receiving socket is active, and is processing data as quickly as it arrives. Why UDP? UDP was chosen as the transport layer for xPC Target precisely because of its lightweight nature.
3 Network Communication vector of uint8. To convert arbitrary Simulink data types into this vector of uint8, a Pack block is provided, while an Unpack block is provided to convert a vector of uint8s back into arbitrary Simulink data types. The UDP part of the xPC Target Block Library is shown below. xPC Target includes a Byte Reversal block for communication with bit-endian architecture systems.
User Datagram Protocol (UDP) UDP Receive Block The Receive block has two output ports. The first port is the actual output of the received data as a vector of uint8 while the second one is a flag indicating whether any new data has been received. This port outputs a value of 1 for the sample when there is new data and a 0, otherwise. The default behavior of the Receive block is to keep the previous output when there is no new data.
3 Network Communication chances of dropped packets. This is especially true when you are using a small sample time. UDP Send Block The Send block has only one input port that receives the uint8 vector that is sent as a UDP packet. The Block Parameters for the Send block are shown below. The IP address to send to and the IP port to send to have to be specified in the appropriate locations. The local IP port that is used for sending will be determined automatically by the networking stack.
User Datagram Protocol (UDP) As seen in the figure above, the data types of each of the signals have to be specified as a cell array of strings in the correct order. Once this is done, the block will automatically convert itself to one with the correct number of input ports. There is always one output port. The supported data types are: double, single, int8, uint8, int16, uint16, int32, uint32, and boolean. The byte alignment field specifies how the data types are aligned.
3 Network Communication Note Individual elements of vector/matrix signals are not byte aligned: only the entire vector/matrix is byte aligned. The individual elements are tightly packed with respect to the first element. UDP Unpack Block This block is the exact analog of the Pack block. It receives a vector of uint8 and outputs various Simulink data types in different sizes.
User Datagram Protocol (UDP) data on the other end may be in the form of a C struct, which is subject to the byte alignment convention of the compiler used. We recommend using a byte alignment value of 1 (tightly packed) whenever possible. This, of course, is easily accomplished when UDP I/O is used to exchange data between two xPC Target systems or between xPC Target and Simulink.
3 Network Communication between two Simulink models. When one or both of the systems is running Simulink in non real-time, care must be taken to set the sample time properly. Our hypothetical models are called Model A and Model B. Two different sets of data are transferred between these two models. One set from Model A to Model B and another set in the opposite direction.
User Datagram Protocol (UDP) Note that Port Data Types and Signal dimensions have been turned on from the Format menu, showing us that the width of the UDP packet to be sent is 75 bytes. The parameters used in the Pack block are Input port datatypes {’uint8’,’int16’,’double’} and Byte Alignment 1. For the Send block, set the IP Address to send to to 192.168.0.2. This is the hypothetical address of the system that will run Model B. Set the IP Port to send to to 25000 (picked arbitrarily).
3 Network Communication For setting up the Receive block, IP address to receive from is set to 192.168.0.1 (the hypothetical address of the system that will run Model B). The IP port to receive from is set to 25000 (the same value as set in the Send block in Model A). The Output port width is set to 75 which is obtained from the output port width of the Pack block in Model A.
User Datagram Protocol (UDP) For constructing the Model B to Model A side of the communication, follow an analogous procedure. The final models are shown below.
3 Network Communication The following table lists the parameters in Model A. Block Parameter Value Receive IP address 192.168.0.2 IP port 25000 Output port width 80 Sampletime 0.
User Datagram Protocol (UDP) Block Parameter Value Output port datatypes {’single’,’double’, ’uint32’,’int8’} Byte Alingment 2 The following table lists the parameters in Model B Block Parameter Value Pack Input Port Datatypes {’single’,’double’, ’uint32’,’int8’} Byte Alingment 2 IP address 192.168.0.1 IP port 25000 Sampletime 0.01 Send Note on UDP Communication The UDP blocks work in the background while the real-time application is not running.
3 Network Communication 3-30
4 Embedded Option Introduction . . . . . . DOSLoader Mode Overview StandAlone Mode Overview Architecture . . . . . . . Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Updating the xPC Target Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3 4-4 4-4 4-5 4-6 . . . . . . . 4-8 Creating a DOS System Disk . . . . . . . . . . . . 4-11 DOS Loader Target Applications . . . . . . . . . .
4 Embedded Option The xPC Target Embedde Option allows you to boot the target PC from an alternate device other than a floppy disk drive such as a hard disk drive or flash memory. It also allows you to create stand-alone applications on the target PC independent from the host PC.
Introduction Introduction The xPC Target Embedded Option allows you to boot the xPC Target kernel from not only a floppy disk drive, but also from other devices, including a flash disk or a hard disk drive. By using xPC Target Embedded Option, you can configure target PCs to automatically start execution of your embedded application for continuous operation each time the system is booted. You use this capability to deploy your own real-time applications on target PC hardware.
4 Embedded Option invokes the autoexec.bat file which in turn starts the xPC Target kernel on the target PC. If you do not provide an target application and an autoexec.bat file to invoke your target application, xPC Target Embedded Option starts the kernel on your target PC and is ready to receive your target application whenever you build and download a new one from the host computer.
Introduction applications using PC hardware. Typically these production applications are found in systems where production quantities are low to moderate. xPC Target Embedded Option also gives you the choice of using target scopes on the target PC. When using StandAlone mode, target scopes allows you to trace signals using the target PC monitor without any interaction from the host computer.
4 Embedded Option StandAlone mode. The module xpcboot.com is executed from DOS. It loads and executes any xPC Target application. The first argument given to xpcboot.com is the name of the image file (*.rtb) to be executed. This image file contains the xPC Target kernel and options, such as whether you are communicating using a serial cable or TCP/IP, and the ethernet address you have assigned to the target PC.
Introduction It is also necessary that your TargetMouse setting is consistent with your hardware. Some PC hardware may use an RS232 port for the mouse, while others use a PS2 mouse. If a mouse is not required in your application, you may choose to select None as your setting for the TargetMouse.
4 Embedded Option Updating the xPC Target Environment After the xPC Target Embedded Option software has been correctly installed, the xPC Target environment, visible through xpcsetup or getxpcenv, contains new property choices for DOSLoader or StandAlone, in addition to the default BootDisk that is normally used with xPC Target. It is assumed that the xPC Target environment is already set up and working properly with the xPC Target Embedded Option disabled.
Updating the xPC Target Environment The default setting for the property TargetBoot is BootFloppy. When using BootFloppy, xPC Target must first create a target boot disk, which is then used to boot the target PC.
4 Embedded Option The property TargetBoot can be set to two other values, namely DOSLoader or StandAlone. If the xPC Target loader is booted from any boot device with DOS installed, the value DOSLoader must be set as shown above. If you want to use a stand-alone application that automatically starts execution of your target application immediately after booting, specify StandAlone.
Creating a DOS System Disk Creating a DOS System Disk When using DOSLoader mode, or StandAlone mode, you must first boot your target PC with DOS. These modes may be used from any boot device including flash disk, floppy disk drive, or a hard disk drive. In order to boot DOS with a target boot disk, a minimal DOS system is required on the boot disk. With Windows 95, Windows 98, or DOS, you can create a DOS boot disk using the command sys a: Note xPC Target Embedded Option does not include a DOS license.
4 Embedded Option DOS Loader Target Applications This section includes the following topics: • “Creating a Target Boot Disk for DOS Loader” • “Creating a Target Application for DOS Loader” Creating a Target Boot Disk for DOS Loader As the first step, we assume you have created a DOS system disk and updated the xPC Target environment by setting the property TargetBoot to DOSLoader. From the xPC Target Setup window, click the BootDisk button and xPC Target copies the necessary files to the DOS disk.
DOS Loader Target Applications The file autoexec.bat is copied to the DOS disk. This file should contain at least the following line: xpcboot xxx.rtb where xxx.rtb is the file described in table 11-1. We recommend that you view this autoexec.bat file to confirm this. Now the target boot disk can be removed from the host and put into the target PC disk drive. By rebooting the target PC, DOS is booted from the target boot disk and the autoexec.
4 Embedded Option Stand-Alone Target Applications This section includes the following topics: • “Creating a Target Application for Stand-Alone” • “Creating a Target Boot Disk for Stand-Alone” • “Using Target Scope Blocks with Stand-Alone” Creating a Target Application for Stand-Alone After selecting StandAlone as your TargetBoot entry, the xPC Target environment is ready to create completely stand-alone applications using the Real-Time Workshop Build button.
Stand-Alone Target Applications Creating a Target Boot Disk for Stand-Alone After making a bootable DOS boot disk, the file autoexec.bat file must contain at least the following line xpcboot model.rtb where model is the name of your Simulink model. These files should be copied to your DOS boot disk and inserted into the target drive. By rebooting the target PC, DOS is booted from the boot disk. The autoexec.
4 Embedded Option xPC Target (basic package) offers a block for such purposes. Copy the Scope (xPC) block into your block diagram and connect the signals you would like to view to this block. Multiple signals can be used provided a Mux block is used to bundle them.
Stand-Alone Target Applications It is necessary to edit the Scope (xPC) dialog box and confirm that the check box entry for Start Scope after download is checked as shown in the following dialog box. This setting is required to enable target scopes to begin operating as soon as the application starts running. The reason this setting is required is that the host PC is not available in StandAlone mode to issue a command that would start scopes.
4 Embedded Option 4-18
5 Environment Reference Environment . . . . . . . . . . . . . . . . . . . 5-3 Environment Properties . . . . . . . . . . . . . . . . 5-3 Environment Functions . . . . . . . . . . . . . . . . 5-11 Using Environment Properties and Functions . . . Getting a List of Environment Properties . . . . . . . . Saving and Loading the Environment . . . . . . . . . Changing Environment Properties with Graphical Interface . . . . . . . . . . . . . . Changing Environment Properties with Command Line Interface . . . . . .
5 Environment Reference The xPC Target environment defines connections and communication between the host and target computers. It also, defines the build process for a real-time application.
Environment Environment The xPC Target environment defines the software and hardware environment of the host PC as well as the target PC. An understanding of the environment properties will help you to correctly configure the xPC Target environment.
5 Environment Reference Table 5-1: List of Environment Properties Environment property Description TargetRAMSizeMB Values are ’Auto’ or ’MB of target RAM’. From the Setup window TargetRAMSizeMB list, choose either Auto or Manual. If you select Manual, enter the amount of RAM, in megabytes, installed on the target PC. This property is set by default to Auto. TargetRAMSizeMB defines the total amount of installed RAM in the target PC.
Environment Table 5-1: List of Environment Properties Environment property Description SystemFontSize Values are ’Small’ or ’Large’. From the Setup window SystemFontSize list, choose either Small, or Large. The xPC Target GUIs use this information to change the font size. CANLibrary Values are ’None’, ’200 ISA’, ’527 ISA’, ’1000 PCI’, ’1000 MB PCI’, or ’PC104’. From the Setup window CANLibrary list, choose None, 200 ISA, 527 ISA, 1000 PCI, 1000 MB PCI, or PC104.
5 Environment Reference Table 5-1: List of Environment Properties Environment property Description TcpIpTargetAddress Value is ’xxx.xxx.xxx.xxx’. In the Setup window TcpIpTargetAddress box, enter a valid IP address for your target PC. Ask you system administrator for this value. For example, 192.168.0.1 TcpIpTargetPort Value is ’xxxxx’. In the Setup window TcpIpTargetPort box, enter a value greater than 20000. This property is set by default to 22222 and should not cause any problems.
Environment Table 5-1: List of Environment Properties Environment property Description TcpIpGateway Value is ’xxx.xxx.xxx.xxx’. In the Setup window TcpIpGateway box, enter the IP address for your gateway. This property is set by default to 255.255.255.255 which means that a gateway is not used to connect to the target PC.
5 Environment Reference Table 5-1: List of Environment Properties Environment property Description TcpIpTargetISAMemP ort Value is ’0xnnnn’. If you are using an ISA-bus Ethernet card, you must enter values for the properties TcpIpISAMemPort and TcpIpISAIRQ. The values of these properties must correspond to the jumper settings or ROM settings on your ISA-bus Ethernet card. On your ISA-bus card, assign an IRQ and I/O-port base address by moving the jumpers on the card.
Environment Table 5-1: List of Environment Properties Environment property Description EmbeddedOption Values are ’Disabled’ or ’Enabled’. This property is read-only. Note The xPC Target Embedded Option is enabled only if you purchase an additioanl license. TargetScope Values are ’Disabled’ or ’Enabled’. From the Setup window TargetScope list, choose either Enabled or Disabled. The property TargetScope is set by default to Enabled.
5 Environment Reference Table 5-1: List of Environment Properties Environment property Description TargetMouse Values are ’None’, ’PS2’, ’RS232 COM1’, ’RS232 COM2’. From the Setup window TargetMouse list, choose None, PS2, RS232 COM1, or RS232 COM2. Before you can select a target mouse, you need to set the Target Scope property to Enabled.
Environment Environment Functions The environment functions allow you to change the environment properties. The functions are listed in the following table. Table 5-2: List of Environment functions Environment functions Description getxpcenv List environment properties in the MATLAB window or assign the list as a cell array to a MATLAB variable. setxpcenv First of two steps to change environment properties. See also updatexpcenv.
5 Environment Reference Using Environment Properties and Functions You use the xPC Target Setup window to enter properties that are independent of your model.
Using Environment Properties and Functions MATLAB displays a list of xPC Target environment properties and the current values. 3 Alternately, in the MATLAB window, type xpcsetup MATLAB opens the xPC Target Setup window with the current values. Saving and Loading the Environment This feature makes it easy and fast to switch between different xPC Target environments: 1 In the xPC Target Setup window, and from the File menu, click Save Settings. The Save xPC Target Environment dialog box opens.
5 Environment Reference Changing Environment Properties with Graphical Interface xPC Target lets you define and change environment properties. These properties include, the path to the C/C++ compiler, the host PC COM-port, the logging buffer size, and many others. Collectively these properties are known as the xPC Target environment.
Using Environment Properties and Functions The xPC Target Setup window has two sections: - xPC Target - xPC Target Embedded Option If your license does not include the xPC Target Embedded Option, the TargetBoot box is grayed-out with BootFloppy as your only selection. With the xPC Target Embedded Option, you have the additional choices of DOSLoader and StandAlone. 2 Change properties in the environment by entering new property values in the text boxes or choosing items from the lists.
5 Environment Reference Changing Environment Properties with Command Line Interface xPC Target lets you define and change different properties. These properties include, the path to the C/C++ compiler, the host COM-port, the logging buffer size, and many others. Collectively these properties are known as the xPC Target environment. You can use the command line functions to write an M-file script that accesses the environment settings according to your own needs.
Using Environment Properties and Functions Creating a Target Boot Disk with Graphical 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 target boot disk. To create a target boot disk for the current xPC Target environment, use the following procedure: 1 In the MATLAB window, type xpcsetup The xPC Target Setup window opens. 2 Click the BootDisk button.
5 Environment Reference NT systems, the status information is displayed only at the end of the write process. xPC Target DiskWrite Utility Version 1.1,(c) 1998-2000 The MathWorks, Inc.Read File: C:\MATLAB\TOOLBOX\RTW\TARGETS\XPC\XPC\BIN\ ..\..\target\kernel\xpcsgb1.rtd Write Write Write Write Write Write Write Write Track Track Track Track Track Track Track Track 0- 9: 10-19: 20-29: 30-39: 40-49: 50-59: 60-69: 70-79: ........
Using Environment Properties and Functions Creating a Target Boot Disk with 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. To create a target boot disk for the current xPC Target environment, use the following procedure: 1 In the MATLAB window, type xpcbootdisk xPC Target displays the following message.
5 Environment Reference System Functions The system functions allow you to open xPC Target GUIs and run tests from the MATLAB window. This section includes the following topics: • “GUI Functions” • “Test Functions” • “xPC Target Demos” GUI Functions The GUI functions are listed in the following table. Table 5-3: List of GUI Functions 5-20 System functions Description xpcscope Opens the scope manager window on the host PC for scopes with type host. xpcsetup Opens the Setup window.
System Functions Test Functions The test functions are listed in the following table. Table 5-4: List of Test Function System functions Description getxpcpci Determine which PCI boards are installed in the target PC. xpctargetping Test the communication between the host PC and the target PC xpctargetspy Open the Target Spy window on the host PC. Use this GUI to upload the target PC screen to the host PC. xpctest Test the xPC Target installation.
5 Environment Reference To locate or edit a demo script 1 In the MATLAB window, type scfreerundemo MATLAB displays the location of the M-file. D:\MATLAB\toolbox\rtw\targets\xpc\xpcdemos\scfreerundemo.m 2 Type edit scfreerundemo MATLAB opens the M-file in a MATLAB editing widow.
Environment and System Function Reference Environment and System Function Reference This section includes an alphabetical listing of the environment and system functions.
getxpcenv Purpose Syntax 5getxpcenv List environment properties assign to a MATLAB variable MATLAB Command Line getxpcenv Description Function for environment properties. This function displays, in the MATLAB window, the property names, the current property values, and the new property values set for the xPC Target environment. Examples Return the xPC Target environment in the structure shown below. The output in the MATLAB window is suppressed.
getxpcpci Purpose Syntax 5getxpcpci Determine which PCI boards are installed in the target PC MATLAB Command Line getxpcpci(’type_of_boards’) Arguments type_of_boards Description The information is displayed in the MATLAB window. Only devices supported by driver blocks in the xPC Target Block Library are displayed. The information includes the PCI bus number, slot number, assigned IRQ number, manufacturer name, board name, device type, manufacturer PCI Id, and the board PCI Id itself.
getxpcpci Display a list of the currently supported PCI devices in the xPC Target block library. The result is stored in a struct instead of displaying it.
setxpcenv Purpose Syntax 5setxpcenv Change xPC Target environment properties. MATLAB Command Line setxpcenv('property_name’, 'property_value') setxpcenv('prop_name1', 'prop_val1', 'prop_name2', prop_val2') setxpcenv Arguments Description property_name Not case sensitive. Property names can be shortened as long as they can be differentiated from the other property names. property_value Character string. Type setxpcenv without arguments to get a listing of allowed values.
setxpcenv Interface” on page 5-14 and “Changing Environment Properties with Command Line Interface” on page 5-16.
updatexpcenv Purpose Syntax 5updatexpcenv Change current environment properties to equal new properties MATLAB Command Line updatexpcenv Description Function for environment properties. This procedure includes creating communication M-files as well as patching the xPC Target kernel and system DLL’s. Calling the function updatexpcenv is necessary after new properties are entered with the function setxpcenv, but before creating a target boot floppy with the function xpcbootdisk.
xpcbootdisk Purpose Syntax 5xpcbootdisk Create xPC Target boot disk, and confirm the current environment properties MATLAB Command Line xpcbootdisk Description Function for environment properties. This function creates a xPC target boot floppy for the current xPC Target environment which has been updated with the function updatexpcenv. Creating an xPC Target boot floppy consists of writing the correct bootable kernel image onto the disk.
xpcscope Purpose Syntax 5xpcscope Open a scope manager window on the host PC. MATLAB Command Line xpcscope Description This graphical user interface (GUI) allows you to define scopes that display on your host PC, choose signals, and control the data acquisition process. See Also The xPC Target function xpctgscope and the procedures “Signal Tracing with xPC Target GUI” on page 3-26 and “Signal Tracing with xPC Target GUI (Target Manager)” on page 3-31.
xpcsetup Purpose Syntax 5xpcsetup Open the Setup window MATLAB Command Line xpcsetup Description This graphical user interface (GUI) allows you to: • Enter and change environment properties • Create an xPC Target boot floppy disk See Also 5-32 See also the functions setxpcenv, getxpcenv, updatexpcenv, xpcbootdisk, and the procedures “I/O boards — If you use I/O boards on the target PC, you need to correctly install the boards. See the manufactures literature for installation instructions.
xpctargetping Purpose Syntax 5xpctargetping Test communication between the host and target computers MATLAB Command Line xpctargetping Examples Check for communication between the host PC and target PC. xpctargetping Description Ping’s the target PC from the host PC and returns either ’success’ or ’failed’. If the xPC Target kernel is loaded, running, and communication is working properly, this function returns the value ’success’. This function works with both RS232 and TCP/IP communication.
xpctargetspy Purpose Syntax 5xpctargetspy Open an xPC Target Spy window on the host PC MATLAB Command Line xpctargetspy Description This graphical user interface (GUI) allows you to upload displayed data from the target PC. The behavior of this function depends on the value for the environment property TargetScope. • If TargetScope is enabled, a single graphics screen is uploaded. The screen is not continually updated because of a higher data volume when a target graphics card is in VGA mode.
xpctest Purpose Syntax 5xpctest Test the xPC Target installation MATLAB Command Line xpctest xpctest(’reboot_flag’) Arguments reboot_flag Description Series of xPC Target tests to check the correct functioning of the following xPC Target tasks: noreboot. Skips the reboot test. User this option if the target hardware does not support software rebooting. Value is 'noreboot' • Initiate communication between the host and target computers. • Reboot the target PC to reset the target environment.
xpctgscope Purpose Syntax 5xpctgscope Open the target scope manager window. MATLAB Command Line xpctgscope 5-36 Description This graphical user interface (GUI) allows you to define scopes that display on your target PC, choose signals, and control the data acquisition process. See Also The xPC Target function xpcscope and the procedures “Signal Tracing with xPC Target GUI (Target Manager)” on page 3-31 and “Signal Tracing with xPC Target GUI” on page 3-26.
xpcwwwenable Purpose Syntax 5xpcwwwenable Disconnect the target PC from the current client application MATLAB Command Line xpcwwwenable Description Use this function to disconnect the target application from MATLAB before you connect to the Web browser. Also, you can use this function to connect to MATLAB after using a Web browser, or switch to another Web browsers.
xpcwwwenable 5-38
6 Target Object Reference Target Object . . . . . What is a Target Object? Target Object Properties . Target Object Methods . Target PC Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using Target Objects . . . . . . . . . Displaying Target Object Properties . . . . . Setting the Value of a Target Object Property from the Host PC . . . . . . . . . . Setting the Value of a Target Object Property from the Target PC . . . . . . . . .
6 Target Object Reference Use target objects to run and control real-time applications on the target PC.
Target Object Target Object xPC Target uses a target object to represent the target application and target kernel. An understanding of the target object properties and methods will help you to control and test your application on the target PC. This section includes the following topics: • “What is a Target Object?” • “Target Object Properties” • “Target Object Methods” What is a Target Object? A target object on the host PC represents the interface to a target application and the kernel on the target PC.
6 Target Object Reference Target Object Properties Target object properties let you access information from your target application and control its execution. You can view and change these properties using target object methods. The properties for a target object are listed in the following table. This table includes a description of the properties and which properties you can change directly by assigning a value.
Target Object Table 6-1: List of Target Object Properties Property Description ExecTime Execution Time. Time, seconds, since your target application started running. When the target application stops, the total execution time is displayed. SessionTime Time since the kernel started running on your target PC. This is also the elapsed time since you booted the target PC. Values are in seconds. StopTime Time when the target application stops running. Values are in seconds.
6 Target Object Reference Table 6-1: List of Target Object Properties Property Description MaxTET Maximum task execution time. Corresponds to the slowest time (longest time measured), in seconds, to update model equations and post outputs. ViewMode Displays either all scopes or a single scope on the target PC. Values are ’all’ or a single scope index. This property is active only if the environemnt property TargetScope is set to enabled.
Target Object Table 6-1: List of Target Object Properties Property Description MaxLogSamples Maximum number of samples for each logged signal within the circular buffers for TimeLog, StateLog, OutputLog, and TETLog. StateLog and OutputLog can have one or more signals. Write This value is calculated by dividing the Signal Logging Buffer Size by the number of logged signals.
6 Target Object Reference Table 6-1: List of Target Object Properties Property Description Signals List of viewable signals. This list is visible only when ShowSignals is set to ’on’. Write • Property name. S0, S1. . . • Property value. Value of the signal • Block Name. Name of the Simulink block the signal is from. S# Property name for a signal. NumParameters The number of parameters from your Simulink model that you can tune or change.
Target Object Target Object Methods The target object methods allow you to control a target application on the target PC from the host PC. Target object methods are entered in the MATLAB window on the host PC. You can also control the target application from the target PC using target PC commands. See “Target PC Commands” on page 6-11. The methods are listed in the following table. Table 6-2: List of Target Object Methods Method Description xpc Creates a target object on the host PC (constructor).
6 Target Object Reference Table 6-2: List of Target Object Methods 6-10 Method Description remscope Removes a scope from the target PC. This method does not remove the scope object, on the host PC, that represent the scope. getparamid Returns the property name or index of a parameter from the target object. getsignalid Returns the property name or index of a signal from the target object. getlog Uploads and returns one of the data logs from the target PC to the host PC.
Target Object Target PC Commands The target PC commands allow you to control a target application on the target PC from the target PC. Target PC commands are entered in the target PC command window on the target PC. You can also control the target application from the host PC using target object methods. See “Target Object Methods” on page 6-9. The commands are listed in the following table. Table 6-3: List of Target PC Commands Command Description delallvar Delete all variables.
6 Target Object Reference Table 6-3: List of Target PC Commands Command Description setpar Changes the value of a block parameter using the parameter index. Syntax: setpar parameter_index = floating_point_number setvar Sets a variable to a value. Later you can use that variable to do a macro expansion. Syntax: setvar variable_name = target_pc_command For example, you can type setvar aa=startscope 2, setvar bb=stopscope 2 showvar Display a list of variables.
Using Target Objects Using Target Objects xPC Target uses a target object to represent the target application and target kernel. This section shows some of the common tasks that you use with target objects.
6 Target Object Reference Setting the Value of a Target Object Property from the Host PC You can change a target object property by using xPC Target methods on the host PC. With xPC Target you can use either a function syntax or an object property syntax. The syntax set(target_object, property_name, new_property_value) can be replaced by: target_object.propety_name = new_property_value. For example, to change the stop time mode for the target object tg: 1 In the MATLAB window, type tg.
Using Target Objects Note Method names are case-sensitive and need to be complete, but property names are not case-sensitive and need not be complete as long as they are unique. Setting the Value of a Target Object Property from the Target PC You can type commands directly from a keyboard on the target PC. These commands create a temporary difference between the behavior of the target application and the properties of the target object.
6 Target Object Reference Getting the Value of a Target Object Property You can list a property value in the MATLAB window, or assign that value to a MATLAB variable. With xPC Target you can use either a function syntax or an object property syntax. The syntax get(target_object, property_name) can be replaced by target_object.propety_name For example, to access the start time: 1 In the MATLAB window, type endrun = tg.stoptime 2 Alternately, you could type endrun = get(tg,’stoptime’) or tg.
Using Target Objects Using the Method Syntax with Target Objects Use the method syntax to run a target object method. The syntax method_name(target_object, argument_list) can be replaced with: target_object.method_name(argument_list) Unlike properties, for which partial but unambiguous names are permitted, method names must be entered in full, and in lowercase. For example, to add a scope of type target with a scope index of 1: 1 In the MATLAB window, type tg.
addscope Purpose Syntax 6addscope Creates one or more scopes on the target PC MATLAB command line Creating a scope and scope object without assigning to a MATLAB variable. addscope(target_object, ’scope_type’, new_scope_index) target_object.addscope(’scope_type’, new_scope_index). Creating a scope, scope object, and assign to a MATLAB variable. scope_object = addscope(target_object,’scope_type’, new_scope_index) scope_object = target_object.
addscope All Scopes of type target or host run on the target PC Scope of type target - Data collected is displayed on the target screen and acquisition of the next data package is initiated by the kernel. Scope of type host - Collects data and waits for a command from the host PC for uploading the data. The data is then displayed using the host scope GUI (xpcscope) or other MATLAB functions.
addscope See Also 6-20 The xPC Target target object methods remscope, getscope. The xPC Target GUI function xpcscope. The xPC target M-file demo scripts listed in “xPC Target Demos” on page 5-21.
close Purpose Syntax 6close Closes the serial port connecting the host PC with the target PC MATLAB command line close(target_object) Arguments target_object Description Method of a target object. If you want to use the serial port for another function without quiting MATLAB, for example a modem, use this function to close the connection. Name of a target object.
get Purpose Syntax 6get Return the property values for target and scope objects. MATLAB command line get(target_object, ’target_object_property’) Arguments target_object Name of a target object target_object_property Name of a target object property. Description Method of target objects. Gets the value of readable target object properties from a target object. Examples List the value for the target object property StopTime. Notice the property name is a string, in quotes, and not case-sensitive.
getlog Purpose Syntax 6getlog Get all or part of the output logs from the target object MATLAB command line log = getlog(target_object, ’log_name’, start_time, number_points, interleave) Arguments log User defined MATLAB variable. log_name Values are TimeLog, StateLog, OutputLog, or TETLog. This argument is required. first_point First data point. The logs begin with 1. This argument is optional. Default is 1 number_points Number of points after the start time. This argument is optional.
getparamid Purpose Syntax 6getparamid Get a parameter index or property name from the parameter list MATLAB command line getparamid(target_object, ’block_name’, ’parameter_name) getparamid(target_object, ’block_name’, ’parameter_name’, ’flag’) Arguments target_object Name of a target object. The default name is tg. block_name Simulink block path and name. parameter_name Name of a parameter within a Simulink block flag If flag = property, then return the property name for the parameter.
getparamid See Also The xPC Target scope object method getsignalid. The xPC target M-file demo scripts listed in “xPC Target Demos” on page 5-21.
getscope Purpose Syntax 6getscope Gets a scope object pointing to a scope already defined in the kernel MATLAB command line scope _object_vector = getscope(target_object, scope_index) scope_object_vector = target_object.getscope(scope_index) Arguments Description target_object Name or a target object. scope_index_vector Vector of existing scope indices listed in the target property Scopes. The vector may have only one element. scope_object_vector MATLAB variable for a new scope object vector.
getscope To get the properties of all scopes on the target PC and create a vector of scope objects on the host PC. If the target object has more than one scope, creates a vector or scope objects. scvector = getscope(tg) See Also The xPC Target target object methods addscope and remscope. The xPC target M-file demo scripts listed in “xPC Target Demos” on page 5-21.
getsignalid Purpose Syntax 6getsignalid Get the signal index or property name from the signal list MATLAB command line getsignalid(target_object, ’block_name’) getsignalid(target_object, ’block_name’, ’flag’) Arguments target_object Name of an existing target object. block_name Name of a Simulink block from you model. flag If flag = property, then return the property name for the signal. If flag = numeric, then return a number index.
load Purpose Syntax 6load Download a target application to the target PC MATLAB command line load(target_object,’target_application’) target_object.load(’target_application’) Arguments Description target_object Name of an existing target object target_application Simulink model and target application name. Method of a target object.
reboot Purpose Syntax 6reboot Reboot the target PC MATLAB command line reboot(target_object) Target PC command line reboot Arguments target_object Description Method of a target object. Reboots the target PC, and if a target boot disk is still present, the xPC target kernal is reloaded. Name of an existing target object You can also use this method to reboot the target PC back to Windows after removing the target boot disk. Note This method may not work on some target hardware.
remscope Purpose Syntax 6remscope Remove a scope from the target PC. MATLAB command line remscope(target_object, scope_index_vector) target_object.remscope(scope_index_vector) remscope(target_object) target_object.remscope Target PC command line remscope scope_index remscope ’all’ Arguments Description target_object Name of a target object. The default name it tg. scope_index_vector Vector of existing scope indices listed in the target property Scopes. scope_index Single scope index.
remscope Remove two scopes. remscope(tg,[1 2]) or tg.remscope([1,2]) Remove all scopes. remscope(tg) or tg.remscope See Also 6-32 The xPC Target target object methods addscope and getscope. The xPC target M-file demo scripts listed in “xPC Target Demos” on page 5-21.
set Purpose Syntax 6set Change property values for target objects MATLAB command line set(target_object) set(target_object, property_name1, property_value1, property_name2, property_value2, . . .) target_object.set(’property_name1’, property_value1) set(target_object, property_name_vector, property_value_vector) target_object_name.property_name = property_value Target PC command line - Commands are limited to the target object properties: stoptime, sampletime, and parameters.
set property_value), it returns the value of the properties after the indicated settings have been made. Examples Get a list of writable properties for a scope object. sc1 = getscope(tg,1) set(sc1) xPC Target Object: Writable Properties StopTime SampleTime ViewMode LogMode ShowParameters ShowSignals : [0 | 1] : [On | {Off}] : [On | {Off}] Change the property showsignals to on. tg.
start Purpose Syntax 6start Start execution of a target application on a target PC. MATLAB command line start(target_object) target_object.start +target_object Target PC command line start Arguments target_object Description Method of both target and scope objects. Starts execution of the target application represented by the target object. Before using this method, the target application must be created and loaded on the target PC. If a target application is running, this command has no effect.
stop Purpose Syntax 6stop Stop execution of a target application on a target PC. MATLAB command line stop(target_object) target_object.stop -target_object Target PC command line stop Arguments target_object Description Stops execution of the target application represented by the target object. If the target application is stopped, this command has no effect. Examples Stop the target application represented by the target object tg. Name of a target object. stop(tg) or tg.
unload Purpose Syntax 6unload Removes the current target application from the target PC. MATLAB command line unload(target_object) target_object.unload Arguments target_object Description Method of a target object. The kernel goes into loader mode is ready to download new target application from the host PC. Examples Unload the target application represented by the target object tg. Name of a target object that represents a target application. unload(tg) or tg.
xpc Purpose Syntax 6xpc Create a target object representing the target application MATLAB command line target_object = xpc Arguments target_object Description Constructor of a target object. The target object represents the target application and target PC. Changes are made to the target application by making changes to the target object using methods and properties.
7 Scope Object Reference Scope Object . . . . What is a Scope Object? Scope Object Properties Scope Object Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using Scope Objects . . . . . . . . . . . . . Displaying Scope Object Properties for a Single Scope . Displaying Scope Object Properties for All Scopes . . Setting the Value of a Scope Property . . . . . . . Getting the Value of a Scope Property . . . . . . .
7 Scope Object Reference Use scope objects to run and control scopes on the target PC.
Scope Object Scope Object xPC Target uses scopes and scope objects as an alternative to using Simulink scopes and external mode. Understanding the structure of scope objects will help you to develop a mental model of the xPC Target software environment.
7 Scope Object Reference The properties for a scope object are listed in the following table. This table includes a description of the properties and which properties you can change directly by assigning a value. Table 7-1: List of Scope Object Properties 7-4 Property Description Application Name of the Simulink model associated to this scope object. ScopeId A numeric index unique for each scope.
Scope Object Table 7-1: List of Scope Object Properties Property Description Write Decimation A number n, where every nth sample is acquired in a scope window. Yes Note This value is the same as Interleave in a scope window. TriggerMode Trigger mode for a scope. Valid values are ’FreeRun’ (default), ’Software’, ’Signal’, and ’Scope’. Yes TriggerSignal If TriggerMode=’Signal’, identifies which block output signal to use for triggering the scope.
7 Scope Object Reference Table 7-1: List of Scope Object Properties Property Description Write YLimit Minimum and maximum y-axis values. This property can be set to ’auto’. Yes Grid Values are ’on’ or ’off’. Yes StartTime Time within the total execution time, when a scope begins acquiring a data package. Time Contains the time data for a single data package from a scope. Data Contains the output data for a single data package from a scope.
Scope Object Table 7-2: List of Scope Object Methods Scope Method Description remsignal Removes a signal from a scope and a scope object. The signal is specified using signal indices from the scope object. start Starts a scope, but does not necessarily start the acquisition of data. The acquisition of data is dependent on the trigger mode. stop Stops a scope and the acquisition of a data. trigger If TriggerMode=’Software’, starts the acquisition of data from the target application.
7 Scope Object Reference Using Scope Objects xPC Target uses scope objects to represent scopes on the target PC. This section shows some of the common tasks that you use with scope objects.
Using Scope Objects Displaying Scope Object Properties for All Scopes To list the properties of all scope objects associated with the target object tg: 1 In the MATLAB window, type getscope(tg) or tg.getscope MATLAB displays a list of all scope objects associated with the target object. 2 Alternately, type allscopes = getscope(tg) or allscopes = tg.
7 Scope Object Reference Note Method names are case-sensitive, but property names are not. Getting the Value of a Scope Property You can list a property value in the MATLAB window, or assign that value to a MATLAB variable. With xPC Target you can use either a function syntax or an object property syntax. The syntax get(scope_object_vector, property_name) can be replaced by • scope_object_vector.property_name • scope_object_vector(index_vector).
Using Scope Objects Using the Method Syntax with Scope Objects Use the method syntax to run a scope object method. The syntax method_name(scope_object_vector, argument_list) can be replaced with: • scope_object.method_name(argument_list) • scope_object_vector(index_vector).method_name(list of arguments) Unlike properties, for which partial but unambiguous names are permitted, method names must be entered in full, and in lowercase.
addsignal Purpose Syntax 7addsignal Adds signals to a scope represented by a scope object MATLAB command line addsignal(scope_object_vector, signal_index_vector) scope_object_vector.addsignal(signal_index_vector) Target command line addsignal scope_index = signal_index, signal_index, . . . Arguments scope_object_vector Name of a single scope object, or the name of a vector of scope objects. signal_index_vector For one signal, use a single number.
addsignal set(sc1,’Signals’, [0,1]) or sc1.set(’signals’,[0,1], Or to directly assign signal values to the scope object property Signals. sc1.signals = [0,1]. See Also The xPC Target scope object methods remsignal and set. The target object method addscope and getsignalid.
get Purpose Syntax 7get Return the property values for scope objects MATLAB command line get(scope_object_vector) get(scope_object_vector, ’scope_object_property’) get(scope_object_vector, scope_object_property_vector) Arguments target_object Name of a target object scope_object_vector Name of a single scope, or name of a vector of scope objects scope_object_property Name of a scope object property Description Method of scope objects.
remsignal Purpose Syntax 7remsignal Remove signals from a scope represented by a scope object MATLAB command line remsignal(scope_object) remsignal(scope_object, signal_index_vector) scope_object.remsignal(signal_index_vector) Target command line remsignal scope_index = signal_index, signal_index, . . . Arguments scope_object MATLAB object created with the target object methods addscope or getscope. signal_index_vector Index numbers from the scope object property Signals.
set Purpose Syntax 7set Change property values for scope objects MATLAB command line set(scope_object_vector) set(scope_object_vector, property_name1, property_value1, property_name2, property_value2, . . .) scope_object_vector.set(’property_name1’, property_value1, ..) set(scope_object, ’property_name’, property_valuse, . . .) Arguments Description scope_object Name of a scope object, or a vector of scope objects property_name Name of a scope object property.
set NumSamples Decimation TriggerMode : [{FreeRun} | Software | Signal | Scope] TriggerSignal TriggerLevel TriggerSlope : [{Either} | Rising | Falling] TriggerScope Signals Mode : [Numerical | {Redraw} | Sliding | Rolling] YLimit Grid The property value for the scope object sc1 is changed to on sc1.set(’grid’, ’on’) or set(sc1, ’grid’, ’on’) See Also The xPC Target scope object method get. The target object methods set and get. The built in MATLAB functions get and set.
start Purpose Syntax 7start Start execution of a scope on a target PC MATLAB command line start(scope_object_vector) scope_object_vector.start +scope_object_vector start(getscope(target_object, scope_index_vector)) Target PC command line startscope scope_index startscope ’all’ Arguments target_object Name of a target object.
start somescopes = getscope(tg,[1,2]) or somescopes= tg.getscope([1,2]) start(somescopes) or somescopes.start or type sc1 = getscope(tg,1) or sc1 =tg.getscope(1) sc2 = getscope(tg,2) or sc2 = tg.getscope(2) start([sc1,sc2]) or type start(getscope(tg,[1,2]) Start all scopes allscopes = getscope(tg) or allscopes = tg.getscope start(allscopes) or allscopes.start or +allscopes or type start(getscope(tg)) or start(tg.getscope) See Also The xPC Target target object methods getscope and stop.
stop Purpose Syntax 7stop Stop execution of a scope on the target PC. MATLAB command line stop(scope_object_vector) scope_object.stop -scope_object stop(getscope(target_object, scope_index_vector)) Target PC command line stopscope scope_index stopscope ’all’ Arguments target_object Name of a target object.
stop See Also The xPC Target target object methods getscope, stop, and start. The scope object method start.
trigger Purpose Syntax 7trigger Software trigger the start of data acquisition for one or more scopes. MATLAB command line trigger(scope_object_vector) or scope_object_vector.trigger Arguments scope_object_vector Description Method for a scope object. If the scope object property TriggerMode has a value of ’software’, then this function triggers the scope represented by the scope object to acquire the number of data points in the scope object property NumSamples.
Index A adding scope blocks 2-13 advanced tutorial 2-1 B block library in Simulink 2-7 with xPC Target 2-4 block parameters defining 2-10 defining scope 2-16 boot disk, see target boot disk C changing environment properties 5-16 changing properties environment properties 5-14 command line interface scope object 7-3 target object 6-3 commands xPC Target 5-20 creating boot disk 5-19 model with I/O blocks 2-3 model with scope blocks 2-13 target boot disk 5-17, 5-19 D E entering environment properties 5-14
Index M with I/O blocks 2-3 with scope blocks 2-13 methods scope object 7-6 target object 6-9, 6-11 T P parameters defining block 2-10 defining scope blocks 2-16 properties changing environment 5-16 environment list 5-12 scope object 7-3 target object 6-4 updating environment 5-16 S saving environment properties 5-13 scope blocks adding to model 2-13 defining parameters 2-16 in Simulink model 2-13 scope object command line interface 7-3 commands 7-3 methods 7-6 methods, see commands properties 7-3 Setu