optimised downconversion and filter, Octave and C working and also tweak to make...
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 3 Aug 2014 05:23:09 +0000 (05:23 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 3 Aug 2014 05:23:09 +0000 (05:23 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1781 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/fdmdv.m
codec2-dev/octave/fdmdv_ut.m
codec2-dev/octave/tfdmdv.m
codec2-dev/src/fdmdv.c
codec2-dev/unittest/tfdmdv.c

index 486cf73357372eb08fe1f583358a409ef6454528..bbe01cf7962ae024508e4b0a4aaf3fd44eec6118 100644 (file)
@@ -389,8 +389,10 @@ function rx_filt = down_convert_and_rx_filter(rx_fdm, nin, dec_rate)
      st -= nin-1;          % first new sample
      st -= Nfilter;        % first sample used in filtering
      
-     for i=st:Nfilter+M
-        phase_rx(c) = phase_rx(c) * freq(c);
+     f_rect = freq(c) .^ dec_rate;
+
+     for i=st:dec_rate:Nfilter+M
+        phase_rx(c) = phase_rx(c) * f_rect;
        rx_baseband(i) = rx_fdm_mem(i)*phase_rx(c)';
      end
  
index d46a42911b9b534d340a8f2715bedcff0b6a4220..4bd8c0182a17c1a9e018712feafcf837849ba23f 100644 (file)
@@ -12,8 +12,8 @@ fdmdv;               % load modem code
  
 % Simulation Parameters --------------------------------------
 
-frames = 20;
-EbNo_dB = 63;
+frames = 200;
+EbNo_dB = 6.3;
 Foff_hz = -100;
 modulation = 'dqpsk';
 hpa_clip = 150;
index 0b9bc8464aedba28d5e5ccdd0870696419e727da..1bdac80490a9c051b3790eb3f5a4276e43249b4b 100644 (file)
@@ -18,7 +18,7 @@ fdmdv; % load modem code
 global passes;
 global fails;
 passes = fails = 0;
-frames = 25;
+frames = 35;
 prev_tx_symbols = ones(Nc+1,1);
 prev_rx_symbols = ones(Nc+1,1);
 foff_phase_rect = 1;
@@ -64,7 +64,7 @@ noise_est_log = [];
 % adjust this if the screen is getting a bit cluttered
 
 global no_plot_list;
-no_plot_list = [];
+no_plot_list = [1 2 3 4 5 6 7 8 11 12 13 14 15 16];
 
 for f=1:frames
 
@@ -146,19 +146,20 @@ for f=1:frames
   end
   nin_log = [nin_log nin];
 
-  [rx_bits sync_bit f_err pd] = psk_to_bits(prev_rx_symbols, rx_symbols, 'dqpsk');
+  [rx_bits sync_bit foff_fine pd] = psk_to_bits(prev_rx_symbols, rx_symbols, 'dqpsk');
   phase_difference_log = [phase_difference_log pd];
 
+  foff_fine_log = [foff_fine_log foff_fine];
+  foff -= 0.5*foff_fine;
+  foff_log = [foff_log foff];
+
   [sig_est noise_est] = snr_update(sig_est, noise_est, pd);
   sig_est_log = [sig_est_log sig_est];
   noise_est_log = [noise_est_log noise_est];
 
   prev_rx_symbols = rx_symbols;
   rx_bits_log = [rx_bits_log rx_bits]; 
-  foff_fine_log = [foff_fine_log foff_fine];
   sync_bit_log = [sync_bit_log sync_bit];  
-  foff -= 0.5*f_err;
-  foff_log = [foff_log foff];
 
   % freq est state machine
 
index 8b7448ca3d4a600eb804182d68614cbade9b218c..f43257120fd3d22c03ca520afcab219526566b82 100644 (file)
@@ -818,7 +818,7 @@ void fdmdv_freq_shift(COMP rx_fdm_fcorr[], COMP rx_fdm[], float foff,
 
 /*---------------------------------------------------------------------------*\
                                                        
-  FUNCTION....: fdm_downconvert()           
+  FUNCTION....: fdm_downconvert     
   AUTHOR......: David Rowe                           
   DATE CREATED: 22/4/2012
 
@@ -999,7 +999,9 @@ void down_convert_and_rx_filter(COMP rx_filt[NC+1][P+1], int Nc, COMP rx_fdm[],
     float windback_phase, mag;
     COMP  windback_phase_rect;
     COMP  rx_baseband[NFILTER+M];
-    TIMER_VAR(windback_start,  downconvert_start, filter_start);
+    COMP  f_rect;
+
+    //TIMER_VAR(windback_start,  downconvert_start, filter_start);
 
     /* update memory of rx_fdm */
 
@@ -1023,12 +1025,12 @@ void down_convert_and_rx_filter(COMP rx_filt[NC+1][P+1], int Nc, COMP rx_fdm[],
           phase continuity.
         */
 
-        TIMER_SAMPLE(windback_start);
+        //TIMER_SAMPLE(windback_start);
         windback_phase           = -freq_pol[c]*NFILTER;
         windback_phase_rect.real = cosf(windback_phase);
         windback_phase_rect.imag = sinf(windback_phase);
         phase_rx[c]              = cmult(phase_rx[c],windback_phase_rect);
-        TIMER_SAMPLE_AND_LOG(downconvert_start, windback_start, "        windback"); 
+        //TIMER_SAMPLE_AND_LOG(downconvert_start, windback_start, "        windback"); 
     
         /* down convert all samples in buffer */
 
@@ -1036,11 +1038,17 @@ void down_convert_and_rx_filter(COMP rx_filt[NC+1][P+1], int Nc, COMP rx_fdm[],
         st -= nin-1;          /* first new sample               */
         st -= NFILTER;        /* first sample used in filtering */
         
-        for(i=st; i<NFILTER+M; i++) {
-            phase_rx[c]    = cmult(phase_rx[c], freq[c]);
+        /* freq shift per dec_rate step is dec_rate times original shift */
+
+        f_rect = freq[c];
+        for(i=0; i<dec_rate-1; i++)
+            f_rect = cmult(f_rect,freq[c]);
+
+        for(i=st; i<NFILTER+M; i+=dec_rate) {
+            phase_rx[c]    = cmult(phase_rx[c], f_rect);
             rx_baseband[i] = cmult(rx_fdm_mem[i],cconj(phase_rx[c]));
         }
-        TIMER_SAMPLE_AND_LOG(filter_start, downconvert_start, "        downconvert"); 
+        //TIMER_SAMPLE_AND_LOG(filter_start, downconvert_start, "        downconvert"); 
  
         /* now we can filter this carrier's P symbols */
 
@@ -1056,7 +1064,7 @@ void down_convert_and_rx_filter(COMP rx_filt[NC+1][P+1], int Nc, COMP rx_fdm[],
            rx_filt[c][k].imag = fir_filter(&rx_baseband[st+i].imag, (float*)gt_alpha5_root, dec_rate);
            #endif
         }
-        TIMER_SAMPLE_AND_LOG2(filter_start, "        filter"); 
+        //TIMER_SAMPLE_AND_LOG2(filter_start, "        filter"); 
 
         /* normalise digital oscilators as the magnitude can drift over time */
 
@@ -1465,6 +1473,7 @@ void fdmdv_demod(struct FDMDV *fdmdv, int rx_bits[],
     float         foff_coarse, foff_fine;
     COMP          rx_fdm_fcorr[M+M/P];
     COMP          rx_fdm_filter[M+M/P];
+    COMP          rx_fdm_bb[M+M/P];
     COMP          rx_filt[NC+1][P+1];
     COMP          rx_symbols[NC+1];
     float         env[NT*P];
@@ -1474,17 +1483,17 @@ void fdmdv_demod(struct FDMDV *fdmdv, int rx_bits[],
 
     /* shift down to complex baseband */
 
-    fdmdv_freq_shift(rx_fdm, rx_fdm, -FDMDV_FCENTRE, &fdmdv->fbb_phase_rx, *nin);
+    fdmdv_freq_shift(rx_fdm_bb, rx_fdm, -FDMDV_FCENTRE, &fdmdv->fbb_phase_rx, *nin);
 
     /* freq offset estimation and correction */
    
     TIMER_SAMPLE(demod_start);
-    foff_coarse = rx_est_freq_offset(fdmdv, rx_fdm, *nin);
+    foff_coarse = rx_est_freq_offset(fdmdv, rx_fdm_bb, *nin);
     TIMER_SAMPLE_AND_LOG(fdmdv_freq_shift_start, demod_start, "    rx_est_freq_offset"); 
     
     if (fdmdv->sync == 0)
        fdmdv->foff = foff_coarse;
-    fdmdv_freq_shift(rx_fdm_fcorr, rx_fdm, -fdmdv->foff, &fdmdv->foff_phase_rect, *nin);
+    fdmdv_freq_shift(rx_fdm_fcorr, rx_fdm_bb, -fdmdv->foff, &fdmdv->foff_phase_rect, *nin);
     TIMER_SAMPLE_AND_LOG(down_convert_and_rx_filter_start, fdmdv_freq_shift_start, "    fdmdv_freq_shift"); 
        
     /* baseband processing */
index 438fb9579e3a7a134ebc9ee45c3aeb91ca47a1e0..746bc94035be3da6548a9aa767a803609b834561 100644 (file)
@@ -38,7 +38,7 @@
 #include "codec2_fdmdv.h"
 #include "octave.h"
 
-#define FRAMES 25
+#define FRAMES 35
 #define CHANNEL_BUF_SIZE (10*M)
 
 extern float pilot_coeff[];