Products & Services Industries Academia Support User Community Company

Learn more about xPC Target   

General xPC Target Troubleshooting

General I/O Troubleshooting Guidelines

If you encounter issues using the xPC Target I/O drivers,

Can I View the Contents of the Target PC Display on the Host PC?

From the host PC, you can view the target PC monitor with the MATLAB xpctargetspy command. For example

xpctargetspy('TargetPC1')

The Real-Time xPC Target Spy window is displayed on the host PC monitor.

Why Do Attempts to Run My Model Cause CPU Overload Messages on the Target PC?

A CPU overload is not an error in the software. This condition indicates that the CPU was unable to complete processing a model time step before being asked to restart.

This error might occur if you have

Dealing with Small Model Sample Times

If the model has too small a sample time, a CPU overload can occur. This error indicates that to run the target application, executing one step of the model requires more time than the sample time for the model (Fixed step size property) allows.

When this error occurs, the target object property CPUoverload changes from none to detected. To correct the issue, perform one of the following:

Target PC BIOS

Undesirable behavior can occur if any of the following BIOS settings are enabled:

Enabling any of these properties causes non-real-time behavior from the target PC. You must disable these BIOS properties for the target PC to run the target application properly in real time. See The xPC Target Software and the Target PC BIOS in the xPC Target Getting Started Guide.

System Management Interrupts

To successfully operate real-time software on any microprocessor system, you must control and manage all interrupt services, including system management interrupts (SMIs). However, the operating system or the application software cannot detect these interrupts.

In addition, your BIOS might not be able to disable SMIs.

For some chipsets, when you cannot disable SMIs from the BIOS, you can programmatically prevent or disable SMIs. For example, see the Disabling SMIs on Intel ICH5 Chipsets document at MATLAB Central for a solution to disable SMIs in the Intel® ICH5 family.

Allow CPU Overloads

Typically, the xPC Target kernel halts model execution when it encounters a CPU overload. You can direct the xPC Target environment to allow CPU overloads using the following options in the TLC options parameter in the Real-Time Workshop pane of the Simulink Configuration Parameters dialog box:

OptionDescriptionDefault
xPCMaxOverloads

Number of acceptable overloads.

0

xPCMaxOverloadLen

Number of contiguous acceptable overloads. If you do not specify this option, the default value is the same as xPCMaxOverlaods. Specify a value that is the same or less than the value for the xPCMaxOverloads option. You should not a use value greater than the xPCMaxOverloads value.

Same as value of xPCMaxOverloads

xPCStartupFlag

Number of executions of the model at startup, where the timer interrupt is temporarily disabled during model execution. After the model finishes the first xPCStartupFlag number of executions, the xPC Target software enables the timer interrupt, which will invoke the next execution for the model.

1

When the xPC Target kernel runs the model, it checks the number of CPU overloads against the values of xPCMaxOverloads and xPCMaxOverloadLen. When the number of CPU overloads reaches the lower of these two values, the xPC Target kernel stops executing the model.

For example, if you enter a line like the following for the TLC options parameter:

-axPCMaxOverloads=30 -axPCOverLoadLen=2 -axPCStartupFlag=5

the xPC Target software ignores CPU overloads for the first five iterations through the model. After this, the xPC Target software allows up to 30 CPU overloads, preventing no more than two consecutive CPU overloads.

With the TLC options, you can use the following blocks in your model to help keep track of the number of CPU overloads.

Other Things to Try

How Can I Obtain PCI Board Information for My xPC Target System?

This topic describes how to obtain information about the PCI devices in your xPC Target system. This information is useful if you want to determine what PCI boards are installed in your xPC Target system, or if you have or want to use multiple boards of a particular type in your system. Before you start, determine what boards are installed in your xPC Target system. Use one of the following:

If you have or want to use multiple boards of a particular type in your system, ensure that the I/O drive supports multiple boards. Refer to one of the following:

If you confirm that the board type supports multiple boards, and these boards are installed in the xPC Target system, perform the following procedure to obtain the bus and slot information for these boards:

  1. In the PCI devices display, note the contents of the Bus and Slot columns of the PCI devices in which you are interested.

  2. Enter the bus and slot numbers as vectors into the PCI Slot parameter of the PCI device. For example

    [1 9]

    where 1 is the bus number and 9 is the slot number.

For additional information about PCI bus I/O devices, refer to the PCI Bus I/O Devices section of xPC Target I/O Reference.

What Sample Time Can I Expect from the xPC Target Software?

The xPC Target kernel is tuned for minimal overhead and maximum performance. On the target PC, the kernel dedicates all of its resources to the target application. For some representative sample time numbers, run xpcbench at the MATLAB command line.

Actual obtainable sample times depend on a number of factors, including:

Why Is My Requested xPC Target Sample Time Different from the Measured Sample Time?

You might notice that the sample time you request does not equal the actual sample time you measure from your model. This difference depends on your hardware. Your model sample time is as close to your requested time as the hardware allows.

However, hardware does not allow infinite precision in setting the spacing between the timer interrupts. This limitation 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 the xPC Target system, 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. Instead, the xPC Target software calculates that number as

