reconcilled C and Octave sync state machines - still some tunign rqd here
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 30 Apr 2018 22:10:58 +0000 (22:10 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 30 Apr 2018 22:10:58 +0000 (22:10 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3540 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/ofdm_ldpc_rx.m
codec2-dev/octave/ofdm_lib.m
codec2-dev/src/ofdm.c

index b1daed49570712c99d7552bf4ec94ce34ce14a70..bf2a8589dd0f6979139b8bc266cf9a85d1ab58cc 100644 (file)
@@ -22,7 +22,7 @@ function ofdm_ldpc_rx(filename, interleave_frames = 1, error_pattern_filename)
   Ts = 0.018; Tcp = 0.002; Rs = 1/Ts; bps = 2; Nc = 17; Ns = 8;
   states = ofdm_init(bps, Rs, Tcp, Ns, Nc);
   ofdm_load_const;
-  states.verbose = 0;
+  states.verbose = 1;
 
   % Set up LDPC code
 
index cfef75f74312be5c6a5829ba8884a01ddcffc570..fedcfd836ab15fa28db2e1b1c73e6883b3dc3385 100644 (file)
@@ -682,34 +682,35 @@ function states = sync_state_machine(states, rx_uw)
     states.frame_count++;
     states.frame_count_interleaver++;
       
-    % during trial sync we don't tolerate errors so much, once we have synced up
-    % we are willing to wait out a fade
-      
-    if states.frame_count == 3
-      next_state = 'synced';
-    end
-    if strcmp(states.sync_state,'synced')
-      sync_counter_thresh = 12;
-      uw_thresh = 2;
-    else
-      sync_counter_thresh = 2;
-      uw_thresh = 1;
+    states.uw_errors = sum(xor(tx_uw,rx_uw));
+
+    if strcmp(states.sync_state,'trial')
+      if states.uw_errors > 1
+        states.sync_counter++;
+        states.frame_count = 0;
+      end
+      if states.sync_counter == 2
+        next_state = "search";
+        states.sync_state_interleaver = "search";
+      end
+      if states.frame_count == 4
+        next_state = "synced";
+      end
     end
 
-    % freq offset est may be too far out, and has aliases every 1/Ts, so
-    % we use a Unique Word to get a really solid indication of sync.
+    if strcmp(states.sync_state,'synced')
+      if states.uw_errors > 2
+        states.sync_counter++;
+      else
+        states.sync_counter = 0;
+      end
 
-    states.uw_errors = sum(xor(tx_uw,rx_uw));
-    if (states.uw_errors > uw_thresh)
-      states.sync_counter++;
-      if states.sync_counter == sync_counter_thresh
-        next_state = 'search';
-        states.sync_state_interleaver = 'search';
+      if states.sync_counter == 6
+        next_state = "search";
+        states.sync_state_interleaver = "search";
       end
-    else
-      states.sync_counter = 0;
     end
-  end
+  end    
 
   states.last_sync_state = states.sync_state;
   states.last_sync_state_interleaver = states.sync_state_interleaver;
index 528175c8ffce31fe0ef8c7ac33a2d17fb2d52359..c13ea1dbad29a94325dadef91ac81213db7c2428 100644 (file)
@@ -1001,7 +1001,7 @@ void ofdm_demod(struct OFDM *ofdm, int *rx_bits, COMP *rxbuf_in) {
 
 void ofdm_sync_state_machine(struct OFDM *ofdm, int *rx_uw) {
     char next_state[OFDM_STATE_STR];
-    int  i, j, sync_counter_thresh, uw_thresh;
+    int  i, j;
     
     strcpy(next_state, ofdm->sync_state);    
     ofdm->sync_start = ofdm->sync_end = 0;