Instrument Control Toolbox | ![]() ![]() |
Writing and Reading Data
Communicating with your instrument involves writing and reading data. For example, you might write a text command to a function generator that queries its peak-to-peak voltage, and then read back the voltage value as a double-precision array.
Before performing a write or read operation, you should consider these three questions:
The Instrument Control Toolbox automatically manages the data transferred between MATLAB and the instrument. For many common applications, you can ignore the buffering and data flow process. However, if you are transferring a large number of values, executing an asynchronous read or write operation, or debugging your application, you may need to be aware of how this process works.
For many instruments, writing text data means writing string commands that change instrument settings, prepare the instrument to return data or status information, and so on. Writing binary data means writing numerical values to the instrument such as calibration or waveform data.
You control access to the MATLAB command line by specifying whether a read or write operation is synchronous or asynchronous. A synchronous operation blocks access to the command line until the read or write function completes execution. An asynchronous operation does not block access to the command, and you can issue additional commands while the read or write function executes in the background.
Note that there are other issues to consider when reading and writing data such as the conditions under which read or write operation completes. Since these issues vary among the supported interfaces, they are described in the respective interface-specific chapters.
![]() | Default Property Values | Writing Data | ![]() |