Skip to content

Commit ef946a0

Browse files
committed
Use tx sr for frequency and waveform generation
Signed-off-by: Julia Pineda <Julia.Pineda@analog.com>
1 parent 15e8c89 commit ef946a0

File tree

1 file changed

+74
-58
lines changed

1 file changed

+74
-58
lines changed

test/AD9081HWTests.m

Lines changed: 74 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function testAD9081Rx(testCase)
8383
function testAD9081RxWithTxDDS(testCase)
8484
% Test DDS output
8585
tx = adi.AD9081.Tx('uri',testCase.uri);
86-
[cdc, fdc, dc] = tx.GetDataPathConfiguration();
86+
[cdc, fdc, dc, srTx] = tx.GetDataPathConfiguration();
8787
testCase.log(sprintf('cdc: %d, fdc: %d, dc: %d',cdc, fdc, dc))
8888
tx = adi.AD9081.Tx(...
8989
'uri',testCase.uri,...
@@ -92,15 +92,9 @@ function testAD9081RxWithTxDDS(testCase)
9292
'num_fine_attr_channels', fdc, ...
9393
'num_dds_channels', fdc*2);
9494
tx.DataSource = 'DDS';
95-
toneFreq = 45e6;
96-
% tx.DDSFrequencies = repmat(toneFreq,2,2);
97-
% tx.DDSScales = repmat(0.9,2,2);
98-
tx.DDSSingleTone(toneFreq, 0.1, 1);
99-
% tx.NCOEnables(:) = 1;
100-
tx();
101-
pause(1);
95+
10296
rx = adi.AD9081.Rx('uri',testCase.uri);
103-
[cdc, fdc, dc] = rx.GetDataPathConfiguration();
97+
[cdc, fdc, dc, srRx] = rx.GetDataPathConfiguration();
10498
testCase.log(sprintf('cdc: %d, fdc: %d, dc: %d',cdc, fdc, dc))
10599
rx = adi.AD9081.Rx(...
106100
'uri',testCase.uri,...
@@ -109,15 +103,25 @@ function testAD9081RxWithTxDDS(testCase)
109103
'num_fine_attr_channels', fdc);
110104
rx.EnabledChannels = 1;
111105
valid = false;
106+
107+
toneFreq = rand(1) * srRx / 2;
108+
% tx.DDSFrequencies = repmat(toneFreq,2,2);
109+
% tx.DDSScales = repmat(0.9,2,2);
110+
tx.DDSSingleTone(toneFreq, 0.1, 1);
111+
% tx.NCOEnables(:) = 1;
112+
tx();
113+
pause(1);
114+
112115
for k=1:10
113116
[out, valid] = rx();
114117
end
115-
sr = rx.SamplingRate;
118+
% sr = rx.SamplingRate;
116119
rx.release();
120+
tx.release();
117121

118122
% plot(real(out));
119123
% testCase.estFrequency(out,rx.SamplingRate);
120-
freqEst = meanfreq(double(real(out)),sr);
124+
freqEst = meanfreq(double(real(out)),srRx);
121125

