% Signal_Analyzer_34411A.m script
% The "Dynamic Signal Analyzer 34411A" program turns the following Agilent
% DMMs into Dynamic signal analyzers: 34411A, 34410A, and the L4411A.
% The program sets up the DMMs as digitizers, fetches the readings,
% and performs an FFT on the readings. The FFT is plotted with dBV on the y
% axis and frequency on the x axis. A second plot is created for the time
% domain view of the signal with amplitude on the y axis and time on the x
% axis. The program connects to the DMM via LAN. The program takes the
% following instrument parameters:
% IP address --> The LAN network address of the DMM for connecting and
% communicating with the DMM. The IP address of the DMM can be obtained from
% the DMM's "Utilities" menu.
% Sample Rate --> Sets the sample digitizing rate of the DMM. The max
% sample rates of the 34411A and L4411A is 50,000 readings per second. The
% max sample rate of the 34410A is 10,000 readings per second. the minimum
% sample rate is 1.
% Sample Count --> Sets the number of measurements made. The minimum
% measurement count is 10 and the max is 500,000. Note the 34410A can only
% make up to 50,000 readings.
% Voltage Range --> sets the voltage measurement range of the DMM. The max
% voltage of the signal you are measuring must be equal or less than the
% measurement range. the ranges are .1 1 10 100 1000 volts
% Start frequency --> The frequency that you want to start the FFT plot at
% on the X axis.
% Stop frequency --> The frequency that you want to stop the FFT plot at on
% the X axis.
% Since the 34411A and L4411A can sample up to 50K readings a second they
% can be used to measure signal frequencies up to 25 KHz (The 34410A up to
% 5 KHz). This makes the program a great tool for doing distortion analysis
% on a power line signal, audio signal, or vibration. Type
% "Low_Freq_Analyzer_34411A" into the command line.
% Any questions or comments email neil(underscore)forcier(at)agilent(dot)com
% My blog: http://gpete-neil.blogspot.com/
%Input IP address
address = input('Enter IP address (ex. 555.555.555.555): ','S');
%enter parameters for setting up DMM and FFT plot
sRate = input('Enter sample rate 1 S/s to 50 KS/s in 20 us increments-->');
sCount = input('Enter sample count between 10 and 500,000-->');
vRange = input('Enter voltage range .1 1 10 100 1000 (V)-->');
start = input('Enter start freq of FFT plot-->');
stop = input('Enter stop freq of FFT plot-->');
%the following 'if' statements make sure the entered parameters are
%valid
if sRate < 1 || sRate > 50e3 || mod((1/sRate),2e-5) ~= 0
disp('Incorrect sample rate, using defaults 1e3');
sRate = 1e3;
end
if sCount < 10 || sCount > 500e3
disp('Incorrect sample count, using defaults 1e2');
sCount = 1e2;
end
if vRange ~= .1 && vRange ~= 1 && vRange ~= 10 && vRange ~= 100 && vRange ~= 1e3
disp('Incorrect voltage range, using defaults 10');
vRange = 10;
end
if start > stop || start < 0 || start > (sRate/2)
disp('Invalid start freq, using default 0');
start = 0;
end
if start > stop || stop < 0 || stop > (sRate/2)
disp('Invalid start freq, using default sRate/2');
stop = (sRate/2);
end
%connect to DMM, setup measurement, and fetch readings
readings = talkTo34411A(sRate,sCount,vRange,address);
%function call for performing FFT and returning y and x axis values
[x y] = performFFT(readings,sRate);
%Get array positions for setting start and stop frequency points on FFT
%plot
[t ind1] = min(abs(x-start));
[t ind2] = min(abs(x-stop));
%build new arrays for setting start and stop freq on FFT plot
sX = x(ind1:ind2);
sY = y(ind1:ind2);
%get array location of max freq component for time domain plot
yL = length(y);
[c,i]= max(y(2:yL));
maxFreq = x(i);
%if maxFreq is 0 just set samples to 100
if maxFreq == 0
tSamples = 100;
else
tSamples = floor(2*((1/maxFreq)/(1/sRate)));
end
%build arrays for time domain plot
tReadings = readings(1:tSamples);
time = 0:(1/sRate):((tSamples*(1/sRate))-(1/sRate)); %setup x axis
%create plots
figure
plot(time,tReadings)
xlabel('Time')
ylabel('Amplitude')
figure
plot(sX,sY) %only show half of FFT result
xlabel('Frequency (Hz)')
ylabel('dBv')