External Interfaces Previous page   Next Page

Example: Recording Information to Disk

This example illustrates how to record information transferred between a serial port object and a Tektronix TDS 210 oscilloscope. Additionally, the structure of the resulting record file is presented.

  1. Create the serial port object - Create the serial port object s associated with the serial port COM1.
  2. Connect to the device - Connect s to the oscilloscope. Because the default value for the ReadAsyncMode property is continuous, data is asynchronously returned the input buffer as soon as it is available from the instrument.
  3. Configure property values - Configure s to record information to multiple disk files using the verbose format. Recording is then initiated with the first disk file defined as WaveForm1.txt.
  4. Write and read data - The commands written to the instrument, and the data read from the instrument are recorded in the record file. Refer to Example: Writing and Reading Text Data for an explanation of the oscilloscope commands.
  1. Read the peak-to-peak voltage with the fread function. Note that the data returned by fread is recorded using hex format.

    Convert the peak-to-peak voltage to a character array.

    The recording state is toggled from on to off. Because the RecordMode value is index, the record filename is automatically updated.

  1. Disconnect and clean up - When you no longer need s, you should disconnect it from the instrument, and remove it from memory and from the MATLAB workspace.

The Record File Contents

The contents of the WaveForm1.txt record file are shown below. Because the RecordDetail property was verbose, the number of values, commands, and data were recorded. Note that data returned by the fread function is in hex format.


Previous page  The Record File Format Saving and Loading Next page

© 1994-2005 The MathWorks, Inc.