about to refactor ofdm_dev state machine to use timing_max as indication of modem...
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 24 Mar 2018 03:46:54 +0000 (03:46 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 24 Mar 2018 03:46:54 +0000 (03:46 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3431 01035d8c-6547-0410-b346-abe4f91aad63

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

index aaeba9e025e3584cf022a155b4206fe24bfd991c..e6ae97009c750e54b050480f14fcc6804a7c20dd 100644 (file)
@@ -862,11 +862,11 @@ function [delta_ct delta_foff] = acquisition_test(Ntests=10, EbNodB=100, foff_hz
   
   [sim_out rx states] = run_sim(sim_in);
   
-  states.verbose = 2;
+  states.verbose = 0;
   
   % set up acquistion 
 
-  Nsamperframe = states.Nsamperframe;
+  Nsamperframe = states.Nsamperframe; M = states.M; Ncp = states.Ncp;
   rate_fs_pilot_samples = states.rate_fs_pilot_samples;
 
   % test fine or acquisition over test signal
@@ -885,6 +885,9 @@ function [delta_ct delta_foff] = acquisition_test(Ntests=10, EbNodB=100, foff_hz
 
   delta_ct = []; delta_foff = [];
 
+  % a fine simulation is a bit like what ofsd_demod() does, just searches a few samples
+  % either side of current coarse est
+  
   if fine_en
 
     window_width = 5;                   % search +/-2 samples from current timing instant
@@ -900,15 +903,14 @@ function [delta_ct delta_foff] = acquisition_test(Ntests=10, EbNodB=100, foff_hz
       delta_t = [delta_ft ft_est - ceil(window_width/2)];
     end
   else
-    % for coarse simulation we just use contant window shifts
+    % for coarse simulation we just use constant window shifts
 
     st = 0.5*Nsamperframe; 
-    en = 2.5*Nsamperframe - 1;
-    ct_target = Nsamperframe/2;
+    en = 2.5*Nsamperframe - 1;    % note this gives Nsamperframe possibilities for coarse timing
+    ct_target = Nsamperframe/2;   % actual known position of correct coarse timing
 
     for w=1:Nsamperframe:length(rx)-4*Nsamperframe
-      %st = w+0.5*Nsamperframe; en = st+2*Nsamperframe-1;
-      %[ct_est foff_est] = coarse_sync(states, rx(st:en), rate_fs_pilot_samples);
+    %for w=1:M+Ncp:length(rx)-4*Nsamperframe
       [ct_est foff_est] = coarse_sync(states, rx(w+st:w+en), rate_fs_pilot_samples);
       if states.verbose
         printf("w: %d ct_est: %4d foff_est: %3.1f\n", w, ct_est, foff_est);
@@ -1007,8 +1009,8 @@ more off;
 
 init_cml('/home/david/Desktop/cml/');
 
-%run_single 
+run_single 
 %run_curves
 %run_curves_estimators
 %acquisition_histograms(0, 0)
-acquisition_test(10, 4, 5)
+%acquisition_test(10, 4, 5)
index 72ebeea8ddd9a361752a3b971b626949498b1be5..2cf282bcb74fb2f2d8c96bb0b1884e0167e39f90 100644 (file)
@@ -323,7 +323,7 @@ function [rx_bits states aphase_est_pilot_log rx_np rx_amp] = ofdm_demod(states,
 
   % update timing estimate --------------------------------------------------
 
-  delta_t = coarse_foff_est_hz = 0;
+  delta_t = coarse_foff_est_hz = timing_valid = timing_mx = 0;
   if timing_en
     % update timing at start of every frame
 
index ba9f3a33eb004f1b0d7c8e8fa5a7f3bb6d5213df..ccd854c720401712892743e386baa1c562ee20b0 100644 (file)
@@ -29,9 +29,10 @@ function ofdm_rx(filename, error_pattern_filename)
 
   % load real samples from file
 
-  Ascale= 2E5*1.1491;
-  frx=fopen(filename,"rb"); rx = 2*fread(frx, Inf, "short")/4E5; fclose(frx);
+  Ascale= 2E5*1.1491/2;
+  frx=fopen(filename,"rb"); rx = fread(frx, Inf, "short")/Ascale; fclose(frx);
   Nsam = length(rx); Nframes = floor(Nsam/Nsamperframe);
+  Nframes = 5;
   prx = 1;
 
   % OK re-generate tx frame for BER calcs
@@ -52,8 +53,8 @@ function ofdm_rx(filename, error_pattern_filename)
 
   prx = 1;
   nin = Nsamperframe+2*(M+Ncp);
-  states.rxbuf(Nrxbuf-nin+1:Nrxbuf) = rx(prx:nin);
-  prx += nin;
+  %states.rxbuf(Nrxbuf-nin+1:Nrxbuf) = rx(prx:nin);
+  %prx += nin;
 
   state = 'searching'; frame_count = 0;
 
@@ -73,6 +74,7 @@ function ofdm_rx(filename, error_pattern_filename)
     end
     prx += states.nin;
 
+    printf("  states.nin: %d\n", states.nin);
     [rx_bits states aphase_est_pilot_log arx_np arx_amp] = ofdm_demod(states, rxbuf_in);
 
     errors = xor(tx_bits, rx_bits);
@@ -117,13 +119,13 @@ function ofdm_rx(filename, error_pattern_filename)
       st = M+Ncp + Nsamperframe + 1; en = st + 2*Nsamperframe; 
       [ct_est foff_est] = coarse_sync(states, states.rxbuf(st:en), states.rate_fs_pilot_samples);
       if states.verbose
-        printf("  Nerrs: %d ct_est: %4d foff_est: %3.1f\n", Nerrs, ct_est, foff_est);
+        printf("   Nerrs: %d ct_est: %4d foff_est: %3.1f\n", Nerrs, ct_est, foff_est);
       end
 
       % calculate number of samples we need on next buffer to get into sync
      
       states.nin = Nsamperframe + ct_est - 1;
-
+      
       % reset modem states
 
       states.sample_point = states.timing_est = 1;
@@ -154,8 +156,8 @@ function ofdm_rx(filename, error_pattern_filename)
 
   figure(1); clf; 
   plot(rx_np_log,'+');
-  mx = max(abs(rx_np_log));
-  %axis([-mx mx -mx mx]);
+  mx = 2*max(abs(rx_np_log));
+  axis([-mx mx -mx mx]);
   title('Scatter');
 
   figure(2); clf;