From 1db95efe9cfadfac1ad35cb8ecbdbf8b0d667a36 Mon Sep 17 00:00:00 2001 From: "Travis F. Collins" Date: Mon, 14 Aug 2023 09:51:55 -0600 Subject: [PATCH 01/10] Update AD9081 tests to use GetDataPathConfiguration helper function Signed-off-by: Travis F. Collins --- test/AD9081HWTests.m | 72 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 3 deletions(-) diff --git a/test/AD9081HWTests.m b/test/AD9081HWTests.m index 67c1a9bb..619ee37b 100644 --- a/test/AD9081HWTests.m +++ b/test/AD9081HWTests.m @@ -1,15 +1,16 @@ classdef AD9081HWTests < HardwareTests properties - uri = 'ip:analog'; + uri = 'ip:analog.local'; author = 'ADI'; end methods(TestClassSetup) % Check hardware connected function CheckForHardware(testCase) - Device = @()adi.AD9081.Rx; - testCase.CheckDevice('ip',Device,testCase.uri(4:end),false); + disp('Skipping init test'); +% Device = @()adi.AD9081.Rx; +% testCase.CheckDevice('ip',Device,testCase.uri(4:end),false); end end @@ -38,6 +39,13 @@ function estFrequency(data,fs) function testAD9081Rx(testCase) % Test Rx DMA data output rx = adi.AD9081.Rx('uri',testCase.uri); + [cdc, fdc, dc] = rx.GetDataPathConfiguration(); + testCase.log(sprintf('cdc: %d, fdc: %d, dc: %d',cdc, fdc, dc)) + rx = adi.AD9081.Rx(... + 'uri',testCase.uri,... + 'num_data_channels', dc, ... + 'num_coarse_attr_channels', cdc, ... + 'num_fine_attr_channels', fdc); rx.EnabledChannels = 1; [out, valid] = rx(); rx.release(); @@ -48,12 +56,27 @@ function testAD9081Rx(testCase) function testAD9081RxWithTxDDS(testCase) % Test DDS output tx = adi.AD9081.Tx('uri',testCase.uri); + [cdc, fdc, dc] = tx.GetDataPathConfiguration(); + testCase.log(sprintf('cdc: %d, fdc: %d, dc: %d',cdc, fdc, dc)) + tx = adi.AD9081.Tx(... + 'uri',testCase.uri,... + 'num_data_channels', dc, ... + 'num_coarse_attr_channels', cdc, ... + 'num_fine_attr_channels', fdc, ... + 'num_dds_channels', fdc); tx.DataSource = 'DDS'; toneFreq = 45e6; tx.DDSFrequencies = repmat(toneFreq,2,2); tx(); pause(1); rx = adi.AD9081.Rx('uri',testCase.uri); + [cdc, fdc, dc] = rx.GetDataPathConfiguration(); + testCase.log(sprintf('cdc: %d, fdc: %d, dc: %d',cdc, fdc, dc)) + rx = adi.AD9081.Rx(... + 'uri',testCase.uri,... + 'num_data_channels', dc, ... + 'num_coarse_attr_channels', cdc, ... + 'num_fine_attr_channels', fdc); rx.EnabledChannels = 1; valid = false; for k=1:10 @@ -74,6 +97,13 @@ function testAD9081RxWithTxDDS(testCase) function testAD9081RxWithTxDDSTwoChan(testCase) % Test DDS output tx = adi.AD9081.Tx('uri',testCase.uri); + [cdc, fdc, dc] = tx.GetDataPathConfiguration(); + tx = adi.AD9081.Tx(... + 'uri',testCase.uri,... + 'num_data_channels', dc, ... + 'num_coarse_attr_channels', cdc, ... + 'num_fine_attr_channels', fdc, ... + 'num_dds_channels', fdc); tx.DataSource = 'DDS'; toneFreq1 = 160e6; toneFreq2 = 300e6; @@ -82,6 +112,13 @@ function testAD9081RxWithTxDDSTwoChan(testCase) tx(); pause(1); rx = adi.AD9081.Rx('uri',testCase.uri); + [cdc, fdc, dc] = rx.GetDataPathConfiguration(); + testCase.log(sprintf('cdc: %d, fdc: %d, dc: %d',cdc, fdc, dc)) + rx = adi.AD9081.Rx(... + 'uri',testCase.uri,... + 'num_data_channels', dc, ... + 'num_coarse_attr_channels', cdc, ... + 'num_fine_attr_channels', fdc); rx.EnabledChannels = [1 2]; valid = false; for k=1:10 @@ -114,10 +151,25 @@ function testAD9081RxWithTxData(testCase) y = swv1(); tx = adi.AD9081.Tx('uri',testCase.uri); + [cdc, fdc, dc] = tx.GetDataPathConfiguration(); + tx = adi.AD9081.Tx(... + 'uri',testCase.uri,... + 'num_data_channels', dc, ... + 'num_coarse_attr_channels', cdc, ... + 'num_fine_attr_channels', fdc, ... + 'num_dds_channels', fdc); tx.DataSource = 'DMA'; tx.EnableCyclicBuffers = true; tx(y); rx = adi.AD9081.Rx('uri',testCase.uri); + [cdc, fdc, dc] = rx.GetDataPathConfiguration(); + testCase.log(sprintf('cdc: %d, fdc: %d, dc: %d',cdc, fdc, dc)) + rx = adi.AD9081.Rx(... + 'uri',testCase.uri,... + 'num_data_channels', dc, ... + 'num_coarse_attr_channels', cdc, ... + 'num_fine_attr_channels', fdc); + rx.EnabledChannels = 1; for k=1:10 [out, valid] = rx(); @@ -150,11 +202,25 @@ function testAD9081RxWithTxDataTwoChan(testCase) y2 = swv1(); tx = adi.AD9081.Tx('uri',testCase.uri); + [cdc, fdc, dc] = tx.GetDataPathConfiguration(); + tx = adi.AD9081.Tx(... + 'uri',testCase.uri,... + 'num_data_channels', dc, ... + 'num_coarse_attr_channels', cdc, ... + 'num_fine_attr_channels', fdc, ... + 'num_dds_channels', fdc); tx.DataSource = 'DMA'; tx.EnableCyclicBuffers = true; tx.EnabledChannels = [1,2]; tx([y1,y2]); rx = adi.AD9081.Rx('uri',testCase.uri); + [cdc, fdc, dc] = rx.GetDataPathConfiguration(); + testCase.log(sprintf('cdc: %d, fdc: %d, dc: %d',cdc, fdc, dc)) + rx = adi.AD9081.Rx(... + 'uri',testCase.uri,... + 'num_data_channels', dc, ... + 'num_coarse_attr_channels', cdc, ... + 'num_fine_attr_channels', fdc); rx.EnabledChannels = [1,2]; for k=1:10 [out, valid] = rx(); From eb76cf76f4960f5ba2e1911d86bf41e26cd3f59a Mon Sep 17 00:00:00 2001 From: "Travis F. Collins" Date: Mon, 14 Aug 2023 11:59:47 -0600 Subject: [PATCH 02/10] General fixes on AD9081 tests Signed-off-by: Travis F. Collins --- test/AD9081HWTests.m | 61 ++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/test/AD9081HWTests.m b/test/AD9081HWTests.m index 619ee37b..d3a73f21 100644 --- a/test/AD9081HWTests.m +++ b/test/AD9081HWTests.m @@ -63,10 +63,13 @@ function testAD9081RxWithTxDDS(testCase) 'num_data_channels', dc, ... 'num_coarse_attr_channels', cdc, ... 'num_fine_attr_channels', fdc, ... - 'num_dds_channels', fdc); + 'num_dds_channels', fdc*2); tx.DataSource = 'DDS'; toneFreq = 45e6; - tx.DDSFrequencies = repmat(toneFreq,2,2); +% tx.DDSFrequencies = repmat(toneFreq,2,2); +% tx.DDSScales = repmat(0.9,2,2); + tx.DDSSingleTone(toneFreq, 0.1, 1); +% tx.NCOEnables(:) = 1; tx(); pause(1); rx = adi.AD9081.Rx('uri',testCase.uri); @@ -82,11 +85,12 @@ function testAD9081RxWithTxDDS(testCase) for k=1:10 [out, valid] = rx(); end + sr = rx.SamplingRate; rx.release(); % plot(real(out)); % testCase.estFrequency(out,rx.SamplingRate); - freqEst = meanfreq(double(real(out)),rx.SamplingRate); + freqEst = meanfreq(double(real(out)),sr); testCase.verifyTrue(valid); testCase.verifyGreaterThan(sum(abs(double(out))),0); @@ -97,16 +101,16 @@ function testAD9081RxWithTxDDS(testCase) function testAD9081RxWithTxDDSTwoChan(testCase) % Test DDS output tx = adi.AD9081.Tx('uri',testCase.uri); - [cdc, fdc, dc] = tx.GetDataPathConfiguration(); + [cdc, fdc, dc, sr] = tx.GetDataPathConfiguration(); tx = adi.AD9081.Tx(... 'uri',testCase.uri,... 'num_data_channels', dc, ... 'num_coarse_attr_channels', cdc, ... 'num_fine_attr_channels', fdc, ... - 'num_dds_channels', fdc); + 'num_dds_channels', fdc*2); tx.DataSource = 'DDS'; - toneFreq1 = 160e6; - toneFreq2 = 300e6; + toneFreq1 = sr/4; + toneFreq2 = sr/5; tx.DDSFrequencies = [toneFreq1,toneFreq2;toneFreq1,toneFreq2]; tx.DDSScales = [1,1;0,0].*0.029; tx(); @@ -124,12 +128,13 @@ function testAD9081RxWithTxDDSTwoChan(testCase) for k=1:10 [out, valid] = rx(); end + sr = rx.SamplingRate; rx.release(); % plot(real(out)); -% testCase.estFrequency(out,rx.SamplingRate); - freqEst1 = testCase.estFrequencyMax(out(:,1),rx.SamplingRate); - freqEst2 = testCase.estFrequencyMax(out(:,2),rx.SamplingRate); +% testCase.estFrequency(out,sr); + freqEst1 = testCase.estFrequencyMax(out(:,1),sr); + freqEst2 = testCase.estFrequencyMax(out(:,2),sr); % freqEst1 = meanfreq(double(real(out(:,1))),rx.SamplingRate); % freqEst2 = meanfreq(double(real(out(:,2))),rx.SamplingRate); @@ -142,22 +147,24 @@ function testAD9081RxWithTxDDSTwoChan(testCase) end function testAD9081RxWithTxData(testCase) + + tx = adi.AD9081.Tx('uri',testCase.uri); + [cdc, fdc, dc, sr] = tx.GetDataPathConfiguration(); + % Test Tx DMA data output - amplitude = 2^15; frequency = 40e6; + amplitude = 2^15; frequency = sr/6; swv1 = dsp.SineWave(amplitude, frequency); swv1.ComplexOutput = false; swv1.SamplesPerFrame = 2^20; - swv1.SampleRate = 1e9; + swv1.SampleRate = sr; y = swv1(); - tx = adi.AD9081.Tx('uri',testCase.uri); - [cdc, fdc, dc] = tx.GetDataPathConfiguration(); tx = adi.AD9081.Tx(... 'uri',testCase.uri,... 'num_data_channels', dc, ... 'num_coarse_attr_channels', cdc, ... 'num_fine_attr_channels', fdc, ... - 'num_dds_channels', fdc); + 'num_dds_channels', fdc*2); tx.DataSource = 'DMA'; tx.EnableCyclicBuffers = true; tx(y); @@ -174,10 +181,11 @@ function testAD9081RxWithTxData(testCase) for k=1:10 [out, valid] = rx(); end + sr = rx.SamplingRate; rx.release(); % plot(real(out)); - freqEst = meanfreq(double(real(out)),rx.SamplingRate); + freqEst = meanfreq(double(real(out)),sr); testCase.verifyTrue(valid); testCase.verifyGreaterThan(sum(abs(double(out))),0); @@ -186,29 +194,31 @@ function testAD9081RxWithTxData(testCase) end function testAD9081RxWithTxDataTwoChan(testCase) + + tx = adi.AD9081.Tx('uri',testCase.uri); + [cdc, fdc, dc, sr] = tx.GetDataPathConfiguration(); + % Test Tx DMA data output - amplitude = 2^15; toneFreq1 = 40e6; + amplitude = 2^15; toneFreq1 = sr/5; swv1 = dsp.SineWave(amplitude, toneFreq1); swv1.ComplexOutput = false; swv1.SamplesPerFrame = 2^20; - swv1.SampleRate = 1e9; + swv1.SampleRate = sr; y1 = swv1(); amplitude = 2^15; toneFreq2 = 180e6; swv1 = dsp.SineWave(amplitude, toneFreq2); swv1.ComplexOutput = false; swv1.SamplesPerFrame = 2^20; - swv1.SampleRate = 1e9; + swv1.SampleRate = sr; y2 = swv1(); - tx = adi.AD9081.Tx('uri',testCase.uri); - [cdc, fdc, dc] = tx.GetDataPathConfiguration(); tx = adi.AD9081.Tx(... 'uri',testCase.uri,... 'num_data_channels', dc, ... 'num_coarse_attr_channels', cdc, ... 'num_fine_attr_channels', fdc, ... - 'num_dds_channels', fdc); + 'num_dds_channels', fdc*2); tx.DataSource = 'DMA'; tx.EnableCyclicBuffers = true; tx.EnabledChannels = [1,2]; @@ -225,12 +235,13 @@ function testAD9081RxWithTxDataTwoChan(testCase) for k=1:10 [out, valid] = rx(); end + sr = rx.SamplingRate; rx.release(); - plot(real(out)); +% plot(real(out)); % testCase.estFrequency(out,rx.SamplingRate); - freqEst1 = testCase.estFrequencyMax(out(:,1),rx.SamplingRate); - freqEst2 = testCase.estFrequencyMax(out(:,2),rx.SamplingRate); + freqEst1 = testCase.estFrequencyMax(out(:,1),sr); + freqEst2 = testCase.estFrequencyMax(out(:,2),sr); % freqEst = meanfreq(double(real(out)),rx.SamplingRate); testCase.verifyTrue(valid); From d25b1a3ddff70116d6fe45f61d7723e291f6e25f Mon Sep 17 00:00:00 2001 From: "Travis F. Collins" Date: Mon, 14 Aug 2023 12:00:09 -0600 Subject: [PATCH 03/10] Update +common to get helper functions Signed-off-by: Travis F. Collins --- +adi/+common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/+adi/+common b/+adi/+common index 385bb5f6..847122c6 160000 --- a/+adi/+common +++ b/+adi/+common @@ -1 +1 @@ -Subproject commit 385bb5f65fd41e0e37405dff45e8a3a0461634da +Subproject commit 847122c65828df2849236c34ec10375c4dab3689 From e23317083897ad357595af143952c075860d93d8 Mon Sep 17 00:00:00 2001 From: "Travis F. Collins" Date: Mon, 14 Aug 2023 12:00:41 -0600 Subject: [PATCH 04/10] Fixes and enhancements for AD9081 Signed-off-by: Travis F. Collins --- +adi/+AD9081/Base.m | 19 ++++++++++++++++++- +adi/+AD9081/Rx.m | 18 +----------------- +adi/+AD9081/Tx.m | 6 +++--- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/+adi/+AD9081/Base.m b/+adi/+AD9081/Base.m index b7e9c1fc..2e7295fe 100644 --- a/+adi/+AD9081/Base.m +++ b/+adi/+AD9081/Base.m @@ -5,6 +5,14 @@ matlabshared.libiio.base %AD9081 Base Class + properties (Dependent) + %SamplingRate Sampling Rate + % Baseband sampling rate in Hz, specified as a scalar + % in samples per second. This value is only readable once + % connected to hardware + SamplingRate + end + properties (Nontunable) %SamplesPerFrame Samples Per Frame % Number of samples per frame, specified as an even positive @@ -41,8 +49,16 @@ '', 'SamplesPerFrame'); obj.SamplesPerFrame = value; end + % Dependent + function value = get.SamplingRate(obj) + if obj.ConnectedToDevice + value = double(obj.getAttributeLongLong('voltage0_i','sampling_frequency',obj.isOutput)); + else + value = NaN; + end + end %% Helpers - function [num_coarse, num_fine, num_data] = GetDataPathConfiguration(obj, isTx) + function [num_coarse, num_fine, num_data, sr] = GetDataPathConfiguration(obj, isTx) if nargin < 2 isTx = isa(obj,'adi.AD9081.Tx'); end @@ -74,6 +90,7 @@ end %% Parse data path configuration + sr = obj.SamplingRate; numChannels = obj.iio_device_get_channels_count(dev); map = {}; paths = {}; diff --git a/+adi/+AD9081/Rx.m b/+adi/+AD9081/Rx.m index 03727e12..e9450576 100644 --- a/+adi/+AD9081/Rx.m +++ b/+adi/+AD9081/Rx.m @@ -9,15 +9,7 @@ % AD9081 Datasheet % % See also adi.DAQ2.Rx - - properties (Dependent) - %SamplingRate Sampling Rate - % Baseband sampling rate in Hz, specified as a scalar - % in samples per second. This value is only readable once - % connected to hardware - SamplingRate - end - + properties %ChannelNCOFrequencies Channel NCO Frequencies % Frequency of NCO in fine decimators in receive path. Property @@ -116,14 +108,6 @@ obj.MainNCOPhases = zeros(1,obj.num_coarse_attr_channels); end - function value = get.SamplingRate(obj) - if obj.ConnectedToDevice - value= obj.getAttributeLongLong('voltage0_i','sampling_frequency',false); - else - value = NaN; - end - end - % Check ChannelNCOFrequencies function set.ChannelNCOFrequencies(obj, value) obj.CheckAndUpdateHW(value,'ChannelNCOFrequencies',... diff --git a/+adi/+AD9081/Tx.m b/+adi/+AD9081/Tx.m index b6a5dbd3..0da57e95 100644 --- a/+adi/+AD9081/Tx.m +++ b/+adi/+AD9081/Tx.m @@ -33,7 +33,7 @@ % Frequency of NCO in fine decimators in transmit path. Property % must be a [1,N] vector where each value is the frequency of an % NCO in hertz. - ChannelNCOGainScales = [0,0,0,0]; + ChannelNCOGainScales = [0.5,0.5,0.5,0.5]; %NCOEnables NCO Enables % Vector of logicals which enabled individual NCOs in channel % interpolators @@ -96,8 +96,8 @@ obj.MainNCOFrequencies = zeros(1,obj.num_coarse_attr_channels); obj.ChannelNCOPhases = zeros(1,obj.num_fine_attr_channels); obj.MainNCOPhases = zeros(1,obj.num_coarse_attr_channels); - obj.ChannelNCOGainScales = zeros(1,obj.num_fine_attr_channels); - obj.NCOEnables = zeros(1,obj.num_fine_attr_channels) > 0; + obj.ChannelNCOGainScales = 0.5.*ones(1,obj.num_fine_attr_channels); + obj.NCOEnables = ones(1,obj.num_fine_attr_channels) > 0; end % Check ChannelNCOFrequencies function set.ChannelNCOFrequencies(obj, value) From 8a5d67873fcba3cd6d7a805e30d015245ab0518c Mon Sep 17 00:00:00 2001 From: "Travis F. Collins" Date: Mon, 14 Aug 2023 14:12:53 -0600 Subject: [PATCH 05/10] Add more hardware for test harness Signed-off-by: Travis F. Collins --- JenkinsfileHW | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/JenkinsfileHW b/JenkinsfileHW index ba286b93..f3ccdf88 100644 --- a/JenkinsfileHW +++ b/JenkinsfileHW @@ -44,7 +44,13 @@ lock(label: 'adgt_test_harness_boards') { harness.set_elastic_server('192.168.10.1') harness.set_required_hardware(["zynq-zc706-adv7511-fmcdaq2", "zynqmp-zcu102-rev10-fmcdaq3", - "zynqmp-zcu102-rev10-ad9081-vm8-l4"]) + "zynqmp-zcu102-rev10-ad9081-vm8-l4", + "zynqmp-zcu102-rev10-ad9081-vm4-l8", + "zynqmp-zcu102-rev10-ad9081-v204b-txmode9-rxmode4", + "zynqmp-zcu102-rev10-ad9081-v204c-txmode0-rxmode1", + "zynq-zc706-adv7511-fmcomms11", + "zynqmp-zcu102-rev10-ad9172-fmc-ebz-mode4"]) + harness.set_docker_args(['Vivado', 'MATLAB']) harness.set_nebula_local_fs_source_root("artifactory.analog.com") From b1aa01c76f3d5d03b413bd21091e28a9377c7492 Mon Sep 17 00:00:00 2001 From: "Travis F. Collins" Date: Tue, 15 Aug 2023 09:05:41 -0600 Subject: [PATCH 06/10] Update AD9081 dual tone testing Signed-off-by: Travis F. Collins --- test/AD9081HWTests.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/AD9081HWTests.m b/test/AD9081HWTests.m index d3a73f21..88b88bc1 100644 --- a/test/AD9081HWTests.m +++ b/test/AD9081HWTests.m @@ -111,8 +111,13 @@ function testAD9081RxWithTxDDSTwoChan(testCase) tx.DataSource = 'DDS'; toneFreq1 = sr/4; toneFreq2 = sr/5; - tx.DDSFrequencies = [toneFreq1,toneFreq2;toneFreq1,toneFreq2]; - tx.DDSScales = [1,1;0,0].*0.029; +% tx.DDSFrequencies = [toneFreq1,toneFreq1,toneFreq2,toneFreq2;... +% 0,0,0,0]; +% tx.DDSScales = [1,1,1,1;0,0,0,0].*0.029; + tx.DDSPhases = [90000,0,90000,0; 0,0,0,0]; + tx.DDSFrequencies = repmat(horzcat([toneFreq1,toneFreq1], ... + [toneFreq2,toneFreq2]),2,1); + tx.DDSScales = repmat([1,1;0,0].*0.029,1,2); tx(); pause(1); rx = adi.AD9081.Rx('uri',testCase.uri); @@ -206,7 +211,7 @@ function testAD9081RxWithTxDataTwoChan(testCase) swv1.SampleRate = sr; y1 = swv1(); - amplitude = 2^15; toneFreq2 = 180e6; + amplitude = 2^15; toneFreq2 = sr/8; swv1 = dsp.SineWave(amplitude, toneFreq2); swv1.ComplexOutput = false; swv1.SamplesPerFrame = 2^20; From feb3b7cd782ee1a878e73dafa51874eb68e7012b Mon Sep 17 00:00:00 2001 From: Julia Pineda Date: Wed, 16 Aug 2023 10:25:49 +0800 Subject: [PATCH 07/10] Add test harness boards Signed-off-by: Julia Pineda --- test/runHWTests.m | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 From e197305d1cb59098203d5c64330c9da20c0692dd Mon Sep 17 00:00:00 2001 From: Julia Pineda Date: Wed, 16 Aug 2023 10:27:32 +0800 Subject: [PATCH 08/10] [FIX] Use estFrequencyMax Signed-off-by: Julia Pineda --- test/FMCOMMS11Test.m | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) 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 From 84d52ef31855ee8572d3b2103b0546a9c0cbdb72 Mon Sep 17 00:00:00 2001 From: "Travis F. Collins" Date: Wed, 16 Aug 2023 15:48:03 -0600 Subject: [PATCH 09/10] Add figure generation for AD9081 tests Signed-off-by: Travis F. Collins --- JenkinsfileHW | 7 +++++++ test/AD9081HWTests.m | 25 +++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/JenkinsfileHW b/JenkinsfileHW index f3ccdf88..4ce42e4a 100644 --- a/JenkinsfileHW +++ b/JenkinsfileHW @@ -63,6 +63,13 @@ lock(label: 'adgt_test_harness_boards') { "pyenv('Version','/usr/bin/python3')", "runHWTests(getenv('board'))"]) harness.add_stage(harness.stage_library("MATLABTests"),'continueWhenFail') + def saveFigures = { + stage('Save Figure') { + archiveArtifacts artifacts: '*.png', followSymlinks: false, allowEmptyArchive: true + archiveArtifacts artifacts: '*.fig', followSymlinks: false, allowEmptyArchive: true + } + } + harness.add_stage(saveFigures,'continueWhenFail') harness.add_stage(harness.stage_library('SendResults'),'continueWhenFail') diff --git a/test/AD9081HWTests.m b/test/AD9081HWTests.m index 88b88bc1..3e98f92b 100644 --- a/test/AD9081HWTests.m +++ b/test/AD9081HWTests.m @@ -15,13 +15,26 @@ function CheckForHardware(testCase) end methods (Static) - function estFrequency(data,fs) + function estFrequency(data,fs,saveNoShow,figname) 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; + if nargin < 3 + saveNoShow = false; + end + if nargin < 4 + figname = 'freq_plot'; + end + if saveNoShow + f = figure('visible','off'); + end plot(freqRangeRx, FFTRxData(end-length(freqRangeRx)+1:end,:)); + if saveNoShow + saveas(f,figname,'png') + saveas(f,figname,'fig') + end end function freq = estFrequencyMax(data,fs) @@ -138,8 +151,8 @@ function testAD9081RxWithTxDDSTwoChan(testCase) % plot(real(out)); % testCase.estFrequency(out,sr); - freqEst1 = testCase.estFrequencyMax(out(:,1),sr); - freqEst2 = testCase.estFrequencyMax(out(:,2),sr); + freqEst1 = testCase.estFrequencyMax(out(:,1),sr,true,'TwoChanDDS_Chan1'); + freqEst2 = testCase.estFrequencyMax(out(:,2),sr,true,'TwoChanDDS_Chan2'); % freqEst1 = meanfreq(double(real(out(:,1))),rx.SamplingRate); % freqEst2 = meanfreq(double(real(out(:,2))),rx.SamplingRate); @@ -190,7 +203,7 @@ function testAD9081RxWithTxData(testCase) rx.release(); % plot(real(out)); - freqEst = meanfreq(double(real(out)),sr); + freqEst = meanfreq(double(real(out)),sr,true,'OneChanData_Chan1'); testCase.verifyTrue(valid); testCase.verifyGreaterThan(sum(abs(double(out))),0); @@ -245,8 +258,8 @@ function testAD9081RxWithTxDataTwoChan(testCase) % plot(real(out)); % testCase.estFrequency(out,rx.SamplingRate); - freqEst1 = testCase.estFrequencyMax(out(:,1),sr); - freqEst2 = testCase.estFrequencyMax(out(:,2),sr); + freqEst1 = testCase.estFrequencyMax(out(:,1),sr,true,'TwoChanData_Chan1'); + freqEst2 = testCase.estFrequencyMax(out(:,2),sr,true,'TwoChanData_Chan2'); % freqEst = meanfreq(double(real(out)),rx.SamplingRate); testCase.verifyTrue(valid); From 7e5297028ff11f424eaeaf6a9793d12ae91f1214 Mon Sep 17 00:00:00 2001 From: "Travis F. Collins" Date: Fri, 18 Aug 2023 09:09:14 -0600 Subject: [PATCH 10/10] Fix save figure API in AD9081 tests Signed-off-by: Travis F. Collins --- test/AD9081HWTests.m | 18 ++++++++++++++++-- test/runHWTests.m | 8 ++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/test/AD9081HWTests.m b/test/AD9081HWTests.m index 3e98f92b..aa75b137 100644 --- a/test/AD9081HWTests.m +++ b/test/AD9081HWTests.m @@ -37,12 +37,26 @@ function estFrequency(data,fs,saveNoShow,figname) end end - function freq = estFrequencyMax(data,fs) + function freq = estFrequencyMax(data,fs,saveNoShow,figname) 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); + if nargin < 3 + saveNoShow = false; + end + if nargin < 4 + figname = 'freq_plot'; + end + if saveNoShow + f = figure('visible','off'); + end + plot(freqRangeRx, FFTRxData(end-length(freqRangeRx)+1:end,:)); + if saveNoShow + saveas(f,figname,'png') + saveas(f,figname,'fig') + end end end @@ -203,7 +217,7 @@ function testAD9081RxWithTxData(testCase) rx.release(); % plot(real(out)); - freqEst = meanfreq(double(real(out)),sr,true,'OneChanData_Chan1'); + freqEst = meanfreq(double(real(out)),sr); testCase.verifyTrue(valid); testCase.verifyGreaterThan(sum(abs(double(out))),0); diff --git a/test/runHWTests.m b/test/runHWTests.m index 69db5d9e..cdcd6b35 100644 --- a/test/runHWTests.m +++ b/test/runHWTests.m @@ -62,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