Matlab Programming Demo - Rigol MSO2000A Series Programming Manual

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

Advertisement

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.
1.
Run the Matlab software and modify the current directory (namely modify the Current Directory at
the top of the software). In this demo, the current directory is modified to
D:\MSO2000A_Demo\MATLAB.
Click File  New  Blank M-File in the Matlab interface to create an empty M file. Add the
2.
following codes in the M file:
% Create VISA object . 'ni' is the saler Parameter and can be agilent, NI or tek.
'USB0::0x1AB1::0x04B0::DS2A0000000000::INSTR' is the device resource descriptor. You need to
set the device property. In this demo, set the length of the input buffer to 2048
MSO2000A = visa(
MSO2000A.InputBufferSize = 2048;
% Open the VISA object created
fopen(MSO2000A);
% Request data
[data,len]= fread(MSO2000A,2048);
% Turn off the device
fclose(MSO2000A);
delete(MSO2000A);
clear MSO2000A;
% 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);
MSO2000A/DS2000A Programming Guide
'ni','USB0::0x1AB1::0x04B0::DS2A0000000000::INSTR'
RIGOL
);
3-11

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents