Skip to content

Commit

Permalink
Merge branch 'tfcollins/ad9081-test-updates' of github.com:analogdevi…
Browse files Browse the repository at this point in the history
…cesinc/HighSpeedConverterToolbox into tfcollins/ad9081-test-updates
  • Loading branch information
tfcollins committed Aug 16, 2023
2 parents 84d52ef + e197305 commit 7108abf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
34 changes: 31 additions & 3 deletions test/FMCOMMS11Test.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
classdef FMCOMMS11Test < matlab.unittest.TestCase
classdef FMCOMMS11Test < HardwareTests
properties
uri ='ip:analog.local';
author = 'ADI';
end

methods(TestClassSetup)
% Check hardware connected
function CheckForHardware(testCase)
Device = @()adi.FMCOMMS11.Rx;
testCase.CheckDevice('ip',Device,testCase.uri(4:end),false);
end
end

methods (Static)
function estFrequency(data,fs)
nSamp = length(data);
FFTRxData = fftshift(10*log10(abs(fft(data))));
% df = fs/nSamp; freqRangeRx = (-fs/2:df:fs/2-df).'/1000;
% plot(freqRangeRx, FFTRxData);
df = fs/nSamp; freqRangeRx = (0:df:fs/2-df).'/1000;
plot(freqRangeRx, FFTRxData(end-length(freqRangeRx)+1:end,:));
end

function freq = estFrequencyMax(data,fs)
nSamp = length(data);
FFTRxData = fftshift(10*log10(abs(fft(data))));
df = fs/nSamp; freqRangeRx = (0:df:fs/2-df).';
[~,ind] = max(FFTRxData(end-length(freqRangeRx)+1:end,:));
freq = freqRangeRx(ind);
end

end

methods(Test)
function testFMCOMMS11Rx(testCase)
Expand Down Expand Up @@ -31,12 +58,13 @@ function testFMCOMMS11RxWithTxDDS(testCase)
for k=1:10
[out, valid] = rx();
end
freqEst = meanfreq(double(real(out)),rx.SamplingRate);
% freqEst = meanfreq(double(real(out)),rx.SamplingRate);
freqEst = testCase.estFrequencyMax(out(:,1),rx.SamplingRate);
rx.release();

testCase.verifyTrue(valid);
testCase.verifyGreaterThan(sum(abs(double(out))),0);
testCase.verifyEqual(freqEst,toneFreq,'RelTol',0.01,...
testCase.verifyEqual(double(freqEst),toneFreq,'RelTol',0.01,...
'Frequency of DDS tone unexpected')
end
end
Expand Down
14 changes: 9 additions & 5 deletions test/runHWTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ function runHWTests(board)
"zynqmp-zcu102-rev10-ad9081-vm4-l8", ...
"zynqmp-zcu102-rev10-ad9081-vm8-l4"}
at = 'AD9081';
case {"zynq-zc706-adv7511-fmcomms11"}
at = 'FMCOMMS11';
case {"zynqmp-zcu102-rev10-ad9172-fmc-ebz-mode4"}
at = 'AD9172';
otherwise
error('%s unsupported for HW test harness', board);
end

ats = {'DAQ2Tests','DAQ3Tests','AD9081HWTests'};
ats = {'DAQ2Tests','DAQ3Tests','AD9081HWTests','FMCOMMS11Test'};

if nargin == 0
suite = testsuite(ats);
Expand Down Expand Up @@ -58,10 +62,10 @@ function runHWTests(board)
fclose(fid);
catch e
disp(getReport(e,'extended'));
bdclose('all');
exit(1);
% bdclose('all');
% exit(1);
end
save(['BSPTest_',datestr(now,'dd_mm_yyyy-HH_MM_SS'),'.mat'],'t');
bdclose('all');
exit(any([results.Failed]));
% bdclose('all');
% exit(any([results.Failed]));
end

0 comments on commit 7108abf

Please sign in to comment.