From 1bc8a2750cc8e836dd8535db11c0984cf05d55b4 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 19 Feb 2013 22:37:11 +0000 Subject: [PATCH] improved sync for hanging on in fades and small big in logging data in fdmdv_demod git-svn-id: https://svn.code.sf.net/p/freetel/code@1165 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/fdmdv.c | 39 ++++++++++++++++++++++++++++-------- codec2-dev/src/fdmdv_demod.c | 8 ++++---- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/codec2-dev/src/fdmdv.c b/codec2-dev/src/fdmdv.c index d80a034e..9453b87d 100644 --- a/codec2-dev/src/fdmdv.c +++ b/codec2-dev/src/fdmdv.c @@ -1123,11 +1123,21 @@ void CODEC2_WIN32SUPPORT fdmdv_put_test_bits(struct FDMDV *f, int *sync, tracking algorithm. If we lose sync we switch back to coarse mode for fast re-acquisition of large frequency offsets. + The sync state is also useful for higher layers to determine when + there is valid FDMDV data for decoding. We want to reliably and + quickly get into sync, stay in sync even on fading channels, and + fall out of sync quickly if tx stops or it's a false sync. + + In multipath fading channels the BPSK sync carrier may be pushed + down in the noise, despite other carriers being at full strength. + We want to avoid loss of sync in these cases. + \*---------------------------------------------------------------------------*/ int freq_state(int sync_bit, int *state) { int next_state, coarse_fine; + int bad_sync = 0; /* acquire state, look for 6 symbol 010101 sequence from sync bit */ @@ -1162,27 +1172,40 @@ int freq_state(int sync_bit, int *state) next_state = 0; break; case 5: - if (sync_bit == 1) + if (sync_bit == 1) { next_state = 6; + bad_sync = 0; + } else next_state = 0; break; /* states 6 and above are track mode, make sure we keep - getting 0101 sync bit sequence */ + getting 0101 sync bit sequence. bad_sync allows us to track + through a few bad symbols when BPSK pilot is temporarilly + faded out, avoiding a costly re-sync when valid data still + exists on other carriers */ case 6: + next_state = 7; if (sync_bit == 0) - next_state = 7; - else - next_state = 0; + bad_sync = 0; + else { + bad_sync++; + if (bad_sync > 2) + next_state = 0; + } break; case 7: + next_state = 6; if (sync_bit == 1) - next_state = 6; - else - next_state = 0; + bad_sync = 0; + else { + bad_sync++; + if (bad_sync > 2) + next_state = 0; + } break; } diff --git a/codec2-dev/src/fdmdv_demod.c b/codec2-dev/src/fdmdv_demod.c index a1f1dd39..391843f1 100644 --- a/codec2-dev/src/fdmdv_demod.c +++ b/codec2-dev/src/fdmdv_demod.c @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) int f; FILE *foct = NULL; struct FDMDV_STATS stats; - float *rx_fdm_log; + COMP *rx_fdm_log; int rx_fdm_log_col_index; COMP rx_symbols_log[FDMDV_NSYM][MAX_FRAMES]; int coarse_fine_log[MAX_FRAMES]; @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) /* malloc some of the bigger variables to prevent out of stack problems */ - rx_fdm_log = (float*)malloc(sizeof(float)*FDMDV_MAX_SAMPLES_PER_FRAME*MAX_FRAMES); + rx_fdm_log = (COMP*)malloc(sizeof(COMP)*FDMDV_MAX_SAMPLES_PER_FRAME*MAX_FRAMES); assert(rx_fdm_log != NULL); rx_spec_log = (float*)malloc(sizeof(float)*FDMDV_NSPEC*MAX_FRAMES); assert(rx_spec_log != NULL); @@ -128,7 +128,7 @@ int main(int argc, char *argv[]) /* log modem states for later dumping to Octave log file */ - memcpy(&rx_fdm_log[rx_fdm_log_col_index], rx_fdm, sizeof(float)*nin_prev); + memcpy(&rx_fdm_log[rx_fdm_log_col_index], rx_fdm, sizeof(COMP)*nin_prev); rx_fdm_log_col_index += nin_prev; for(c=0; c