Specifications

2 RS232 I/O Support
2-16
RS-232 Asynchronous Mode
Use asynchronous mode when you do not need a response before continuing
with other computations. You can achieve faster sample rates with the
Asynchronous Mode since neither the Send or Receive blocks wait for a
reply. As a result, the Asynchronous Mode blocks do not block as do the
Synchronous Mode blocks. The applicaiton updates the outputs only when
the entire package of data is received from the external device.
This section includes the following topics:
Adding RS-232 Driver Blocks (Asynchronous) — Add the setup, send, and
receive blocks you need to your Simulink model for RS-232 communicating
Creating RS-232 Message Structures (Asynchronous) — Create the
initialize, send/receive, and termination message structures you need in the
MATLAB workspace
Building and Running the Target Application (Asynchronous) — Run a
real-time application with RS-232 communication
For the example in this section, two Asynchronous Mode blocks illustrate
how you can test RS-232 I/O on the target PC in a simple loop-back test. This
simple but effective test lets you check that the RS-232 Send and RS-232
Receive blocks work correctly with your system using minimal hardware.
In this loop-back test, you use the COM1 port for sending signals and the
COM2 port for receiving signals. A null modem serial cable connects COM1 to
COM2 so that any messages sent from the target PC through COM1 are
received by COM2 on the same target PC.
Use a Sine Wave block as an input to an RS-232 Send block that you connect
to the COM1 port. Connect the COM2 port to an RS-232 Receive block. The
signal received from this block is then passed through a Gain block of -1.
Adding RS-232 Driver Blocks (Asynchronous)
You add RS-232 driver blocks to your Simulink model when you want to use
the serial ports on the target PC for I/O.
After you create a Simulink model, you can add xPC Target driver blocks and
define the initialization, send, receive, and termination message structures.