Specifications
2 RS232 I/O Support
2-22
16 Double-click the Signal Generator block, and enter parameters. For
example, from the
Wave Form list, choose, sine. In the Amplitude and
Frequency boxes enter 1. From the Units list, choose Hertz. Click OK.
17 Double-click the Gain block, and enter parameters. For example, in the Gain
box, enter
-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)” on page 2-13.
Creating RS-232 Message Structures
(
Asynchronous)
RS-232 drivers use MATLAB structures to send and receive messages and map
the input and output ports on the RS-232 driver blocks to the data written and
read from the RS-232 devices in synchronous mode.
After you add and RS-232 Setup, Asynchronous Send, and Asynchronous
Receive block to your Simulink model, you can create the message structures
to communicate with the RS-232 devices. You need to create and load these
structures into the MATLAB workspace before you build your target
application. The easiest way to create these structures is to use an M-file and
load that M-file into the MATLAB workspace.
1 In the MATLAB command window, and from the File menu, point to New,
and then click
M-file.
A MATLAB text editor window opens.
2 Enter the initialization, send, receive, and termination messages. Each
message is an element in a MATLAB structure array with a series of fields
For information and examples of these fields, see “RS-232 MATLAB
Structure Reference” on page 2-31.
For example, if you want to send and receive two floating-point numbers,
type the following.