From: drowe67 Date: Tue, 24 Apr 2012 00:04:10 +0000 (+0000) Subject: rx_est_timing working in C X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=48e5b73d84d3d9b20b0b484fd27289e1edd21b9d;p=freetel-svn-tracking.git rx_est_timing working in C git-svn-id: https://svn.code.sf.net/p/freetel/code@378 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/octave/README_fdmdv.txt b/codec2-dev/octave/README_fdmdv.txt index 541e4a81..d0a011dc 100644 --- a/codec2-dev/octave/README_fdmdv.txt +++ b/codec2-dev/octave/README_fdmdv.txt @@ -21,6 +21,7 @@ TODO [ ] block diagram [ ] blog posts(s) [ ] Codec 2 web page update +[ ] demo modem C test program Tests diff --git a/codec2-dev/octave/fdmdv.m b/codec2-dev/octave/fdmdv.m index afa503e6..6ce43b71 100644 --- a/codec2-dev/octave/fdmdv.m +++ b/codec2-dev/octave/fdmdv.m @@ -318,7 +318,7 @@ endfunction % Estimate optimum timing offset, re-filter receive symbols -function [rx_symbols rx_timing] = rx_est_timing(rx_filt, rx_baseband, nin) +function [rx_symbols rx_timing env] = rx_est_timing(rx_filt, rx_baseband, nin) global M; global Nt; global Nc; @@ -365,7 +365,7 @@ function [rx_symbols rx_timing] = rx_est_timing(rx_filt, rx_baseband, nin) rx_timing += M; end - % rx_filt_mem_timing contains M + Nfilter + M samples of the + % rx_baseband_mem_timing contains M + Nfilter + M samples of the % baseband signal at rate M this enables us to resample the filtered % rx symbol with M sample precision once we have rx_timing diff --git a/codec2-dev/octave/tfdmdv.m b/codec2-dev/octave/tfdmdv.m index 1ba7a794..776bcc4a 100644 --- a/codec2-dev/octave/tfdmdv.m +++ b/codec2-dev/octave/tfdmdv.m @@ -34,6 +34,9 @@ S2_log = []; foff_log = []; rx_baseband_log = []; rx_filt_log = []; +env_log = []; +rx_timing_log = []; +rx_symbols_log = []; for f=1:frames @@ -69,7 +72,10 @@ for f=1:frames rx_baseband_log = [rx_baseband_log rx_baseband]; rx_filt = rx_filter(rx_baseband, M); rx_filt_log = [rx_filt_log rx_filt]; - + [rx_symbols rx_timing env] = rx_est_timing(rx_filt, rx_baseband, M); + env_log = [env_log env]; + rx_timing_log = [rx_timing_log rx_timing]; + rx_symbols_log = [rx_symbols_log rx_symbols]; end % Compare to the output from the C version @@ -112,7 +118,7 @@ endfunction n = 28; stem_sig_and_error(1, 211, tx_bits_log_c(1:n), tx_bits_log(1:n) - tx_bits_log_c(1:n), 'tx bits', [1 n -1.5 1.5]) -stem_sig_and_error(1, 212, real(tx_symbols_log_c(1:n/2)), tx_symbols_log(1:n/2) - tx_symbols_log_c(1:n/2), 'tx symbols real', [1 n/2 -1.5 1.5]) +stem_sig_and_error(1, 212, real(tx_symbols_log_c(1:n/2)), real(tx_symbols_log(1:n/2) - tx_symbols_log_c(1:n/2)), 'tx symbols real', [1 n/2 -1.5 1.5]) % tx_filter() @@ -146,6 +152,7 @@ plot_sig_and_error(8, 211, real(S2_log), real(S2_log - S2_log_c), 'S2 real' ) plot_sig_and_error(8, 212, imag(S2_log), imag(S2_log - S2_log_c), 'S2 imag' ) plot_sig_and_error(9, 211, real(foff_log), real(foff_log - foff_log_c), 'Freq Offset' ) +plot_sig_and_error(9, 212, rx_timing_log, rx_timing_log - rx_timing_log_c, 'Rx Timing' ) c=10; plot_sig_and_error(10, 211, real(rx_baseband_log(c,:)), real(rx_baseband_log(c,:) - rx_baseband_log_c(c,:)), 'Rx baseband real' ) @@ -154,6 +161,9 @@ plot_sig_and_error(10, 212, imag(rx_baseband_log(c,:)), imag(rx_baseband_log(c,: plot_sig_and_error(11, 211, real(rx_filt_log(c,:)), real(rx_filt_log(c,:) - rx_filt_log_c(c,:)), 'Rx filt real' ) plot_sig_and_error(11, 212, imag(rx_filt_log(c,:)), imag(rx_filt_log(c,:) - rx_filt_log_c(c,:)), 'Rx filt imag' ) +plot_sig_and_error(12, 211, env_log, env_log - env_log_c, 'env' ) +plot_sig_and_error(12, 212, real(rx_symbols_log(c,:)), real(rx_symbols_log(c,:) - rx_symbols_log_c(c,:)), 'rx symbols' ) + % --------------------------------------------------------------------------------------- % AUTOMATED CHECKS ------------------------------------------ % --------------------------------------------------------------------------------------- @@ -190,5 +200,8 @@ check(S2_log, S2_log_c, 'S2'); check(foff_log, foff_log_c, 'rx_est_freq_offset'); check(rx_baseband_log, rx_baseband_log_c, 'fdm_downconvert'); check(rx_filt_log, rx_filt_log_c, 'fdm_downconvert'); +check(env_log, env_log_c, 'env'); +check(rx_timing_log, rx_timing_log_c, 'rx_est_timing'); +check(rx_symbols_log, rx_symbols_log_c, 'rx_symbols'); printf("\npasses: %d fails: %d\n", passes, fails); diff --git a/codec2-dev/src/fdmdv.c b/codec2-dev/src/fdmdv.c index 3f691d8f..4525a114 100644 --- a/codec2-dev/src/fdmdv.c +++ b/codec2-dev/src/fdmdv.c @@ -818,11 +818,11 @@ float rx_est_timing(COMP rx_symbols[], for(c=0; cphase_rx, fdmdv->freq, nin); rx_filter(rx_filt, rx_baseband, fdmdv->rx_filter_memory, nin); + rx_timing = rx_est_timing(rx_symbols, rx_filt, rx_baseband, fdmdv->rx_filter_mem_timing, env, fdmdv->rx_baseband_mem_timing, nin); /* save log of outputs ------------------------------------------------------*/ @@ -135,7 +142,7 @@ int main(int argc, char *argv[]) memcpy(&pilot_lpf2_log[f*NPILOTLPF], fdmdv->pilot_lpf2, sizeof(COMP)*NPILOTLPF); memcpy(&S1_log[f*MPILOTFFT], fdmdv->S1, sizeof(COMP)*MPILOTFFT); memcpy(&S2_log[f*MPILOTFFT], fdmdv->S2, sizeof(COMP)*MPILOTFFT); - memcpy(&foff_log[f], &foff, sizeof(float)); + foff_log[f] = foff; /* rx down conversion */ @@ -153,6 +160,12 @@ int main(int argc, char *argv[]) } rx_filt_log_col_index += (P*M)/nin; + /* timing estimation */ + + memcpy(&env_log[NT*P*f], env, sizeof(float)*NT*P); + rx_timing_log[f] = rx_timing; + for(c=0; c