Skip to content

Commit

Permalink
new refactor and USRP implementation from Akshay
Browse files Browse the repository at this point in the history
  • Loading branch information
adwaitnd committed Feb 14, 2019
1 parent 0a649ff commit 4782c27
Show file tree
Hide file tree
Showing 59 changed files with 446 additions and 3,388,155 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# custom settings for project
data/
old\ matlab\ code\ -\ pls\ clean/

# Created by https://www.gitignore.io/api/matlab,macos,windows,linux,latex

Expand Down
119 changes: 0 additions & 119 deletions .ipynb_checkpoints/Pluto test-checkpoint.ipynb

This file was deleted.

This file was deleted.

16 changes: 16 additions & 0 deletions Charm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
SF = 10;
BW = 1.25e5;
chirp_size=1024;
chirpsize=chirp_size;
preamble_length=20;
extra_sampling_factor = 1;
Fs = BW;
symbol_length=chirp_size;
symbol_length_upsampled = extra_sampling_factor*chirp_size;
freq_shift_per_sample = Fs/symbol_length; % How each frequency bin maps to a difference in frequency
Ts = 1/freq_shift_per_sample; % Symbol Duration
f = linspace(-BW/2,BW/2-freq_shift_per_sample,symbol_length); % The X-Axis
reset_freq = -BW/2; % The initial frequency of the base chirp
final_freq = (BW/2)-freq_shift_per_sample; % The final frequency
[up,down] = my_create_chirpspecial(extra_sampling_factor*Fs,Ts,reset_freq,final_freq,chirp_size);

42 changes: 42 additions & 0 deletions Charm.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
SF = 10;
BW = 1.25e5;
chirp_size=1024;
chirpsize=chirp_size;
extra_sampling_factor = 1;
Fs = BW;
symbol_length=chirp_size;
symbol_length_upsampled = extra_sampling_factor*chirp_size;
freq_shift_per_sample = Fs/symbol_length; % How each frequency bin maps to a difference in frequency
Ts = 1/freq_shift_per_sample; % Symbol Duration
f = linspace(-BW/2,BW/2-freq_shift_per_sample,symbol_length); % The X-Axis
reset_freq = -BW/2; % The initial frequency of the base chirp
final_freq = (BW/2)-freq_shift_per_sample; % The final frequency
[up,down] = my_create_chirpspecial(extra_sampling_factor*Fs,Ts,reset_freq,final_freq,chirp_size);
upfft=fft(up);
downfft=fft(down);
up250=(ifft([upfft(1:512);zeros(1024,1);upfft(513:1024)]));
down250=(ifft([downfft(1:512);zeros(1024,1);downfft(513:1024)]));
sig1=read_complex_binary('predabs52_15_04_47.dat');
sig2=read_complex_binary('predabs3_15_04_47.dat');
sig3=read_complex_binary('predabs7_15_04_47.dat');
sig4=read_complex_binary('predabs50_15_04_47.dat');

p1=getPacket(sig1,down250,up250);
p2=getPacket(sig2,down250,up250);
p3=getPacket(sig3,down250,up250);
p4=getPacket(sig4,down250,up250);
close all;
figure; hold on;
plot(abs(p1+p2+p3+p4),'Color','black');
plot(abs(p1),'Color','blue')
plot(abs(p2),'Color','blue')
plot(abs(p3),'Color','blue')
plot(abs(p4),'Color','blue')

p2=OffsetCorrectorNew(p2,p1);
p3=OffsetCorrectorNew(p3,p1);
p4=OffsetCorrectorNew(p4,p1);

plot(abs(p1+p2+p3+p4),'Color','red')


41 changes: 41 additions & 0 deletions CharmData
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
SF = 10;
BW = 1.25e5;
chirp_size=1024;
chirpsize=chirp_size;
extra_sampling_factor = 1;
Fs = BW;
symbol_length=chirp_size;
symbol_length_upsampled = extra_sampling_factor*chirp_size;
freq_shift_per_sample = Fs/symbol_length; % How each frequency bin maps to a difference in frequency
Ts = 1/freq_shift_per_sample; % Symbol Duration
f = linspace(-BW/2,BW/2-freq_shift_per_sample,symbol_length); % The X-Axis
reset_freq = -BW/2; % The initial frequency of the base chirp
final_freq = (BW/2)-freq_shift_per_sample; % The final frequency
[up,down] = my_create_chirpspecial(extra_sampling_factor*Fs,Ts,reset_freq,final_freq,chirp_size);
upfft=fft(up);
downfft=fft(down);
up250=(ifft([upfft(1:512);zeros(1024,1);upfft(513:1024)]));
down250=(ifft([downfft(1:512);zeros(1024,1);downfft(513:1024)]));
sig1=read_complex_binary('predabs52_15_04_47.dat');
sig2=read_complex_binary('predabs3_15_04_47.dat');
sig3=read_complex_binary('predabs7_15_04_47.dat');
sig4=read_complex_binary('predabs50_15_04_47.dat');

