xPC Target    

GPIB Send/Receive Message Structure

Below is a description of the possible fields for the send/receive message structure. The order of the message fields in a message does not matter. However, the field names are case sensitive.

Message Fields
Description
Address

Sets the GPIB address for the device being accessed. After the GPIB address is set, the remaining messages use this address value until another message changes the address value. Default value = 0.

The keyword ADDR is equal to the value in the message field .Address. You can use this keyword in the message fields .Command or .SendData to replace the numerical value of the GPIB address. For example, you can write

  • GPIB_Send_Receive(1).Command='wrt 16';
    

Or you can write

  • GPIB_Send_Receive(1).Address = 16;
    GPIB_Send_Receive(1).Command='wrt ADDR';
    
Command

GPIB command sent to a GPIB device. Default value = ''.

SendData

Data sent with the GPIB command. Default value = ''.

InputPorts

Defines the input ports for the driver block. Data from the input ports is sent to the GPIB device with the message fields .Command and .SendData. Default value = []. The highest number you enter determines the number of input ports on the driver block.

For example, the following message creates two input ports on the driver block, and passes data from the input ports to the read command.

  • GPIB_Send_Receive(1).Command = 'rd #%d %d';
    GPIB_Send_Receive(1).InputPorts= [1 2];
    

The first port is used to dynamically provide the length of the receive string, while the second port provides the value of the GPIB device.

RecData

Format of the data received from the GPIB device. Default value = ''. The format of this statement is very similar to a scanf statement. The read data is mapped to the output ports defined in the field .OutputPorts. If a negative output port is given, the data is read in, but not sent to any output port

For example, to read from a GPIB device with an address of 16, one floating- point number with a maximum number of bytes of 20, and send the data to the first driver block output, type the following

  • GPIB_Send_Receive(1).Command = 'rd #20 16';
    GPIB_Send_Receive(1).RecData = '%f';
    GPIB_Send_Receive(1).OutputPorts = [1];
    
RdLength

Defines the length of the data, in bytes, received with the read command and defines the keyword LENGTH. Default value = 0.

OutputPorts

Defines the output ports from the driver block. Data received from a GPIB device with the read command is sent to the output ports. Default value = []. The highest number you enter determines the number of output ports on the driver block.

For example, to use output ports 1 and 2 on the driver block, type

  • GPIB_Send_Receive.OutputPorts = [1 2];
    
OutputDataTypes

Defines the data types for the output ports on the driver block. Default value = []

If this value is not define, and there are output ports, the default type is double. Also, if there are more output ports than output data types listed, the default type for the undefined ports is double.

Wait

The amount of time, in seconds, to wait before executing the next message. This value is limited to 50 milliseconds. Default value = 0.

Timeout

Time, in seconds, the driver block waits for data to be returned Default value = 0.049.


  GPIB Initialization and Termination Message Structures Shortcuts and Features for Messages