From 755ac4990cd9edcd4e631f497fcad0b437b35c96 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Mon, 30 Apr 2018 22:10:58 +0000 Subject: [PATCH] reconcilled C and Octave sync state machines - still some tunign rqd here git-svn-id: https://svn.code.sf.net/p/freetel/code@3540 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/octave/ofdm_ldpc_rx.m | 2 +- codec2-dev/octave/ofdm_lib.m | 47 ++++++++++++++++---------------- codec2-dev/src/ofdm.c | 2 +- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/codec2-dev/octave/ofdm_ldpc_rx.m b/codec2-dev/octave/ofdm_ldpc_rx.m index b1daed49..bf2a8589 100644 --- a/codec2-dev/octave/ofdm_ldpc_rx.m +++ b/codec2-dev/octave/ofdm_ldpc_rx.m @@ -22,7 +22,7 @@ function ofdm_ldpc_rx(filename, interleave_frames = 1, error_pattern_filename) 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; - states.verbose = 0; + states.verbose = 1; % Set up LDPC code diff --git a/codec2-dev/octave/ofdm_lib.m b/codec2-dev/octave/ofdm_lib.m index cfef75f7..fedcfd83 100644 --- a/codec2-dev/octave/ofdm_lib.m +++ b/codec2-dev/octave/ofdm_lib.m @@ -682,34 +682,35 @@ function states = sync_state_machine(states, rx_uw) states.frame_count++; states.frame_count_interleaver++; - % during trial sync we don't tolerate errors so much, once we have synced up - % we are willing to wait out a fade - - if states.frame_count == 3 - next_state = 'synced'; - end - if strcmp(states.sync_state,'synced') - sync_counter_thresh = 12; - uw_thresh = 2; - else - sync_counter_thresh = 2; - uw_thresh = 1; + states.uw_errors = sum(xor(tx_uw,rx_uw)); + + if strcmp(states.sync_state,'trial') + if states.uw_errors > 1 + states.sync_counter++; + states.frame_count = 0; + end + if states.sync_counter == 2 + next_state = "search"; + states.sync_state_interleaver = "search"; + end + if states.frame_count == 4 + next_state = "synced"; + end end - % freq offset est may be too far out, and has aliases every 1/Ts, so - % we use a Unique Word to get a really solid indication of sync. + if strcmp(states.sync_state,'synced') + if states.uw_errors > 2 + states.sync_counter++; + else + states.sync_counter = 0; + end - states.uw_errors = sum(xor(tx_uw,rx_uw)); - if (states.uw_errors > uw_thresh) - states.sync_counter++; - if states.sync_counter == sync_counter_thresh - next_state = 'search'; - states.sync_state_interleaver = 'search'; + if states.sync_counter == 6 + next_state = "search"; + states.sync_state_interleaver = "search"; end - else - states.sync_counter = 0; end - end + end states.last_sync_state = states.sync_state; states.last_sync_state_interleaver = states.sync_state_interleaver; diff --git a/codec2-dev/src/ofdm.c b/codec2-dev/src/ofdm.c index 528175c8..c13ea1db 100644 --- a/codec2-dev/src/ofdm.c +++ b/codec2-dev/src/ofdm.c @@ -1001,7 +1001,7 @@ void ofdm_demod(struct OFDM *ofdm, int *rx_bits, COMP *rxbuf_in) { void ofdm_sync_state_machine(struct OFDM *ofdm, int *rx_uw) { char next_state[OFDM_STATE_STR]; - int i, j, sync_counter_thresh, uw_thresh; + int i, j; strcpy(next_state, ofdm->sync_state); ofdm->sync_start = ofdm->sync_end = 0; -- 2.25.1