frequencyOffsetCorrector=ones(2048*55.25+1,1);
phaseOffsetCorrector=ones(2048*55.25+1,1);
for i=1:2048*55.25
frequencyOffsetCorrector(i)=exp(1j*i);
phaseOffsetCorrector(i)=exp(1j);
end

p1=getPacket(sig1,down250,up250);
p2=getPacket(sig2,down250,up250);
p3=getPacket(sig3,down250,up250);
p4=getPacket(sig4,down250,up250);

p2=OffsetCorrectorNew(p2,p1);
p3=OffsetCorrectorNew(p3,p1);
p4=OffsetCorrectorNew(p4,p1);



42 changes: 42 additions & 0 deletions Demo.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
SF = 10;
BW = 1.25e5;
chirp_size=1024;
chirpsize=chirp_size;
extra_sampling_factor = 1;
Fs = BW;
symbol_length=chirp_size;
symbol_length_upsampled = extra_sampling_factor*chirp_size;
freq_shift_per_sample = Fs/symbol_length; % How each frequency bin maps to a difference in frequency
Ts = 1/freq_shift_per_sample; % Symbol Duration
f = linspace(-BW/2,BW/2-freq_shift_per_sample,symbol_length); % The X-Axis
reset_freq = -BW/2; % The initial frequency of the base chirp
final_freq = (BW/2)-freq_shift_per_sample; % The final frequency
[up,down] = my_create_chirpspecial(extra_sampling_factor*Fs,Ts,reset_freq,final_freq,chirp_size);
upfft=fft(up);
downfft=fft(down);
up250=(ifft([upfft(1:512);zeros(1024,1);upfft(513:1024)]));
down250=(ifft([downfft(1:512);zeros(1024,1);downfft(513:1024)]));
sig1=read_complex_binary('predabs52_15_04_47.dat');
sig2=read_complex_binary('predabs3_15_04_47.dat');
sig3=read_complex_binary('predabs7_15_04_47.dat');
sig4=read_complex_binary('predabs50_15_04_47.dat');


p1=getPacket(sig1,down250,up250);
p2=getPacket(sig2,down250,up250);
p3=getPacket(sig3,down250,up250);
p4=getPacket(sig4,down250,up250);
close all;
figure; hold on;
plot(abs(p1+p2+p3+p4),'Color','black');
plot(abs(p1),'Color','blue')
plot(abs(p2),'Color','blue')
plot(abs(p3),'Color','blue')
plot(abs(p4),'Color','blue')

p2=OffsetCorrectorNew(p2,p1);
p3=OffsetCorrectorNew(p3,p1);
p4=OffsetCorrectorNew(p4,p1);
plot(abs(p1+p2+p3+p4),'Color','red')


25 changes: 0 additions & 25 deletions Descriptions.txt

This file was deleted.

