xPC Target | ![]() ![]() |
Shortcuts and Features for Messages
xPC Target defines the abbreviations wrt
and rd
to make message writing easier with GPIB commands. When the message interpreter sees the statements:
Structure_name(index).'wrt'
, it is replaced with Structure_name(index).'wrt ADDR'
. For example, you could write
The following message fields, with the keyword ADDR, use the address value 8
defined in the message field .Address
.
Structure_name (index).Command = 'rd'
, it is replaced with Structure_name(index).Command = 'rd #LENGTH ADDR
'. For example, you could write
If you enter numerical values in the wrt
and rd
commands, then the command uses those values instead of the values in the variables ADDR and LENGH. For example, the following message uses the GPIB address 10 even though the value for ADDR is defined as 8.
Changes to the Read Command -- When a GPIB rd
command is sent to the GPIB controller, the controller responds with the data and length of data. To make using this command easier, the xPC Target diver block, discards the length of data information. For example, using the normal GPIB rd
command, you could write
GPIB_Message(1).Command = 'rd #20 16'; GPIB_Message(1).RecData = '%f%d'; GPIB_Message(1).OutputPorts = [1 -1];
The code %d
reads the length of data and the -1
discards the length. Using the modified xPC Target rd
command, you would write
GPIB_message(1).Command = 'rd #20 16'; GPIB_message(1).RecData = '%f'; GPIB_message(1).OutputPorts = [1];
Automatic Addition of Escape Characters -- The message interpreter automatically places the correct escape characters at the end of the message fields .Command
, .SendData
, and .Ack
. However, if you add the escape characters, then the message interpreter does not add additional characters.
The escape characters that are: \\
, \a
, \b
, \f
, \r
,\t
, \v
, \'
, \''
, and \n
.
GPIB_Message.Command = 'wrt 16\n'; GPIB_Message.SendData = ':conf:volt:dc\r'; GPIB_Message.Ack = '10\n\r';
or you can write the following, and the appropriate escape characters are added.
![]() | GPIB Send/Receive Message Structure | Supported Data Types for Message Fields | ![]() |