Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add very basic QMxFE example #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions hsx_examples/qmxfe/QuadMxFE_Basic.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
% Basic example of looping back Quad-MxFE (AD9081) using FPGA DDSs
uri = 'ip:192.168.2.1';

%% Tx set up
tx = adi.QuadMxFE.Tx('uri',uri);
tx.DataSource = 'DDS';
toneFreq = 45e6;
tx.DDSFrequencies = repmat(toneFreq,2,64);
tx();

%% Rx set up
rx = adi.QuadMxFE.Rx('uri',uri);
rx.SamplesPerFrame = 1024;

%% Set NCOs to be the same between TX/RX
mainNCOFrequency = 1e6*ones(1,4);
channelNCOFrequency = 2e6*ones(1,4);
for chip = {'A','B','C','D'}
rx.(['MainNCOFrequenciesChip',chip{:}]) = mainNCOFrequency;
rx.(['ChannelNCOFrequenciesChip',chip{:}]) = channelNCOFrequency;
tx.(['MainNCOFrequenciesChip',chip{:}]) = mainNCOFrequency;
tx.(['ChannelNCOFrequenciesChip',chip{:}]) = channelNCOFrequency;
end

%% Run
for k=1:10
valid = false;
while ~valid
[out, valid] = rx();
end
end
rx.release();
tx.release();

%% Plot
nSamp = length(out);
fs = tx.SamplingRate;
FFTRxData = fftshift(10*log10(abs(fft(out))));
df = fs/nSamp; freqRangeRx = (-fs/2:df:fs/2-df).'/1000;
plot(freqRangeRx, FFTRxData);
xlabel('Frequency (kHz)');ylabel('Amplitude (dB)');grid on;