a little more work on the sync algorithm
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 26 Feb 2013 02:35:01 +0000 (02:35 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 26 Feb 2013 02:35:01 +0000 (02:35 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1171 01035d8c-6547-0410-b346-abe4f91aad63

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

index 701fdcc0613aa119b459cfbfdbe27f8104481c71..7102d6fc9714982d928b1a4a781f77fc683164e4 100644 (file)
@@ -758,7 +758,7 @@ endfunction
 % then switch to a more robust tracking algorithm.  If we lose sync we switch
 % back to acquire mode for fast-requisition.
 
-function [track state] = freq_state(sync_bit, state)
+function [track state bad_sync] = freq_state(sync_bit, state, bad_sync)
 
   % acquire state, look for 6 symbol 010101 sequence from sync bit
 
@@ -799,6 +799,7 @@ function [track state] = freq_state(sync_bit, state)
   if state == 5
     if sync_bit == 1
       next_state = 6;
+      bad_sync = 0;
     else 
       next_state = 0;
     end        
@@ -807,20 +808,33 @@ function [track state] = freq_state(sync_bit, state)
   % states 6 and above are track mode, make sure we keep getting 0101 sync bit sequence
 
   if state == 6
+    next_state = 7;
     if sync_bit == 0
-      next_state = 7;
-    else 
-      next_state = 0;
+      bad_sync = 0;
+    else
+      printf("inc ");
+      bad_sync++;
+      if bad_sync > 2
+        next_state = 0;
+      end
     end        
   end
+
   if state == 7
+    next_state = 6;
     if sync_bit == 1
-      next_state = 6;
-    else 
-      next_state = 0;
+      bad_sync = 0;
+    else
+      printf("inc ");
+      bad_sync++;
+      if bad_sync > 2
+        next_state = 0;
+      end
     end        
   end
 
+  %printf("state: %d  next_state: %d  sync_bit: %d bad_sync: %d\n", state, next_state, sync_bit, bad_sync);
+
   state = next_state;
   if state >= 6
     track = 1;
index b08d7ffa495b9acabcfcaca51ccae5932ec20103..94c16900f461049bc8cfc74dfd616b7e75ec7647 100644 (file)
@@ -51,6 +51,7 @@ function fdmdv_demod(rawfilename, nbits, errorpatternfilename)
   track_log = [];
   track = 0;
   fest_state = 0;
+  bad_sync = 0;
 
   % spectrum states
 
@@ -125,7 +126,7 @@ function fdmdv_demod(rawfilename, nbits, errorpatternfilename)
 
     % freq est state machine
 
-    [track fest_state] = freq_state(sync, fest_state);
+    [track fest_state bad_sync] = freq_state(sync, fest_state, bad_sync);
     track_log = [track_log track];
 
     % count bit errors if we find a test frame
index c89aa78c3ab2ded3573a5460408b25029413c87a..871cfcc8f470b8e79ad1a98d8ed03fba9c14a537 100644 (file)
@@ -12,8 +12,8 @@ fdmdv;               % load modem code
  
 % Simulation Parameters --------------------------------------
 
-frames = 50*10;
-EbNo_dB = 10.3;
+frames = 100;
+EbNo_dB = 7.3;
 Foff_hz = 0;
 modulation = 'dqpsk';
 hpa_clip = 150;
@@ -93,6 +93,7 @@ foff_phase = 1;
 t = 0;
 foff = 0;
 fest_state = 0;
+bad_sync = 0;
 track = 0;
 track_log = [];
 
@@ -212,7 +213,7 @@ for f=1:frames
   
   % freq est state machine
 
-  [track fest_state] = freq_state(sync, fest_state);
+  [track fest_state bad_sync] = freq_state(sync, fest_state, bad_sync);
   track_log = [track_log track];
 
   % Update SNR est