100 x 10-6 seconds X 1.193 x 106 ticks/seconds = 119.3 ticks 

The xPC Target software rounds this number to the nearest whole number, 119 ticks. The actual sample time is then

119 ticks/(1.193 X 106 ticks/second) = 99.75 X 10-6 seconds
(99.75 microseconds)

Compared to the requested original sample time of 100 microseconds, this value is 0.25% faster.

As an example of how you can use this value to derive the expected deviation for your hardware, assume the following:

The difference between the expected and measured signals is .145, which deviates from the expected signal value by 0.29% (0.145/50). Compared to the previously calculated value of 0.25%, there is a difference of 0.04% from the expected value.

If you want to further refine the measured deviation for your hardware, assume the following:

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 0.019, which deviates from the expected signal value by 0.038% (0.019/50.002). The deviation when the sample time is 1/10000 is 0.04%.

Some amount of error is common for most PCs, and the margin of error varies from machine to machine.

Why Did I Get Error -10: Invalid File ID on the Target PC?

You might get this error if you are acquiring signal data with a scope of type file. This error occurs because the size of the signal data file exceeds the available space on the disk. The signal data will most likely be corrupted and irretrievable. You should delete the signal data file and reboot the xPC Target system. To prevent this occurrence, monitor the size of the signal data file as the scope acquires data.

Refer to The MathWorks Support xPC Target Web site (http://www.mathworks.com/support/product/XP) for additional information.

Can I Write Custom xPC Target Device Drivers?

You might want to write your own driver if you want to include an unsupported device driver in your xPC Target system. See the xPC Target Device Drivers Guide for details.

Before you consider writing custom device drivers for the xPC Target system, you should possess

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 license. Without this license, you can create and use the stand-alone application in your environment, but cannot deploy that application on another host PC that does not contain your licensed copy of the xPC Target software.

See the xPC Target API Guide for details.

Can Signal Outputs from Virtual Blocks Be Tagged?

You cannot directly tag signal outputs from virtual blocks. Instead, do the following:

  1. Add a unity gain block (a Gain block with a gain of 1) to the model.

  2. Connect the signal output of the virtual block to the input of the unity gain block.

  3. Tag the output signal of the unity gain block.

Why Has the Stop Time Changed?

If you change the step size of a target application after it has been built, it is possible that the target application will execute for fewer steps than you expect. The number of execution steps is

floor(stop time/step size)

When you compile code for a model, the Real-Time Workshop software calculates a number of steps based on the current step size and stop time. If the stop time is not an integral multiple of the step size, the Real-Time Workshop software also adjusts the stop time for that model based on the original stop time and step size. If you later change a step size for a target application, but do not recompile the code, the xPC Target software uses the new step size and the adjusted stop time. This might lead to fewer steps than you expect.

For example, if a model has a stop time of 2.4 and a step size of 1, the Real-Time Workshop software 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 the Real-Time Workshop software still uses the adjusted stop time of 2.

To avoid this problem, ensure that the original stop time (as specified in the model) is an integral multiple of the original step size.

Why Do I Get a File System Disabled Error?

If your target PC does not have a FAT hard disk, the monitor on the target PC displays the following error:

ERROR -4: drive not found 
No accessible disk found: file system disabled

If you do not want to access the target PC file system, you can ignore this message. If you want to access the target PC file system, add a FAT hard disk to the target PC system and reboot.

Note, ensure that the hard drive is not cable-selected and that the BIOS can detect it.

Can the Target PC Hard Drive Contain Multiple Partitions?

Yes, the target PC hard drive can contain multiple partitions. However, the xPC Target software supports file systems of type FAT-12, FAT-16, or FAT-32 only.

Why Does the getparamid Function Return Nothing?

The getparamid and getsignalid functions accept block_name parameters. For these functions, enter for block_name the mangled name that the Real-Time Workshop software uses for code generation. You can determine the block_name as follows:

For example, if carriage return '\n' is part of the block path, the mangled name returns with carriage returns replaced by spaces.

How Do I Handle Register Rollover for xPC Target Encoder Blocks?

Encoder boards have a fixed size counter register of 16 bits, 24 bits, or 32 bits. Regardless of the size, the register always eventually overflows and rolls over. This can happen in either the positive or negative direction.

Some boards provide a hardware mechanism to account for overflows or rollovers. As a best practice, you should design your model to always deal with overflows or rollovers. An initial count can handle the issue for some applications.

To handle register rollovers, you can use standard Simulink blocks to design the following counter algorithm types:

The Incremental Encoder sublibrary of the xPC Target library contains example blocks for these two types of counters. See Rollover Counter and Extended Counter for further details. You can use these blocks in your model as is, or modified for your model. Connect the output of the encoder block to these blocks.

These counters perform the following. To view the algorithms used in these implementations, right-click the subsystem and select the Look Under Mask option.

Keep the following requirements in mind when using these sample blocks:

Why Do I Get Compile Error When Compiling Models?

The xPC Target software supports only static links. When you compile your models, ensure that you use only static links. When compiling with xPC Target S-functions, this is not an issue.

  


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