User`s manual
Debugging: Recording Information to Disk
8-65
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.
s = serial('COM1');
2. Connect to the device – Connect s to the oscilloscope. Since 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.
fopen(s)
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.
s.RecordMode = 'index';
s.RecordDetail = 'verbose';
s.RecordName = 'WaveForm1.txt';
record(s)
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” on page 8-42 for an explanation of
the oscilloscope commands.
fprintf(s,'*IDN?')
idn = fscanf(s);
fprintf(s,'MEASUREMENT:IMMED:SOURCE CH2')
fprintf(s,'MEASUREMENT:IMMED:SOURCE?')
source = fscanf(s);
Read the peak-to-peak voltage with the fread function. Note that the data
returned by
fread is recorded using hex format.
fprintf(s,'MEASUREMENT:MEAS1:TYPE PK2PK')
fprintf(s,'MEASUREMENT:MEAS1:VALUE?')
ptop = fread(s,s.BytesAvailable);
Convert the peak-to-peak voltage to a character array.