refactored ofdm rx a little, progressing towards better sync state machine
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 20 Mar 2018 08:56:00 +0000 (08:56 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 20 Mar 2018 08:56:00 +0000 (08:56 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3421 01035d8c-6547-0410-b346-abe4f91aad63

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

index 648e5e510f3c68bb8013004cf2f9dd9aeb891c69..48059ade273cc03614f672bcf3897687310623e1 100644 (file)
@@ -943,7 +943,8 @@ endfunction
    0       AWGN    10     1.00  0.98
    0       HF      10     1.00  0.65
 
-   -> Suggests we will sync up in 2-3 frames which is pretty cool.
+   -> Suggests we will sync up in 2-3 frames which is pretty cool.  Would be good
+      to have freq est about as reliable as timing est.....
 #}
 
 function acquisition_histograms(fine_en = 0, foff)
index 8d47e375fc18cb38bb5e9a54b864ca6a32e05945..32d4c3431096ca19427b2d3c69080301452d22a2 100644 (file)
@@ -6,7 +6,7 @@
 
 #{
   TODO:
-    [ ] single frame based sync state machine
+    [X] single frame based sync state machine
         + that doesn't depend on payload data
     [ ] make robust to fading
         + what are win conditions?
@@ -74,9 +74,14 @@ function ofdm_rx(filename, error_pattern_filename)
     prx += states.nin;
 
     [rx_bits states aphase_est_pilot_log arx_np arx_amp] = ofdm_demod(states, rxbuf_in);
+
+    errors = xor(tx_bits, rx_bits);
+    Nerrs = sum(errors);
+    aber = Nerrs/Nbitsperframe;
+    
     frame_count++;
 
-    printf("f: %d state: %s frame_count: %d\n", f, state, frame_count);
+    printf("f: %d state: %s Nerrs: %d aber: %3.2f\n", f, state, Nerrs, aber);
 
     % If looking for sync: check raw BER on frame just received
     % against all possible positions in the interleaver frame.
@@ -89,9 +94,7 @@ function ofdm_rx(filename, error_pattern_filename)
       % If looking for sync: check raw BER on frame just received
       % against all possible positions in the interleaver frame.
 
-      errors = xor(tx_bits, rx_bits);
-      Nerrs = sum(errors); 
-      if Nerrs/Nbitsperframe < 0.1
+      if aber < 0.1
         next_state = 'synced';
         % make sure we get an interleave frame with correct freq offset
         % note this introduces a lot of delay, a better idea would be to
@@ -139,9 +142,7 @@ function ofdm_rx(filename, error_pattern_filename)
 
       % measure uncoded bit errors on modem frame
 
-      errors = xor(tx_bits, rx_bits);
-      Nerrs = sum(errors);
-      if Nerrs/Nbitsperframe < 0.2
+      if aber < 0.2
         Terrs += Nerrs;
         Nerrs_log = [Nerrs_log Nerrs];
         Tbits += Nbitsperframe;
index b40b978dc5876338da07fac66dde9472bdcb8570..79edb597b2c3dbff9e322d5c6ba11e0547503bed 100644 (file)
@@ -37,7 +37,7 @@ function ofdm_tx(filename, Nsec, EbNodB=100, channel='awgn', freq_offset_Hz=0)
   for f=1:Nframes
     tx = [tx ofdm_mod(states, tx_bits)];
   end
-
+  
   Nsam = length(tx);
 
   % channel simulation
@@ -59,7 +59,8 @@ function ofdm_tx(filename, Nsec, EbNodB=100, channel='awgn', freq_offset_Hz=0)
     dopplerSpreadHz = 1; path_delay_ms = 1;
 
     path_delay_samples = path_delay_ms*Fs/1000;
-    printf("Doppler Spread: %3.2f Hz Path Delay: %3.2f ms %d samples\n", dopplerSpreadHz, path_delay_ms, path_delay_samples);
+    printf("Doppler Spread: %3.2f Hz Path Delay: %3.2f ms %d samples\n",
+           dopplerSpreadHz, path_delay_ms, path_delay_samples);
 
     % generate same fading pattern for every run