xPC Target | ![]() ![]() |
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.
Note This library contains two setup blocks. The second block is included for compatibility with xPC Target Version 1.0.
Alternatively, you could access the xPC Target block library from the Simulink Library Browser. In the Simulink window, and from the View menu, click Show Library Browser. In the left pane, double-click xPC Target, and then click RS-232.
57600
baud, 8 databits, and 1 stopbit. Your Block Parameter dialog box should look similar to the figure shown below.
Note If you are not using an initialization or termination structure, in the Initialization Struct and Termination Struct boxes, enter the empty matrix []
.
For more information on entering the block parameters, see RS-232 Setup Block. For the procedure to create the initialization and termination structures, see RS-232 MATLAB Structure Reference.
COM1
or COM2
. For this example, select COM1
. In the Message struct name box, enter the name for the MATLAB structure this block uses to send messages to the COM1 port. In the Sample Time box, enter the sample time or a multiple of the sample time you entered in the RS-232 Receive block.
For information on entering the block parameters, see RS-232 Send Block (Asynchronous). For the procedure to create the send structure, see RS-232 MATLAB Structure Reference.
COM1
or COM2
. For this example, select COM2
. In the Message Struct Name box, enter the name for the MATLAB structure this block uses to receive messages from the COM2 port. In the Sample Time box, enter the sample time or a multiple of the sample time you entered in the RS-232 Send block.
For information on entering the block parameters, see RS-232 Receive Block (Asynchronous). For the procedure to create the send structure, see RS-232 MATLAB Structure Reference.
sine
. In the Amplitude and Frequency boxes enter 1
. From the Units list, select Hertz
. Click OK.
-1
. Click OK.
Your next task is to create the MATLAB message structures that the RS-232 driver blocks use to sequence commands to the RS-232 device. See Creating RS-232 Message Structures (Synchronous).
![]() | Notes for RS-232 Asynchronous Mode | Creating RS-232 Message Structures (Asynchronous) | ![]() |