Specifications

1 I/O Drivers
1-6
Creating a message structure You could enter the message structure
directly in the edit field of the driver Parameter dialog box. But because the
message structure is an array and very large, this becomes cumbersome very
easily.
A prefered way is to define the message structure as an array in an M-file and
pass the structure array to the dirver by referencing it by mane. For example,
to initialize an external A/D module and acquire a value during each sample
interval, create and M-file with the following statements.
Message(1).senddata=’InitADConv, Channel %d’
Message(1).inputports=[1]
Message(1).recdata=’’
Message(1).outputports=[]
Message(2).senddata=’Wait and Read converted Value’
Message(2).inputports=[]
Message(2).recdata=’%f’
Message(2).outputports=[1]
This approach has two issues different from other xPC Target driver blocks:
The M-file containing the definition of the message structure has to be
executed before the model is opened.
After creating your Simulink model and message M-file, set the preload
function of the Simulink model to load the M-file the next time you open the
model. In the Mathlab window, type
set_param(gcs, ’PreLoadFcn’, ’M-file_name
When you move or copy the model file to a new directory, you also need to
move or copy the M-file defining the message structure.
During each sample interval, the driver block locates the structure defined in
the Parameter dialog box, interprets the series of messages, and executes the
command defined by each message.
Specific drivers and structures For detailed information on the fields in a
message structure see the following chapters:
RS232 I/O Support
GPIB I/O Support
CAN I/O Support