added refinement stage, now syncing up quckly at high an dlow SNRs
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 8 Apr 2018 00:55:12 +0000 (00:55 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 8 Apr 2018 00:55:12 +0000 (00:55 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3451 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/ofdm_dev.m
codec2-dev/octave/ofdm_lib.m
codec2-dev/octave/ofdm_rx.m

index 40f17ac68d14fa2acdde4a8081d867ab81e6dfc9..a5a6e4e5692cf0d238e54a09d500f841d5710e44 100644 (file)
@@ -901,16 +901,16 @@ function [delta_ct delta_foff timing_mx_log] = acquisition_test(Ntests=10, EbNod
     ct_target = Nsamperframe/2;   % actual known position of correct coarse timing
 
     for w=1:Nsamperframe:length(rx)-4*Nsamperframe
-      [ct_est foff_est timing_valid timing_mx1 timing_mx2] = coarse_sync(states, real(rx(w+st:w+en)), rate_fs_pilot_samples);
+      [ct_est foff_est timing_valid timing_mx] = coarse_sync(states, real(rx(w+st:w+en)), rate_fs_pilot_samples);
       if states.verbose
-        printf("w: %5d ct_est: %4d foff_est: %5.1f timing_mx1: %3.2f timing_mx2: %3.2f\n", w, ct_est, foff_est, timing_mx1, timing_mx2);
+        printf("w: %5d ct_est: %4d foff_est: %5.1f timing_mx: %3.2f\n", w, ct_est, foff_est, timing_mx);
       end
 
       % valid coarse timing ests are modulo Nsamperframe
 
       delta_ct = [delta_ct ct_est-ct_target];
       delta_foff = [delta_foff (foff_est-foff_hz)];
-      timing_mx_log = [timing_mx_log; timing_mx1 timing_mx2];
+      timing_mx_log = [timing_mx_log; timing_mx];
     end
   end
 
index a424c42ce42f089c715805fae3812718edb87d21..7011adbfeacd8f71546b3b784e0b3d5d9ebfe8ee 100644 (file)
@@ -79,12 +79,13 @@ function [t_est foff_est timing_valid timing_mx] = coarse_sync(states, rx, rate_
     p2 = rx(t_est+Npsam/2:t_est+Npsam-1) * rate_fs_pilot_samples(Npsam/2+1:Npsam)';
     p3 = rx(t_est+Nsamperframe:t_est+Nsamperframe+Npsam/2-1) * rate_fs_pilot_samples(1:Npsam/2)';
     p4 = rx(t_est+Nsamperframe+Npsam/2:t_est+Nsamperframe+Npsam-1) * rate_fs_pilot_samples(Npsam/2+1:Npsam)';
+   
     Fs1 = Fs/(Npsam/2);
-    foff_est = Fs1*angle( (conj(p1)*p2 + conj(p3)*p4))/(2*pi);
+    foff_est = Fs1*angle(conj(p1)*p2 + conj(p3)*p4)/(2*pi);
         
     if verbose > 1
       figure(7); clf;
-      plot(abs(corr2))
+      plot(abs(corr))
 
       figure(8)
       subplot(211)
index 6df1082710984ba1861e0544d8c6f60a745a424c..fc4d11b4f140db7f22b49c776d06ba7a33f89592 100644 (file)
@@ -71,6 +71,12 @@ function ofdm_rx(filename, error_pattern_filename)
       [timing_valid states] = ofdm_sync_search(states, rxbuf_in);
 
       if states.timing_valid
+        st = M+Ncp + Nsamperframe + 1; en = st + 2*Nsamperframe;
+        woff_est = 2*pi*states.foff_est_hz/Fs;
+        [ct_est foff_est timing_valid timing_mx] = coarse_sync(states, states.rxbuf(st:en) .* exp(-j*woff_est*(st:en)), states.rate_fs_pilot_samples);
+        printf("  coarse_foff: %4.1f refine: %4.1f combined: %4.1f\n", states.foff_est_hz, foff_est, states.foff_est_hz+foff_est);
+        states.foff_est_hz += foff_est;
+        
         Nerrs_log = [];
         Terrs = Tbits = frame_count = 0;
         sync_counter = 0;
@@ -110,7 +116,7 @@ function ofdm_rx(filename, error_pattern_filename)
       if strcmp(state,'synced')
         sync_counter_thresh = 6;
       else
-        sync_counter_thresh = 2;
+        sync_counter_thresh = 3;
       end
 
       % freq offset est may be too far out, and has aliases every 1/Ts