xPC Target ® For Use with Real-Time Workshop User’s Guide Version 2
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.
Printing History: September 1999 November 2000 June 2001 September 2001 July 2002 June 2004 August 2004 October 2004 November 2004 March 2005 First printing Online only Online only Online only Online only Online only Online only Online only Online only Online only New for Version 1 (Release 11.1) Revised for Version 1.1 (Release 12) Revised for Version 1.2 (Release 12.1) Revised for Version 1.3 (Release 12.1+) Revised for Version 2 (Release 13) Revised for Version 2.5 (Release 14) Revised for Version 2.
Contents Target and Scope Objects 1 Target Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 What Is a Target Object? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 Scope Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 What Is a Scope Object? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 Targets and Scopes in the MATLAB Interface 2 Working with Target Objects . . . . . . . . . . . .
Signals and Parameters 3 Monitoring Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Signal Monitoring with xPC Target Explorer . . . . . . . . . . . . . . Signal Monitoring with MATLAB . . . . . . . . . . . . . . . . . . . . . . . . Monitoring Stateflow States . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 3-2 3-6 3-6 Signal Tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Signal Tracing with xPC Target Explorer . . . . . .
Embedded Option Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9 Updating the xPC Target Environment . . . . . . . . . . . . . . . . . . . 4-9 Creating a DOS System Disk . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11 DOSLoader Target Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Updating Environment Properties and Creating a Boot Disk Copying the Kernel to Flash Memory . . . . . . . . . . . . . . . . . . . .
Using the Target PC Command-Line Interface 6 Target PC Command-Line Interface . . . . . . . . . . . . . . . . . . . . Using Target Application Methods on the Target PC . . . . . . . . Manipulating Target Object Properties from the Target PC . . Manipulating Scope Objects from the Target PC . . . . . . . . . . . . Manipulating Scope Object Properties from the Target PC . . . Aliasing with Variable Commands on the Target PC . . . . . . . .
Graphical User Interfaces 8 xPC Target Interface Blocks to Simulink Models . . . . . . . . . 8-2 Simulink User Interface Model . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2 Creating a Custom Graphical Interface . . . . . . . . . . . . . . . . . . . 8-3 To xPC Target Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-5 From xPC Target Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6 Creating a Target Application Model . . . . . . . . . . . . . . .
xPC Target and Fortran 11 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Simulink Demos Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Steps to Incorporate Fortran in Simulink for xPC Target . . . . 11-2 11-2 11-3 11-3 Step-by-Step Example of Fortran and xPC Target . . . . . . . 11-5 Creating an xPC Target Atmosphere Model for Fortran . . . . .
Function Reference 14 Functions — Categorical List . . . . . . . . . . . . . . . . . . . . . . . . . Software Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Target Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Scope Objects . . . . . . . . . . . .
viii Contents
1 Target and Scope Objects Before you can work with xPC Target target and scope objects, you should understand the concept of target and scope objects. Target Objects (p. 1-2) Description of target objects Scope Objects (p.
1 Target and Scope Objects Target Objects xPC Target uses a target object (of class xpctarget.xpc) to represent the target kernel and your target application. Use target object functions to run and control real-time applications on the target PC with scope objects to collect signal data. See Chapter 14, “Function Reference,” for a reference of the target functions.
Scope Objects Scope Objects xPC Target uses scope objects to represent scopes on the target PC. Use scope object functions to view and collect signal data. See Chapter 14, “Function Reference,” for a reference of the scope functions. What Is a Scope Object? xPC Target uses scopes and scope objects as an alternative to using Simulink® scopes and external mode. A scope can exist as part of a Simulink model system or outside a model system. • A scope that is part of a Simulink model system is a scope block.
1 Target and Scope Objects A scope object on the host PC represents a scope on the target PC. You use scope objects to observe the signals from your target application during a real-time run or analyze the data after the run is finished. To create a scope object, • Add an xPC Target scope block to your Simulink model, build the model to create a scope, and then use the target object method getscope to create a scope object.
Scope Objects The xpcschost scope object of type host has the following object properties: • Data • StartTime • Time The xpcfs scope object of type file has the following object properties: • AutoRestart • Filename • Mode • StartTime • WriteSize The xpcsc scope object has the following object properties.
1 Target and Scope Objects 1-6
2 Targets and Scopes in the MATLAB Interface You can work with xPC Target target and scope objects through the MATLAB interface (MATLAB Command Window), the target PC command line, a Web browser, or an xPC Target API. This chapter describes how to use the MATLAB interface to work with the target and scope objects in the following topics. Working with Target Objects (p.
2 Targets and Scopes in the MATLAB Interface Working with Target Objects This topic describes how to work with target objects using target object functions.
Working with Target Objects To check a connection between a host and a target, use the target function targetping. For example, tg.targetping Note To ensure that you always know which target PC is associated with your target object, you should always use this method to create target objects. • To create a single target object, or to create the first of many targets in your system, use the target object constructor function xpctarget.xpc as follows. In the MATLAB Command Window, type tg = xpctarget.
2 Targets and Scopes in the MATLAB Interface 1 In the MATLAB window, type tg The current target application properties are uploaded to the host PC, and MATLAB displays a list of the target object properties with the updated values. Note that the target object properties for TimeLog, StateLog, OutputLog, and TETLog are not updated at this time. 2 Type +tg The Status property changes from stopped to running, and the log properties change to Acquiring.
Working with Target Objects To get a list of the writable properties, type set(target_object). The build process assigns the default name of the target object to tg. 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.
2 Targets and Scopes in the MATLAB Interface 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, you must enter method names 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.
Working with Scope Objects Working with Scope Objects This topic describes how to work with scope objects using scope object functions.
2 Targets and Scopes in the MATLAB Interface For a list of target object properties with a description, see the target function get (target object) on page 14-37. 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 Alternatively, type allscopes = getscope(tg) or type allscopes = tg.
Working with Scope Objects 2 Alternatively, you can type set(sc1,'triggermode', 'signal') or type sc1.set('triggermode', 'signal') Note that you cannot use dot notation to set vector object properties. To assign properties to a vector of scopes, use the set method.
2 Targets and Scopes in the MATLAB Interface 2 Alternatively, you can type beginrun = get(sc1,'starttime') or type sc1.get('starttime') Note that you cannot use dot notation to get the values of vector object properties. To get properties of a vector of scopes, use the get method. For example, assume you have two scopes, 1 and 2, assigned to the variable sc12.
Working with Scope Objects 1 In the MATLAB window, type allscopes(1).addsignal([0,1]) 2 Alternatively, you can type addsignal(allscopes(1), [0,1]) Acquiring Signal Data with Scopes of Type File You can acquire signal data into a file on the target PC. To do so, you add a scope of type file to the application. After you build an application and download it to the target PC, you can add a scope of type file to that application.
2 Targets and Scopes in the MATLAB Interface • Freerun — Starts to acquire data as soon as the scope is started (default) • Software — Starts to acquire data in response to a user request.
Working with Scope Objects • “Triggering One Scope with Another Scope to Acquire Data” on page 2-13 — Describes a configuration of one scope to trigger another using the concept of pre- and posttriggering • “Acquiring Gap-Free Data Using Two Scopes” on page 2-16 — Describes how to apply the concept of triggering one scope with another to acquire gap-free data Triggering One Scope with Another Scope to Acquire Data This section describes the concept of triggering one scope with another to acquire data.
2 Targets and Scopes in the MATLAB Interface • For Scope 2, set the following values: - sc(2).ScopeId = 2 sc(2).TriggerMode = 'Scope' sc(2).TriggerScope =1 sc(2).TriggerSample = range 0 to (N + P - 1) In the figures below, TP is the trigger point or sample where a trigger event occurs. Scope 1 begins acquiring data as described. In the simplest case, where P = 0, Scope 1 acquires data right away.
Working with Scope Objects Posttriggering (P>0) Scope 1 triggers Scope 2 after the trigger event occurs. The following describes some of the ways you can trigger Scope 2: • sc(2).TriggerSample = 0 — Causes Scope 2 to be triggered when Scope 1 is triggered. TP for both scopes as at the same sample. • sc(2).TriggerSample = n > 0 — Causes TP for Scope 2 to be n samples after TP for Scope 1. Note that setting sc(2).
2 Targets and Scopes in the MATLAB Interface Note The difference between setting TriggerSample = (N + P - 1), where N and P are the parameters of the triggering scope (Scope 1) and TriggerSample = -1 is that in the former case, the first sample of Scope 2 will be at the same time as the last sample of Scope 1, whereas in the latter, the first sample of Scope 2 will be one sample after the last sample of Scope 1.
Working with Scope Objects “Acquisition of Gap-Free Data” on page 2-17, illustrates how the scopes trigger one another. Acquisition of Gap-Free Data The following code is a typical example of how you can retrieve gap-free data. You can type this code into an m file and run that file for a downloaded target application. This example assumes that the communication speed and number of samples are fast enough to acquire the full data set before the next acquisition cycle is due to start.
2 Targets and Scopes in the MATLAB Interface sc(1).trigger; % Start things off by triggering scope 1 data = zeros(0, 2); t = []; scNum = 1; % We will look at scope 1 first % Use some appropriate condition instead of an infinite loop while(1) % loop until the scope has finished while ~strcmp(sc(scNum).Status, 'Finished'), end data(end + 1 : end + 500, :) = sc(scNum).Data; t( end + 1 : end + 500) = sc(scNum).
3 Signals and Parameters Changing parameters in your target application while it is running in real time, and checking the results by viewing signal data, are two important prototyping tasks. xPC Target includes command-line and graphical user interfaces to complete these tasks. This chapter includes the following sections: Monitoring Signals (p. 3-2) Acquire signal data while running a target application without time information Signal Tracing (p.
3 Signals and Parameters Monitoring Signals Signal monitoring is the process for acquiring signal data during a real-time run without time information. The advantage with signal monitoring is that there is no additional load on the real-time tasks. Use signal monitoring to acquire signal data without creating scopes that run on the target PC.
Monitoring Signals 2 In the Solver pane, change the Stop time parameter to inf (infinity). 3 To get the list of signals in the target application, expand the target application node, then expand the Model Hierarchy node under the target application node. The model hierarchy expands to show the Simulink objects (signals and parameters) in the Simulink model.
3 Signals and Parameters Target PC file system drives Application node Parameters Signals The Model Hierarchy node can have up to three types of nodes: subsystems ( ) (including their signals and parameters), parameters ( ), and signals ( ). Only xPC Target tunable parameters and signals of the application, as represented in the Simulink model, appear in the Model Hierarchy node. This example currently has only parameters and signals.
Monitoring Signals 4 To get the value of a signal, select the signal in the Model Hierarchy node. The value of the signal is shown in the right pane. For example, 5 Right-click the target application and select Start. The application starts running.
3 Signals and Parameters Signal Monitoring with MATLAB This procedure uses the model xpc_osc3.mdl as an example, and assumes you created and downloaded the target application to the target PC. It also assumes that you have assigned tg to the appropriate target PC. 1 To get a list of signals, type either set(tg, 'ShowSignals', 'On') or tg.ShowSignals='On' The latter command causes the MATLAB window to display a list of the target object properties for the available signals.
Monitoring Signals 3 Click the Real-Time Workshop® node. The Real-Time Workshop pane opens. 4 To build a basic target application, in the Target selection section, click the Browse button at the RTW system target file list. Click xpctarget.tlc, and then click OK. 5 As necessary, you can click the xPC Target options node and continue to make changes. 6 When you are done, click OK. 7 In the sf_car model, double-click the shift_logic chart. The shift_logic chart is displayed.
3 Signals and Parameters 8 In the chart, select Tools -> Explore. The Model Explorer is displayed. 9 In the Model Explorer, expand sf_car. 10 Expand gear_state, then select first. 11 In the rightmost pane, State first, select the Test point check box. This creates a test point for the first state. 12 Click Apply. 13 Build and download the sf_car target application to the target PC. You can now view the states with the xPC Target Explorer or MATLAB.
Monitoring Signals 3 Choose the state as you do a signal to monitor. Monitoring Stateflow States with MATLAB This topic assumes that you have already test-pointed Stateflow states (see “Monitoring Stateflow States” on page 3-6 if you have not). 1 To get a list of signals in the MATLAB Command Window, type tg=xpc 2 To display the signals in the target application, type either set(tg, 'ShowSignals', 'On'); tg or tg.
3 Signals and Parameters For test pointed Stateflow states, the state appears in the BLOCK NAME column like any signal. For example, if you set a test point for the first state of gear_state in the shift_logic chart of the sf_car model. The state of interest is first. This state appears as follows in the list of signals in MATLAB: shift_logic:gear_state.first shift_logic is the path to the Stateflow chart and gear_state.first is the path to the specific state.
Signal Tracing Signal Tracing Signal tracing is the process of acquiring and visualizing signals while running a target application. In its most basic sense, signal tracing allows you to acquire signal data and visualize it on the target PC or upload the signal data and visualize it on the host PC while the target application is running.
3 Signals and Parameters Creating Scopes 1 In xPC Target Explorer, ensure that your xpcosc application is still running. 2 To get the list of signals in the target application, expand the Model Hierarchy node under the target application. The model hierarchy expands to show the elements in the Simulink model. 3 To get the list of scope types you can have in the target application, expand the xPC Scopes node below the application node.
Signal Tracing 4 To create a scope to display on the target PC, right-click the Target Scopes node under the xPC Scopes node. A context menu appears. This lists the actions you can perform on target PC scopes. For example, within the current context, you can create a target PC scope. 5 Select Add Target Scope. A scope node appears under Target Scopes. In this example, the new scope is labeled Scope 1.
3 Signals and Parameters 6 To create a scope to be displayed on the host PC, right-click the Host Scopes node under the xPC Scopes node. A context menu appears. This lists the actions you can perform on host PC scopes. For example, within the current context, you can create a host PC scope. 7 Select Add Host Scope. A scope node appears under Host Scopes. In this example, the new scope is labeled as Scope 2. 8 To visualize the host scope on the host PC, right-click Host Scopes from the xPC Scopes node.
Signal Tracing 10 To list the properties of the scope object Scope 2, select the xPC Target Explorer tab to return to that window, and left-click Scope 2. (Note that you can configure the docking view using the MATLAB docking feature.) The scope properties are shown in the rightmost pane. 11 To create a scope to acquire signal data into a file on the target PC file system, in the xPC Target Hierarchy pane, select the target PC drive and subdirectory in which you create the file for the signal data.
3 Signals and Parameters 12 Right-click the File Scopes node under the xPC Scopes node. A scope node appears under File Scopes. In this example, the new scope is labeled Scope 3. You next task is to add signals to the scopes. The following procedure assumes that you have added scopes to the target PC and host PC. Adding Signals to Scopes 1 In the xPC Target Explorer window, add signals to the target PC scope, Scope 1.
Signal Tracing 3 Start the scope. For example, to start Scope 1, right-click it and select Start. The target screen plots the signals after collecting each data package. During this time you can observe the behavior of the signals while the scope is running. 4 Add signals to the host PC scope. For example, to add signals Integrator1 and Signal Generator, right-click each signal and select Add to Scopes. From the Add to Scopes list, select Scope 2. The Scope 2 node is shown with a plus sign.
3 Signals and Parameters 5 Expand the Scope 2 node. The Scope 2 signals are displayed. 6 Start the scope. For example, to start the scope Scope 2, right-click Scope 2 in the Host Scopes node of the xPC Target Explorer and select Start. The xPC Target Host Scope Viewer window plots the signals after collecting each data package. During this time you can observe the behavior of the signals while the scope is running.
Signal Tracing 7 Add signals to the scope of type file. For example, to add signals Integrator1 and Signal Generator, right-click each signal and select Add to Scopes. From the Add to Scopes list, select Scope 3. The Scope 3 node is shown with a plus sign. 8 Expand the Scope 3 node. The Scope 3 signals are displayed.
3 Signals and Parameters 9 To specify a filename for the data file, select the scope of type file. In the right pane, enter a name in the Filename parameter. While in the parameter field, press Enter to save the filename. Note that there is no name initially assigned. If you do not specify a filename, then after you start the scope, xPC Target assigns a name for the target PC file to acquire the signal data.
Signal Tracing If you have scopes of type file, you can copy the file that contains the signal data from the target PC to the host PC. See “Copying Files to the Host PC” on page 3-24. Software Triggering Scopes You can set up a scope such that only a user can trigger the scope. This section assumes that you have added a scope to your target application (see “Creating Scopes” on page 3-12) and that you have added signals to that scope (“Adding Signals to Scopes” on page 3-16).
3 Signals and Parameters 3 Start the scope and target application. 4 Right-click the scope to be triggered. For example, select Scope 1. 5 Select Trigger.
Signal Tracing Configuring the Host Scope Viewer You can customize your host scope viewer. This section assumes that you have added a host scope to your target application, started the host scope viewer, and added signals Integrator1 and Signal Generator (see “Creating Scopes” on page 3-12 and “Adding Signals to Scopes” on page 3-16). These viewer settings are per scope. • In the xPC Target Host Scope Viewer, right-click anywhere in the axis area of the viewer. A context menu is displayed.
3 Signals and Parameters Copying Files to the Host PC From xPC Target Explorer, you can download target PC files from the target PC to the host PC. This is most useful when you want to examine the data from the scope data file. 1 In xPC Target Explorer, expand the target PC node associated with the target PC file system you want to access. For example, expand TargetPC1. 2 Under TargetPC1, expand the File System node. Nodes representing the drives on the target PC are displayed.
Signal Tracing A file Save As dialog is displayed. 7 Choose the directory to contain the signal data file. If you want, you can also save the file under a different name. xPC Target Explorer copies the contents of the selected file, for example SC1INTEG.DAT, to the selected directory. You can examine the contents of the signal data file. See “Retrieving a File from the Target PC to the Host PC” on page 7-7 in Chapter 7, “Working with Target PC Files and File Systems.
3 Signals and Parameters Signal Tracing with MATLAB Creating a scope object allows you to select and view signals using the scope methods. This section describes how to trace signals using xPC Target functions instead of using the xPC Target graphical user interface. This procedure assumes that you have assigned tg to the appropriate target PC. After you create and download the target application, you can view output signals.
Signal Tracing ShowSignals = on Signals = INDEX 0 1 2 3 4 5 6 VALUE 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 BLOCK NAME Integrator1 Signal Generator Gain Integrator Gain1 Gain2 Sum For more information, see “Signal Monitoring with MATLAB” on page 3-6. 3 Create a scope to be displayed on the target PC. For example, to create a scope with an identifier of 1 and a scope object name of sc1, type sc1=tg.
3 Signals and Parameters YLimit Grid Signals = Auto = On = no Signals defined 5 Add signals to the scope object. For example, to add Integrator1 and Signal Generator, type sc1.addsignal ([0,1]) or addsignal(sc1,[0,1]) The target PC displays the following messages. Scope: 1, signal 0 added Scope: 1, signal 1 added After you add signals to a scope object, the signals are not shown on the target screen until you start the scope. 6 Start the scope.
Signal Tracing Signal Tracing with MATLAB and Scopes of Type File This procedure uses the Simulink model xpcosc.mdl as an example, and assumes you have built the target application for this model. It also assumes that you have a serial communication connection. This topic describes how to trace signals with scopes of type file. Note The signal data file can quickly increase in size. You should examine the file size between runs to gauge the growth rate for the file.
3 Signals and Parameters 3 Start running your target application. Type +tg or tg.start or start(tg) The target PC displays the following message: System: execution started (sample time: 0.0000250) 4 Create a scope to be displayed on the target PC. For example, to create a scope with an identifier of 2 and a scope object name of sc2, type sc2=tg.addscope('file', 2) or sc2=addscope(tg, 'file', 2) 5 List the properties of the scope object.
Signal Tracing Mode WriteSize AutoRestart = Lazy = 512 = off Note that there is no name initially assigned to FileName. After you start the scope, xPC Target assigns a name for the file to acquire the signal data. This name typically consists of the scope object name, ScopeId, and the beginning letters of the first signal added to the scope. 6 Add signals to the scope object. For example, to add Integrator1 and Signal Generator, type sc2.
3 Signals and Parameters TriggerScope TriggerSample TriggerSignal TriggerLevel TriggerSlope StartTime Signals = = = = = = = StartTime FileName Mode WriteSize AutoRestart = = = = = 2 0 0 0.000000 Either NaN 0 : Integrator1 1 : Signal Generator NaN c:\sc2Integ.dat Lazy 512 off 8 Stop the scope. Type -sc2 or sc2.stop or stop(sc2) The signals shown on the target PC stop updating while the target application continues running, and the target PC displays the following message. FileSys:File c:\sc2Integ.
Signal Tracing Signal Tracing with xPC Target Scope Blocks Use scopes of type host to log signal data triggered by an event while your target application is running. This topic describes how to use the three scope block types. Note xPC Target supports ten scopes of type target and host, and eight scopes of type file, for a maximum of 28 scopes. Scope of Type Host For a scope of type host, the scope acquires the first N samples into a buffer. You can retrieve this buffer into the scope object property sc.
3 Signals and Parameters Scope of Type File For a scope of type file, the scope acquires data and writes it to the file named in the FileName parameter in blocks of size WriteSize. The scope acquires the first N samples into the memory buffer. This memory buffer is of length Number of Samples. The memory buffer writes data to the file in WriteSize chunks. If the AutoRestart check box is selected, the scope then starts over again, overwriting the memory buffer.
Signal Tracing 3 Click the Edit button. The scope editing pane opens. From this pane, you can edit the properties of any scope, and control the scope. 4 Click the Add Signals button. The browser displays an Add New Signals list. 5 Select the check boxes next to the signal names, and then click the Apply button. A Remove Existing Signals list is added above the Add New Signals list. You do not have to stop a scope to make changes.
3 Signals and Parameters Signal Logging Signal logging is the process for acquiring signal data during a real-time run, stopping the target application, and then transferring the data to the host PC for analysis. You can plot and analyze the data, and later save it to a disk. xPC Target signal logging samples at the base sample time. If you have a model with multiple sample rates, add xPC Target scopes to the model to ensure that signals are sampled at their appropriate sample rates.
Signal Logging 1 In xPC Target Explorer, select the downloaded target application node. For example, xpc_osc4. The right pane displays the target application properties dialog for xpc_osc4. 2 In the Logging pane, select the boxes of the signals you are interested in logging. For example, select Output and TET. 3 Start the target application. For example, in the Target Hierarchy pane, select the xpc_osc4 target application, then select Start. 4 Stop the target application.
3 Signals and Parameters 5 Send the selected logged data to the MATLAB workspace. In the target application properties dialog for xpc_osc4, go to the Logging pane and click the Send to MATLAB Workspace button. In the MATLAB desktop, the Workspace pane displays the logged data. You can examine or otherwise manipulate the data.
Signal Logging All scopes copy the last N samples from the log buffer to the target object logs (tg.TimeLog, tg.OutputLog, tg.StateLog, and tg.TETLog). xPC Target calculates the number of samples N for a signal as the value of Signal logging buffer size in doubles divided by the number of logged signals (1 time, 1 task execution time (TET), outputs, states). After you run a target application, you can plot the state and output signals. This procedure uses the Simulink model xpc_osc3.
3 Signals and Parameters 3-40
Signal Logging 3 In the MATLAB window, type plot(tg.TimeLog,tg.TETLog) Values for the task execution time (TET) log are uploaded to the host PC from the target PC. If you want to upload part of the logs, see the target object method getlog on page 14-44. The plot shown below is the result of a real-time run. The TET is the time to calculate the signal values for the model during each sample interval.
3 Signals and Parameters 4 In the MATLAB window, type either tg.AvgTET or get(tg,'AvgTET') MATLAB displays the following information about the average task execution time. ans = 5.7528e-006 The percentage of CPU performance is the average TET divided by the sample time. Signal Logging with a Web Browser When you stop the model execution, another section of the Web browser interface appears that enables you to download logging data. This data is in comma-separated value (CSV) format.
Parameter Tuning and Inlining Parameters Parameter Tuning and Inlining Parameters By default, xPC Target lets you change parameters in your target application while it is running in real time. You can also improve overall efficiency by inlining parameters. xPC Target supports the Real-Time Workshop inline parameters functionality (see the using Real-Time Workshop documentation for further details on inlined parameters). By default, this functionality makes all parameters nontunable.
3 Signals and Parameters Parameter Tuning with xPC Target Explorer xPC Target lets you change parameters in your target application while it is running in real time. With these functions you do not need to set Simulink to external mode, and you do not need to connect Simulink with the target application. You can download parameters to the target application while it is running or between runs. This feature lets you change parameters in your target application without rebuilding the Simulink model.
Parameter Tuning and Inlining Parameters Parameters Signals The model hierarchy only shows blocks that have tunable parameters. 4 Select the parameter of the signal you want to edit. For example, select Gain. The right pane displays the block parameters dialog for Gain. There is one parameter, Gain, for this block. The current value of the Gain parameter is displayed. 5 Double-click the box that contains the gain value. The box becomes editable. 6 Enter a new value for the gain. 7 Press the Enter key.
3 Signals and Parameters Updated gain value If there is a scope, the plot frame then updates the signals after running the simulation with the new parameter value. 8 Stop the target application. For example, to stop the target application xpcosc, right-click it and select Stop. The target application on the target PC stops running.
Parameter Tuning and Inlining Parameters Parameter Tuning with MATLAB You use the MATLAB functions to change block parameters. With these functions you do not need to set Simulink to external mode, and you do not need to connect Simulink with the target application. You can download parameters to the target application while it is running or between runs. This feature lets you change parameters in your target application without rebuilding the Simulink model.
3 Signals and Parameters Parameters = INDEX VALUE TYPE SIZE PARAMETER NAME BLOCK NAME 0 0 DOUBLE Scalar Initial Condition Integrator1 1 4 DOUBLE Scalar Amplitude Signal Generator 2 20 DOUBLE Scalar Frequency Signal Generator 3 1000000 DOUBLE Scalar Gain Gain 4 0 DOUBLE Scalar Initial Condition Integrator 5 400 DOUBLE Scalar Gain Gain1 6 1000000 DOUBLE Scalar Gain Gain2 3 Change the gain. For example, to change the Gain1 block, type either tg.
Parameter Tuning and Inlining Parameters 4 Stop the target application. In the MATLAB window, type -tg or tg.stop or stop(tg) The target application on the target PC stops running, and the target PC displays the messages like the following: System: execution stopped minimal TET: 0.000023 at time 1313.789000 maximal TET: 0.000034 at time 407.956000 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.
3 Signals and Parameters 2 To reset to the previous values, type setparam(tg,pt.parIndexVec,pt.OldValues) ans = parIndexVec: 5 OldValues: 800 NewValues: 100 Parameter Tuning with Simulink External Mode You use Simulink external mode to connect your Simulink block diagram to your target application. The block diagram becomes a graphical user interface to your target application.
Parameter Tuning and Inlining Parameters 2 In the Simulink block window, and from the Simulation menu, click Connect to target. All of the current Simulink model parameters are downloaded to your target application. This downloading guarantees the consistency of the parameters between the host model and the target application.
3 Signals and Parameters 5 In the Gain text box, enter 800 and click OK. As soon as you change a model parameter and click OK, or you click the Apply button on the Block Parameters: Gain1 dialog box, all the changed parameters in the model are downloaded to the target application, as shown below. 6 From the Simulation menu, click Disconnect from Target. The Simulink model is disconnected from the target application.
Parameter Tuning and Inlining Parameters Parameter Tuning with a Web Browser The Parameters pane 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 browser loads the Parameter List pane into the right frame.
3 Signals and Parameters • You have parameters you would like to save for reuse. See - “Parameter Tuning with MATLAB” on page 3-47 - “Parameter Tuning with Simulink External Mode” on page 3-50 - “Parameter Tuning with a Web Browser” on page 3-53 Saving the Current Set of Target Application Parameters To save a set of parameters to a target application, use the saveparamset method. The target application can be stopped or running. 1 Identify the set of parameter values you want to save.
Parameter Tuning and Inlining Parameters 2 In the MATLAB window, type either tg.loadparamset('xpc_osc4_param1') or loadparamset(tg,'xpc_osc4_param1') xPC Target loads the parameter values into the target application. For a description of how to list the parameters and values stored in the parameter file, see “Listing the Values of the Parameters Stored in a File” on page 3-55.
3 Signals and Parameters Inlined Parameters This procedure describes how you can globally inline parameters for a model, then specify which of these parameters you still want to be tunable. It assumes that you are familiar with how to build target applications (if you are not, read the xPC Target getting started documentation first). After you have performed this procedure, you will able to tune these parameters.
Parameter Tuning and Inlining Parameters 8 Click the Configure button. The Model Parameter Configuration dialog is displayed. Note that the MATLAB workspace contains the constant you assigned to A. 9 Select the line that contains your constant and click Add to table. The Model Parameters Configuration dialog appears as follows. If you have more global parameters you want to be able to tune, add them also. 10 If you want, increase the model stop time, or set it to inf.
3 Signals and Parameters 12 Build and download the model to your target PC. You can next use xPC Target Explorer or MATLAB to work with the tunable parameters. Tuning Inlined Parameters with xPC Target Explorer This procedure describes how you can tune inlined parameters through the xPC Target Explorer. It assumes that you have built and downloaded the model from the topic “Inlined Parameters” on page 3-56 to the target PC. It also assumes that the model is running.
Parameter Tuning and Inlining Parameters 5 Enter a new value for the parameter. 6 Press the Enter key. The box is updated and the Update Parameter button becomes active. 7 To apply the new value, press the Update Parameter button. 8 To verify the updated value, select the signal object associated with A. For example, select Signal Generator. The value of Signal Generator is shown in the right pane.
3 Signals and Parameters 9 Stop the target application. Tuning Inlined Parameters with MATLAB This procedure describes how you can tune inlined parameters through MATLAB. It assumes that you have built and downloaded the model from the topic “Inlined Parameters” on page 3-56 to the target PC. It also assumes that the model is running. You can tune inline parameters using a parameter ID similar to the way that you use conventional parameters.
Parameter Tuning and Inlining Parameters 1 Save the following code in an M-file. For example, change_inlineA, tg=xpc; %Create xPC Target object pid=tg.getparamid('','A'); %Get parameter ID of A if isempty(pid) %Check value of pid. error('Could not find A'); end tg.setparam(pid,100); %If pid is valid, set parameter value. 2 Execute that M-file. For example, type change_inlineA 3 To see the new parameter value, type tg.
3 Signals and Parameters 3-62
4 Embedded Option The xPC Target Embedded Option allows you to boot the target PC from a device other than a 3.5 inch disk drive, such as a hard disk or flash memory. It also allows you to deploy stand-alone applications on the target PC independent of the host PC. This chapter includes the following sections: Introduction (p. 4-2) Learn about the different types of embedded target applications you can create using the xPC Target Embedded Option xPC Target Embedded Option Modes (p.
4 Embedded Option Introduction The xPC Target Embedded Option allows you to boot the xPC Target kernel from a 3.5 inch disk drive and other devices, including a flash disk or a hard disk drive. By using the xPC Target Embedded Option, you can configure a target PC to automatically start execution of your embedded application for continuous operation each time the system is booted. You can use this capability to deploy your own real-time applications on target PC hardware.
xPC Target Embedded Option Modes xPC Target Embedded Option Modes The xPC Target Embedded Option extends the xPC Target base product with two modes: • DOSLoader — Use this mode of operation to start the kernel on the target PC from a 3.5 inch disk, flash disk, or a hard disk. After the target PC boots with the kernel, it waits for the host computer to download a real-time application. You can control the target application from either the host PC or the target PC.
4 Embedded Option The following are some instances where you might want to use the xPC Target Embedded Option. You might have one of these situations if you deploy the target PC in a small or rugged environment. • Target PC does not have a 3.5 inch disk drive. • The Target PC 3.5 inch disk drive must be removed after setting up the target system.
xPC Target Embedded Option Modes - autoexec.bat — xPC Target version of this file that calls the xpcboot.com executable to boot the xPC Target kernel. - checksum.dat — xPC Target version of this file that optimizes boot disk creation. - *.rtb — This file contains the xPC Target kernel. It also contains, as applicable, specifications such as serial or TCP/IP communications and the IP address of the target PC. - xpcboot.com — Contains the xPC Target boot executable.
4 Embedded Option StandAlone Mode Overview The primary purpose of the StandAlone mode is to allow you to use a target PC as a stand-alone system. StandAlone mode enables you to deploy control systems, DSP applications, and other systems on PC hardware for use in production applications using PC hardware. Typically these production applications are found in systems where production quantities are low to moderate. The following summarizes the sequence of events for StandAlone mode.
xPC Target Embedded Option Modes - xpcboot.com — Contains the xPC Target boot executable. This file executes an xPC Target application and executes the *.rtb file. - autoexec.bat — xPC Target version of this file that calls the xpcboot.com executable to boot the xPC Target kernel. 8 Move the boot disk to the target PC. 9 Set up the target PC boot device such as a 3.5 inch disk, flash disk, or a hard disk drive. Transfer the contents of the boot disk to the target PC boot device. 10 Boot the target PC.
4 Embedded Option Restrictions The following restrictions apply to the booted DOS environment when you use xpcboot.com to execute the target applications: • The CPU must execute in real-time mode. • While loaded in memory, the DOS partition must not overlap the address range of a target application. To satisfy these restrictions, • Do not use additional memory managers like emm386 or qemm. • Avoid any utilities that attempt to load in high memory (for example, himem.sys).
Embedded Option Setup Embedded Option Setup This section includes the following topics: • “Updating the xPC Target Environment” on page 4-9 • “Creating a DOS System Disk” on page 4-11 Updating the xPC Target Environment After the xPC Target Embedded Option software has been correctly installed, the xPC Target environment, visible through xpcexplr or getxpcenv, contains two additional property choices for DOSLoader or StandAlone, in addition to the default BootDisk that you normally use with xPC Target.
4 Embedded Option The default setting for the option Target boot mode is BootFloppy. When you are using BootFloppy, xPC Target must first create a target boot disk, which is then used to boot the target PC. The option 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.
Embedded Option Setup For more detailed information about how to use the xPC Target Explorer window, see “xPC Target Explorer” in Chapter 2 in the xPC Target getting starting documentation. Creating a DOS System Disk When using DOSLoader mode or StandAlone mode, you must first boot your target PC with DOS. These modes can be used from any boot device including flash disk, 3.5 inch disk drive, or a hard disk drive.
4 Embedded Option DOSLoader Target Setup DOSLoader mode allows you to copy the xPC Target kernel to the target flash disk, remove the 3.5 inch disk drive, and then boot the xPC Target kernel. Alternatively, you can also boot the xPC Target kernel from the target PC 3.5 inch disk drive. The target application is still downloaded from the host PC. Use this mode for applications where an xPC Target host is not easily accessible.
DOSLoader Target Setup 5 Click Create BootDisk. A message box opens with the following message. Insert a formatted floppy disk into your host PC disk drive and click OK to continue. 6 Insert a 3.5 inch disk, and then click OK. The files checksum.dat, xpcsgo1.rtb (serial) or xpctgo1.rtb (TCP/IP), xpcboot.com, and autoexec.bat are copied to the disk. With DOSLoader mode, the correct *.rtb file is added to the DOS disk according to the options specified in the following table.
4 Embedded Option c Reboot the target PC. The DOS is booted from the target boot disk and the autoexec.bat files, resulting in the automatic execution of the xPC Target loader. From this point onward, the CPU runs in protected mode and DOS is discarded. Otherwise, if you want to boot the target PC from flash memory instead of the 3.5 inch disk, see “Copying the Kernel to Flash Memory” on page 4-14 for a description of how to copy the kernel to flash memory.
DOSLoader Target Setup 4 Type copy A:\xpcsgo1.rtb C:\work copy A:\xpcboot.com C:\work copy A:\autoexec.bat C:\work 5 If you want the kernel to run when you press the Reset button on your target PC, save a copy of the file C:\autoexec.bat to a backup file, such as C:\autoexec_back.wrk. 6 Edit the file C:\autoexec.bat to include the following lines. Adding these commands to C:\autoexec.bat directs the system to execute the autoexec.bat file located in C:\work.
4 Embedded Option Creating a Target Application for DOSLoader Mode For DOSLoader mode, a target application is created on a host PC and downloaded to your target PC. After you set the Simulink and Real-Time Workshop® parameters for code generation with xPC Target in your Simulink model, you can use xPC Target with DOSLoader mode to create a target application. 1 In the MATLAB window, type the name of a Simulink model. For example, type xpc_osc3 A Simulink window opens with the model.
Stand-Alone Target Setup Stand-Alone Target Setup StandAlone mode combines the target application with the kernel and boots them together on the target PC from flash memory (or alternatively, the target PC 3.5 inch disk drive). The host PC does not need to be connected to the target PC. This section includes the following topics: • “Updating Environment Properties” on page 4-17 — Select StandAlone mode in the xPC Target Explorer window.
4 Embedded Option 5 From the Target boot mode list, choose StandAlone. xPC Target updates the environment properties, and the build process is ready to create a stand-alone kernel/target application. For StandAlone mode, you do not create an xPC Target boot disk. Instead, you copy files created from the build process onto a formatted 3.5 inch disk.
Stand-Alone Target Setup 2 Edit the Scope (xPC) dialog box and confirm that the check box entry for Start scope when application starts is selected, as shown in the following dialog box.
4 Embedded Option This setting is required to enable target scopes to begin operating as soon as the application starts running. This setting is important because the host PC is not available in StandAlone mode to issue a command to start scopes. 3 Ensure that the Scope type field is Target or File. 4 Save the model. Your next task is to create a kernel/target application. See “Creating a Kernel/Target Application” on page 4-21.
Stand-Alone Target Setup Creating a Kernel/Target Application Use xPC Target with StandAlone mode to create a combined kernel and target application with utility files. A combined kernel and target application allows you to disconnect your target PC from a host PC and run stand-alone applications.
4 Embedded Option c Reboot the target PC. DOS is booted from the target boot disk and the autoexec.bat files, resulting in the automatic execution of the xPC Target loader. From this point onward, the CPU runs in protected mode and DOS is discarded. If you want to boot the target PC from flash memory instead of the 3.5 inch disk, see “Copying the Kernel to Flash Memory” on page 4-14 for a description of how to copy the kernel to flash memory.
Stand-Alone Target Setup 6 Edit the file C:\autoexec.bat to include the following lines. Adding these commands to C:\autoexec.bat directs the system to execute the autoexec.bat file located in C:\work. cd C:\work autoexec Note Do not confuse C:\work\autoexec.bat with C:\autoexec.bat. The file C:\work\autoexec.bat includes the command xpcboot.com to start the xPC Target kernel and stand-alone application. The file C:\autoexec.bat includes the files you want the system to execute when the system starts up.
4 Embedded Option 4-24
5 Software Environment and Demos The xPC Target environment defines the connections and communication between the host and target computers. It also defines the build process for a real-time application. You can define the xPC Target environment through either the MATLAB interface or the xPC Target GUI environment. xPC Target provides a number of demos that help you understand the product. Using Environment Properties and Functions (p.
5 Software Environment and Demos Using Environment Properties and Functions Use the xPC Target Explorer window or the MATLAB Command Window to enter environment properties that are independent of your model.
Using Environment Properties and Functions Changing Environment Properties with xPC Target Explorer 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.
5 Software Environment and Demos This pane contains all the objects in your xPC Target hierarchy. As you add objects to your system, xPC Target Explorer adds their corresponding nodes to the xPC Target Hierarchy pane. The most important node is the HostPC node. It represents the host PC. The most important node is the TargetPC node.
Using Environment Properties and Functions Note In general, the default values of these parameters are sufficient for you to use xPC Target. 1 In the xPC Target Explorer, expand a target PC node. A Configuration node appears. Under this are nodes for Communication, Settings, and Appearance. The parameters for the target PC node are grouped in these categories. 2 Select Settings. The Settings Component pane appears to the right.
5 Software Environment and Demos 7 From the Target scope list, select either Enabled or Disabled. The property Target scope is set by default to Enabled. If you set Target scope to Disabled, the target PC displays information as text. To use all the features of the target scope, you also need to install a keyboard and mouse on the target PC. 8 Set the Target scope property to Enabled. 9 Target mouse allows you to disable or enable mouse support on the target PC.
Using Environment Properties and Functions 2 In the MATLAB window, type updatexpcenv The environment properties you changed with the function setxpcenv become the current values.
5 Software Environment and Demos xPC Target Demos The xPC Target demos are used to demonstrate the features of xPC Target. But they are also M-file scripts that you can view to understand how to write your own scripts for creating and testing target applications.
6 Using the Target PC Command-Line Interface You can interact with the xPC Target environment through the target PC command window. xPC Target provides a limited set of commands that you can use to work with the target application after it has been loaded to the target PC, and to interface with the scopes for that application. Target PC Command-Line Interface (p.
6 Using the Target PC Command-Line Interface Target PC Command-Line Interface This interface is useful with stand-alone applications that are not connected to the host PC. You can type commands directly from a keyboard on the target PC. As you start to type at the keyboard, a command window appears on the target PC screen.
Target PC Command-Line Interface Once the command window is active, you do not have to reactivate it before typing the next command. Manipulating Target Object Properties from the Target PC xPC Target uses a target object to represent the target kernel and your target application. This section shows some of the common tasks that you use with target objects and their properties.
6 Using the Target PC Command-Line Interface The command window displays a message to indicate that the new parameter has registered. System: S0 has value 5.1851 5 Change the stop time. For example, to set the stop time to 1000, type stoptime = 1000 The parameter changes are made to the target application but not to the target object. When you type any xPC Target command in the MATLAB Command Window, the target PC returns the current properties of the target object.
Target PC Command-Line Interface 2 Type a scope command. For example, to add a target scope (scope 2) in the model xpcosc, type addscope 2 xPC Target adds another scope monitor to the target PC screen. The command window displays a message to indicate that the new scope has registered. Scope: 2, created, type is target S0 3 Type a scope command. For example, to add a signal (0) to the new scope, type addsignal 2=0 The command window displays a message to indicate that the new parameter has registered.
6 Using the Target PC Command-Line Interface Manipulating Scope Object Properties from the Target PC This section shows some of the common tasks that you use with target objects and their properties. These commands create a temporary difference between the behavior of the target application and the properties of the target object. The next time you access the target object, the properties are updated from the target PC.
Target PC Command-Line Interface 2 Type the variable name to run that command sequence. For example, to turn the motor on, type on The parameter P7 is changed to 1, and the motor turns on.
6 Using the Target PC Command-Line Interface 6-8
7 Working with Target PC Files and File Systems xPC Target scopes of type file create files on the target PC. To work with these files from the host PC, you need to work with the xpctarget.ftp and xpctarget.fs objects. The xpctarget.ftp object allows you to perform basic file transfer operations on the target PC file system. The xpctarget.fs object allows you to perform file system-like operations on the target PC file system. This chapter contains the following topics: Introduction (p.
7 Working with Target PC Files and File Systems Introduction The xPC Target scope object of type file always writes acquired signal data to a file on the target PC. You cannot direct the scope to write the data to a file on the xPC Target host PC. Once xPC Target has written the signal data file to the target PC, you can access the contents of the file for plotting or other inspection from the host PC. xPC Target can write data files to • The C:\ or D:\ drive of the target PC.
Introduction This chapter describes procedures on how to use the xpctarget.ftp and xpctarget.fs methods for common operations. See Chapter 14, “Function Reference,” for a reference of the methods for these objects. Note This section focuses primarily on working with the target PC data files that you generate from an xPC Target scope object of type file.
7 Working with Target PC Files and File Systems FTP and File System Objects xPC Target uses two objects, xpctarget.ftp and xpctarget.fs (file system), to work with files on a target PC. You use the xpctarget.ftp object to perform file transfer operations between the host and target PC. You use the xpctarget.fs object to access the target PC file system. For example, you can use an xpctarget.fs object to open, read, and close a signal data file created by an xPC Target scope of type file.
Using xpctarget.ftp Objects Using xpctarget.ftp Objects The xpctarget.ftp object enables you to work with any file on the target PC, including the data file that you generate from an xPC Target scope object of type file. The xpctarget.
7 Working with Target PC Files and File Systems For example, to list the name of the current directory of a target PC through a TCP/IP connection, 1 In the MATLAB window, type a command like the following to assign the xpctarget.ftp object to a variable. f=xpctarget.ftp('TCPIP','192.168.0.1','22222'); 2 Type f.pwd; Alternatively, you can use the xpctarget.xpc constructor to first construct a target object, then use that target object as an argument to xpctarget.ftp.
Using xpctarget.ftp Objects Note You must use the dir(f) syntax to list the contents of the directory. To get the results in an M-by-1 structure, use a syntax like y=dir(f). See the dir method reference for further details. For example, to list the contents of the C:\ drive, 1 In the MATLAB window, type the following to assign the xpctarget.ftp object to a variable: f=xpctarget.ftp; 2 Type f.pwd This gets the current directory.
7 Working with Target PC Files and File Systems 2 Type f.get('data.dat'); This retrieves the file and saves that file to the variable data. This content is in the xPC Target file format. Copying a File from the Host PC to the Target PC You can place a copy of a file from the host PC by using xPC Target methods on the host PC for the xpctarget.ftp object. Use the method syntax to run an xpctarget.ftp object method. The syntax method_name(ftp_object, argument_list) can be replaced with ftp_object.
Using xpctarget.fs Objects Using xpctarget.fs Objects The fs object enables you to work with the target PC file system.
7 Working with Target PC Files and File Systems • “Getting Information about a File on the Target PC” on page 7-15 • “Getting Information about a Disk on the Target PC” on page 7-15 xPC Target also provides methods that allow you to perform file transfer operations, such as putting files on and getting files from a target PC. For a description of these methods, see “Using xpctarget.ftp Objects” on page 7-5.
Using xpctarget.fs Objects 1 In the MATLAB window, type a command like the following to assign the xpctarget.fs object to a variable. fsys=xpctarget.fs; xPC Target assigns the fsys variable to the default target PC. 2 Type fsys.dir; Retrieving the Contents of a File from the Target PC to the Host PC You can retrieve the contents of a data file from the target PC by using xPC Target methods on the host PC for the xpctarget.fs object. Use the method syntax to run an xpctarget.fs object method.
7 Working with Target PC Files and File Systems data2=fread(fsys,h); This reads the file data.dat and stores the contents of the file to data2. This content is in the xPC Target file format. 4 Type fsys.fclose(h); This closes the file data.dat. Before you can view or plot the contents of this file, you must convert the contents. See “Converting xPC Target File Format Content to Bytes” on page 7-12.
Using xpctarget.fs Objects If you are using xPC Target in StandAlone mode, you can extract the data from the data file if you know the number of signals in the scope. If you know this number, you can extract the data. Note the following: • Ignore the first 512 bytes of the file. This is file header information. • After the first 512 bytes, the file stores the signals sequentially as doubles. For example, assume the scope has three signals, x, y, and z.
7 Working with Target PC Files and File Systems Getting a List of Open Files on the Target PC You can get a list of open files on the target PC file system from the host PC by using xPC Target methods on the host PC for the xpctarget.fs object. Do this to ensure you do not have files open unnecessarily. The target PC file system limits the number of open files you can have to eight. Use the method syntax to run an xpctarget.fs object method.
Using xpctarget.fs Objects Getting Information about a File on the Target PC You can display information for a file on the target PC file system from the host PC by using xPC Target methods on the host PC for the xpctarget.fs object. Use the method syntax to run an xpctarget.fs object method. The syntax method_name(fs_object, argument_list) can be replaced with fs_object.
7 Working with Target PC Files and File Systems Use the method syntax to run an xpctarget.fs object method. The syntax method_name(fs_object, argument_list) can be replaced with fs_object.method_name(argument_list) For example, to display the disk information for the C:\ drive, 1 If you have not already done so, in the MATLAB window, type the following to assign the xpctarget.fs object to a variable. fsys=xpctarget.fs; 2 Type fsys.
8 Graphical User Interfaces You can run and test your target application using the MATLAB command-line interface or the Simulink block diagram for your application. You can also use special blocks provided with xPC Target to interface signals and parameters from a target application to a custom GUI application. This chapter includes the following sections: xPC Target Interface Blocks to Simulink Models (p.
8 Graphical User Interfaces xPC Target Interface Blocks to Simulink Models You can use Simulink to create a custom graphical user interface (GUI) for your xPC Target application. You do this by creating an user interface model with Simulink and add-on products like the Virtual Reality Blockset and Altia Design (a third-party product).
xPC Target Interface Blocks to Simulink Models Altia Design — Altia also provides Simulink blocks that communicate with xPC Target interface blocks. These blocks then communicate with Altia’s graphical interface or with a Web browser using the Altia ProtoPlay plug-in.
8 Graphical User Interfaces 5 To the user interface template model, add Simulink interface blocks from add-on products (Virtual Reality Toolbox, Altia Design). - You can connect Altia blocks to the xPC Target To PC Target interface blocks. To xPC Target blocks on the left should be connected to control devices. - You can connect Altia and Virtual Reality Toolbox blocks to the xPC Target From PC Target interface blocks. From xPC Target blocks on the right should be connected to the display devices.
xPC Target Interface Blocks to Simulink Models To xPC Target Block This block behaves as a sink and usually receives its input data from a control device. The purpose of this block is to write a new value to a specific parameter on the target application. Host PC Control device block Target PC To xPC Target block Simulink instrumentation model Parameter xPC Target application This block is implemented as an M-file S-function.
8 Graphical User Interfaces Note The use of To xPC Target blocks require a connection between the host and target PC. If there is no connection between the host and target PC, operations such as opening a model that contains these blocks or copying these blocks within or between models, will take significantly longer than normal. Block Parameters xPC Target application name — The function xpcsliface automatically enters a name entry for this parameter.
xPC Target Interface Blocks to Simulink Models xpclib/Misc sublibrary. See “From xPC Target” on page 34-10 in the xPC Target I/O reference documentation for further configuration details. Note The use of From xPC Target blocks require a connection between the host and target PC. If there is no connection between the host and target PC, operations such as opening a model that contains these blocks or copying these blocks within or between models, will take significantly longer than normal.
8 Graphical User Interfaces Creating a Target Application Model A target application model is a Simulink model that describes your physical system, a controller, and its behavior. You use this model to create a real-time target application, and you use this model to select the parameters and signals you want to connect to a custom graphical interface.
xPC Target Interface Blocks to Simulink Models 4 In the Description box, delete the existing tag and enter a tag to the parameters for this block. For example, the SetPoint block is a constant with a single parameter that selects the level of water in the tank. Enter the tag shown below. The tag has the following format syntax xPCTag(1, . . . index_n)= label_1 . . . label_n; For single dimension ports, the following syntax is also valid: xPCTag=label; index_n — Index of a block parameter.
8 Graphical User Interfaces For the PumpSwitch and ValveSwitch blocks, enter the following tags respectively: xPCTag(2)=pump_switch; xPCTag(1)=drain_valve; To create the To xPC blocks in an user interface model for a block with four properties, use the following syntax: xPCTag(1,2,3,4)=label_1 label_2 label_3 label_4; To create the To xPC blocks for the second and fourth properties in a block with at least four properties, use the following syntax: xPCTag(2,4)=label_1 label_2; 6 From the File menu, clic
xPC Target Interface Blocks to Simulink Models Note that you cannot select signals on the output ports of any virtual blocks such as Subsystem and Mux blocks. Also, you cannot select signals on any function-call, triggered signal output ports. 1 Open a Simulink model. For example, in the MATLAB Command Window, type xpc_tank or xpc_tank1 2 Point to a Simulink signal line, and then right-click. 3 From the menu, click Signal Properties. A Signal Properties dialog box opens. 4 Select the Documentation tab.
8 Graphical User Interfaces The tag has the following format syntax: xPCTag(1, . . . index_n)=label_1 . . . label_n; For single dimension ports, the following syntax is also valid: XPCTag=label: - index_n — Index of a signal within a vector signal line. Begin numbering signals with an index of 1. - label_n — Name for a signal that will be connected to a From xPC Target block in the user interface model. Separate the labels with a space, not a comma. label_1...
xPC Target Interface Blocks to Simulink Models xPCTag(2,4)=label_1 label_2; 6 From the File menu, click Save as. Enter a filename for your model. For example, enter xpc_tank1 You next task is to mark block parameters if you have not already done so. See “Marking Block Parameters” on page 8-8. If you have already marked block signals, return to “Creating a Custom Graphical Interface” on page 8-3 for additional guidance on creating a user interface template model.
8 Graphical User Interfaces 8-14
9 xPC Target Web Browser Interface xPC Target has a Web server that allows you to interact with your target application through a Web browser. You can access the Web browser with either a TCP/IP or serial (RS-232) connection. This chapter includes the following section: Web Browser Interface (p.
9 xPC Target Web Browser Interface Web Browser Interface xPC Target has a Web server built into the kernel that allows you to interact with 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 host PC connected to the network. Currently Microsoft Internet Explorer (Version 4.0 or later) and Netscape Navigator (Version 4.5 or later) are the only supported browsers.
Web Browser Interface 1 In the MATLAB window, type 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 might 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 Explorer window. For example, if the target computer IP address is 192.168.0.1 and the port is 22222, type http://192.168.0.
9 xPC Target Web Browser Interface 2 Open a DOS command window, and enter the command to start the TCP/IP to RS-232 gateway. For example, if the target PC is connected to COM1 and you would like to use the TCP/IP port 22222, type the following: c:\\toolbox\rtw\targets\xpc\xpc\bin\xpctcp2ser -v -t 22222 -c 1 For a description of the xpctcp2ser command, see “Syntax for the xpctcp2ser Command” on page 9-5.
Web Browser Interface 6 In the MATLAB Command Window, type xpc MATLAB reconnects to the target application and lists the properties of the target object. If you did not close the gateway application, MATLAB displays the message Error in ==> C:\MATLABR13\toolbox\rtw\targets\xpc\xpc\@xpc\xpc.m On line 31 ==> sync(xpcObj); You must close MATLAB and then restart it. Syntax for the xpctcp2ser Command The xpctcp2ser command starts the TCP/IP to RS-232 gateway.
9 xPC Target Web Browser Interface CommandLine Option Description -t tcpPort Use TCP port tcpPort. Default t is 22222. For example, to connect to port 20010, type -t 20010. -h Print a help message. -c comPort Use COM port comPort (1 <= comPort <= 4). Default is 1. For example, to use COM2, type -c 2. Using the Main Pane The Main pane is divided into four parts, one below the other. The four parts are System Status, xPC Target Properties, Navigation, and WWW Properties.
Web Browser Interface After you connect a Web browser to the target PC, you can use the Main pane to control the target application: 9-7
9 xPC Target Web Browser Interface 1 In the left frame, click the Refresh button. System status information in the top cell is uploaded from the target PC. If the right frame is either the Signals List pane or the Screen Shot pane, updating the left frame also updates the right frame. 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.
Web Browser Interface The new property values are downloaded to the target application. Note that the SampleTime 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, select one or all of the scopes to view. Note The ViewMode control is visible in the xPC Target Properties pane only if you add two or more scopes to the target PC.
9 xPC Target Web Browser Interface 2 In the Refresh Interval box, enter a value greater than 10. For example, enter 20. The signal pane updates automatically every 20 seconds. Entering -1 or Inf does not automatically refresh the pane. Sometimes, both the frames try to update simultaneously, or the auto refresh starts before the previous load has finished. This problem can happen with slow network connections.
Web Browser Interface Viewing Parameters with a Web Browser The Parameters pane 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 pane 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 pane is loaded into the right frame.
9 xPC Target Web Browser Interface 3 In the Target selection section, access levels are set in the RTW system target file box. For example, to set the access level to 1, enter xpctarget.tlc -axpcWWWAccessLevel=1 The effect of not specifying -axpcWWWAccessLevel is that the highest access level (0) is set. 4 Click OK. The various fields disappear, depending on the access level. For example, if your access level does not allow you access to the parameters, you do not see the button for parameters.
10 Interrupts Versus Polling xPC Target interrupt mode is the default real-time execution mode for the xPC Target kernel. For performance reasons, you might want to change the real-time execution mode to polling mode. This chapter includes the following section: Polling Mode (p.
10 Interrupts Versus Polling Polling Mode A good understanding of polling mode will help you to use it effectively, and a better understanding of interrupt mode will help you to decide under which circumstances it makes sense for you to switch to the polling mode.
Polling Mode Additionally, background tasks like host-target communication or updating the target screen run in parallel with sample-time-based model tasks. This allows you to interact with the target system while the target application is executing in real time at high sample rates. This is made possible by an interrupt-driven real-time scheduler that is responsible for executing the various tasks according to their priority.
10 Interrupts Versus Polling • Interrupt handler entry and exit latency — Because an interrupt can stop the currently executing task at any instruction and the interrupted task has to resume proper execution when the interrupting task completes execution, its state has to be saved and restored accordingly. This includes saving CPU data and address registers, including the stack pointer.
Polling Mode Polling means that the kernel waits in an empty while loop until the time at which the next model step has to be executed is reached. Then the next model step is executed. At least a counter implemented in hardware has to be accessible by the kernel in order to get a base reference for when the next model step execution has to commence. The kernel polls this hardware counter. If this hardware counter must be outside the CPU, e.g.
10 Interrupts Versus Polling • The model is optimal concerning execution speed — First, you should run the model through the Simulink profiler to find any possible speed optimizations using alternative blocks. If the model contains continuous states, the discretization of these states will reduce model complexity significantly, because a costly fixed-step integration algorithm can be avoided.
Polling Mode 1 In the Simulink window, and from the Tools menu, point to Real-Time Workshop, and then click Options. The Configuration Parameters dialog box opens. 2 In the left pane, click the Real-Time Workshop node. 3 In the TLC options edit field, specify the option -axpcCPUClockPoll=CPUClockRateMHz The assignment of the clock rate of the target PC’s CPU is necessary because the Pentium’s on-chip counter used for polling mode counts up with the CPU clock rate.
10 Interrupts Versus Polling displays the CPU clock rate in MHz right after the target PC has been powered up. For example, if your target PC is a 1.2 GHz AMD Athlon, specify option -axpcCPUClockPoll=1200 If you want to execute the target application in interrupt mode again, either remove the option or assign a CPU clock rate of 0 to the option: -axpcCPUClockPoll=0 If you make a change to the TLC options field, you need to rebuild the target application for the change to take effect.
Polling Mode Restrictions Introduced by Polling Mode As explained above, polling mode executes the Simulink-based target application in real time exclusively. While the target application is executing in polling mode, the background tasks, mainly the ones for host-target communication and target screen updating, are inactive. This is because all interrupts of the target PC are fully disabled during the execution of the target application.
10 Interrupts Versus Polling If the target application execution finally reaches the stop time and polling mode execution is stopped, host-target communication will begin functioning again. However, the host-target communication link might be in a bad state. If you still get communication error messages after polling mode execution stops, type the command xpctargetping to reset the host-target communication link.
Polling Mode • Signal tracing through scope objects — Neither through scope objects of type host (xPC Target Explorer or scripts) or type target (scopes on the target screen if property Enable target scope is enabled) • Signal monitoring — You cannot run a GUI interface on the host PC using an environment that depends on communication between the host and target computers.
10 Interrupts Versus Polling I/O Drivers Using Kernel Timing Information Cannot Be Used Within a Model Some xPC Target drivers use timing information exported from the kernel in order to run properly, for example, for the detection of time-outs. Because the standard timing engine of the real-time kernel is not running during the entire target application execution in polling mode, timing information passed back to the drivers is incorrect.
Polling Mode Generally, you can use the same software/hardware setup for passing other information back and forth during run time of the target application. It is important to understand that any additional feature beside signal logging has to be implemented at the model level, and it is therefore the user’s responsibility to optimize for the minimal additional latency the feature introduces.
10 Interrupts Versus Polling 10-14
11 xPC Target and Fortran xPC Target supports the incorporation of Fortran code into Simulink models. This chapter describes the following: Introduction (p. 11-2) Use Simulink S-functions to incorporate Fortran code into xPC Target. Step-by-Step Example of Fortran and xPC Target (p. 11-5) Follow the example to build your own xPC Target application with Fortran code.
11 xPC Target and Fortran Introduction xPC Target supports Fortran in Simulink models with S-functions. (See “Creating Fortran S-Functions” in the writing S-Functions documentation for a description of how to incorporate Fortran code into Simulink models.) This chapter describes how to incorporate Fortran into a Simulink model for xPC Target.
Introduction 5 Double-click the Fortran S-functions block. A library of Fortran S-functions and associated templates appears. This library also contains a README block. This file contains the same information as that contained in “Creating Fortran S-Functions” in the writing S-Functions documentation. In that chapter, the sections “Creating Level 2 Fortran S-Functions” and “Porting Legacy Code” are most applicable to xPC Target.
11 xPC Target and Fortran 6 Define the Fortran libraries, and the Fortran object files from step 1, in the Real-Time Workshop dialog of the Simulink model. You must define these libraries and files as additional components to be linked in when the xPC Target application link stage takes place. 7 Initiate the xPC Target specific Real-Time Workshop build procedure for the demo model. Real-Time Workshop builds and downloads the xPC Target onto the target PC.
Step-by-Step Example of Fortran and xPC Target Step-by-Step Example of Fortran and xPC Target This example uses the demo Atmosphere model that comes with Simulink. The following procedures require you to know how to write Fortran code appropriate for Simulink and xPC Target. See “Creating Fortran S-Functions” in the writing S-Functions documentation for these details.
11 xPC Target and Fortran 4 Connect this Scope block to the Tamb, K signal. The model sfcndemo_atmos.mdl should look like the figure shown. 5 Double-click the target Scope block. 6 From the Scope mode parameter, choose Graphical rolling. 7 For the Number of samples parameter, enter 240. 8 Click Apply, then OK. 9 Double-click the Sine Wave block. 10 For the Sample time parameter, enter 0.05. 11 Click OK. 12 From the File menu, click Save as.
Step-by-Step Example of Fortran and xPC Target Compiling Fortran Files This section describes the ways that you can compile Fortran code for xPC Target. Choose the procedure most convenient to your needs: • DOS command window • Microsoft Developer Studio IDE Before you start, 1 Change directory to \simulink\src. 2 Copy the file sfun_atmos_sub.f into your Fortran working directory, for example, xpc_fortran_test.
11 xPC Target and Fortran 3 Type fl32 -c /iface:cref -G5 -Ox -Zi sfun_atmos_sub.f This command generates the sfun_atmos_sub.obj file. Of these options, -c and /iface:cref are the most important. The remaining options are typical compiler optimization and debug options. The -c option ensures that the compiler compiles only the file and does not link it into an executable. The /iface:cref option defines the interface as C, making direct calls of the subroutines from C code possible.
Step-by-Step Example of Fortran and xPC Target Creating a C-MEX Wrapper S-Function This section assumes that you have compiled your Fortran code. See “Compiling Fortran Files” on page 11-7. Write the wrapper S-function for sfun_atmos_sub.f. A wrapper S-function is code that incorporates existing Fortran code into a Simulink S-Function block. For details on writing such wrapper functions, refer to the writing S-Functions Simulink documentation.
11 xPC Target and Fortran Invoking the mex command includes the following steps: 1 Compile the wrapper C file sfun_atmos.c. Be sure to link in the following: - Compiled wrapper file: sfun_atmos.obj - Compiled Fortran code: sfun_atmos_sub.obj - Necessary Fortran run-time libraries to resolve external function references and the Fortran run-time environment 2 Type mex -v LINKFLAGS#"$LINKFLAGS dformd.lib dfconsol.lib dfport.lib" sfun_atmos.c sfun_atmos_sub.
Step-by-Step Example of Fortran and xPC Target 1 At the MATLAB window, type fortran_atmos_xpc This opens the Simulink model associated with the Atmosphere model. This model includes the correct S-function block that is bound to sfun_atmos.dll. 2 Select the Simulation menu Start option to simulate the model. 3 Examine the behavior of the Atmosphere model by looking at the signals traced by the Scope block. Your next task is to prepare the model to build an xPC Target application.
11 xPC Target and Fortran 3 In the left pane, click the Real-Time Workshop node. The Real-Time Workshop pane opens. 4 In the Target selection section, click the Browse button at the RTW system target file list. 5 Click xpctarget.tlc. 6 In the Make command field, replace make_rtw with the following string: make_rtw S_FUNCTIONS_LIB="..\sfun_atmos_sub.obj ..\dfor.lib ..\dfconsol.lib ..\dfport.lib" Ensure that this whole command is all on one line. 7 Press Apply. 8 Press OK.
Step-by-Step Example of Fortran and xPC Target Building and Running the xPC Target Application This section assumes that you have prepared the model to build an xPC Target application. See “Preparing the Model for the xPC Target Application Build” on page 11-11. Build and run the xPC Target application as usual. Be sure that you have defined Microsoft Visual C/C++ as the xPC Target C compiler using xpcexplr.
11 xPC Target and Fortran 11-14
12 Troubleshooting This chapter describes guidelines, hints, and tips for issues you might encounter while using xPC Target. Refer to The MathWorks Support xPC Target Web site (http://www.mathworks.com/support/product/XP) for specific troubleshooting solutions. The xPC Target documentation is also available from this site. This chapter includes the following sections: General Troubleshooting Hints and Tips (p.
12 Troubleshooting General Troubleshooting Hints and Tips This section lists general troubleshooting tips that you can use as a first attempt to resolve your issues.
General Troubleshooting Hints and Tips • Verify that the xPC Target boot disk contains files like the following: - BOOTSECT.RTT - checksum.dat - XPCTGB1.RTA Note that the name of the last file varies depending on the communication method. • If any of these files are not present, reinstall xPC Target. This should fix any corrupted files from the previous (initial) installation. • If problems persist, see “Troubleshooting the Boot Process” in Chapter 3 of the xPC Target getting started documentation.
12 Troubleshooting The xpctest command performs a series of tests on your xPC Target system. These tests range from performing a basic communication check to building and running target applications. At the end of each test, the command returns an OK or failure message. If the test is inappropriate for your setup, the command returns a SKIPPED message. Use this command for a thorough check of your xPC Target installation.
General Troubleshooting Hints and Tips • USB support — Disable all USB support, including general USB and USB keyboard support. Failure to do this will cause occasional long task execution times (TET). • PCI boards — Do not detect PCI boards with class code 0xff in the target PC BIOS. Set this option to Off to enable the BIOS to detect and configure all boards.
12 Troubleshooting Refer to The MathWorks Support Web Site This chapter contains general xPC Target troubleshooting tips. Refer to the MathWorks Support xPC Target Web site (http://www.mathworks.com/support/product/XP) for more specific troubleshooting solutions. The xPC Target documentation is also available from this site. Refer to the Documentation The xPC Target documentation has hints and tips embedded throughout. You should install the Help and PDF documentation to provide easy reference.
Installation, Configuration, and Test Troubleshooting Installation, Configuration, and Test Troubleshooting The following are some issues you might encounter with xPC Target when trying to set up. Troubleshooting xpctest Results This section assumes that you have read the “Testing and Troubleshooting the Installation” section of the xPC Target getting started documentation. xpctest: Test 1 Fails.
12 Troubleshooting xpctest: Test 2 Fails. First, follow the procedure described in the “Test 2, Ping Target System xPC Target Ping” section of the xPC Target getting started documentation. If you need more help with Test 2, check the following: • Use the PC MATLAB command xpcexplr to check the environment variables, in particular Target PC IP address. If Test 1 passes but Test 2 fails, you might have entered an incorrect IP address.
Installation, Configuration, and Test Troubleshooting xpctest noreboot This command runs the test without trying to reboot the target PC. It displays the following message: ### Test 3, Reboot target using direct call: ... SKIPPED • If you directly or indirectly modify the xpcosc demo mode that is supplied with xPC Target, Test 3 is likely to fail.
12 Troubleshooting Error executing build command: Error using ==> make_rtw Error using ==> rtw_c Errors encountered while building model "xpcosc" with the following MATLAB Command Window error: NMAKE: fatal error U1064: MAKEFILE not found and no target specified Stop. To correct these errors, 1 Ensure that your compiler is properly installed. For example, all Microsoft Visual compiler components must be in the Microsoft Visual Studio folder after installation. 2 At the MATLAB prompt, type xpcexplr.
Installation, Configuration, and Test Troubleshooting xpctest: Test 5 Fails. This error occurs only when the environment variable settings are out of date. To correct this, perform the following: 1 At the MATLAB prompt, start xPC Target Explorer. For example, xpcexplr 2 Inspect the environment variables for the problem target PC. 3 If you have xPC Target Embedded Option installed, ensure that, in the Target boot mode section, you have selected the BootFloppy option. 4 Make necessary changes.
12 Troubleshooting xpctest: Test 6 Fails. This test runs the basic target object constructor, xpc. This error rarely occurs without an earlier test failing. To correct this, perform the following, 1 At the MATLAB command line, refer to and read the xpc reference page. For example, help xpc 2 Follow any guidance that might be helpful. 3 Reboot the target PC. 4 Rerun and check the results of earlier tests and make the necessary corrections. xpctest: Test 7 Fails.
Installation, Configuration, and Test Troubleshooting • There is a known issue with an earlier version of xPC Target (1.3). It might occur when you run xpctest two immediately consecutive times. See the known issue and solution documented in http://www.mathworks.com/support/solutions/data/27889.html. • If you are running a new xPC Target release, be sure that you have a new boot disk for this release. See “Are You Working with a New xPC Target Release?” on page 12-5.
12 Troubleshooting Advanced Troubleshooting The following are some advanced issues or questions you might have with xPC Target.
Advanced Troubleshooting General I/O Troubleshooting Guidelines If you encounter issues using the xPC Target I/O drivers, • Ensure that you have properly configured the driver. • Ensure that you are using the latest version of xPC Target. • Test the hardware using the available diagnostic software included with the I/O board from the manufacturer. • Try a different target PC to verify the behavior. • Report the issue to The MathWorks Support at (http://www.mathworks.com/support/contact_us/index.html).
12 Troubleshooting When this error occurs, the target object property CPUoverload changes from none to detected. To correct the issue, perform one of the following: • Change the model Fixed step size property to a larger value and rebuild the model. Use the Solver node in the Simulink model Configuration Parameters dialog. • Run the target application on a target PC with a faster processor. Target PC BIOS. This section assumes that the target PC has BIOS running on it.
Advanced Troubleshooting More Help. If the preceding procedures do not resolve the issue, if you can build a target application with the CAN board in your model, but cannot download that application to the target, ensure that • You are using a supported CAN board. • You selected the correct choice from the Can Library parameter in xpcexplr. Obtaining PCI Board Slot and Bus Information This section describes how to obtain information about the PCI devices in your xPC Target system.
12 Troubleshooting Note You can also obtain PCI device information from xPC Target Explorer. To do so, in xPC Target Explorer, select a connected target PC, right-click in the Target Display pane, and select View -> Target PC devices. To return to the default view of target PC properties, select View -> Target PC Properties. For additional information about PCI bus I/O devices, refer to the “PCI Bus I/O Devices” section of the xPC Target I/O reference documentation.
Advanced Troubleshooting • The referenced xPC Target driver has an issue. xPC Target I/O Boards with Slow Initialization Times. Some xPC Target boards have an initialization time that is too slow. This might cause xPC Target to run out of time before a model downloads, causing the host PC to disconnect from the target PC. By default, if the host PC does not get a response from the target PC after downloading a target application and waiting 5 seconds, the host PC software times out.
12 Troubleshooting In this case, the host PC waits for about 20 seconds before declaring that a time-out has occurred. Note that it does not take 20 seconds for every download. The host PC polls the target PC about once every second, and if a response is returned, declares success. Only in the case where a download really fails does it take the full 20 seconds. If the file xpcdltimeout.dat exists, it is read once before every download. To change the time-out value, change the number in this file.
Advanced Troubleshooting However, hardware does not allow infinite precision in setting the spacing between the timer interrupts. It is this limitation that can cause the divergent sample times. For all PCs, the only timer that can generate interrupts is based on a 1.193 MHz clock. For xPC Target, the timer is set to a fixed number of ticks of this frequency between interrupts. If you request a sample time of 1/10000, or 100, microseconds, you do not get exactly 100 ticks.
12 Troubleshooting Round this number to the nearest whole number of 117 ticks. The resulting frequency is then (116.96 ticks/117)(50) = 49.983 Hz The difference between the expected and measured signal is .019, which deviates from the expected signal value by .038% (.019/50.002). The deviation when the sample time is 1/10000 is .04%. Some amount of error is common for most PCs, and the margin of error varies from machine to machine.
Advanced Troubleshooting • http://www.mathworks.com/support/solutions/data/31528.html • Existing xPC Target device driver source code. Refer to the following directory: MATLABROOT\toolbox\rtw\targets\xpc\target\build\xpcblocks • In the include directory of the device driver source code area, pay particular attention to the following files: - io_xpcimport.h - pci_xpcimport.h - time_xpcimport.
12 Troubleshooting Can I Create a Stand-Alone xPC Target Application to Interact with a Target Application? Yes. You can use either the xPC Target API dynamic link library (DLL) or the xPC Target component object model (COM) API library to create custom stand-alone applications to control a real-time application running on the target PC. To deploy these stand-alone applications, you must have the xPC Target Embedded Option.
Advanced Troubleshooting For example, if a model has a stop time of 2.4 and a step size of 1, Real-Time Workshop adjusts the stop time of the model to 2 at compilation. If you change the step size to .6 but do not recompile the code, the expected number of steps is 4, but the actual number of steps is 3. This is because Real-Time Workshop still uses the adjusted stop time of 2.
12 Troubleshooting 12-26
13 Target PC Command-Line Interface Reference xPC Target provides a limited set of commands that you can use to work the target application after it has been loaded to the target PC, and to interface with the scopes for that application. This chapter is a reference of those commands. Target PC Commands (p.
13 Target PC Command-Line Interface Reference Target PC Commands The target PC command-line interface enables you to work with target and scope objects in a limited capacity. Methods let you interact directly with the scope or target. Property commands let you work with target and scope properties. Variable commands let you alias target PC command-line interface commands to names of your choice.
Target PC Commands Target Object Methods When you are 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 equivalent MATLAB syntax is shown in the right column, and the target object name tg is used as an example for the MATLAB methods.These methods assume that you have already loaded the target application onto the target PC.
13 Target PC Command-Line Interface Reference Target PC Command Description and Syntax MATLAB Equivalent getpar Display the value of a block parameter using the parameter index. get(tg, 'parameter_name') Syntax: getpar parameter_index setpar Change the value of a block parameter using the parameter index. set(tg, 'parameter_name', number) Syntax: setpar parameter_index = floating_point_number stoptime Enter a new stop time.
Target PC Commands Target PC Command Description and Syntax MATLAB Equivalent P# Display or change the value of a block parameter. For example, P2 or P2=1.23e-4. tg.getparam(parameter_ index) tg.setparam(parameter_ index,floating_point_ number) Syntax: parameter_name or parameter_name = floating_point_number parameter_name is P0, P1, . . . S# Display the value of a signal. For example, S2. tg.getsignal(signal_index) Syntax: signal_name signal_name is S0, S1, . . .
13 Target PC Command-Line Interface Reference 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. The target object name tg and the scope object name sc are used as an example for the MATLAB methods. Target PC Command Description and Syntax MATLAB Equivalent addscope addscope scope_index addscope tg.addscope(scope_index) tg.addscope remscope remscope scope_index remscope all tg.
Target PC Commands Target PC Command Description and Syntax ylimit ylimit scope_index ylimit scope_index = auto ylimit scope_index = num1, num2 grid grid scope_index on grid scope_index off MATLAB Equivalent 13-7
13 Target PC Command-Line Interface Reference Scope Object Property Commands When you use the target PC command-line interface, scope object properties are limited to those shown in the following table. Notice the difference between a scope index (0, 1, . . .) and the MATLAB variable name for the scope object on the host PC. The scope index is indicated in the top left corner of a scope window (SC0, SC1, . . .). If a scope is running, you need to stop the scope before you can change a scope property.
Target PC Commands Target PC MATLAB triggerslope scope_index = 0, either, 1, rising, 2, falling sc.TriggerSlope = 'Either', 'Rising', 'Falling' triggerscope scope_index2 = scope_index1 sc.TriggerScope = scope_index1 triggerscopesample scope_index= integer sc.TriggerSample = integer Press the function key for the scope, and then press S or move mouse into the scope window. sc.
13 Target PC Command-Line Interface Reference Aliasing with Variable Commands The following table lists the syntax for the aliasing variable commands that you can use on the target PC. The MATLAB equivalent syntax is shown in the right column. Target PC Command Description and Syntax MATLAB Equivalent setvar Set a variable to a value. Later you can use that variable to do a macro expansion.
14 Function Reference
14 Function Reference Functions — Categorical List This topic contains reference pages for xPC Target functions.
Functions — Categorical List GUI xpcexplr Open xPC Target Explorer window xpctargetspy Open Real-Time xPC Target Spy window on host PC Test getxpcpci Determine which PCI boards are installed in target PC xpctargetping Test communication between host and target computers xpctest Test the xPC Target installation Target Objects The target object methods allow you to control a target application on the target PC from the host PC.
14 14-4 Function Reference start (target object) Start execution of target application on target PC stop (target object) Stop execution of target application on target PC load Download target application to target PC unload Remove current target application from target PC addscope Create one or more scopes setparam Change writable target object parameters getparam Return value of target object parameter index getparamid Get parameter index from parameter list getparamname Get block path
Functions — Categorical List close Close serial port connecting host PC with target PC. targetping Test communication between a host and its target computers Scope Objects The scope object methods allow you to control scopes on your target PC. If you want to control the target application from the target PC, use target PC commands. See Chapter 6, “Using the Target PC Command-Line Interface.
14 Function Reference File and File System Objects xPC Target uses the xpctarget.ftp object to represent a target PC file, such as a signal data file created by an xPC Target scope of type file. Use this object to perform file transfer operations on that file. xPC Target uses the xpctarget.fs object to represent the target PC file system. Use this object to perform file system manipulations. Both xpctarget.ftp and xpctarget.fs belong to the xpctarget.fsbase object.
Functions — Categorical List pwd Retrieve current directory path of target PC rmdir Remove directory from target PC xpctarget.ftp Functions The xpctarget.ftp methods allow you to work with a target PC file, such as a signal data file, from the host PC. You enter target object methods in the MATLAB window on the host PC or use M-file scripts. xpctarget.ftp Create xPC Target FTP object get (ftp) Retrieve copy of requested file from target PC put Copy file from host PC to target PC xpctarget.
14 Functions — Alphabetical List This section contains function reference pages listed alphabetically.
addscope Purpose Syntax 14addscope Create one or more scopes MATLAB command line Create a scope and scope object without assigning to a MATLAB variable. addscope(target_object, scope_type, scope_number) target_object.addscope(scope_type, scope_number) Create a scope, scope object, and assign to a MATLAB variable scope_object = addscope(target_object, scope_type, scope_number) scope_object = target_object.
addscope A scope acquires data from the target application and displays that data on the target PC, uploads the data to the host PC, or stores that data in a file in the target PC file system. All scopes of type target, host, or file 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.
addscope sc1 = getscope(tg,1) or sc1 = tg.getscope(1) Create two scopes using a vector of scope objects scvector. Two target scopes are created on the target PC with scope indices of 1 and 2, and two scope objects are created on the host PC that represent the scopes on the target PC. The target object property Scopes is changed from No scopes defined to 1,2. scvector = addscope(tg, 'target', [1, 2]) Create a scope and scope object sc4 of type file using the method addscope.
addsignal Purpose Syntax 14addsignal Add 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 Description 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 Signals = 1 0 : Signal Generator : Integrator1 Another way to add signals without using the method addsignal is to use the scope object method set. 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 (scope object). The target object methods addscope and getsignalid.
cd Purpose Syntax 14cd Change directory on target PC MATLAB command line cd(file_obj,target_PC_dir) file_obj.cd(target_PC_dir) Arguments file_obj Name of the xpctarget.ftp or xpctarget.fs object. target_PC_dir Name of the target PC directory to change to. Description Method of xpctarget.fsbase, xpctarget.ftp, and xpctarget.fs objects. From the host PC, changes directory on the target PC. Examples Change directory from the current to one named logs for the file system object fsys.
close Purpose Syntax 14close Close serial port connecting host PC with target PC MATLAB command line close(target_object) target_object.close Arguments target_object Description close closes the serial connection between the host PC and a target PC. If you want to use the serial port for another function without quitting MATLAB — for example, a modem — use this function to close the connection. Name of a target object.
delete Purpose Syntax 14delete Remove target object MATLAB command line delete(target_object) target_object.delete Arguments target_object Description Use this method to completely remove the target object. If there are any scopes still associated with the target, this method removes all those scope objects as well. Name of a target object.
dir Purpose Syntax 14dir List contents of current directory on target PC MATLAB command line dir(file_obj) Arguments file_obj Description Method of xpctarget.fsbase, xpctarget.ftp, and xpctarget.fs objects. From the host PC, lists the contents of the current directory on the target PC. Name of the xpctarget.ftp or xpctarget.fs object. To get the results in an M-by-1 structure, use a syntax like ans=dir(file_obj).
dir 11/2/2003 11/5/1998 11/2/2003 11/2/2003 11/2/2003 18/2/2003 18/2/2003 29/3/2003 28/3/2003 28/3/2003 1/4/2003 11/2/2003 4/5/2001 4/5/2001 11/2/2003 22/1/2001 28/3/2003 29/3/2003 11/2/2003 11/2/2003 29/3/2003 1/4/2003 11/2/2003 13:54 20:01 13:54 14:00 14:00 16:33 16:17 19:19 16:41 16:29 9:28 14:13 13:05 13:05 14:15 11:42 16:41 19:19 14:25 14:28 19:10 18:05 17:26
6 93880 0 33 512 4512 0 8512 8512 4512 201326592 0 214432 34468 0 217 8512 2512 0 0 2512 2512 0 MSDdiskinfo Purpose Syntax 14diskinfo Get information about target PC drive MATLAB command line diskinfo(filesys_obj,target_PC_drive) filesys_obj.diskinfo(target_PC_drive) Arguments filesys_obj Name of the xpctarget.fs file system object. target_PC_drive Name of the target PC drive for which to return information. Description Method of xpctarget.fs objects. From the host PC, returns disk information for the specified target PC drive.
fclose Purpose Syntax 14fclose Close one or more open target PC files MATLAB command line fclose(filesys_obj,file_ID) filesys_obj.fclose(file_ID) Arguments filesys_obj Name of the xpctarget.fs file system object. file_ID File identifier of the file to close. Description Method of xpctarget.fs objects. From the host PC, closes one or more open files in the target PC file system (except standard input, output, and error).
fc422mexcalcbits Purpose Syntax 14fc422mexcalcbits Calculate parameter values for Fastcom 422/2-PCI board MATLAB command line [a b ] = fc422mexcalcbits(frequency) [a b df] = fc422mexcalcbits(frequency) Arguments frequency Desired baud rate for the board [a b] = fc422mexcalcbits(frequency) accepts a baud rate (in units of baud/ second) and converts this value into two parameters a b. You must enter these values for the parameter Clock bits of the Fastcom 422/2-PCI driver clock.
fileinfo Purpose Syntax 14fileinfo Get target PC file information MATLAB command line fileinfo(filesys_obj,file_ID) filesys_obj.fileinfo(file_ID) Arguments filesys_obj Name of the xpctarget.fs file system object. file_ID File identifier of the file for which to get file information. Description Method of xpctarget.fs objects. From the host PC, gets the information for the file associated with file_ID.
filetable Purpose Syntax 14filetable Get information about open files in target PC file system MATLAB command line filetable(filesys_obj) filesys_obj.filetable Arguments filesys_obj Description Method of xpctarget.fs objects. From the host PC, displays a table of the open files in the target PC file system. You cannot have more than eight files open in the file system. Examples Return a table of the open files in the target PC file system for the file system object fsys. Name of the xpctarget.
fopen Purpose Syntax 14fopen Open target PC file for reading MATLAB command line file_ID file_ID file_ID file_ID Arguments Description = = = = fopen(file_obj,'file_name') file_obj.fopen('file_name') fopen(file_obj,'file_name',permission) file_obj.fopen('file_name',permission) file_obj Name of the xpctarget.fs object. 'file_name' Name of the target PC to open. permission Values are 'r' or 'w'. This argument is optional with 'r' as the default value. Method of xpctarget.fs objects.
fread Purpose Syntax 14fread Read open target PC file MATLAB command line fread(file_obj,file_ID) file_obj.fread(file_ID) Arguments file_obj Name of the xpctarget.fs object. file_ID File identifier of the file to read. Description Method of xpctarget.fs objects. From the host PC, reads the binary data from the file on the target PC and writes it into matrix A. The file_ID argument is the file identifier associated with an open file (see fopen). Examples Open the file data.
fwrite Purpose Syntax 14fwrite Write binary data to the open target PC file MATLAB command line fwrite(file_obj,file_ID,A) file_obj.fwrite(file_ID,A) Arguments file_obj Name of the xpctarget.fs object. file_ID File identifier of the file to write. A Elements of matrix A to be written to the specified file. Description Method of xpctarget.fs objects. From the host PC, writes the elements of matrix A to the file identified by file_ID. The data is written to the file in column order.
get (ftp) Purpose Syntax 14get (ftp) Retrieve copy of requested file from target PC MATLAB command line get(file_obj,file_name) file_obj.get(file_name) Arguments file_obj Name of the xpctarget.ftp object. file_name Name of a file on the target PC. Description Method of xpctarget.ftp objects. Copies the specified filename from the target PC to the current directory of the host PC.
get (scope object) Purpose Syntax 14get (scope object) Return 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 Description 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.
get (scope object) The properties for a scope object are listed in the following table. This table includes descriptions of the properties and the properties you can change directly by assigning a value. Property Description Application Name of the Simulink model associated with this scope object. AutoRestart For scopes of type 'File', enable the file scope to collect data up to the number of samples (NumSamples), then start over again, appending the new data to the end of the signal data file.
get (scope object) Property Description Writable Filename Provide a name for the file to contain the signal data. By default, the target PC writes the signal data to a file named C:\data.dat for scope blocks. Note that for scopes of type 'File' created through the MATLAB interface, there is no name initially assigned to FileName. After you start the scope, xPC Target assigns a name for the file to acquire the signal data.
get (scope object) Property Description Writable Mode For scopes of type 'Target', indicate how a scope displays the signals. Values are 'Numerical', 'Redraw' (default), 'Sliding', and 'Rolling'. Yes For scopes of type File, specify when a file allocation table (FAT) entry is updated. Values are 'Lazy' or 'Commit'. Both modes write the signal data to the file. With 'Commit' mode, each file write operation simultaneously updates the FAT entry for the file.
get (scope object) Property Description Writable NumSamples Number of contiguous samples captured during the acquisition of a data package. If the scope stops before capturing this number of samples, the scope has the collected data up to the end of data collection, then has zeroes for the remaining uncollected data. Note that you should know what type of data you are collecting, it is possible that your data contains zeroes.
get (scope object) Property Description Writable Status Indicate whether data is being acquired, the scope is waiting for a trigger, the scope has been stopped (interrupted), or acquisition is finished. Values are 'Acquiring', 'Ready for being Triggered', 'Interrupted', and 'Finished'. Time Contains the time data for a single data package from a scope. TriggerLevel If TriggerMode is 'Signal', indicates the value the signal has to cross to trigger the scope and start acquiring data.
get (scope object) Property Description TriggerSample If TriggerMode is 'Scope', then TriggerSample specifies which sample of the triggering scope the current scope should trigger on. For example, if TriggerSample is 0 (default), the current scope triggers on sample 0 (first sample acquired) of the triggering scope. This means that the two scopes will be perfectly synchronized.
get (scope object) Property Description Writable TriggerSlope If TriggerMode is 'Signal', indicates whether the trigger is on a rising or falling signal. Values are 'Either' (default), 'Rising', and 'Falling'. Yes Type Determines whether the scope is displayed on the host computer or on the target computer. Values are 'Host', 'Target', and 'File'. WriteSize Enter the block size, in bytes, of the data chunks.
get (scope object) List the value for the scope object property Type. Notice that the property name is a string, in quotation marks, and is not case sensitive. get(sc,'type') ans = Target See Also 14-36 The xPC Target scope object method set (scope object). The target object methods set (target object). The built-in MATLAB functions get and set.
get (target object) Purpose Syntax 14get (target object) Return target object property values 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 get gets the value of readable target object properties from a target object. The properties for a target object are listed in the following table.
get (target object) Property Description ExecTime Execution time. Time, in seconds, since your target application started running. When the target application stops, the total execution time is displayed. LogMode Controls which data points are logged: • Time-equidistant logging. Logs a data point at every time interval. Set value to 'Normal'. • Value-equidistant logging. Logs a data point only when an output signal from the OutputLog changes by a specified value (increment).
get (target object) Property Description Mode Type of Real-Time Workshop code generation. Values are 'Real-Time Singletasking', 'Real-Time Multitasking', and 'Accelerate'. The default value is 'Real-Time Singletasking'. Writable Even if you select 'Real-Time Multitasking', the actual mode can be 'Real-Time Singletasking'. This happens if your model contains only one or two tasks and the sample rates are equal. NumLogWraps The number of times the circular buffer wrapped.
get (target object) Property Description Parameters List of tunable parameters. This list is visible only when ShowParameters is set to 'on': Writable • Property value. Value of the parameter in a Simulink block. • Type. Data type of the parameter. Always double. • Size. Size of the parameter. For example, scalar, 1-by-2 vector, or 2-by-3 matrix. • Parameter name. Name of a parameter in a Simulink block. • Block name. Name of a Simulink block. 14-40 SampleTime Time between samples.
get (target object) Property Description Signals List of viewable signals. This list is visible only when ShowSignals is set to 'on'. Writable • Property name. S0, S1. . . • Property value. Value of the signal. • Block name. Name of the Simulink block the signal is from. StateLog Storage in the MATLAB workspace for the state or x-vector logged during execution of the target application. Status Execution status of your target application. Values are 'stopped' and 'running'.
get (target object) Examples Property Description TimeLog Storage in the MATLAB workspace for the time or t-vector logged during execution of the target application. ViewMode Display either all scopes or a single scope on the target PC. Value is 'all' or a single scope index. This property is active only if the environment property TargetScope is set to enabled. Writable Yes List the value for the target object property StopTime.
getfilesize Purpose Syntax 14getfilesize Get size of file on target PC MATLAB command line getfilesize(file_obj,file_ID) file_obj.getfilesize(file_ID) Arguments file_obj Name of the xpctarget.fs object. file_ID File identifier of the file to get the size of. Description Method of xpctarget.fs objects. From the host PC, gets the size (in bytes) of the file identified by the file_ID file identifier on the target PC file system.
getlog Purpose Syntax 14getlog Get all or part of output logs from target object MATLAB command line log = getlog(target_object, 'log_name', first_point, number_samples, decimation) 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_samples Number of samples after the start time. This argument is optional.
getparam Purpose Syntax 14getparam Return value of target object parameter index MATLAB command line getparam(target_object, parameter_index) Arguments target_object Name of a target object. The default name is tg. parameter_index Index number of the parameter. Description getparam returns the value of the parameter associated with parameter_index. Examples Get the value of parameter index 5.
getparamid Purpose Syntax 14getparamid Get parameter index from parameter list MATLAB command line getparamid(target_object, 'block_name', 'parameter_name') Arguments Description target_object Name of a target object. The default name is tg. 'block_name' Simulink block path without model name. 'parameter_name' Name of a parameter within a Simulink block. getparamid returns the index of a parameter in the parameter list based on the path to the parameter name.
getparamname Purpose Syntax 14getparamname Get block path and parameter name from index list MATLAB command line getparamname(target_object, parameter_index) Arguments target_object Name of a target object. The default name is tg. parameter_index Index number of the parameter. Description getparamname returns two argument strings, block path and parameter name, from the index list for the specified parameter index. Examples Get the block path and parameter name of parameter index 5.
getscope Purpose Syntax 14getscope Get scope object pointing to scope defined in kernel MATLAB command line scope _object_vector = getscope(target_object, scope_number) scope_object = target_object.getscope(scope_number) Arguments Description target_object Name of a target object. scope_number_vector Vector of existing scope indices listed in the target object property Scopes. The vector can have only one element. scope_object MATLAB variable for a new scope object vector.
getscope The following example gets the properties of all scopes on the target PC and creates a vector of scope objects on the host PC. If the target object has more than one scope, it create a vector of scope objects. scvector = getscope(tg) See Also xPC Target target object methods getxpcenv and remscope. xPC target M-file demo scripts listed in “xPC Target Demos” on page 5-8.
getsignal Purpose Syntax 14getsignal Return value of target object signal index MATLAB command line getsignal(target_object, 'signal index') Arguments target_object Name of a target object. The default name is tg. signal_index Index number of the signal. Description getsignal returns the value of the signal associated with signal_index. Examples Get the value of signal index 2. getsignal(tg, 2) ans = -3.
getsignalid Purpose Syntax 14getsignalid Get signal index or signal property from signal list MATLAB command line getsignalid(target_object, 'signal_name') tg.getsignalid('signal_name') Arguments target_object Name of an existing target object. signal_name Enter the name of a signal from your Simulink model. For blocks with a single signal, the signal_name is equal to the block_name. For blocks with multiple signals, xPC Target appends S1, S2 ... to the block_name.
getsignalname Purpose Syntax 14getsignalname Get signal name from index list MATLAB command line getsignalname(target_object, signal_index) Arguments target_object Name of a target object. The default name is tg. signal_index Index number of the signal. Description getparamname returns one argument string, signal name, from the index list for the specified signal index. Examples Get the signal name of signal ID 2.
getxpcenv Purpose Syntax 14getxpcenv List environment properties assigned to MATLAB variable MATLAB Command Line getxpcenv Description Function to list environment properties. This function displays, in the MATLAB Command Window, the property names, the current property values, and the new property values set for the xPC Target environment.
getxpcenv Environment Property Description TargetRAMSizeMB Values are 'Auto' and 'Manual'. From the xPC Target Explorer window Target RAM size list, select 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. Target RAM size defines the total amount of installed RAM in the target PC. This RAM is used for the kernel, target application, data logging, and other functions that use the heap.
getxpcenv Environment Property Description HostTargetComm Values are 'RS232' and 'TcpIp'. From the xPC Target Explorer window Host target communication list, select either RS232 or TCP/IP. If you select RS232, you also need to set the property RS232HostPort. If you select TCP/IP, then you also need to set all properties that start with TcpIp. RS232HostPort Values are 'COM1' and 'COM2'.
getxpcenv Environment Property Description TcpIpTargetPort Value is 'xxxxx'. In the xPC Target Explorer window TcpIp target port box, enter a value greater than 20000. This property is set by default to 22222 and should not cause any problems. The number is higher than the reserved area (telnet, ftp, ...) and it is only of use on the target PC. TcpIpSubNetMask Value is 'xxx.xxx.xxx.xxx'. In the xPC Target Explorer window LAN subnet mask address text box, enter the subnet mask of your LAN.
getxpcenv Environment Property Description TcpIpTargetDriver Values are 'NE2000', 'SMC91C9X', 'I82559', and 'RTLANCE'. From the xPC Target Explorer window TcpIp target driver list, select NE2000, SMC91C9X, I82559, or RTLANCE. The Ethernet card provided with xPC Target uses the NE2000 driver. TcpIpTargetBusType Values are 'PCI' and 'ISA'. From the xPC Target Explorer window TcpIp target bus type list, select either PCI or ISA.
getxpcenv Environment Property Description TcpIpTargetISAMemPort 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. Set the I/O port base address to around 0x300.
getxpcenv Environment Property Description TargetScope Values are 'Disabled' and 'Enabled'. From the xPC Target Explorer window Enable target scope list, select either Enabled or Disabled. The property TargetScope is set by default to Enabled. If you set TargetScope to Disabled, the target PC displays information as text. To use all the features of the target scope, you also need to install a keyboard and mouse on the target PC. TargetMouse Values are 'None', 'PS2', 'RS232 COM1', and 'RS232 COM2'.
getxpcenv Environment Property Description EmbeddedOption Values are 'Disabled' and 'Enabled'. This property is read only. Note that the xPC Target Embedded Option is enabled only if you purchase an additional license. TargetBoot Values are 'BootFloppy', 'DOSLoader', and 'StandAlone'. From the xPC Target Explorer window Target boot mode list, select BootFloppy, DOSLoader, or StandAlone.
getxpcpci Purpose Syntax 14getxpcpci Determine which PCI boards are installed in target PC MATLAB Command Line getxpcpci(target_object, 'type_of_boards') Arguments Description target_object Variable name to reference the target object. type_of_boards Values are no arguments, 'all', and 'supported'. The getxpcpci function displays, in the MATLAB window, which PCI boards are installed in the target PC. By default, getxpcpci displays this information for the target object, tg.
getxpcpci getxpcpci('all') Display a list of the currently supported PCI devices in the xPC Target block library. The result is displayed. getxpcpci('supported') When called with the 'supported' option, getxpcpci does not access the target PC. To display the list of PCI devices installed on the target PC, tg1, first create a target object, tg1, for that target PC. Then, call getxpcpci with the 'all' option. For example tg1=xpctarget.
load Purpose Syntax 14load Download target application to 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. Before using this function, the target PC must be booted with the xPC Target kernel, and the target application must be built in the current working directory on the host PC.
loadparamset Purpose Syntax 14loadparamset Restore parameter values saved in specified file MATLAB command line loadparamset(target_object,'filename') target_object.loadparamset('filename') Arguments target_object Name of an existing target object. filename Enter the name of the file that contains the saved parameters. Description loadparamset restores the target application parameter values saved in the file filename. This file must be located on a local drive of the target PC.
mkdir Purpose Syntax 14mkdir Make a directory on target PC MATLAB command line mkdir(file_obj,dir_name) file_obj.mkdir(dir_name) Arguments Description file_obj Name of the xpctarget.ftp or xpctarget.fs object. dir_name Name of the directory to be created. Method of xpctarget.fsbase, xpctarget.ftp, and xpctarget.fs objects. From the host PC, makes a new directory in the current directory on the target PC file system.
put Purpose Syntax 14put Copy file from host PC to target PC MATLAB command line put(file_obj,file_name) file_obj.put(file_name) Arguments Description file_obj Name of the xpctarget.ftp object. file_name Name of the file to copy to the target PC. Method of xpctarget.ftp objects. Copies a file from the host PC to the target PC. file_name must be a file in the current directory of the host PC. The method writes file_name to the target PC disk.
pwd Purpose Syntax 14pwd Retrieve current directory path of target PC MATLAB command line pwd(file_obj) file_obj.pwd Arguments file_obj Description Method of xpctarget.fsbase, xpctarget.ftp, and xpctarget.fs objects. Returns the pathname of the current target PC directory. Examples Return the target PC current directory for the file system object fsys. Name of the xpctarget.ftp or xpctarget.fs object. pwd(fsys) or fsys.pwd Return the target PC current directory for the FTP object f. pwd(f) or f.
reboot Purpose Syntax 14reboot Reboot target PC MATLAB command line reboot(target_object) Target PC command line reboot Arguments target_object Description reboot reboots the target PC, and if a target boot disk is still present, the xPC Name of an existing target object. target kernel is reloaded. You can also use this method to reboot the target PC back to Windows after removing the target boot disk. Note This method might not work on some target hardware.
remscope Purpose Syntax 14remscope Remove scope from target PC MATLAB command line remscope(target_object, scope_number_vector) target_object.remscope(scope_number_vector) remscope(target_object) target_object.remscope Target PC command line remscope scope_number remscope 'all' Arguments Description target_object Name of a target object. The default name is tg. scope_number_vector Vector of existing scope indices listed in the target object property Scopes. scope_number Single scope index.
remscope Examples Remove a single scope. remscope(tg,1) or tg.remscope(1) Remove two scopes. remscope(tg,[1 2]) or tg.remscope([1,2]) Remove all scopes. remscope(tg) or tg.remscope See Also xPC Target target object methods addscope and getscope. xPC target M-file demo scripts listed in “xPC Target Demos” on page 5-8.
removefile Purpose Syntax 14removefile Remove file from target PC MATLAB command line removefile(file_obj,file_name) file_obj.removefile(file_name) Arguments Description file_name Name of the file to remove from the target PC file system. file_obj Name of the xpctarget.fs object. Method of xpctarget.fs objects Removes a file from the target PC file system. Note You cannot recover this file once it is removed. Examples Remove the file data2.dat from the target PC file system fsys.
remsignal Purpose Syntax 14remsignal 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 Description scope_object MATLAB object created with the target object method addscope or getscope. signal_index_vector Index numbers from the scope object property Signals.
remsignal See Also The xPC Target scope object method remsignal and the target object method getsignalid.
rmdir Purpose Syntax 14rmdir Remove directory from target PC MATLAB command line rmdir(file_obj,dir_name) file_obj.rmdir(dir_name) Arguments Description dir_name Name of the directory to remove from the target PC file system. file_obj Name of the xpctarget.fs object. Method of xpctarget.fsbase, xpctarget.ftp, and xpctarget.fs objects. Removes a directory from the target PC file system. Note You cannot recover this directory once it is removed. Examples Remove the directory data2dir.
saveparamset Purpose Syntax 14saveparamset Save current target application parameter values MATLAB command line saveparamset(target_object,'filename') target_object.saveparamset('filename') Arguments Description target_object Name of an existing target object. filename Enter the name of the file to contain the saved parameters. saveparamset saves the target application parameter values in the file filename. This method saves the file on a local drive of the target PC (C:\ by default).
set (scope object) Purpose Syntax 14set (scope object) 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_value, . . .) Arguments Description scope_object Name of a scope object or a vector of scope objects. 'property_name' Name of a scope object property.
set (scope object) The properties for a scope object are listed in the following table. This table includes descriptions of the properties and the properties you can change directly by assigning a value. Property Description Application Name of the Simulink model associated with this scope object. AutoRestart For scopes of type 'File', enable the file scope to collect data up to the number of samples (NumSamples), then start over again, appending the new data to the end of the signal data file.
set (scope object) Property Description Writable Filename Provide a name for the file to contain the signal data. By default, the target PC writes the signal data to a file named C:\data.dat for scope blocks. Note that for scopes of type 'File' created through the MATLAB interface, there is no name initially assigned to FileName. After you start the scope, xPC Target assigns a name for the file to acquire the signal data.
set (scope object) Property Description Writable Mode For scopes of type 'Target', indicate how a scope displays the signals. Values are 'Numerical', 'Redraw' (default), 'Sliding', and 'Rolling'. Yes For scopes of type File, specify when a file allocation table (FAT) entry is updated. Values are 'Lazy' or 'Commit'. Both modes write the signal data to the file. With 'Commit' mode, each file write operation simultaneously updates the FAT entry for the file.
set (scope object) Property Description Writable NumSamples Number of contiguous samples captured during the acquisition of a data package. If the scope stops before capturing this number of samples, the scope has the collected data up to the end of data collection, then has zeroes for the remaining uncollected data. Note that you should know what type of data you are collecting, it is possible that your data contains zeroes.
set (scope object) Property Description Writable Status Indicate whether data is being acquired, the scope is waiting for a trigger, the scope has been stopped (interrupted), or acquisition is finished. Values are 'Acquiring', 'Ready for being Triggered', 'Interrupted', and 'Finished'. Time Contains the time data for a single data package from a scope. TriggerLevel If TriggerMode is 'Signal', indicates the value the signal has to cross to trigger the scope and start acquiring data.
set (scope object) Property Description TriggerSample If TriggerMode is 'Scope', then TriggerSample specifies which sample of the triggering scope the current scope should trigger on. For example, if TriggerSample is 0 (default), the current scope triggers on sample 0 (first sample acquired) of the triggering scope. This means that the two scopes will be perfectly synchronized.
set (scope object) Property Description Writable TriggerSlope If TriggerMode is 'Signal', indicates whether the trigger is on a rising or falling signal. Values are 'Either' (default), 'Rising', and 'Falling'. Yes Type Determines whether the scope is displayed on the host computer or on the target computer. Values are 'Host', 'Target', and 'File'. WriteSize Enter the block size, in bytes, of the data chunks.
set (scope object) NumSamples: Decimation: TriggerMode: TriggerSignal: TriggerLevel: TriggerSlope: TriggerScope: TriggerSample: Signals: NumPrePostSamples: Mode: YLimit: Grid: {} {} {5x1 cell} {} {} {4x1 cell} {} {} {} {} {5x1 cell} {} {} The property value for the scope object sc1 is changed to on: sc1.set('grid', 'on') or set(sc1, 'grid', 'on') See Also 14-84 The xPC Target scope object method get (scope object). The target object methods set (target object) and get (target object).
set (target object) Purpose Syntax 14set (target object) Change target object property values 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.
set (target object) Properties must be entered in pairs or, using the alternate syntax, as one-dimensional cell arrays of the same size. This means they must both be row vectors or both column vectors, and the corresponding values for properties in property_name_vector are stored in property_value_vector. The writable properties for a target object are listed in the following table.
set (target object) Property Description Writable StopTime Time when the target application stops running. Values are in seconds. The original value is set in the Simulation menu Configuration Parameters dialog. Yes When the ExecTime reaches the StopTime, the application stops running. ViewMode Display either all scopes or a single scope on the target PC. Value is 'all' or a single scope index. This property is active only if the environment property TargetScope is set to enabled.
set (target object) See Also xPC Target target object method get (target object). Scope object methods get (scope object) and set (scope object). Built in MATLAB functions get and set. xPC target M-file demo scripts listed in “xPC Target Demos” on page 5-8.
setparam Purpose Syntax 14setparam Change writable target object parameters MATLAB command line setparam(target_object, 'parameter_value') Arguments Description target_object Name of an existing target object. The default name is tg. parameter_value Value for a target object parameter. Method of a target object. Set the value of the target parameter.
setxpcenv Purpose Syntax 14setxpcenv 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 Environment Property Description CompilerPath Value is a valid compiler root directory. Enter the path where you installed a Watcom C/C++ or Microsoft Visual C/C++ compiler. If the path is invalid or the directory does not contain the compiler, an error message appears when you use the function updatexpcenv or build a target application. TargetRAMSizeMB Values are 'Auto' and 'Manual'. From the xPC Target Explorer window Target RAM size list, select either Auto or Manual.
setxpcenv Environment Property Description MaxModelSize Values are '1MB', '4MB', and '16MB'. From the xPC Target Explorer window Maximum model size list, select either 1 MB, 4 MB, or 16 MB. Choosing the maximum model size reserves the specified amount of memory on the target PC for the target application. The remaining memory is used by the kernel and by the heap for data logging. Selecting too high a value leaves less memory for data logging.
setxpcenv Environment Property Description RS232Baudrate Values are '115200', '57600', '38400', '19200', '9600', '4800', '2400', and '1200'. From the Baud rate list, select 115200, 57600, 38400, 19200, 9600, 4800, 2400, or 1200. TcpIpTargetAddress Value is 'xxx.xxx.xxx.xxx'. In the xPC Target Explorer window Target PC IP address box, enter a valid IP address for your target PC. Ask your system administrator for this value. For example, 192.168.0.1. TcpIpTargetPort Value is 'xxxxx'.
setxpcenv Environment Property Description TcpIpGateway Value is 'xxx.xxx.xxx.xxx'. In the xPC Target Explorer window TcpIp gateway address 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. If you communicate with your target PC from within a LAN that uses gateways, and your host and target computers are connected through a gateway, then you need to enter a value for this property.
setxpcenv Environment Property Description TcpIpTargetISAMemPort 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. Set the I/O port base address to around 0x300.
setxpcenv Environment Property Description TargetScope Values are 'Disabled' and 'Enabled'. From the xPC Target Explorer window Enable target scope list, select either Enabled or Disabled. The property TargetScope is set by default to Enabled. If you set TargetScope to Disabled, the target PC displays information as text. To use all the features of the target scope, you also need to install a keyboard and mouse on the target PC. TargetMouse Values are 'None', 'PS2', 'RS232 COM1', and 'RS232 COM2'.
setxpcenv Environment Property Description EmbeddedOption Values are 'Disabled' and 'Enabled'. This property is read only. Note that the xPC Target Embedded Option is enabled only if you purchase an additional license. TargetBoot Values are 'BootFloppy', 'DOSLoader', and 'StandAlone'. From the xPC Target Explorer window Target boot mode list, select BootFloppy, DOSLoader, or StandAlone.
setxpcenv See Also 14-98 The xPC Target functions getxpcenv, updatexpcenv, and xpcbootdisk. The procedures “Changing Environment Properties with xPC Target Explorer” on page 5-3 and “Changing Environment Properties with a Command-Line Interface” on page 5-6.
start (scope object) Purpose Syntax 14start (scope object) Start execution of a scope on target PC MATLAB command line start(scope_object_vector) scope_object_vector.start +scope_object_vector start(getscope((target_object, signal_index_vector)) Target PC command line startscope scope_index startscope 'all' Arguments target_object Name of a target object.
start (scope object) 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.
start (target object) Purpose Syntax 14start (target object) Start execution of target application on 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.
stop (scope object) Purpose Syntax 14stop (scope object) Stop execution of a scope on target PC MATLAB command line stop(scope_object_vector) scope_object.stop -scope_object stop(getscope(target_object, signal_index_vector)) Target PC command line stopscope scope_index stopscope 'all' Arguments target_object Name of a target object.
stop (scope object) See Also The xPC Target target object methods getscope, stop (target object), and start (target object). The scope object method start (scope object).
stop (target object) Purpose Syntax 14stop (target object) Stop execution of target application on 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.
targetping Purpose Syntax 14targetping Test communication between a host and its target computers MATLAB command line targetping(target_object) target_object.targetping Arguments target_object Description Method of a target object. Use this method to ping a target PC from the host PC. It returns either success or failed. If the xPC Target kernel is loaded, running, and communication is working properly, this function returns the value success. Name of a target object.
trigger Purpose Syntax 14trigger Software-trigger 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', this function triggers the scope represented by the scope object to acquire the number of data points in the scope object property NumSamples.
unload Purpose Syntax 14unload Remove current target application from 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 and 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.
updatexpcenv Purpose Syntax 14updatexpcenv Change current environment properties to new properties MATLAB Command Line updatexpcenv Description Function to update environment properties. Call the function updatexpcenv in the following order: 1 Enter new properties with the function setxpcenv. 2 Type updatexpcenv to change the current properties to match the new properties. 3 Create a target boot floppy with the function xpcbootdisk.
xpc Purpose 14xpc Note See “xpctarget.xpc” on page 14-116 Call target object constructor, xpctarget.
xpcbootdisk Purpose Syntax 14xpcbootdisk Create xPC Target boot disk and confirm the current environment properties MATLAB Command Line xpcbootdisk Description Function to create an xPC target boot floppy for the current xPC Target environment that has been updated with the function updatexpcenv. Creating an xPC Target boot floppy consists of writing the correct bootable kernel image onto the disk. You are asked to insert an empty formatted floppy disk into the 3.5 inch disk drive.
xpcexplr Purpose Syntax 14xpcexplr Open xPC Target Explorer window MATLAB Command Line xpcexplr Description This graphical user interface (GUI) allows you to • Manage an xPC Target system • Enter and change environment properties • Create an xPC Target boot disk • Build, download, and run target applications • Monitor signals • Tune parameters See Also The xPC Target functions setxpcenv, getxpcenv, updatexpcenv, and xpcbootdisk.
xpctarget.fs Purpose Syntax 14xpctarget.fs Create xPC Target file system object MATLAB command line filesys_object = xpctarget.fs('mode', 'arg1', 'arg2') Arguments filesys_object Variable name to reference the file system object. mode Optionally, enter the communication mode: arg1 TCPIP Specify TCP/IP connection with target PC. RS232 Specify RS-232 connection with target PC.
xpctarget.fs If you have multiple target PCs in your system, or if you want to identify a target PC with the file system object, use the following syntax to create the additional file system objects. filesys_object=xpctarget.fs('mode', 'arg1', 'arg2') Examples In the following example, a file system object for a target PC with an RS-232 connection is created. fs1=xpctarget.fs('RS232','COM1','115200') fs1 = xpctarget.fs Optionally, if you have an xpctarget.xpc object, you can construct an xpctarget.
xpctarget.ftp Purpose Syntax 14xpctarget.ftp Create xPC Target FTP object MATLAB command line file_object = xpctarget.fs('mode', 'arg1', 'arg2') Arguments file_object Variable name to reference the FTP object. mode Optionally, enter the communication mode: arg1 TCPIP Specify TCP/IP connection with target PC. RS232 Specify RS-232 connection with target PC. Optionally, enter an argument based on the mode value: IP address If mode is 'TCPIP', enter the IP address of the target PC.
xpctarget.ftp If you have multiple target PCs in your system, or if you want to identify a target PC with the file object, use the following syntax to create the additional file objects. file_object=xpctarget.ftp('mode', 'arg1', 'arg2') Examples In the following example, a file object for a target PC with an RS-232 connection is created. f=xpctarget.ftp('RS232','COM1','115200') f = xpctarget.ftp Optionally, if you have an xpctarget.xpc object, you can construct an xpctarget.
xpctarget.xpc Purpose Syntax 14xpctarget.xpc Create a target object representing target application MATLAB command line target_object = xpctarget.xpc('mode', 'arg1', 'arg2') Arguments target_object Variable name to reference the target object: mode Optionally, enter the communication mode arg1 TCPIP Enable TCP/IP connection with target PC. RS232 Enable RS-232 connection with target PC.
xpctarget.xpc If you have multiple target PCs in your system, use the following syntax to create the additional target objects. target_object=xpctarget.xpc('mode', 'arg1', 'arg2') Examples Before you build a target application, you can check the connection between your host and target computers by creating a target object, then using the targetping method to check the connection. tg = xpctarget.xpc xPC Object Connected Application = Yes = loader tg.
xpctargetping Purpose Syntax 14xpctargetping Test communication between host and target computers MATLAB Command Line xpctargetping Examples Check for communication between the host PC and target PC. xpctargetping Description Pings 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 RS-232 and TCP/IP communication.
xpctargetspy Purpose Syntax 14xpctargetspy Open Real-Time xPC Target Spy window on host PC MATLAB Command Line xpctargetspy(target_object) Arguments target_object Description This graphical user interface (GUI) allows you to upload displayed data from the target PC. By default, xpctargetspy opens a Real-Time xPC Target Spy window for the target object, tg. If you have multiple target PCs in your system, you can call the xpctargetspy function for a particular target object, target_object.
xpctest Purpose Syntax 14xpctest Test the xPC Target installation MATLAB Command Line xpctest xpctest('noreboot') Arguments 'noreboot' Description xpctest is a series of xPC Target tests to check the correct functioning of the following xPC Target tasks: Only one possible option. Skips the reboot test. Use this option if the target hardware does not support software rebooting. Value is 'noreboot'. • Initiate communication between the host and target computers.
xpcwwwenable Purpose Syntax 14xpcwwwenable Disconnect target PC from 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. You can also use this function to connect to MATLAB after using a Web browser, or to switch to another Web browser.
xpcwwwenable 14-122
Index A applications with DOSLoader mode 4-16 with StandAlone mode 4-21 DOSLoader mode 4-3 copying kernel 4-14 creating target application 4-16 B E block parameters parameter tuning with external mode 3-50 embedded option DOSLoader 4-3 introduction 4-2 StandAlone 4-3 updating xPC Target environment 4-9 entering environment properties xPC Target Explorer 5-3 environment properties and StandAlone mode 4-17 changing through CLI 5-6 changing through xPC Target Explorer 5-3 list 5-2 updating through CLI 5-6
Index FreeDOS copying kernel 4-14 copying kernel/application 4-22 FTP objects xpctarget.
Index R T readxpcfile 7-12 target application copying with StandAlone mode 4-22 with DOSLoader mode 4-16 target object properties scopes of type file 3-29 target objects changing parameters 3-47 command-line interface 1-2 commands 1-2 list of properties with files 3-29 methods, see commands parameter properties 3-47 properties 1-2 signal properties 3-6 target PC command-line interface 6-1 copying files with xpctarget.ftp 7-8 directory listings with xpctarget.
Index task execution time (TET) average 14-37 definition 3-41 in an example 3-42 logging 14-41 maximum 14-38 minimum 14-38 with the getlog function 14-44 TET, see task execution time tracing signals xPC Target Explorer 3-11 troubleshooting accessing documentation 12-6 advanced xPC Target 12-14 BIOS settings 12-4 boot disk 12-5 CAN boards 12-16 changed stop time 12-24 communication issues 12-3 connection lost 12-18 CPU Overload 12-15 custom device drivers 12-22 device drivers 12-22 different sample times 12
Index xPC Target Explorer adding signals 3-16 configuring the host scope viewer 3-23 creating scopes 3-12 monitoring signals 3-2 stopping scopes 3-20 tracing signals 3-11 tuning parameters 3-44 xPC Target Setup window 5-2 xpctarget.fs creation 7-4 introduction 7-2 methods 14-7 overview 7-9 xpctarget.fsbase methods 14-6 xpctarget.
Index Index-6