Skip to content

Instantly share code, notes, and snippets.

@tfcollins
Last active December 12, 2019 20:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfcollins/393278ead85126811d800567829118c4 to your computer and use it in GitHub Desktop.
Save tfcollins/393278ead85126811d800567829118c4 to your computer and use it in GitHub Desktop.
clear;
clc;
s = iio_sys_obj_matlab; % Constructor
s.ip_address = '192.168.3.2';
s.dev_name = 'ad9361-1';
s.in_ch_no = 8;
s.out_ch_no = 8;
s.in_ch_size = 8192;
s.out_ch_size = 8192;
s = s.setupImpl();
s2 = iio_sys_obj_matlab; % Constructor
s2.dev_name = 'ad9361-2';
s2.ip_address = '192.168.3.2';
s2.in_ch_no = 0;
s2.out_ch_no = 0;
s2.in_ch_size = 8192;
s2.out_ch_size = 8192;
s2 = s2.setupImpl();
input = cell(1, s.in_ch_no + length(s.iio_dev_cfg.cfg_ch));
Fs = 30.72e6;
Fc = 1e6;
t = 1/Fs:1/Fs:s.in_ch_size/Fs;
for i=1:s.in_ch_no
input{i} = sin(2*pi*Fc*t+(i-1)*pi/2)*1024;
end
input{s.in_ch_no+1} = 2.4e9;
input{s.in_ch_no+2} = 30.72e6;
input{s.in_ch_no+3} = 18.0e6;
input{s.in_ch_no+4} = 'slow_attack';
input{s.in_ch_no+5} = 0;
input{s.in_ch_no+6} = 'slow_attack';
input{s.in_ch_no+7} = 0;
input{s.in_ch_no+8} = 2.4e9;
input{s.in_ch_no+9} = 30.72e6;
input{s.in_ch_no+10} = 18.0e6;
input2{s2.in_ch_no+1} = 2.4e9;
input2{s2.in_ch_no+2} = 30.72e6;
input2{s2.in_ch_no+3} = 18.0e6;
input2{s2.in_ch_no+4} = 'slow_attack';
input2{s2.in_ch_no+5} = 0;
input2{s2.in_ch_no+6} = 'slow_attack';
input2{s2.in_ch_no+7} = 0;
input2{s2.in_ch_no+8} = 2.4e9;
input2{s2.in_ch_no+9} = 30.72e6;
input2{s2.in_ch_no+10} = 18.0e6;
output = cell(1, s.out_ch_no + length(s.iio_dev_cfg.mon_ch));
output2 = cell(1, s2.out_ch_no + length(s2.iio_dev_cfg.mon_ch));
for i = 1:30
output = stepImpl(s, input);
output2 = stepImpl(s2, input2);
rssi1 = output{s.out_ch_no+1};
rssi2 = output{s.out_ch_no+2};
rssi3 = output2{1};
rssi4 = output2{2};
end
s.releaseImpl();
s2.releaseImpl();
figure % new figure
for i=1:8
ax = subplot(8,1,i); % top subplot
plot(ax,output{i});
xlabel('Sample');
ylabel('Amplitude');
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment