Example: Writing and Reading Text Data
This example illustrates how to communicate with a serial port instrument by writing and reading text data.
The instrument is a Tektronix TDS 210 two-channel oscilloscope connected to the COM1 port. Therefore, many of the commands given below are specific to this instrument. A sine wave is input into channel 2 of the oscilloscope, and your job is to measure the peak-to-peak voltage of the input signal.
sassociated with serial port COM1.
sto the oscilloscope. Because the default value for the
continuous, data is asynchronously returned to the input buffer as soon as it is available from the instrument.
*IDN?command to the instrument using
fprintf, and then read back the result of the command using
The scope is configured to return a measurement from channel 1. Because the input signal is connected to channel 2, you must configure the instrument to return a measurement from this channel.
You can now configure the scope to return the peak-to-peak voltage, and then request the value of this measurement.
Transfer data from the input buffer to MATLAB using
s, you should disconnect it from the instrument, and remove it from memory and from the MATLAB workspace.
|Reading Data||Example: Parsing Input Data Using strread|
© 1994-2005 The MathWorks, Inc.