Send simulation data to instrument
Instrument Control Toolbox
The To Instrument block configures and opens an interface to an instrument, initializes the instrument, and sends data to the instrument. The configuration and initialization happen at the start of the model execution. The block sends data to the instrument during model run time.
The block has no output ports. The block has one input port corresponding to the data sent to the instrument. This data type must be double precision.
Note
The To Instrument block can be used with these interfaces: VISA, GPIB, Serial, TCP/IP, and UDP. It is not supported on these interfaces: SPI, I2C, and Bluetooth.
This block supports the use of Simulink® Accelerator™ mode, but not Rapid Accelerator or code generation.
The block supports the use of model referencing, so that your model can include other Simulink models as modular components.
For more information on these features, see the Simulink documentation.
The Block sample time parameter is the only setting outside
of the dialog box tabs. The default value of -1
sets
the block to inherit timing. A positive value is used as the sample
period.
The Hardware Configuration tab is where you define the settings for communications with your instrument. You have two choices about establishing an interface:
Specify a new hardware configuration.
Use an interface object from the MATLAB® workspace.
The following figure shows the Hardware Configuration tab set to specify a new hardware configuration using a serial port interface.
Because some parameters apply to multiple interface types, they appear here in alphabetical order.
The rate at which bits are transmitted for the serial or VISA serial interface.
The index of the board used for GPIB, VISA GPIB, VISA TCPIP,
or VISA USB interface to the instrument. See BoardIndex
property for more information.
The vendor of the GPIB board used for the interface to the instrument. Your choices are Keysight™ (formerly Agilent®), ICS Electronics™, Measurement Computing™ (MCC), and National Instruments®.
The index number of the VXI chassis. Used for VISA VXI and VISA VXI-GPIB interface types.
The total number of bytes that can be stored in the software output buffer during a read operation.
Select the type of hardware interface to the instrument. Your options are those interfaces supported by the Instrument Control Toolbox™ software. The previous figure shows a configuration for a serial port interface.
The logical address of the VXI instrument. Used for VISA VXI and VISA VXI-GPIB interface types.
The manufacturer ID of the VISA USB instrument defined as a
character vector. See ManufacturerID
property
for more information.
The model code of the VISA USB instrument defined as a character
vector. See ModelCode
property
for more information.
The port for the serial interface: COM1, COM2, etc.
The primary address of the instrument on the GPIB.
The host name or IP address of the instrument. Used for UDP, TCPIP, or VISA TCPIP interface types.
The port on the instrument or remote host used for communication. Used for UDP, TCPIP, or VISA TCPIP interface types.
The secondary address of the instrument on the GPIB.
The serial number of the VISA USB instrument defined as a character
vector. See SerialNumber
property
for more information.
Time in seconds, allowed to complete the query operation.
The vendor of the VISA instrument used for any of the VISA interface types. Your choices are Keysight (formerly Agilent), National Instruments, and Tektronix®.
Select this option to use an interface object from the MATLAB workspace.
Enter the object name that you want to use from the MATLAB workspace.
The Instrument Initialization tab is where you define what happens when you first open your connection to the instrument.
The default initialization option is none.
A string sent to the instrument as an instrument command to initialize the instrument or set it up in a known state.
Any function that has as its only argument the interface object representing the instrument. You can write this function to include several instrument commands and initialization data.
The Send tab is where you define the optional command sent to the instrument and the format of the sent data.
This is the command that is sent to the instrument with the Simulink data. This command is optional—if you leave this field blank, the Simulink data is sent to the instrument without any prefix or additional formatting.
Your options are ASCII
, Binary
,
or Binblock
(binary block — the binblock
format
is described in the binblockwrite
function
reference page).
Available only when the format is ASCII, this defines the format
string for the data. For a list of formats, see the fprintf
function.
Used for binary or binblock format. Your options are:
8-bit integer
(default)
16-bit integer
32-bit integer
8-bit unsigned integer
16-bit unsigned integer
32-bit unsigned integer
32-bit float
64-bit float
When using binary or binblock format with more than 8 bits,
you can specify the instrument's byte order for the data. Your options
are Big Endian
or Little Endian
.
Tip
Hardware information shown in the dialog box is determined and cached when you first open the dialog box. To refresh the display with new values, restart MATLAB.
Query Instrument, TCP/IP Receive, TCP/IP Send, UDP Receive, UDP Send