diff --git a/test/FMCOMMS11Test.m b/test/FMCOMMS11Test.m index 2a517093..7f231a2f 100644 --- a/test/FMCOMMS11Test.m +++ b/test/FMCOMMS11Test.m @@ -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) @@ -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 diff --git a/test/runHWTests.m b/test/runHWTests.m index 5e076abd..69db5d9e 100644 --- a/test/runHWTests.m +++ b/test/runHWTests.m @@ -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); @@ -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