External Interfaces |
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.
s
associated with the serial port COM1.
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.
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
.
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.
The recording state is toggled from on
to off
. Because the RecordMode
value is index
, the record filename is automatically updated.
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.
type WaveForm1.txt Legend: * - An event occurred. > - A write operation occurred. < - A read operation occurred. 1 Recording on 22-Jan-2000 at 11:21:21.575. Binary data in... 2 > 6 ascii values. *IDN? 3 < 56 ascii values. TEKTRONIX,TDS 210,0,CF:91.1CT FV:v1.16 TDS2CM:CMV:v1.04 4 > 29 ascii values. MEASUREMENT:IMMED:SOURCE CH2 5 > 26 ascii values. MEASUREMENT:IMMED:SOURCE? 6 < 4 ascii values. CH2 7 > 27 ascii values. MEASUREMENT:MEAS1:TYPE PK2PK 8 > 25 ascii values. MEASUREMENT:MEAS1:VALUE? 9 < 15 uchar values. 32 2e 30 31 39 39 39 39 39 38 30 39 45 30 0a 10 Recording off.
The Record File Format | Saving and Loading |
© 1994-2005 The MathWorks, Inc.