Matlab Programming Demo - Rigol DS1000Z Series Programming Manual

Digital oscilloscope
Hide thumbs Also See for DS1000Z Series:
Table of Contents

Advertisement

Chapter 3 Programming Demos

Matlab Programming Demo

The program used in this demo: MATLAB R2009a
The function realized in this demo: make FFT operation on the waveform data and draw the
waveform.
Run the Matlab software and modify the current directory (namely modify the Current Directory at
1.
the top of the software). In this demo, the current directory is modified to E:\DS1000Z_Demo.
2.
Click File  New  Blank M-File in the Matlab interface to create an empty M file.
3.
Add the following codes in the M file:
% Create VISA object
DS1000z = visa('ni','USB0::0x1AB1::0x04CE::DS1T00000006::INSTR');
% Set the device property. In this demo, the length of the input buffer is set to 2048.
DS1000z.InputBufferSize = 2048;
% Open the VISA object created
fopen(DS1000z);
% Read the waveform data
fprintf(DS1000z, ':wav:data?' );
% Request the data
[data,len]= fread(DS1000z,2048);
% Close the VISA object
fclose(DS1000z);
delete(DS1000z);
clear DS1000z;
% Data processing. The waveform data read contains the TMC header. The length of the header is 11
bytes, wherein, the first 2 bytes are the TMC header denoter (#) and the width descriptor (9)
respectively, the 9 bytes following are the length of the data which is followed by the waveform data
and the last byte is the terminator (0x0A). Therefore, the effective waveform points read is from the
12nd to the next to last.
wave = data(12:len-1);
wave = wave';
subplot(211);
plot(wave);
fftSpec = fft(wave',2048);
fftRms = abs(fftSpec');
fftLg = 20*log(fftRms);
subplot(212);
plot(fftLg);
4.
Save the M file under the current directory. In this demo, the M file is named as
DS1000Z_Demo_MATLAB.m.
DS1000Z Programming Guide
RIGOL
3-7

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ds1104zDs1074zDs1104z-sDs1074z-s

Table of Contents