122126
testCase.verifyTrue(valid);
123127
testCase.verifyGreaterThan(sum(abs(double(out))),0);
@@ -128,27 +132,17 @@ function testAD9081RxWithTxDDS(testCase)
128132
function testAD9081RxWithTxDDSTwoChan(testCase)
129133
% Test DDS output
130134
tx = adi.AD9081.Tx('uri',testCase.uri);
131-
[cdc, fdc, dc, sr] = tx.GetDataPathConfiguration();
135+
[cdc, fdc, dc, srTx] = tx.GetDataPathConfiguration();
132136
tx = adi.AD9081.Tx(...
133137
'uri',testCase.uri,...
134138
'num_data_channels', dc, ...
135139
'num_coarse_attr_channels', cdc, ...
136140
'num_fine_attr_channels', fdc, ...
137141
'num_dds_channels', fdc*2);
138142
tx.DataSource = 'DDS';
139-
toneFreq1 = sr/4;
140-
toneFreq2 = sr/5;
141-
% tx.DDSFrequencies = [toneFreq1,toneFreq1,toneFreq2,toneFreq2;...
142-
% 0,0,0,0];
143-
% tx.DDSScales = [1,1,1,1;0,0,0,0].*0.029;
144-
tx.DDSPhases = [90000,0,90000,0; 0,0,0,0];
145-
tx.DDSFrequencies = repmat(horzcat([toneFreq1,toneFreq1], ...
146-
[toneFreq2,toneFreq2]),2,1);
147-
tx.DDSScales = repmat([1,1;0,0].*0.029,1,2);
148-
tx();
149-
pause(1);
143+
150144
rx = adi.AD9081.Rx('uri',testCase.uri);
151-
[cdc, fdc, dc] = rx.GetDataPathConfiguration();
145+
[cdc, fdc, dc, srRx] = rx.GetDataPathConfiguration();
152146
testCase.log(sprintf('cdc: %d, fdc: %d, dc: %d',cdc, fdc, dc))
153147
rx = adi.AD9081.Rx(...
154148
'uri',testCase.uri,...
@@ -157,16 +151,31 @@ function testAD9081RxWithTxDDSTwoChan(testCase)
157151
'num_fine_attr_channels', fdc);
158152
rx.EnabledChannels = [1 2];
159153
valid = false;
154+
155+
toneFreqs = rand(2) * srRx / 2;
156+
toneFreq1 = toneFreqs(1);
157+
toneFreq2 = toneFreqs(2);
158+
% tx.DDSFrequencies = [toneFreq1,toneFreq1,toneFreq2,toneFreq2;...
159+
% 0,0,0,0];
160+
% tx.DDSScales = [1,1,1,1;0,0,0,0].*0.029;
161+
tx.DDSPhases = [90000,0,90000,0; 0,0,0,0];
162+
tx.DDSFrequencies = repmat(horzcat([toneFreq1,toneFreq1], ...
163+
[toneFreq2,toneFreq2]),2,1);
164+
tx.DDSScales = repmat([1,1;0,0].*0.029,1,2);
165+
tx();
166+
pause(1);
167+
160168
for k=1:10
161169
[out, valid] = rx();
162170
end
163-
sr = rx.SamplingRate;
171+
% sr = rx.SamplingRate;
164172
rx.release();
173+
tx.release();
165174

166175
% plot(real(out));
167176
% testCase.estFrequency(out,sr);
168-
freqEst1 = testCase.estFrequencyMax(out(:,1),sr,true,'TwoChanDDS_Chan1');
169-
freqEst2 = testCase.estFrequencyMax(out(:,2),sr,true,'TwoChanDDS_Chan2');
177+
freqEst1 = testCase.estFrequencyMax(out(:,1),srRx,true,'TwoChanDDS_Chan1');
178+
freqEst2 = testCase.estFrequencyMax(out(:,2),srRx,true,'TwoChanDDS_Chan2');
170179
% freqEst1 = meanfreq(double(real(out(:,1))),rx.SamplingRate);
171180
% freqEst2 = meanfreq(double(real(out(:,2))),rx.SamplingRate);
172181

@@ -181,14 +190,24 @@ function testAD9081RxWithTxDDSTwoChan(testCase)
181190
function testAD9081RxWithTxData(testCase)
182191

183192
tx = adi.AD9081.Tx('uri',testCase.uri);
184-
[cdc, fdc, dc, sr] = tx.GetDataPathConfiguration();
193+
[cdc, fdc, dc, srTx] = tx.GetDataPathConfiguration();
194+
195+
rx = adi.AD9081.Rx('uri',testCase.uri);
196+
[cdc, fdc, dc, srRx] = rx.GetDataPathConfiguration();
197+
testCase.log(sprintf('cdc: %d, fdc: %d, dc: %d',cdc, fdc, dc))
198+
rx = adi.AD9081.Rx(...
199+
'uri',testCase.uri,...
200+
'num_data_channels', dc, ...
201+
'num_coarse_attr_channels', cdc, ...
202+
'num_fine_attr_channels', fdc);
203+
rx.EnabledChannels = 1;
185204

186205
% Test Tx DMA data output
187-
amplitude = 2^15; frequency = sr/6;
206+
amplitude = 2^15; frequency = rand(1) * srRx / 2;
188207
swv1 = dsp.SineWave(amplitude, frequency);
189208
swv1.ComplexOutput = false;
190209
swv1.SamplesPerFrame = 2^20;
191-
swv1.SampleRate = sr;
210+
swv1.SampleRate = srTx;
192211
y = swv1();
193212

