- fixed CFO tracking
git-svn-id: http://moon:8086/svn/matlab/trunk@68 801c6759-fa7c-4059-a304-17956f83a07c
This commit is contained in:
+14
-13
@@ -72,6 +72,7 @@ equalizer = struct('Z', 0, 'sync_counter', 20, 'sync', 0, 'started', 0, 's', 0,
|
|||||||
H_syms = [];
|
H_syms = [];
|
||||||
H_pilots = [];
|
H_pilots = [];
|
||||||
H_ = [];
|
H_ = [];
|
||||||
|
df_track = 1000;
|
||||||
df_track_ = [];
|
df_track_ = [];
|
||||||
|
|
||||||
symbols_per_frame = ofdm_drm_params.nspf;
|
symbols_per_frame = ofdm_drm_params.nspf;
|
||||||
@@ -109,7 +110,7 @@ while(fileRemain > fileChunkSize)
|
|||||||
if (~isModePassband)
|
if (~isModePassband)
|
||||||
xwav = xwav(:, 1) + j*xwav(:, 2);
|
xwav = xwav(:, 1) + j*xwav(:, 2);
|
||||||
end
|
end
|
||||||
% xwav = xwav - mean(xwav);
|
xwav = xwav - mean(xwav);
|
||||||
|
|
||||||
x = xwav.*exp(-j*(2*pi*omega_xwav*(0:fileChunkSize-1)' + phi_xwav));
|
x = xwav.*exp(-j*(2*pi*omega_xwav*(0:fileChunkSize-1)' + phi_xwav));
|
||||||
phi_xwav = mod(phi_xwav + 2*pi*omega_xwav*fileChunkSize, 2*pi);
|
phi_xwav = mod(phi_xwav + 2*pi*omega_xwav*fileChunkSize, 2*pi);
|
||||||
@@ -119,7 +120,7 @@ while(fileRemain > fileChunkSize)
|
|||||||
end
|
end
|
||||||
|
|
||||||
% add noise
|
% add noise
|
||||||
x = awgn(x, SNR, 'measured');
|
x = awgn(x, SNR);
|
||||||
|
|
||||||
if (isModePassband)
|
if (isModePassband)
|
||||||
[x, filter_z] = filter(filter_h, 1, x, filter_z);
|
[x, filter_z] = filter(filter_h, 1, x, filter_z);
|
||||||
@@ -157,7 +158,7 @@ while(fileRemain > fileChunkSize)
|
|||||||
end
|
end
|
||||||
|
|
||||||
% Integer CFO coarse
|
% Integer CFO coarse
|
||||||
if (timingCoarse.sync) && (~cfoCoarseInteger.sync)
|
if (timingCoarse.sync) & (~cfoCoarseInteger.sync)
|
||||||
if (~cfoCoarseInteger.started)
|
if (~cfoCoarseInteger.started)
|
||||||
cfoCoarseInteger.started = 1;
|
cfoCoarseInteger.started = 1;
|
||||||
fprintf('Coarse integer CFO acquisition');
|
fprintf('Coarse integer CFO acquisition');
|
||||||
@@ -181,7 +182,7 @@ while(fileRemain > fileChunkSize)
|
|||||||
end
|
end
|
||||||
|
|
||||||
% Fractional CFO coarse
|
% Fractional CFO coarse
|
||||||
if (cfoCoarseInteger.sync) && (~cfoCoarseFractional.sync)
|
if (cfoCoarseInteger.sync) & (~cfoCoarseFractional.sync)
|
||||||
if (~cfoCoarseFractional.started)
|
if (~cfoCoarseFractional.started)
|
||||||
cfoCoarseFractional.started = 1;
|
cfoCoarseFractional.started = 1;
|
||||||
fprintf('Coarse fractional CFO acquisition');
|
fprintf('Coarse fractional CFO acquisition');
|
||||||
@@ -228,14 +229,18 @@ while(fileRemain > fileChunkSize)
|
|||||||
cfoFine.err = kn*angle(Z(bin_pilot));
|
cfoFine.err = kn*angle(Z(bin_pilot));
|
||||||
cfoFine.err_ = [cfoFine.err_ cfoFine.err];
|
cfoFine.err_ = [cfoFine.err_ cfoFine.err];
|
||||||
|
|
||||||
if (abs(cfoFine.df) > 0.001)
|
if cfoFine.sync
|
||||||
|
cfoFine.df = cfoFine.df + 0.1*df_track;
|
||||||
|
else
|
||||||
cfoFine.df = cfoFine.df + 0.1*mean(cfoFine.err(cfoFine.bin_track));
|
cfoFine.df = cfoFine.df + 0.1*mean(cfoFine.err(cfoFine.bin_track));
|
||||||
elseif ~cfoFine.sync
|
end
|
||||||
|
|
||||||
|
if (abs(df_track) < 0.1) & (cfoFine.sync == 0)
|
||||||
if cfoFine.sync_counter > 0
|
if cfoFine.sync_counter > 0
|
||||||
cfoFine.sync_counter = cfoFine.sync_counter - 1;
|
cfoFine.sync_counter = cfoFine.sync_counter - 1;
|
||||||
else
|
else
|
||||||
cfoFine.sync = 1;
|
cfoFine.sync = 1;
|
||||||
fprintf('Enter fine tracking mode\n');
|
fprintf('Enter fine tracking mode at frame %d\n', equalizer.kk);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
cfoFine.df_ = [cfoFine.df_ cfoFine.df];
|
cfoFine.df_ = [cfoFine.df_ cfoFine.df];
|
||||||
@@ -305,7 +310,7 @@ while(fileRemain > fileChunkSize)
|
|||||||
H_pilots = (H_gain)*W_pilots{equalizer.n+1};
|
H_pilots = (H_gain)*W_pilots{equalizer.n+1};
|
||||||
|
|
||||||
% Get the correctly delayed symbols
|
% Get the correctly delayed symbols
|
||||||
Z = buf_Z.readAt(N, -N*symbols_to_delay);
|
Z = buf_Z.readAt(N, -N*(symbols_to_delay+1));
|
||||||
sym = Z(carrier_indexes).';
|
sym = Z(carrier_indexes).';
|
||||||
|
|
||||||
% Get the correctly delayed raw channel estimate
|
% Get the correctly delayed raw channel estimate
|
||||||
@@ -314,7 +319,6 @@ while(fileRemain > fileChunkSize)
|
|||||||
% get frequency error
|
% get frequency error
|
||||||
% correlate wiener filtered channel with raw estimate
|
% correlate wiener filtered channel with raw estimate
|
||||||
df_track = fs/(2*pi*N)*angle(H_pilots * Hr' + equalizer.eps_abs_h);
|
df_track = fs/(2*pi*N)*angle(H_pilots * Hr' + equalizer.eps_abs_h);
|
||||||
cfoFine.df = cfoFine.df + 0.01*df_track;
|
|
||||||
df_track_ = [df_track_ df_track];
|
df_track_ = [df_track_ df_track];
|
||||||
|
|
||||||
% check for too small values
|
% check for too small values
|
||||||
@@ -383,7 +387,7 @@ subplot(3, 1, 1)
|
|||||||
plot(0:length(cfoCoarseFractional.df_)-1, cfoCoarseFractional.df_); grid; title('df_{coarse} (Acquisition)')
|
plot(0:length(cfoCoarseFractional.df_)-1, cfoCoarseFractional.df_); grid; title('df_{coarse} (Acquisition)')
|
||||||
|
|
||||||
subplot(3, 1, 2)
|
subplot(3, 1, 2)
|
||||||
plot(0:length(cfoFine.df_)-1, cfoFine.df_); grid; title('df_{fine} (Acquisition)')
|
plot(0:length(cfoFine.df_)-1, cfoFine.df_, 0:length(df_track_)-1, df_track_); grid; title('df_{fine} (Acquisition), df_{track}')
|
||||||
|
|
||||||
subplot(3, 1, 3)
|
subplot(3, 1, 3)
|
||||||
plot(0:length(cfoFine.err_.')-1, cfoFine.err_.'); grid; title('Error(df_{fine}) (Acquisition)')
|
plot(0:length(cfoFine.err_.')-1, cfoFine.err_.'); grid; title('Error(df_{fine}) (Acquisition)')
|
||||||
@@ -403,8 +407,5 @@ wavwrite(y,fs4,nbits,'rx_y.wav');
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
figure;
|
|
||||||
plot(df_track_); grid; title('df_{track}');
|
|
||||||
|
|
||||||
function Y = spec_order(N, X)
|
function Y = spec_order(N, X)
|
||||||
Y = [X(N/2+1:N)' X(1:N/2)']';
|
Y = [X(N/2+1:N)' X(1:N/2)']';
|
||||||
|
|||||||
Reference in New Issue
Block a user