Products & Services Industries Academia Support User Community Company

Learn more about xPC Target   

xPC Target Application

Booting the Target PC

Booting the target computer loads and starts the xPC Target kernel on the target PC. The loader then waits for the xPC Target software to download your target application from the host PC.

After you have configured the xPC Target product using the xPC Target Explorer and created a target boot disk for that setup, you can boot the target PC. You need to boot the target computer before building your target application because the build process automatically downloads your target application to the target PC. Be sure that you have followed the instructions from Installation and Configuration before continuing.

  1. Insert the target boot disk into the target PC disk drive.

  2. Turn on the target PC or press the Reset button.

    The target PC displays the following screen.

In the example above, the status window shows that the kernel is in loader mode and waiting to load a target application. 1 MB of memory is reserved for the application, 3 MB is used by the kernel, and 28 MB is available from a total of 32 MB. The xPC Target kernel uses the 28 MB for the heap, running scopes, and acquiring data.

Your next task is to enter the simulation and real-time run parameters for Real-Time Workshop. See Entering the Real-Time Workshop Parameters.

Troubleshooting the Boot Process

Possible Problem

When booting the target PC, it might display a message like the following

xPC Target 4.X loading kernel..@@@@@@@@@@@@@@@@@@@@@@

The target PC displays this message when it cannot read and load the kernel from the target boot disk. The probable cause is a bad disk.

Solution.   If you have a 3.5-inch target boot disk, reformat the disk or use a new formatted floppy disk and create a new target boot disk. If you have a CD target boot disk, create a new disk.

Possible Problem

When booting the target PC, you get a message similar to the following:

Not a bootable medium or NTLDR is missing

Selecting either DOS Loader or Standalone mode instead of Boot Floppy mode can cause this message.

Solution.   If the xPC Target Explorer window is not already open, open it. In the MATLAB Command Window, type xpcexplr. In the xPC Target Explorer xPC Target Hierarchy pane, select a target PC Configuration node. For example, select the Configuration node for TargetPC1. In the configuration pane, select your desired boot mode. Create a new boot disk or network boot image.

Entering the Real-Time Workshop Parameters

You enter the simulation and real-time run parameters in the Configuration Parameters dialog box. These parameters give information to Real-Time Workshop on how to build the target application from your Simulink model.

After you load a Simulink model and boot the target PC, you can enter the simulation parameters. This procedure uses the Simulink model xpc_osc2.mdl as an example and assumes you have already loaded that model (see Simulink Model).

  1. In the MATLAB window, type

    xpc_osc2

    MATLAB loads the oscillator model and displays the Simulink block diagram, as shown below.

  2. In the Simulink window, and from the Simulation menu, click Configuration Parameters.

    The Configuration Parameters dialog box is displayed for the model.

  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 System target file list. Click xpctarget.tlc, and then click OK.

    The system target file xpctarget.tlc, the template makefile xpc_default_tmf, and the make command make_rtw are automatically entered into the page. The xPC Target options node appears in the left pane. The Real-Time Workshop pane should now look like the figure shown.

    If you have the Real-Time Workshop Embedded Coder, you can build an ERT target application. To build an ERT target application, in the Target selection section, click the Browse button at the System target file list. Click xpctargetert.tlc, and then click OK.

    Note that if the Real-Time Workshop Embedded Coder is not installed and you select the xpctargetert.tlc, the build fails.

  5. In the left pane, click the xPC Target options node.

    The associated pane is displayed.

  6. From the Execution mode list, select either Real-Time or Freerun. The option Freerun is similar to a simulation, but with the generated code. It runs the target application as fast as it can. However, unlike a simulation, the Freerun mode of the xPC Target software does not support variable-step solvers.

  7. From the Real-time interrupt source list, select a source. The default value is Timer.

  8. Select the Log Task Execution Time check box to log task execution times to the target object property tg.TETlog.

    The task execution time is the time in seconds to complete calculations for the model equations and post outputs during each sample interval. If you do not select this box, your average TET value appears as Not a Number (NaN).

  9. In the Signal logging buffer size in doubles box, enter the maximum number of sample points to save before wrapping, for example, 100000. This buffer includes the time, states, outputs, and task execution time logs.

  10. In the Name of xPC Target object created by build process box, enter the name of the target object created by the build process. The default target object name is tg.

    The Real-Time Workshop pane should now look like the figure shown.

  11. Click OK.

  12. From the File menu, click Save as. Enter a filename. For example, enter xpc_osc3 and then click Save.