194213
tx = adi.AD9081.Tx(...
@@ -200,24 +219,16 @@ function testAD9081RxWithTxData(testCase)
200219
tx.DataSource = 'DMA';
201220
tx.EnableCyclicBuffers = true;
202221
tx(y);
203-
rx = adi.AD9081.Rx('uri',testCase.uri);
204-
[cdc, fdc, dc] = rx.GetDataPathConfiguration();
205-
testCase.log(sprintf('cdc: %d, fdc: %d, dc: %d',cdc, fdc, dc))
206-
rx = adi.AD9081.Rx(...
207-
'uri',testCase.uri,...
208-
'num_data_channels', dc, ...
209-
'num_coarse_attr_channels', cdc, ...
210-
'num_fine_attr_channels', fdc);
211222

212-
rx.EnabledChannels = 1;
213223
for k=1:10
214224
[out, valid] = rx();
215225
end
216-
sr = rx.SamplingRate;
226+
% sr = rx.SamplingRate;
217227
rx.release();
228+
tx.release();
218229

219230
% plot(real(out));
220-
freqEst = meanfreq(double(real(out)),sr);
231+
freqEst = testCase.estFrequencyMax(double(real(out)),srRx);
221232

222233
testCase.verifyTrue(valid);
223234
testCase.verifyGreaterThan(sum(abs(double(out))),0);
@@ -228,21 +239,33 @@ function testAD9081RxWithTxData(testCase)
228239
function testAD9081RxWithTxDataTwoChan(testCase)
229240

230241
tx = adi.AD9081.Tx('uri',testCase.uri);
231-
[cdc, fdc, dc, sr] = tx.GetDataPathConfiguration();
242+
[cdc, fdc, dc, srTx] = tx.GetDataPathConfiguration();
243+
244+
rx = adi.AD9081.Rx('uri',testCase.uri);
245+
[cdc, fdc, dc, srRx] = rx.GetDataPathConfiguration();
246+
testCase.log(sprintf('cdc: %d, fdc: %d, dc: %d',cdc, fdc, dc))
247+
rx = adi.AD9081.Rx(...
248+
'uri',testCase.uri,...
249+
'num_data_channels', dc, ...
250+
'num_coarse_attr_channels', cdc, ...
251+
'num_fine_attr_channels', fdc);
252+
rx.EnabledChannels = [1,2];
253+
232254

233255
% Test Tx DMA data output
234-
amplitude = 2^15; toneFreq1 = sr/5;
256+
toneFreqs = rand(2) * srRx / 2;
257+
amplitude = 2^15; toneFreq1 = toneFreqs(1);
235258
swv1 = dsp.SineWave(amplitude, toneFreq1);
236259
swv1.ComplexOutput = false;
237260
swv1.SamplesPerFrame = 2^20;
238-
swv1.SampleRate = sr;
261+
swv1.SampleRate = srTx;
239262
y1 = swv1();
240263

241-
amplitude = 2^15; toneFreq2 = sr/8;
264+
amplitude = 2^15; toneFreq2 = toneFreqs(2);
242265
swv1 = dsp.SineWave(amplitude, toneFreq2);
243266
swv1.ComplexOutput = false;
244267
swv1.SamplesPerFrame = 2^20;
245-
swv1.SampleRate = sr;
268+
swv1.SampleRate = srTx;
246269
y2 = swv1();
247270

248271
tx = adi.AD9081.Tx(...
@@ -255,25 +278,18 @@ function testAD9081RxWithTxDataTwoChan(testCase)
255278
tx.EnableCyclicBuffers = true;
256279
tx.EnabledChannels = [1,2];
257280
tx([y1,y2]);
258-
rx = adi.AD9081.Rx('uri',testCase.uri);
259-
[cdc, fdc, dc] = rx.GetDataPathConfiguration();
260-
testCase.log(sprintf('cdc: %d, fdc: %d, dc: %d',cdc, fdc, dc))
261-
rx = adi.AD9081.Rx(...
262-
'uri',testCase.uri,...
263-
'num_data_channels', dc, ...
264-
'num_coarse_attr_channels', cdc, ...
265-
'num_fine_attr_channels', fdc);
266-
rx.EnabledChannels = [1,2];
281+
267282
for k=1:10
268283
[out, valid] = rx();
269284
end
270-
sr = rx.SamplingRate;
285+
% sr = rx.SamplingRate;
271286
rx.release();
287+
tx.release();
272288

273289
% plot(real(out));
274290
% testCase.estFrequency(out,rx.SamplingRate);
275-
freqEst1 = testCase.estFrequencyMax(out(:,1),sr,true,'TwoChanData_Chan1');
276-
freqEst2 = testCase.estFrequencyMax(out(:,2),sr,true,'TwoChanData_Chan2');
291+
freqEst1 = testCase.estFrequencyMax(out(:,1),srRx,true,'TwoChanData_Chan1');
292+
freqEst2 = testCase.estFrequencyMax(out(:,2),srRx,true,'TwoChanData_Chan2');
277293
% freqEst = meanfreq(double(real(out)),rx.SamplingRate);
278294

279295
testCase.verifyTrue(valid);

0 commit comments

Comments
 (0)