Specifications
RS-232 Asynchronous Mode
2-25
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 communication 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.
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
+tg or tg.start or start(tg)
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 of one delay to send
the data and also receive it. When running at faster sample rates, it is
possible for additional sample intervals to happen while one transfer of data
is processed since RS-232 communication is not particularly fast. The
sample delay just described is not visible in this example.