xPC Target    

Building and Running the Target Application (Asynchronous)

xPC Target and Real-Time Workshop create C code from your Simulink model. You can then use a C compiler to create executable code that runs on the target PC.

After you have added the RS-232 blocks for asynchronous mode to your Simulink model, and created and loaded the RS-232 structures into the MATLAB workspace, you can build your target application.

  1. In the Simulink window, and from the Tools menu, point to Real-Time Workshop, and then click Build Model.
  2. In the MATLAB command window, type
  1. The target application begins running in real time.

    For each sample period, the RS-232 messages you entered in the RS-232 send and receive message structures are executed.

    In this example, the target PC displays the inverted waveform. The RS-232 Send and RS-232 Receive blocks require a minimum delay or one sample to send the data and also receive it. When running at faster sample rates, several sample intervals may elapse while one set of data is transmitted since RS-232 communication is not particularly fast. The sample delay just described is not visible in this example.

This example can be extended for multiple D/A channels by simply adding more input signals and modifying the format string to have additional '%f'format specifiers.


  Creating RS-232 Message Structures (Asynchronous) RS-232 Simulink Block Reference