Capturing FFT from TDS Oscilloscope with MATLAB Code
Show older comments
I have a code shown below that can capture voltage versus time data and then calculate the spectrogram for the system I am working with... I am trying to read/store the FFT directly from the oscilloscope and having difficulty finding anything on Tektronix website or their support...
I am trying to replicate an old paper (which shows them capture the data directly from the scope). I can FFT the data myself and get a matching curve, but I would like to capture it directly from the scope.
%%Instrument Connection
clear all; close all; clc;
% Create a VISA-USB object.
resourceName = instrfind('Type', 'visa-usb', 'RsrcName', 'USB0::0x0699::0x0363::C054303::0::INSTR', 'Tag', '');
% Create the VISA-USB object if it does not exist
% otherwise use the object that was found.
if isempty(resourceName)
resourceName = visa('NI', 'USB0::0x0699::0x0363::C054303::0::INSTR');
else
fclose(resourceName);
resourceName = resourceName(1);
end
% Create a device object .
scope = icdevice('tektronix_tds2000B.mdd', resourceName);
%%Section 1
% Channel 1 is used to capture the BACKGROUND
clc;
disconnect(scope);
connect(scope);
devicereset(scope);
set(scope.Channel(1), 'Scale', 20);
set(scope.Channel(1), 'Coupling', 'ac');
set(scope.Channel(1), 'Probe', 1.0);
set(scope.Trigger(1), 'Coupling', 'ac');
set(scope.Trigger(1), 'Source', 'channel1');
set(scope.Trigger(1), 'Level', 0.40);
set(scope.Display(1), 'Format', 'yt');
set(scope.Display(1), 'Persistence', 0.0);
set(scope.Acquisition(1), 'Timebase', 2.5E-06);
set(scope.Acquisition(1), 'Delay', 12.5e-6);
set(scope.Trigger(1), 'Mode', 'auto');
disconnect(scope);
%%Section 2
% Graphing the BACKGROUND and incoming Fast FFT
clc;
disconnect(scope);
connect(scope);
scopeTrigger = get(scope,'trigger');
invoke(scopeTrigger, 'trigger');
[Y, X, YUNIT, XUNIT] = invoke(get(scope, 'Waveform'), 'readwaveform', 'channel1');
disconnect(scope);
close all;
plot(X,Y);
xlabel('Time (us)');
ylabel('Voltage (V)');
axis([0 2.5e-5 -6 6]) % Time in us and Volts in V
figure(2)
spectrogram(Y,kaiser(256,2),240,1280,1E8);
ax = gca;
ax.XLim = [0.3,5]; % Frequency range in MHz
ax.YLim = [0,25]; % Time range in us
[S,F,T] = spectrogram(Y,kaiser(256,2),240,1280,1E8); % Storing as a vector
figure(3)
Fs = 1e8; % Sampling frequency
T = 1/Fs; % Sampling period
L = 2500; % Length of signal
t = (0:L-1)*T; % Time vecto
FT = fft(Y);
P2 = abs(FT/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
Answers (0)
Categories
Find more on Oscilloscopes in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!