Your next task is to create (build) the target application. See Building and Downloading the Target Application.

Building and Downloading the Target Application

You use the xPC Target build process to generate C code, compile, link, and download your target application to the target PC.

After you enter your changes in the Configuration Parameters dialog box, you can build your target application. This procedure uses the Simulink model xpc_osc3.mdl as an example. To create this model, see xPC Target Application. By default, the build procedure downloads the target application to the default target PC, as designated in the xPC Target Explorer. See xPC Target Options for further details on setting the target PC for a target application.

  1. In the MATLAB window, type

    xpc_osc3

    MATLAB loads the oscillator model and displays the Simulink block diagram.

  2. In the Simulink window and from the Tools menu, select Real-Time Workshop. From the Real-Time Workshop submenu, click Build Model.

    After the compiling, linking, and downloading process, a target object is created in your MATLAB workspace. The default name of the target object is tg. For more information about the target object, see Targets and Scopes in the MATLAB Interface in the xPC Target User's Guide.

    On the host computer, MATLAB displays the following lines after a successful build process:

    ### Starting Real-Time Workshop build procedure for model: 
    xpc_osc3
    . . .
    ### Successful completion of xPC Target build procedure for 
    model: xpc_osc3

    The target PC displays the following information:

  3. In the MATLAB window, type

    tg

    MATLAB displays a list of properties for the target object tg.

If you do not have a successful build, see Troubleshooting the Build Process.

Your next task is to run the target application in real time on the target PC. See Running the Target Application.

Troubleshooting the Build Process

If the host PC and target PC are not properly connected, or you have not correctly entered the environment properties, the download process is terminated after about 5 seconds with a time-out error. Be sure that you have followed the instructions outlined in Installation and Configuration before continuing.

To correct the problem, use the following procedure:

  1. If the xPC Target Explorer is not already up, in the MATLAB window, type

    xpcexplr

    The xPC Target Explorer window opens.

  2. For the target PC in question, check the RS-232 or TCP/IP parameters. If necessary, make changes to the communication properties and recreate the target boot disk.

    In some cases, the download might have completed successfully even though you get a time-out error. To detect this, wait until the target screen displays

    System:initializing application finished.
  3. In the xPC Target Explorer window

    1. Select the target PC in question

    2. From the menu bar, select Target > Ping Target.

    For a working connection between the host PC and target PC, xPC Target Explorer displays a pop-up dialog box.

  4. Right-click the target PC in question and select Connect.

    If the connection is resumed, the connection is all right. If the connection is timing out consistently for a particular model, the time-out needs to be increased. See Increasing the Time-Out Value.

For information on setting up the xPC Target software environment, see either Environment Properties for Serial Communication or Environment Properties for Network Communication, and then see Booting Target PCs from Boot Floppy Disk.

Increasing the Time-Out Value

By default, if the host PC does not get a response from the target PC after downloading a target application and waiting about 5 seconds, the host PC software times out. On the other hand, the target PC responds only after downloading and initializing the target application.

Usually 5 seconds is enough time to download a target application, but in some cases it may not be sufficient. The time to download a target application mostly depends on your I/O hardware. For example, thermocouple hardware takes longer to initialize. In this case, even though the target PC is fine, a false time-out is reported.

You can increase the time-out value in one of the following ways.

For both methods, 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.

xPC Target Options

Following is a description of the fields in the xPC Target options node. To access this node, from the model, select Simulation > Configuration Parameters. In the left pane, click the xPC Target options node.

