From 54971eec9c25deacdf61829f610cb4118f0c75f3 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Thu, 21 May 2015 03:09:27 +0000 Subject: [PATCH] cohspk modem support for different symbol and sample rates, preparing to match codec data and frame rate req git-svn-id: https://svn.code.sf.net/p/freetel/code@2143 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/octave/fdmdv.m | 5 ++- codec2-dev/octave/tcohpsk.m | 61 +++++++++++++++++++++-------------- codec2-dev/octave/test_foff.m | 32 +++++++++--------- 3 files changed, 56 insertions(+), 42 deletions(-) diff --git a/codec2-dev/octave/fdmdv.m b/codec2-dev/octave/fdmdv.m index b1d68376..b872697b 100644 --- a/codec2-dev/octave/fdmdv.m +++ b/codec2-dev/octave/fdmdv.m @@ -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 diff --git a/codec2-dev/octave/tcohpsk.m b/codec2-dev/octave/tcohpsk.m index 4e38d9bc..ffeebef3 100644 --- a/codec2-dev/octave/tcohpsk.m +++ b/codec2-dev/octave/tcohpsk.m @@ -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,:); diff --git a/codec2-dev/octave/test_foff.m b/codec2-dev/octave/test_foff.m index 4ead6d9d..ee5df9dd 100644 --- a/codec2-dev/octave/test_foff.m +++ b/codec2-dev/octave/test_foff.m @@ -20,7 +20,7 @@ function sim_out = freq_off_est_test(sim_in) global Nfilter; global M; - Rs = 50; + Rs = 100; Nc = 4; Nd = 2; framesize = 32; @@ -36,11 +36,12 @@ function sim_out = freq_off_est_test(sim_in) afdmdv.Fs = 8000; 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); + 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).^1.1 ); afdmdv.freq_pol = 2*pi*freq_hz/Fs; @@ -252,11 +253,11 @@ endfunction function freq_off_est_test_single - sim_in.frames = 35; - sim_in.EsNodB = 12; - sim_in.foff = -55.5; + sim_in.frames = 5; + sim_in.EsNodB = 120; + sim_in.foff = 0; sim_in.dfoff = 0; - sim_in.fading_en = 1; + sim_in.fading_en = 0; sim_out = freq_off_est_test(sim_in); @@ -394,11 +395,8 @@ function [freq_off_log EsNodBSet] = freq_off_est_test_curves endfunction -%freq_off_est_test_single; -freq_off_est_test_curves; +% select on of these to run: + +freq_off_est_test_single; +%freq_off_est_test_curves; -% 1. start with +/- 20Hz offset -% 2. Measure frames to sync. How to define sync? Foff to withn 1 Hz. Sync state -% Need to see if we get false sync -% 3. Try shortened filter -% 4. Extend to parallel demods at +/- -- 2.25.1