cohspk modem support for different symbol and sample rates, preparing to match codec...
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 21 May 2015 03:09:27 +0000 (03:09 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 21 May 2015 03:09:27 +0000 (03:09 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2143 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/fdmdv.m
codec2-dev/octave/tcohpsk.m
codec2-dev/octave/test_foff.m

index b1d68376af2870476d3b3aa6392ec4b84afaa090..b872697b6733a234030ada5333776785c8820b91 100644 (file)
@@ -15,6 +15,7 @@ randn('state',1);
 
 % Constants
 
+if 0
 global Fs = 8000;      % sample rate in Hz
 global T  = 1/Fs;      % sample period in seconds
 global Rs;
@@ -58,6 +59,7 @@ global Nrxdec;
        Nrxdec=31;
 global rxdec_coeff;
        rxdec_coeff = fir1(Nrxdec-1, 0.25);
+end
 if 0
   % tmp code to plot freq resp.  20dB attn of any aliases should be fine
   % not real sensitive to in-band attn, e.g. outer tones a dB down should be OK
@@ -1134,7 +1136,7 @@ function dump_bits(rx_bits)
 
 endfunction
 
-
+if 0
 % Initialise ----------------------------------------------------
 
 global pilot_bit;
@@ -1254,3 +1256,4 @@ global prev_phase_offsets;
 prev_phase_offsets = zeros(Nc+1, 1);
 global phase_amb;
 phase_amb = zeros(Nc+1, 1);
+end
index 4e38d9bce768fd8f68d7e8769c5f6bd6721cb87f..ffeebef37ccac9dc9efffdae762e52a5768463c7 100644 (file)
@@ -43,12 +43,18 @@ autotest;
 rand('state',1); 
 randn('state',1);
 
-% test parameters ----------------------------------------------------------
-
+% select which test  ----------------------------------------------------------
 
 %test = 'compare to c';
-%test = 'awgn';
-test = 'fading';
+test = 'awgn';
+%test = 'fading';
+
+% some parameters that can be over ridden, e.g. to disable parts of modem
+
+initial_sync = 0;  % setting this to 1 put us straight into sync w/o freq offset est
+ftrack_en    = 1;  % set to 0 to disable freq tracking
+
+% predefined tests ....
 
 if strcmp(test, 'compare to c')
   frames = 35;
@@ -63,10 +69,10 @@ end
 % should be BER around 0.015 to 0.02
 
 if strcmp(test, 'awgn')
-  frames = 100;
+  frames = 10;
   foff =  0;
   dfoff = 0;
-  EsNodB = 8;
+  EsNodB = 80;
   fading_en = 0;
   hf_delay_ms = 2;
   compare_with_c = 0;
@@ -88,27 +94,30 @@ EsNo = 10^(EsNodB/10);
 
 % modem constants ----------------------------------------------------------
 
-Rs = 50;
-Nc = 4;
-Nd = 2;
-framesize = 32;
+Rs = 75;               % symbol rate in Hz
+Nc = 4;                % number of carriers
+Nd = 2;                % diveristy factor
+framesize = 32;        % number of payoad data bits in the frame
 
-Nsw = 3;
-afdmdv.Nsym = 6;
-afdmdv.Nt = 5;
+Nsw = 3;               % frames we demod for initial sync window
+afdmdv.Nsym = 6;       % size of tx/tx root nyquist filter in symbols
+afdmdv.Nt = 5;         % number of symbols we estimate timing over
 
 % FDMDV init ---------------------------------------------------------------
 
-afdmdv.Fs = 8000;
+Fs = afdmdv.Fs = 7500;
 afdmdv.Nc = Nd*Nc-1;
 afdmdv.Rs = Rs;
-afdmdv.M  = afdmdv.Fs/afdmdv.Rs;
-afdmdv.tx_filter_memory = zeros(afdmdv.Nc+1, Nfilter);
-afdmdv.Nfilter =  Nfilter;
-afdmdv.gt_alpha5_root = gen_rn_coeffs(0.5, 1/Fs, Rs, afdmdv.Nsym, afdmdv.M);
-afdmdv.Fsep = 75;
+M = afdmdv.M  = afdmdv.Fs/afdmdv.Rs;
+afdmdv.Nfilter = afdmdv.Nsym*M;
+afdmdv.tx_filter_memory = zeros(afdmdv.Nc+1, afdmdv.Nfilter);
+excess_bw = 0.5;
+afdmdv.gt_alpha5_root = gen_rn_coeffs(excess_bw, 1/Fs, Rs, afdmdv.Nsym, afdmdv.M);
+
+Fcentre = afdmdv.Fcentre = 1500;
+afdmdv.Fsep = afdmdv.Rs*(1+excess_bw);
 afdmdv.phase_tx = ones(afdmdv.Nc+1,1);
-freq_hz = afdmdv.Fsep*( -Nc*Nd/2 - 0.5 + (1:Nc*Nd).^0.98 )
+freq_hz = afdmdv.Fsep*( -Nc*Nd/2 - 0.5 + (1:Nc*Nd).^0.98 );
 afdmdv.freq_pol = 2*pi*freq_hz/Fs;
 afdmdv.freq = exp(j*afdmdv.freq_pol);
 afdmdv.Fcentre = 1500;
@@ -119,7 +128,7 @@ afdmdv.fbb_phase_rx = 1;
 
 afdmdv.Nrxdec = 31;
 afdmdv.rxdec_coeff = fir1(afdmdv.Nrxdec-1, 0.25)';
-afdmdv.rxdec_lpf_mem = zeros(1,afdmdv.Nrxdec-1+M);
+afdmdv.rxdec_lpf_mem = zeros(1,afdmdv.Nrxdec-1+afdmdv.M);
 
 P = afdmdv.P = 4;
 afdmdv.phase_rx = ones(afdmdv.Nc+1,1);
@@ -152,7 +161,7 @@ acohpsk = symbol_rate_init(acohpsk);
 acohpsk.Ndft = 1024;
 acohpsk.f_est = afdmdv.Fcentre;
 
-ch_fdm_frame_buf = zeros(1, Nsw*acohpsk.Nsymbrowpilot*M);
+ch_fdm_frame_buf = zeros(1, Nsw*acohpsk.Nsymbrowpilot*afdmdv.M);
 
 % -----------------------------------------------------------
 
@@ -190,7 +199,11 @@ Nerrs = Tbits = 0;
 prev_tx_bits = [];
 
 phase_ch = 1;
-sync = 0;
+sync = initial_sync;
+acohpsk.f_est = Fcentre;
+acohpsk.f_fine_est = 0;
+acohpsk.ct = 4;
+acohpsk.ftrack_en = ftrack_en;
 
 [spread spread_2ms hf_gain] = init_hf_model(Fs, Fs, frames*acohpsk.Nsymbrowpilot*afdmdv.M);
 hf_n = 1;
@@ -353,7 +366,7 @@ for f=1:frames
   % If in sync just do sample rate processing on latest frame
 
   if sync == 1
-    [ch_symb rx_timing rx_filt rx_baseband afdmdv acohpsk.f_est] = rate_Fs_rx_processing(afdmdv, ch_fdm_frame, acohpsk.f_est, acohpsk.Nsymbrowpilot, nin, 1);
+    [ch_symb rx_timing rx_filt rx_baseband afdmdv acohpsk.f_est] = rate_Fs_rx_processing(afdmdv, ch_fdm_frame, acohpsk.f_est, acohpsk.Nsymbrowpilot, nin, acohpsk.ftrack_en);
     [next_sync acohpsk] = frame_sync_fine_freq_est(acohpsk, ch_symb, sync, next_sync);
 
     acohpsk.ct_symb_ff_buf(1:2,:) = acohpsk.ct_symb_ff_buf(acohpsk.Nsymbrowpilot+1:acohpsk.Nsymbrowpilot+2,:);
index 4ead6d9d4ca0dfaca82303759c634f6aa42b0e7e..ee5df9ddda915ff0acd78f5e5d900995c4487a9b 100644 (file)
@@ -20,7 +20,7 @@ function sim_out = freq_off_est_test(sim_in)
   global Nfilter;\r
   global M;\r
 \r
-  Rs = 50;\r
+  Rs = 100;\r
   Nc = 4;\r
   Nd = 2;\r
   framesize = 32;\r
@@ -36,11 +36,12 @@ function sim_out = freq_off_est_test(sim_in)
   afdmdv.Fs = 8000;\r
   afdmdv.Nc = Nd*Nc-1;\r
   afdmdv.Rs = Rs;\r
-  afdmdv.M  = afdmdv.Fs/afdmdv.Rs;\r
-  afdmdv.tx_filter_memory = zeros(afdmdv.Nc+1, Nfilter);\r
-  afdmdv.Nfilter =  Nfilter;\r
-  afdmdv.gt_alpha5_root = gen_rn_coeffs(0.5, 1/Fs, Rs, afdmdv.Nsym, afdmdv.M);\r
-  afdmdv.Fsep = 75;\r
+  M = afdmdv.M  = afdmdv.Fs/afdmdv.Rs;\r
+  afdmdv.Nfilter = afdmdv.Nsym*M;\r
+  afdmdv.tx_filter_memory = zeros(afdmdv.Nc+1, afdmdv.Nfilter);\r
+  excess_bw = 0.5;\r
+  afdmdv.gt_alpha5_root = gen_rn_coeffs(excess_bw, 1/Fs, Rs, afdmdv.Nsym, afdmdv.M);\r
+  afdmdv.Fsep = afdmdv.Rs*(1+excess_bw);\r
   afdmdv.phase_tx = ones(afdmdv.Nc+1,1);\r
   freq_hz = afdmdv.Fsep*( -Nc*Nd/2 - 0.5 + (1:Nc*Nd).^1.1 );\r
   afdmdv.freq_pol = 2*pi*freq_hz/Fs;\r
@@ -252,11 +253,11 @@ endfunction
 \r
 \r
 function freq_off_est_test_single\r
-  sim_in.frames    = 35;\r
-  sim_in.EsNodB    = 12;\r
-  sim_in.foff      = -55.5;\r
+  sim_in.frames    = 5;\r
+  sim_in.EsNodB    = 120;\r
+  sim_in.foff      = 0;\r
   sim_in.dfoff     = 0;\r
-  sim_in.fading_en = 1;\r
+  sim_in.fading_en = 0;\r
 \r
   sim_out = freq_off_est_test(sim_in);\r
 \r
@@ -394,11 +395,8 @@ function [freq_off_log EsNodBSet] = freq_off_est_test_curves
 endfunction\r
 \r
 \r
-%freq_off_est_test_single;\r
-freq_off_est_test_curves;\r
+% select on of these to run:\r
+\r
+freq_off_est_test_single;\r
+%freq_off_est_test_curves;\r
 \r
-% 1. start with +/- 20Hz offset\r
-% 2. Measure frames to sync.  How to define sync?  Foff to withn 1 Hz. Sync state\r
-%    Need to see if we get false sync\r
-% 3. Try shortened filter\r
-% 4. Extend to parallel demods at +/- \r