restoring Octave files lost when SourceForge mysteriously backed up two days #4
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 11 Apr 2018 22:58:28 +0000 (22:58 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 11 Apr 2018 22:58:28 +0000 (22:58 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3463 01035d8c-6547-0410-b346-abe4f91aad63

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

index 0518a96413fd2ba0239219bd6e84e310760bb25e..a853946acaafd4e0089a4a687becaeb03b48f6da 100644 (file)
@@ -143,7 +143,7 @@ function states = ofdm_init(bps, Rs, Tcp, Ns, Nc)
 
   rand('seed',1);
   states.pilots = 1 - 2*(rand(1,Nc+2) > 0.5);
-
+  
   % carrier tables for up and down conversion
 
   fcentre = 1500;
@@ -192,7 +192,16 @@ function states = ofdm_init(bps, Rs, Tcp, Ns, Nc)
   Npsam = length(states.rate_fs_pilot_samples);
   states.timing_norm = Npsam*(states.rate_fs_pilot_samples * states.rate_fs_pilot_samples');
   % printf("timing_norm: %f\n", states.timing_norm)
+
+  % sync state machine
   
+  states.sync_state = states.last_sync_state = 'searching';
+  states.uw_errors = 0;
+  states.sync_counter = 0;
+  states.sync_frame_count = 0;
+  states.sync_start = 0;
+  states.sync_end = 0;
+
   % LDPC code is optionally enabled
 
   states.rate = 1.0;
@@ -509,13 +518,15 @@ endfunction
 
 function test_bits_ofdm_file
 
-  Ts = 0.018; Tcp = 0.002; Rs = 1/Ts; bps = 2; Nc = 16; Ns = 8;
+  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;
 
   rand('seed',1);
   test_bits_ofdm = round(rand(1,Nbitsperframe));
-
+  test_bits_ofdm(1:states.uw_len) = 0;  % insert Unique Word
+  printf("%d test bits\n", Nbitsperframe);
+  
   f=fopen("../src/test_bits_ofdm.h","wt");
   fprintf(f,"/* Generated by test_bits_ofdm_file() Octave function */\n\n");
   fprintf(f,"const int test_bits_ofdm[]={\n");
index 868251cec23320e5f1ba86f1be677f86993a8c5a..b8ee9dd171e31c188eb3c991b1d885973b58a467 100644 (file)
@@ -44,13 +44,6 @@ function ofdm_rx(filename, error_pattern_filename)
   nin = Nsamperframe+2*(M+Ncp);
   %states.rxbuf(Nrxbuf-nin+1:Nrxbuf) = rx(prx:nin);
   %prx += nin;
-
-  states.sync_state = states.last_sync_state = 'searching';
-  states.uw_errors = 0;
-  states.sync_counter = 0;
-  states.sync_frame_count = 0;
-  states.sync_start = 0;
-  states.sync_end = 0;
   
   states.verbose = 1;
 
@@ -123,7 +116,7 @@ function ofdm_rx(filename, error_pattern_filename)
 
   Ndiscard = 20;
   if frame_count > Ndiscard
-    Terrs -= sum(Nerrs_log(1:Ndiscard)); Tbits -= Ndiscard;
+    Terrs -= sum(Nerrs_log(1:Ndiscard)); Tbits -= Ndiscard*Nbitsperframe;
     printf("BER2.: %5.4f Tbits: %5d Terrs: %5d\n", Terrs/Tbits, Tbits, Terrs);
   end