Skip to content

Commit

Permalink
synthetic signal generated
Browse files Browse the repository at this point in the history
  • Loading branch information
arnauochoa committed Nov 27, 2020
1 parent 90ec634 commit c9d0bda
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 2 deletions.
46 changes: 46 additions & 0 deletions main.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
clear; close all; clc;
%blabla

%% Initializations
prn = 20; % PRN index
duration = 200e-3; % sec - 200 times the PRN
tR = 1e-3; % sec - PRN period
prnLength = 1023; % samples
kDelay = 8945; % samples
fDoppler = 1755; % Hz
fIF = 4.348e6; % Hz
fs = 23.104e6; % Hz
phi = 0; % Phase delay
sLength = duration/tR * prnLength; % Signal length in samples
tC = tR/prnLength;
tDelay = kDelay * tC;

%% Generation of signal
tVec = 0:1/fs:duration; % Vector of time
kVec = 1:sLength; % Vector of samples
code = ca_code(prn);
% Code samples
cm = create_code_samples(code, kVec);
% Shift in time
cm = circshift(cm, sLength - kDelay);
% Modulation
signal = ones(1, length(tVec));
for t = 1:length(tVec)-1
signal(t) = cm(fix(tVec(t)/tC)+1);
end
signal = signal .* cos(2*pi*fIF*(tVec-tDelay) + phi);

% Quantization
signal(signal <= -0.5) = -1;
signal(signal >= 0.5) = 1;
signal(signal > -0.5 & signal < 0.5) = 0;

figure; plot((kVec(1:5)-1)*tC, cm(1:5), 'o-');
figure; plot(tVec(1:ceil(5*tC*fs)), signal(1:ceil(5*tC*fs)), 'o-');
xlabel('Time (s)');
ylabel('Amplitude');


%% PLL


49 changes: 49 additions & 0 deletions main.m~
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
clear; close all; clc;
%blabla

%% Initializations
prn = 20; % PRN index
duration = 200e-3; % sec - 200 times the PRN
tR = 1e-3; % sec - PRN period
prnLength = 1023; % samples
kDelay = 8945; % samples
fDoppler = 1755; % Hz
fIF = 4.348e6; % Hz
fs = 23.104e6; % Hz
phi = 0; % Phase delay
sLength = duration/tR * prnLength; % Signal length in samples
tC = tR/prnLength;
tDelay = kDelay * tC;

%% Generation of signal
tVec = 0:1/fs:duration; % Vector of time
kVec = 1:sLength; % Vector of samples
code = ca_code(prn);
% Code samples
cm = create_code_samples(code, kVec);
% Shift in time
cm = circshift(cm, sLength - kDelay);
% Modulation
signal = ones(1, length(tVec));
for t = 1:length(tVec)-1
signal(t) = cm(fix(tVec(t)/tC)+1);
end
signal = signal .* cos(2*pi*fIF*(tVec-tDelay) + phi);



% signal = signal;
% Quantization
% signal(signal <= -0.5) = -1;
% signal(signal >= 0.5) = 1;
% signal(signal > -0.5 & signal < 0.5) = 0;

figure; plot((kVec(1:5)-1)*tC, cm(1:5), 'o-');
figure; plot(tVec(1:5*tC*fs), signal(1:5*tC*fs), 'o-');
xlabel('Time (s)');
ylabel('Amplitude');


%% PLL


4 changes: 2 additions & 2 deletions rx_signal_analysis.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

filepath = 'test_real_long.dat';

Nsamp = 500*4096;
Nsamp = 1000*4096;
signal = DataReader(filepath, Nsamp);

N = 2^20;
Expand All @@ -21,7 +21,7 @@
title('Quantized signal in time domain');
xlabel('k');

[Swelch, fwelch] = pwelch(s, 256, 0, 256, fs);
[Swelch, fwelch] = pwelch(s, 512, 0, 512, fs);
figure
plot(fwelch./1e6, 10*log10(Swelch)); hold on;
xline(fIF/1e6);
Expand Down

0 comments on commit c9d0bda

Please sign in to comment.