You might need to enter and select these options before you create (build) a target application. However, this is not normally necessary because the parameters have reasonable defaults.

Automatically download application after building — Selecting this option allows Real-Time Workshop to build and download the target application to the target PC. If you do not select this check box, Real-Time Workshop builds the application (DLM), but does not download it to the target PC. By default, this check box is selected.

Download to default target PC — Selecting this option directs Real-Time Workshop to build and download the target application to the default target PC. This assumes that you configured a default target PC through the xPC Target Explorer (see sections Serial Communication and Network Communication if you have not). By default, this check box is selected.

Specify the target PC name — If you deselect the Download to default target PC check box, this field is displayed.

Name of xPC Target object created by build process — Enter the name of the target object created by the build process. The default target object name is tg. Use this name to work with the target object through the command line interface.

Use default communication timeout — Selecting this option directs the xPC Target software to wait 5 seconds (default) for the target application to download to the target PC.

Specify the communication timeout in seconds — If you deselect the Use default communication timeout check box, this field is displayed. Enter the maximum length of time in seconds you want to allow the xPC Target software to wait for the target application to download to the target PC. If the target application is not downloaded within this time frame, the software generates an error.

Execution mode — From the list, select either Real-Time or Freerun.

Real-time interrupt source — From the list, select Timer, Auto (PCI only), or a number from 3 to 15. Multiple boards can share the same interrupt number.

Choose Auto (PCI only) to enable the xPC Target software to automatically determine the IRQ that the BIOS assigned to the board and use it. Note the following:

I/O board generating the interrupt — From the list, select the board interrupt source.

PCI slot (-1: autosearch) or ISA base address — Enter the slot number or base address for the I/O board generating the interrupt.

Log Task Execution Time — Select this check box to log task execution times to the target object property tg.TETlog.

Signal logging data buffer size in doubles — Enter the maximum number of sample points to save before wrapping. Your target application uses this buffer to store the time, states, outputs, and task execution time logs as defined in your Simulink model.

Note that the maximum value for this option derives from available target PC memory, which the xPC Target software also uses to hold other items. For example, in addition to signal logging data, the software also uses the target PC memory for the xPC Target kernel, target application, and scopes.

For example, the model xpc_osc2.mdl has six data items (one time, two states, two outputs, and one task execution time (TET)). If you enter a buffer size of 100000, then the target object property tg.MaxLogSamples is calculated as floor(100000) / 6) = 16666. After saving 16666 sample points, the buffer wraps and further samples overwrite the older ones.

If you enter a logging buffer size larger than the available RAM on the target PC, after downloading and initializing the target application, the target PC displays a message, ERROR: allocation of logging memory failed. In this case you need to install more RAM or reduce the buffer size for logging. In any case you must reboot the target PC. To calculate the maximum buffer size you might have for you target application logs, divide the amount of available RAM on your target PC by 8. Enter that value for the Signal logging data buffer size in doubles value.

Double buffer parameter changes — Selecting this option changes parameter tuning so that the process of changing parameters in the target application uses a double buffer:

Double buffering leads to a more robust parameter tuning interface, at the cost of increased TET and a higher probability of overloads. You should normally clear this check box. It is cleared by default.

Load a parameter set from a file on the designated target file system — Select this check box to load a parameter set from a file on the designated target PC file system. Selecting this check box enables the File name parameter.

File name — Specify the file name from which to load the parameter set on the target PC file system.

Build COM objects from tagged signals/parameters — If you select this check box, the build process creates a model-specific COM library file:

<model_name>COMiface.dll

Use this file to create custom GUI interfaces with Visual Basic or other tools that can use COM objects.

Generate CANape extensions — Selecting this check box enables target applications to generate data, such as that for A2L, for Vector CANape. By default, this check box is not selected.

Include model hierarchy on the target application — Selecting this check box includes the model hierarchy as part of the target application. If you select this, you can connect to the target PC from xPC Target Explorer without being in the target application build folder. Note, selecting this check box might increase the size of the target application, depending on the size of the model.

  


Related Products & Applications

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

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