xPC (Experimental Control)

What is xPC Target?

xPC Target is a Matlab-based real-time digital signal processing (DSP) system. It allows you to develop DSP code as a Simulink block diagram and run it in real-time on standard PC hardware equipped with I/O boards. xPC uses a host-target structure, with the host PC running Matlab/Simulink, and the target PC running a real-time kernel. The host PC builds and loads the DSP code onto the target PC via TCP/IP, making for quick DSP development.

Example xPC application

To help demonstrate how xPC is to be used, we will consider the example of developing a simple proportional controller. This example is broken down into three sections:

  1. Build a Simulink block diagram
  2. Generate and load code
  3. Controlling xPC

The Lab's Base Model

In the lab, the Simulink model that runs on the xPC Target interacts with the experimental GUI that coordinates experiments. As such, the model is required to have certain standard blocks to facilitate interaction with the GUI. If possible, get a working model from a student and modify it to suit your needs. Failing that, there is a base model which contains the minimal block set to get you started.

Notes:

It has been found in the lab that for models to run properly on the xPC Target it is necessary, with the Watcom compiler, to disable code optimization when the model is built. The optimizer can be turned off by changing the Make command line in the Real-Time Workshop page of the model configuration parameters.
Change: make_rtw into: make_rtw OPT_OPTS

Subject Feedback

The xPC Target may also be used to send data to a computer which is used solely to provide visual feedback to the subject. The blocks required to send the feedback information are in the lab's base model.

The following demo contains three files,

  • DemoHrdWare.mdl is the Simulink model that runs on RENSHAW (the xPC Target system) and sends data to a receiving machine (TWITCH) for display.
  • UDP_Receive.mdl is the Simulink model that runs on TWITCH and captures the data.
  • UDP_plot.m is an S-function used by UDP_Receive to plot the data on the screen.

which may be used as a starting point when customizing the subject feedback for your experiments. In your application you will have to, at the very least, modify UDP_plot to process the proper number of input signals and program the display graphics (e.g., whether you wish to displace a symbol or some geometric figure).

Last modified: 2009-06-23 Ross Wagner