added function to generate pilot signal at rx
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 30 Mar 2012 09:11:41 +0000 (09:11 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 30 Mar 2012 09:11:41 +0000 (09:11 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@358 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/fdmdv.m
codec2-dev/octave/fdmdv_ut.m

index 71a098c2d84a9f46252609370c7a61e31d0ee4ff..fbecfcfeab7d7f81b830bed01ad9b3fd87544ed2 100644 (file)
@@ -127,9 +127,9 @@ function tx_symbols = bits_to_qpsk(prev_tx_symbols, tx_bits, modulation)
   % lines at +/- Rs/2
  
   if pilot_bit
-     tx_symbols(Nc+1) = -prev_tx_symbols(c+1);
+     tx_symbols(Nc+1) = -prev_tx_symbols(Nc+1);
   else
-     tx_symbols(Nc+1) = prev_tx_symbols(c+1);
+     tx_symbols(Nc+1) = prev_tx_symbols(Nc+1);
   end
   if pilot_bit 
     pilot_bit = 0;
@@ -539,6 +539,7 @@ freq(Nc+1) = exp(j*2*pi*Fcentre/Fs);
 % This really helped PAPR.  We don't need to adjust rx
 % phase a DPSK takes care of that
 
+%global phase_tx = ones(Nc+1,1);
 global phase_tx = exp(j*2*pi*(0:Nc)/(Nc+1));
 global phase_rx = ones(Nc+1,1);
 
@@ -551,7 +552,6 @@ global Npilotlpf      = 4*M;                            % number of samples we D
 global pilot_baseband = zeros(1, Npilotbaseband);       % pilot baseband samples
 global pilot_lpf      = zeros(1, Npilotlpf);            % LPC pilot samples
 global phase_rx_pilot = [1 1];
-global freq_rx_pilot  = [ exp(-j*2*pi*(Fcentre-Rs/4)/Fs) exp(-j*2*pi*(Fcentre+Rs/4)/Fs) ];
 
 % Timing estimator states
 
@@ -565,3 +565,42 @@ global current_test_bit = 1;
 global test_bits = rand(1,Ntest_bits) > 0.5;
 global rx_test_bits_mem = zeros(1,Ntest_bits);
 
+% Generate M samples of DBPSK pilot signal for Freq offset estimation
+
+function [pilot_fdm bit symbol filter_mem phase] = generate_pilot_fdm(bit, symbol, filter_mem, phase, freq)
+  global M;
+  global Nfilter;
+  global gt_alpha5_root;
+
+  % +1 -1 +1 -1 DBPSK sync carrier, once filtered becomes two spectral
+  % lines at +/- Rs/2
+  if bit
+     symbol = -symbol;
+  else
+     symbol = symbol;
+  end
+  if bit 
+    bit = 0;
+  else
+    bit = 1;
+  end
+
+  % filter DPSK symbol to create M baseband samples
+
+  filter_mem(Nfilter) = (sqrt(2)/2)*symbol;
+  for i=1:M
+    tx_baseband(i) = M*filter_mem(M:M:Nfilter) * gt_alpha5_root(M-i+1:M:Nfilter)';
+  end
+  filter_mem(1:Nfilter-M) = filter_mem(M+1:Nfilter);
+  filter_mem(Nfilter-M+1:Nfilter) = zeros(1,M);
+
+  % upconvert
+
+  for i=1:M
+    phase = phase * freq;
+    pilot_fdm(i) = sqrt(2)*2*tx_baseband(i)*phase;
+  end
+
+endfunction
+
index 89c02c14bd39bc01e747673d5d2b112e82a75582..ae77ae66722d11d7a183c8215544b8f07803c0bf 100644 (file)
@@ -17,7 +17,7 @@ frames = 100;
 EbNo_dB = 7.3;
 Foff_hz = -100;
 modulation = 'dqpsk';
-hpa_clip = 10;
+hpa_clip = 100;
 
 % ------------------------------------------------------------
 
@@ -41,6 +41,16 @@ tx_fdm_log = [];
 sync_log = [];
 bit_errors_log = [];
 
+% pilot states, used for copy of pilot at rx
+
+pilot_rx_bit = 0;
+pilot_symbol = sqrt(2);
+pilot_freq = freq(Nc+1);
+pilot_phase = 1;
+pilot_filter_mem = zeros(1, Nfilter);
+
+% fixed delay simuation
+
 Ndelay = M+20;
 rx_fdm_delay = zeros(Ndelay,1);
 
@@ -93,7 +103,7 @@ for i=1:frames
   prev_tx_symbols = tx_symbols;
   tx_baseband = tx_filter(tx_symbols);
   tx_baseband_log = [tx_baseband_log tx_baseband];
-  [tx_fdm pilot] = fdm_upconvert(tx_baseband);
+  [tx_fdm pilot_tx] = fdm_upconvert(tx_baseband);
   tx_pwr = 0.9*tx_pwr + 0.1*real(tx_fdm)*real(tx_fdm)'/(M);
 
   % -------------------
@@ -138,6 +148,7 @@ for i=1:frames
 
   % frequency offset estimation and correction
 
+  [pilot pilot_rx_bit pilot_symbol pilot_filter_mem pilot_phase] = generate_pilot_fdm(pilot_rx_bit, pilot_symbol, pilot_filter_mem, pilot_phase, pilot_freq);
   foff = rx_est_freq_offset(rx_fdm, pilot);
   foff_log = [ foff_log foff ];
   %foff = 0;