ModelingSimulationImplementationxPC Target For Use with Real-Time Workshop ®User’s GuideVersion 1
1 Introduction1-4
5 Environment Reference5-18NT systems, the status information is displayed only at the end of the write process.xPC Target DiskWrite Utility Version 1
Using Environment Properties and Functions5-19Creating a Target Boot Disk with Command Line InterfaceYou use the target boot disk to load and run the
5 Environment Reference5-20System FunctionsThe system functions allow you to open xPC Target GUIs and run tests from the MATLAB window. This section i
System Functions5-21Test FunctionsThe test functions are listed in the following table.xPC Target DemosThe xPC Target demos are used to demonstrate th
5 Environment Reference5-22To locate or edit a demo script1 In the MATLAB window, typescfreerundemoMATLAB displays the location of the M-file.D:\MATLA
Environment and System Function Reference5-23Environment and System Function ReferenceThis section includes an alphabetical listing of the environment
getxpcenv5-245getxpcenvPurpose List environment properties assign to a MATLAB variable Syntax MATLAB Command LinegetxpcenvDescription Function for env
getxpcpci5-255getxpcpciPurpose Determine which PCI boards are installed in the target PCSyntax MATLAB Command Linegetxpcpci(’type_of_boards’)Arguments
getxpcpci5-26Display a list of the currently supported PCI devices in the xPC Target block library. The result is stored in a struct instead of displa
setxpcenv5-275setxpcenvPurpose Change xPC Target environment properties.Syntax MATLAB Command Linesetxpcenv('property_name’, 'property_value
2Advanced ProceduresI/O Driver Blocks . . . . . . . . . . . . . . . . . 2-3xPC Target I/O Driver Blocks .
setxpcenv5-28Interface” on page 5-14 and “Changing Environment Properties with Command Line Interface” on page 5-16.
updatexpcenv5-295updatexpcenvPurpose Change current environment properties to equal new properties Syntax MATLAB Command LineupdatexpcenvDescription F
xpcbootdisk5-305xpcbootdiskPurpose Create xPC Target boot disk, and confirm the current environment propertiesSyntax MATLAB Command LinexpcbootdiskDes
xpcscope5-315xpcscopePurpose Open a scope manager window on the host PC.Syntax MATLAB Command LinexpcscopeDescription This graphical user interface (G
xpcsetup5-325xpcsetupPurpose Open the Setup window Syntax MATLAB Command LinexpcsetupDescription This graphical user interface (GUI) allows you to:•En
xpctargetping5-335xpctargetpingPurpose Test communication between the host and target computersSyntax MATLAB Command LinexpctargetpingExamples Check f
xpctargetspy5-345xpctargetspyPurpose Open an xPC Target Spy window on the host PCSyntax MATLAB Command LinexpctargetspyDescription This graphical user
xpctest5-355xpctestPurpose Test the xPC Target installationSyntax MATLAB Command Linexpctestxpctest(’reboot_flag’)Arguments Description Series of xPC
xpctgscope5-365xpctgscopePurpose Open the target scope manager window.Syntax MATLAB Command LinexpctgscopeDescription This graphical user interface (G
xpcwwwenable5-375xpcwwwenablePurpose Disconnect the target PC from the current client applicationSyntax MATLAB Command LinexpcwwwenableDescription Use
2 Advanced Procedures2-2After learning the basic procedures for creating and running a target application, signal acquisition and parameter tuning, yo
xpcwwwenable5-38
6Target Object ReferenceTarget Object . . . . . . . . . . . . . . . . . . . 6-3What is a Target Object? .
6 Target Object Reference6-2Use target objects to run and control real-time applications on the target PC.This chapter includes the following sections
Target Object6-3Target ObjectxPC Target uses a target object to represent the target application and target kernel. An understanding of the target obj
6 Target Object Reference6-4Target Object PropertiesTarget object properties let you access information from your target application and control its e
Target Object6-5ExecTimeExecution Time. Time, seconds, since your target application started running. When the target application stops, the total exe
6 Target Object Reference6-6MaxTETMaximum task execution time. Corresponds to the slowest time (longest time measured), in seconds, to update model eq
Target Object6-7MaxLogSamplesMaximum number of samples for each logged signal within the circular buffers for TimeLog, StateLog, OutputLog, and TETLog
6 Target Object Reference6-8SignalsList of viewable signals. This list is visible only when ShowSignals is set to ’on’.•Property name. S0, S1. . .•Pro
Target Object6-9Target Object MethodsThe target object methods allow you to control a target application on the target PC from the host PC. Target obj
I/O Driver Blocks2-3I/O Driver BlocksYou add I/O driver blocks to your Simulink model to connect your model to physical I/O boards. These I/O boards t
6 Target Object Reference6-10remscopeRemoves a scope from the target PC. This method does not remove the scope object, on the host PC, that represent
Target Object6-11Target PC CommandsThe target PC commands allow you to control a target application on the target PC from the target PC. Target PC com
6 Target Object Reference6-12setparChanges the value of a block parameter using the parameter index.Syntax: setpar parameter_index = floating_point_nu
Using Target Objects6-13Using Target ObjectsxPC Target uses a target object to represent the target application and target kernel. This section shows
6 Target Object Reference6-14Setting the Value of a Target Object Property from the Host PCYou can change a target object property by using xPC Target
Using Target Objects6-15Note Method names are case-sensitive and need to be complete, but property names are not case-sensitive and need not be compl
6 Target Object Reference6-16Getting the Value of a Target Object PropertyYou can list a property value in the MATLAB window, or assign that value to
Using Target Objects6-17Using the Method Syntax with Target ObjectsUse the method syntax to run a target object method. The syntax method_name(target_
addscope6-186addscopePurpose Creates one or more scopes on the target PC Syntax MATLAB command lineCreating a scope and scope object without assigning
addscope6-19All Scopes of type target or host run on the target PCScope of type target - Data collected is displayed on the target screen and acquisit
2 Advanced Procedures2-4Adding I/O Blocks with the xPC Target LibraryxPC Target contains an I/O driver library with Simulink blocks. You can drag-and-
addscope6-20See Also The xPC Target target object methods remscope, getscope. The xPC Target GUI function xpcscope. The xPC target M-file demo scripts
close6-216closePurpose Closes the serial port connecting the host PC with the target PCSyntax MATLAB command lineclose(target_object)Arguments Descri
get6-226getPurpose Return the property values for target and scope objects. Syntax MATLAB command lineget(target_object, ’target_object_property’)Arg
getlog6-236getlogPurpose Get all or part of the output logs from the target object Syntax MATLAB command linelog = getlog(target_object, ’log_name’, s
getparamid6-246getparamidPurpose Get a parameter index or property name from the parameter listSyntax MATLAB command linegetparamid(target_object, ’bl
getparamid6-25See Also The xPC Target scope object method getsignalid. The xPC target M-file demo scripts listed in “xPC Target Demos” on page 5-21.
getscope6-266getscopePurpose Gets a scope object pointing to a scope already defined in the kernel Syntax MATLAB command linescope _object_vector = ge
getscope6-27To 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 th
getsignalid6-286getsignalidPurpose Get the signal index or property name from the signal list Syntax MATLAB command linegetsignalid(target_object, ’bl
load6-296loadPurpose Download a target application to the target PCSyntax MATLAB command lineload(target_object,’target_application’)target_object.loa
I/O Driver Blocks2-5The manufacturer level opens.Within each manufacturer group are the blocks for a single function.3 Open a manufacturer group. For
reboot6-306rebootPurpose Reboot the target PCSyntax MATLAB command linereboot(target_object)Target PC command linerebootArguments Description Method
remscope6-316remscopePurpose Remove a scope from the target PC.Syntax MATLAB command lineremscope(target_object, scope_index_vector)target_object.rems
remscope6-32Remove two scopes.remscope(tg,[1 2]) or tg.remscope([1,2])Remove all scopes.remscope(tg) or tg.remscopeSee Also The xPC Target target obje
set6-336setPurpose Change property values for target objectsSyntax MATLAB command lineset(target_object)set(target_object, property_name1, property_va
set6-34property_value), it returns the value of the properties after the indicated settings have been made.Examples Get a list of writable properties
start6-356startPurpose Start execution of a target application on a target PC.Syntax MATLAB command linestart(target_object)target_object.start+target
stop6-366stopPurpose Stop execution of a target application on a target PC. Syntax MATLAB command linestop(target_object)target_object.stop-target_obj
unload6-376unloadPurpose Removes the current target application from the target PC. Syntax MATLAB command lineunload(target_object)target_object.unlo
xpc6-386xpcPurpose Create a target object representing the target application Syntax MATLAB command linetarget_object = xpcArguments Description Cons
7Scope Object ReferenceScope Object . . . . . . . . . . . . . . . . . . . 7-3What is a Scope Object? . .
2 Advanced Procedures2-65 From the block library, click-and-drag the name of an A/D board to the Simulink block diagram. Likewise, click-and-drag the
7 Scope Object Reference7-2Use scope objects to run and control scopes on the target PC.This chapter includes the following sections:•“Scope Object” —
Scope Object7-3Scope ObjectxPC Target uses scopes and scope objects as an alternative to using Simulink scopes and external mode. Understanding the st
7 Scope Object Reference7-4The properties for a scope object are listed in the following table. This table includes a description of the properties an
Scope Object7-5DecimationA number n, where every nth sample is acquired in a scope window.Note This value is the same as Interleave in a scope window.
7 Scope Object Reference7-6Scope Object MethodsThe scope object methods allow you to control scopes on your target PC. The methods are listed in the f
Scope Object7-7remsignalRemoves a signal from a scope and a scope object. The signal is specified using signal indices from the scope object.startStar
7 Scope Object Reference7-8Using Scope ObjectsxPC Target uses scope objects to represent scopes on the target PC. This section shows some of the commo
Using Scope Objects7-9Displaying Scope Object Properties for All ScopesTo list the properties of all scope objects associated with the target object t
7 Scope Object Reference7-10Note Method names are case-sensitive, but property names are not.Getting the Value of a Scope PropertyYou can list a prop
Using Scope Objects7-11Using the Method Syntax with Scope ObjectsUse the method syntax to run a scope object method. The syntax method_name(scope_obje
I/O Driver Blocks2-7Adding I/O Blocks with the Simulink Library BrowserYou can access the xPC Target driver blocks using the Simulink Library Browser.
addsignal7-127addsignalPurpose Adds signals to a scope represented by a scope objectSyntax MATLAB command lineaddsignal(scope_object_vector, signal_in
addsignal7-13set(sc1,’Signals’, [0,1]) or sc1.set(’signals’,[0,1], Or to directly assign signal values to the scope object property Signals. sc1.signa
get7-147getPurpose Return the property values for scope objectsSyntax MATLAB command lineget(scope_object_vector)get(scope_object_vector, ’scope_objec
remsignal7-157remsignalPurpose Remove signals from a scope represented by a scope object Syntax MATLAB command lineremsignal(scope_object)remsignal(sc
set7-167setPurpose Change property values for scope objectsSyntax MATLAB command lineset(scope_object_vector)set(scope_object_vector, property_name1,
set7-17 NumSamples Decimation TriggerMode : [{FreeRun} | Software | Signal | Scope] TriggerSignal TriggerL
start7-187startPurpose Start execution of a scope on a target PCSyntax MATLAB command linestart(scope_object_vector)scope_object_vector.start+scope_ob
start7-19somescopes = getscope(tg,[1,2]) or somescopes= tg.getscope([1,2])start(somescopes) or somescopes.startor typesc1 = getscope(tg,1) or sc1 =tg.
stop7-207stopPurpose Stop execution of a scope on the target PC. Syntax MATLAB command linestop(scope_object_vector)scope_object.stop-scope_objectstop
stop7-21See Also The xPC Target target object methods getscope, stop, and start. The scope object method start.
2 Advanced Procedures2-8You can access the xPC Target I/O library by right-clicking xPC Target, and then clicking Open the xPC Target Library.3 Double
trigger7-227triggerPurpose Software trigger the start of data acquisition for one or more scopes.Syntax MATLAB command linetrigger(scope_object_vector
I-1IndexAaddingscope blocks 2-13advanced tutorial 2-1Bblock libraryin Simulink 2-7with xPC Target 2-4block parametersdefining 2-10defining scope 2-16b
IndexI-2Mmethodsscope object 7-6target object 6-9, 6-11Pparametersdefining block 2-10defining scope blocks 2-16propertieschanging environment 5-16envi
I/O Driver Blocks2-94 Open a function group. For example, to open the A/D group for ComputerBoards, double-click A/D, and then double-click ComputerBo
How to Contact The MathWorks:www.mathworks.com Webcomp.soft-sys.matlab [email protected] Technical [email protected] Product e
2 Advanced Procedures2-10Your next task is to define the I/O block parameters. See “Defining I/O Block Parameters”.Defining I/O Block ParametersThe I/
I/O Driver Blocks2-113 In the Simulink window, double-click the output block labeled Analog Output.The dialog box for the D/A converter opens.4 Fill i
2 Advanced Procedures2-12The Block Parameters dialog box should look similar to the figure shown below.If you change the sample time by changing the t
xPC Target Scope Blocks2-13xPC Target Scope BlocksUsually scope objects are defined using xPC Target functions or the graphical interface after downlo
2 Advanced Procedures2-14You can drag an xPC Target scope block into any Simulink model, and the input to the scope can be connected to any block outp
xPC Target Scope Blocks2-154 Double-click Misc.A list of miscellaneous group blocks opens.5 Click-and-drag Scope (xPC) to your Simulink block diagram.
2 Advanced Procedures2-166 Connect the xPC Target scope block with the Simulink scope block.The model xpcosc should look like the figure shown below.Y
xPC Target Scope Blocks2-172 In the Scope Number box, enter a unique number to identify the scope. This number is used to identify the xPC Target scop
2 Advanced Procedures2-186 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
Target PC Command Line Interface2-19Target PC Command Line InterfaceYou can interact with the xPC Target environment through the target PC command win
iContents1IntroductionWhat Is xPC Target? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32Advanced ProceduresI/O Driver Bloc
2 Advanced Procedures2-20Target Object MethodsWhen using the target PC command line interface, target object methods are limited to starting and stopp
Target PC Command Line Interface2-21Scope Object MethodsWhen using the target PC command line interface, you use scope object methods to start a scope
2 Advanced Procedures2-22Scope Object PropertiesWhen using the target PC command line interface, scope object properties are limited to those shown in
Target PC Command Line Interface2-23scopemode scope_index = 0 or numerical, 1 or redraw, 2 or sliding, 3 or rollingsc.Mode = ’numerical’, ’redraw’, ’s
2 Advanced Procedures2-24Using Variables on the Target PCUse variables to tag unfamiliar commands, parameter indices, and signal indexes with more des
3Network CommunicationWeb Interface . . . . . . . . . . . . . . . . . . . 3-3Connecting the Web Interface thro
3 Network Communication3-2xPC Target provides support for TCP/IP and UDP/IP communication protocols.This chapter includes the following sections:•“Web
Web Interface3-3Web InterfacexPC Target has a Web server build in the TCP/IP mode to the kernel that allows you to interact your target application us
3 Network Communication3-4xpcwwwenableMATLAB is disconnected from the target PC, and the connection is reset for connecting to another client. If you
Web Interface3-5c:\MATLABR12\toolbox\rtw\targets\xpc\xpc\bin\xpctcp2ser -v -t 22222 -c 1The TCP/IP to RS232 gateway starts running, and the DOS comman
ii Contents3Network CommunicationWeb Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3Connecting the We
3 Network Communication3-6xpcMATLAB reconnects to the target application and lists the properties of the target object.If you did not close the gatewa
Web Interface3-7-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
3 Network Communication3-87 In the MATLAB window, type!c:\MATLABR12\toolbox\rtw\targets\xpc\xpc\bin\xpctcp2ser -hAlternatively, you can open a DOS com
Web Interface3-92 Click the Start Execution button.The target application begins running on the target PC, the Status line is changed from Stopped to
3 Network Communication3-10The new property values are downloaded to the target application. Notice, the sample time box is visible only when the targ
Web Interface3-112 In the Refresh Interval box, enter a value greater than 10. For example, enter 20.The signal page updates automatically every 20 se
3 Network Communication3-12Using Scopes with the Web BrowserThe Web browser interface allows you to visualize data using an interactive graphical inte
Web Interface3-13Viewing and Changing Parameters with the Web InterfaceThe parameters page displays a list of all the tunable parameters in your model
3 Network Communication3-14Changing Access Levels to the Web BrowserThe Web browser interface allows you to set access levels to the target applicatio
User Datagram Protocol (UDP)3-15User Datagram Protocol (UDP)xPC Target supports communication with another system using User Datagram Protocol (UDP) p
iiiDOS Loader Target Applications . . . . . . . . . . . . . . . . . . . . . . 4-12Creating a Target Boot Disk for DOS Loader . . . . . . . . . . .
3 Network Communication3-16packets while the stack at the other end is responsible for reassembling the packets into a data stream using information i
User Datagram Protocol (UDP)3-17Note Unreliable is used in the sense of “not guaranteed to succeed” as opposed to “will fail a lot of the time.” In
3 Network Communication3-18vector of uint8. To convert arbitrary Simulink data types into this vector of uint8, a Pack block is provided, while an Unp
User Datagram Protocol (UDP)3-19UDP Receive BlockThe Receive block has two output ports. The first port is the actual output of the received data as a
3 Network Communication3-20chances of dropped packets. This is especially true when you are using a small sample time.UDP Send BlockThe Send block has
User Datagram Protocol (UDP)3-21As seen in the figure above, the data types of each of the signals have to be specified as a cell array of strings in
3 Network Communication3-22Note Individual elements of vector/matrix signals are not byte aligned: only the entire vector/matrix is byte aligned. The
User Datagram Protocol (UDP)3-23data on the other end may be in the form of a C struct, which is subject to the byte alignment convention of the compi
3 Network Communication3-24between two Simulink models. When one or both of the systems is running Simulink in non real-time, care must be taken to se
User Datagram Protocol (UDP)3-25Note that Port Data Types and Signal dimensions have been turned on from the Format menu, showing us that the width of
iv Contents6Target Object ReferenceTarget Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3What is a Targ
3 Network Communication3-26For setting up the Receive block, IP address to receive from is set to 192.168.0.1 (the hypothetical address of the system
User Datagram Protocol (UDP)3-27For constructing the Model B to Model A side of the communication, follow an analogous procedure. The final models are
3 Network Communication3-28The following table lists the parameters in Model A.Block Parameter ValueReceive IP address 192.168.0.2IP port 25000Output
User Datagram Protocol (UDP)3-29The following table lists the parameters in Model BNote on UDP CommunicationThe UDP blocks work in the background whil
3 Network Communication3-30
4Embedded OptionIntroduction . . . . . . . . . . . . . . . . . . . 4-3DOSLoader Mode Overview . . .
4 Embedded Option4-2The xPC Target Embedde Option allows you to boot the target PC from an alternate device other than a floppy disk drive such as a h
Introduction4-3IntroductionThe xPC Target Embedded Option allows you to boot the xPC Target kernel from not only a floppy disk drive, but also from ot
4 Embedded Option4-4invokes the autoexec.bat file which in turn starts the xPC Target kernel on the target PC.If you do not provide an target applicat
Introduction4-5applications using PC hardware. Typically these production applications are found in systems where production quantities are low to mod
1IntroductionWhat Is xPC Target? . . . . . . . . . . . . . . . . . . . . 1-3
4 Embedded Option4-6StandAlone mode. The module xpcboot.com is executed from DOS. It loads and executes any xPC Target application. The first argument
Introduction4-7It is also necessary that your TargetMouse setting is consistent with your hardware. Some PC hardware may use an RS232 port for the mou
4 Embedded Option4-8Updating the xPC Target EnvironmentAfter the xPC Target Embedded Option software has been correctly installed, the xPC Target envi
Updating the xPC Target Environment4-9The default setting for the property TargetBoot is BootFloppy. When using BootFloppy, xPC Target must first crea
4 Embedded Option4-10The property TargetBoot can be set to two other values, namely DOSLoader or StandAlone. If the xPC Target loader is booted from a
Creating a DOS System Disk4-11Creating a DOS System DiskWhen using DOSLoader mode, or StandAlone mode, you must first boot your target PC with DOS. Th
4 Embedded Option4-12DOS Loader Target ApplicationsThis section includes the following topics:•“Creating a Target Boot Disk for DOS Loader”•“Creating
DOS Loader Target Applications4-13The file autoexec.bat is copied to the DOS disk. This file should contain at least the following line:xpcboot xxx.rt
4 Embedded Option4-14Stand-Alone Target ApplicationsThis section includes the following topics:•“Creating a Target Application for Stand-Alone”•“Creat
Stand-Alone Target Applications4-15Creating a Target Boot Disk for Stand-AloneAfter making a bootable DOS boot disk, the file autoexec.bat file must c
1 Introduction1-2xPC Target has many features. An introduction to these features and the xPC Target software environment will help you develop a model
4 Embedded Option4-16xPC Target (basic package) offers a block for such purposes.Copy the Scope (xPC) block into your block diagram and connect the si
Stand-Alone Target Applications4-17It is necessary to edit the Scope (xPC) dialog box and confirm that the check box entry for Start Scope after downl
4 Embedded Option4-18
5Environment ReferenceEnvironment . . . . . . . . . . . . . . . . . . . 5-3Environment Properties . . .
5 Environment Reference5-2The xPC Target environment defines connections and communication between the host and target computers. It also, defines the
Environment5-3EnvironmentThe xPC Target environment defines the software and hardware environment of the host PC as well as the target PC. An understa
5 Environment Reference5-4TargetRAMSizeMBValues are ’Auto’ or ’MB of target RAM’. From the Setup window TargetRAMSizeMB list, choose either Auto or Ma
Environment5-5SystemFontSizeValues are ’Small’ or ’Large’. From the Setup window SystemFontSize list, choose either Small, or Large.The xPC Target GUI
5 Environment Reference5-6TcpIpTargetAddressValue is ’xxx.xxx.xxx.xxx’.In the Setup window TcpIpTargetAddress box, enter a valid IP address for your t
Environment5-7TcpIpGatewayValue is ’xxx.xxx.xxx.xxx’.In the Setup window TcpIpGateway box, enter the IP address for your gateway. This property is set
What Is xPC Target?1-3What Is xPC Target?xPC Target is a host-target solution for prototyping, testing, and deploying real-time systems using standard
5 Environment Reference5-8TcpIpTargetISAMemPortValue is ’0xnnnn’.If you are using an ISA-bus Ethernet card, you must enter values for the properties T
Environment5-9EmbeddedOptionValues are ’Disabled’ or ’Enabled’. This property is read-only.Note The xPC Target Embedded Option is enabled only if you
5 Environment Reference5-10TargetMouseValues are ’None’, ’PS2’, ’RS232 COM1’, ’RS232 COM2’.From the Setup window TargetMouse list, choose None, PS2, R
Environment5-11Environment FunctionsThe environment functions allow you to change the environment properties. The functions are listed in the followin
5 Environment Reference5-12Using Environment Properties and FunctionsYou use the xPC Target Setup window to enter properties that are independent of y
Using Environment Properties and Functions5-13MATLAB displays a list of xPC Target environment properties and the current values.3 Alternately, in the
5 Environment Reference5-14Changing Environment Properties with Graphical InterfacexPC Target lets you define and change environment properties. These
Using Environment Properties and Functions5-15The xPC Target Setup window has two sections:-xPC Target- xPC Target Embedded OptionIf your license does
5 Environment Reference5-16Changing Environment Properties with Command Line InterfacexPC Target lets you define and change different properties. Thes
Using Environment Properties and Functions5-17Creating a Target Boot Disk with Graphical InterfaceYou use the target boot disk to load and run the xPC
Kommentare zu diesen Handbüchern