Generating and Loading Code

Once the model has been set up, it must be compiled. The required compile options needed to build code for xPC are shown below.

  1. Clicking on the Browse button will open a window that shows all the possible templates and target files for use with the Real-Time Workshop. Select the xPC Real-Time target option.
  2. Click on the Build button to start the compile.
  3. Note that the Build button will generate the code and attempt to upload the code to Renshaw.

Using the Command Window

Alternatively, the code can be compiled (and loaded) from the Command WIndow with the rtwbuild <model_name.mdl> command.

TIP: The xPC loading stage uses a Matlab object called an xpc object handle as the means to control the application. The default xpc object handle name is tg.

Once code has been successfully compiled once, it can be uploaded to the target using the load(<xpc_object_handle>,'<code.dlm>') from the Command Window.

Some Common Errors

Error Message
Problem
Solution(s)
TCP/IP Connect Error There is a problem with the host-target communication
  1. ensure the target is running
  2. check xpcsetup parameters
  3. ensure the target Boot Disk is current
Undefined function or variable '<xpc_object_handle>' The variable <xpc_object_handle> has not been initialized as an xpc object Initialize the <xpc_object_handle> with the command <xpc_object_handle> = xpc;

 

... now you can start the code with xPC Control

back to xPC

 

Last modified: 2010-03-24 Ross Wagner