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.
Note You cannot use a serial port to communicate between the host PC and target PC with this example. Using a serial port would disable the COM port and the example would not operate. |
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.
Note This example requires that you are not using host PC to target PC communication using a serial port since that would disable that COM port and the example would not operate. |
![]() | Creating RS-232 Message Structures (Asynchronous) | RS-232 Simulink Block Reference | ![]() |