20 changes: 20 additions & 0 deletions OffsetCorrector.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function [p1] = OffsetCorrector(p1,up250)
%UNTITLED5 Summary of this function goes here
% Detailed explanation goes here
ang1=angle(p1(1:8*2048)./repmat(up250,8,1));
fOffset1=mean(removeoutliers(gradient(unwrap(ang1(512:512+1024)))));
for i=1:2048*55.25
p1(i)=p1(i)*exp(-1j*i*fOffset1);
end
ang1=angle(p1(1:1*2048)./repmat(up250,1,1));
p=polyfit([1:1025]',unwrap(ang1(512:512+1024)),1);
for i=1:2048*55.25
p1(i)=p1(i)*exp(-1j*i*p(1));
end
ang1=angle(p1(1:1*2048)./repmat(up250,1,1));
for i=1:2048*55.25
p1(i)=p1(i)*exp(-1j*mean(ang1(512:512+1024)));
end

end

32 changes: 32 additions & 0 deletions OffsetCorrectorNew.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function [sig] = OffsetCorrectorNew(sig,ref)
%UNTITLED5 Summary of this function goes here
% Detailed explanation goes here
%ang1=angle(p1(1:8*2048)./repmat(up250,8,1));
fOffset1=mean(removeoutliers(gradient(unwrap(angle(sig./ref)))));
for i=1:2048*55.25
sig(i)=sig(i)*exp(-1j*i*fOffset1);
end
ang1=angle(sig(1:1*2048)./ref(1:1*2048));
p=polyfit([1:1025]',unwrap(ang1(512:512+1024)),1);
for i=1:2048*55.25
sig(i)=sig(i)*exp(-1j*i*p(1));
end
p=polyfit([1:length(angle(sig./ref))]',unwrap((angle(sig./ref))),1);
for i=1:2048*55.25
sig(i)=sig(i)*exp(-1j*i*p(1));
end
ang1=angle(sig./ref);
if(max(ang1(1:1e5))-min(ang1(1:1e5))>6)
ang1=mod(ang1,2*pi);
for i=1:2048*55.25
sig(i)=sig(i)*exp(-1j*mean(ang1(1:1e5)));
end
else
for i=1:2048*55.25
sig(i)=sig(i)*exp(-1j*mean(ang1(1:1e5)));
end

end

end

227 changes: 0 additions & 227 deletions Pluto test.ipynb

This file was deleted.

2 changes: 2 additions & 0 deletions asyncRX.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sudo bash asyncRX3.sh & sudo bash asyncRX7.sh & sudo bash asyncRX50.sh & sudo bash asyncRX52.sh &

17 changes: 17 additions & 0 deletions asyncRX3
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

while true
do
current_sec=$(date +%S);
current_time=$(date +%H_%M_%S);
mod12=$((10#$current_sec % 12));

if [ "$mod12" -eq 11 ]; then
echo $current_time
rx_samples_to_file --args="addr0=192.168.10.3" --freq=915e6 --rate=250e3 --file="predabs3_${current_time}.dat" --type=float --ant=TX/RX --gain=30 --nsamps=250000;
else
echo "waiting"
fi

done

17 changes: 17 additions & 0 deletions asyncRX3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

while true
do
current_sec=$(date +%S);
current_time=$(date +%H_%M_%S);
mod12=$((10#$current_sec % 12));

if [ "$mod12" -eq 11 ]; then
echo $current_time
rx_samples_to_file --args="addr0=192.168.10.3" --freq=915e6 --rate=250e3 --file="predabs3_${current_time}.dat" --type=float --ant=TX/RX --gain=30 --nsamps=750000;
else
echo "waiting"
fi

done

17 changes: 17 additions & 0 deletions asyncRX50
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

while true
do
current_sec=$(date +%S);
current_time=$(date +%H_%M_%S);
mod12=$((10#$current_sec % 12));

if [ "$mod12" -eq 11 ]; then
echo $current_time
rx_samples_to_file --args="addr0=192.168.10.50" --freq=915e6 --rate=250e3 --file="predabs50_${current_time}.dat" --type=float --ant=TX/RX --gain=30 --nsamps=250000;
else
echo "waiting"
fi

done

17 changes: 17 additions & 0 deletions asyncRX50.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

while true
do
current_sec=$(date +%S);
current_time=$(date +%H_%M_%S);
mod12=$((10#$current_sec % 12));

if [ "$mod12" -eq 11 ]; then
echo $current_time
rx_samples_to_file --args="addr0=192.168.10.50" --freq=915e6 --rate=250e3 --file="predabs50_${current_time}.dat" --type=float --ant=TX/RX --gain=30 --nsamps=750000;
else
echo "waiting"
fi

done

17 changes: 17 additions & 0 deletions asyncRX52.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

while true
do
current_sec=$(date +%S);
current_time=$(date +%H_%M_%S);
mod12=$((10#$current_sec % 12));

if [ "$mod12" -eq 11 ]; then
echo $current_time
rx_samples_to_file --args="addr0=192.168.10.52" --freq=915e6 --rate=250e3 --file="predabs52_${current_time}.dat" --type=float --ant=TX/RX --gain=30 --nsamps=750000;
else
echo "waiting"
fi

done

17 changes: 17 additions & 0 deletions asyncRX7.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

while true
do
current_sec=$(date +%S);
current_time=$(date +%H_%M_%S);
mod12=$((10#$current_sec % 12));

if [ "$mod12" -eq 11 ]; then
echo $current_time
rx_samples_to_file --args="addr0=192.168.10.7" --freq=915e6 --rate=250e3 --file="predabs7_${current_time}.dat" --type=float --ant=TX/RX --gain=30 --nsamps=750000;
else
echo "waiting"
fi

done

13 changes: 0 additions & 13 deletions calcSR.m

This file was deleted.

19 changes: 0 additions & 19 deletions charmDecode.m

This file was deleted.

Loading

0 comments on commit 4782c27

Please sign in to comment.