This repository has been archived by the owner on Jan 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
close all; | ||
clear all; | ||
|
||
center_frequency = 173500000; | ||
sampling_frequency = 2000000; | ||
target_frequency = 173763000; | ||
filter_frequency = 500; | ||
upsample_ratio = 1; | ||
downsample_ratio = 200; | ||
num_taps = 100; | ||
|
||
|
||
% get data | ||
data = raw2complex('/home/ntlhui/workspace/tmp/testData/RAW_DATA_000001_000001'); | ||
tic | ||
signal_length = length(data) / sampling_frequency; | ||
shifted_signal = shift(data, target_frequency - (center_frequency + ... | ||
filter_frequency), sampling_frequency); | ||
resampled_signal = resample(shifted_signal', upsample_ratio, downsample_ratio); | ||
match_output = match(resampled_signal, filter_frequency, num_taps, ... | ||
sampling_frequency); | ||
resampled_t = 0:1 / (sampling_frequency / downsample_ratio) : 1 / (sampling_frequency / downsample_ratio) * (length(match_output) - 1); | ||
mean_output = mean(match_output); | ||
var_output = var(match_output); | ||
bound = mean_output + 3 * sqrt(var_output); | ||
toc | ||
plot(resampled_t, match_output); | ||
hold on; | ||
plot([0 max(resampled_t)], [bound bound]); | ||
plot([0 max(resampled_t)], [mean_output mean_output]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
clear all; | ||
close all; | ||
|
||
run_num = 55; | ||
files = 41; | ||
data_dir = sprintf("/media/ntlhui/43C8-B1EA/2017.08.22/RUN_%06d", run_num); | ||
% data_dir = "/home/ntlhui/workspace/tmp/testData/"; | ||
f_s = 2000000; | ||
|
||
ignore = mkdir(sprintf("RUN_%06d", run_num)); | ||
|
||
int_len = 6400; | ||
|
||
final_freq = f_s / int_len; | ||
start_idx = 0; | ||
|
||
threshold = 100; | ||
for i = 1:files | ||
data = raw2complex(sprintf("%s/RAW_DATA_%06d_%06d", data_dir, run_num, i)); | ||
mag_data = abs(data).^2; | ||
% integrated_data = mag_data; | ||
integrated_data = zeros(floor(length(data) / int_len), 1); | ||
for j = 1:length(integrated_data) | ||
integrated_data(j) = sum(mag_data((j - 1) * int_len + 1 : j * int_len - 1)); | ||
end | ||
log_data = 20 * log10(integrated_data); | ||
|
||
if threshold == 100 | ||
threshold = log_data(1); | ||
end | ||
|
||
time = start_idx / final_freq : 1 / final_freq : (start_idx + length(log_data) - 1) / final_freq; | ||
|
||
plot(time, log_data); | ||
saveas(gcf, sprintf("RUN_%06d/RAW_DATA_%06d_%06d.fig", run_num, run_num, i)); | ||
start_idx = start_idx + length(log_data); | ||
end | ||
|
||
close; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
function [signal] = match(input_signal, filter_frequency, num_taps, sampling_freq) | ||
filter_length = num_taps / sampling_freq; | ||
t = 0:1/sampling_freq:filter_length - 1/sampling_freq; | ||
filter_taps = cos(2 * pi * filter_frequency * t) + i * sin(2 * pi * filter_frequency * t); | ||
filter_taps = filter_taps(:); | ||
input_signal = input_signal(:); | ||
conv_output = conv(input_signal, filter_taps); | ||
amp = abs(conv_output); | ||
signal = 10 * log10(amp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function [signal] = shift(input_signal, shift_amt, sampling_freq) | ||
signal_length = length(input_signal) / sampling_freq; | ||
t = 0:1/sampling_freq:signal_length - 1/sampling_freq; | ||
mixing_signal = cos(-2 * pi * shift_amt * t) + i * sin(-2 * pi * shift_amt * t); | ||
mixing_signal = mixing_signal(:); | ||
input_signal = input_signal(:); | ||
signal = input_signal .* mixing_signal; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
close all; | ||
clear all; | ||
|
||
threshold_history = csvread('/home/ntlhui/workspace/radio_collar_tracker_drone/tests/sdr_record/classifier_threshold.log'); | ||
data_in = csvread('/home/ntlhui/workspace/radio_collar_tracker_drone/tests/sdr_record/classifier_in.log'); | ||
% gps_data = csvread('/media/ntlhui/43C8-B1EA/2017.08.22/RUN_000055/GPS_000055'); | ||
signal_start_time_s = 1502770034.363384; | ||
% gps_start_time_s = gps_data(1:1); | ||
% local time, lat, lon, global time, alt, relative alt, vx, vy, vz, hdg | ||
% lat = gps_data(:,2); | ||
% lon = gps_data(:,3); | ||
% gps_data_times = gps_data(:,1) - signal_start_time_s; | ||
f_s = 2000000/6400; | ||
time = 0:1/f_s:(length(data_in) - 1) / f_s; | ||
|
||
static_offset = 1.5; | ||
|
||
% recreation | ||
% avg_len = floor(0.25*f_s) | ||
% ping_len = ceil(0.02*f_s); | ||
% peak_history = [ones(ping_len,1) * data_in(1); data_in]; | ||
% peak = zeros(length(data_in), 1); | ||
% for k = 1:length(peak) | ||
% peak(k) = max(peak_history(k:k+ping_len)); | ||
% end | ||
% peak = [ones(avg_len,1) * peak(1); peak]; | ||
% peak_threshold = zeros(length(data_in), 1); | ||
% for k = 1:length(peak_threshold) | ||
% peak_threshold = median(peak(k:k+avg_len)) + 0.5; | ||
% end | ||
|
||
% peak_history = [ones(avg_len,1) * data_in(1); data_in]; | ||
% threshold = zeros(length(data_in),1); | ||
% for k = 1:length(threshold) | ||
% threshold(k) = mean(peak_history(k:k+avg_len)) + 1; | ||
% end | ||
|
||
|
||
figure; | ||
subplot(2,1,1); | ||
plot(time, data_in); | ||
hold on; | ||
grid on; | ||
plot(time, threshold_history+1.5); | ||
% plot(time, threshold); | ||
% plot(time, peak_threshold); | ||
lims = xlim; | ||
% subplot(2,1,2); | ||
% plot(gps_data_times, lat); | ||
% hold on; | ||
% grid on; | ||
% yyaxis right; | ||
% plot(gps_data_times, lon); | ||
% xlim(lims); |