From: drowe67 Date: Thu, 10 Jul 2014 01:54:21 +0000 (+0000) Subject: debugged freq offset correction issue X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=f928c7302cbfab7b281b4c0ca138138f582f5ca9;p=freetel-svn-tracking.git debugged freq offset correction issue git-svn-id: https://svn.code.sf.net/p/freetel/code@1749 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/octave/fdmdv_demod.m b/codec2-dev/octave/fdmdv_demod.m index 53a303ac..704ac231 100644 --- a/codec2-dev/octave/fdmdv_demod.m +++ b/codec2-dev/octave/fdmdv_demod.m @@ -48,12 +48,12 @@ function fdmdv_demod(rawfilename, nbits, NumCarriers, errorpatternfilename, symb nin = M; % timing correction for sample rate differences foff = 0; - track_log = []; - track = 0; + fest_state = 0; - bad_sync = 0; - sync_track = 0; - entered_track_log = []; + fest_timer = 0; + sync_mem = zeros(1,Nsync_mem); + sync = 0; + sync_log = []; % spectrum states @@ -94,8 +94,8 @@ function fdmdv_demod(rawfilename, nbits, NumCarriers, errorpatternfilename, symb [pilot prev_pilot pilot_lut_index prev_pilot_lut_index] = get_pilot(pilot_lut_index, prev_pilot_lut_index, nin); [foff_coarse S1 S2] = rx_est_freq_offset(rx_fdm, pilot, prev_pilot, nin); - if track == 0 - foff = foff_coarse = 0; + if sync == 0 + foff = foff_coarse; end foff_log = [ foff_log foff ]; foff_rect = exp(j*2*pi*foff/Fs); @@ -110,7 +110,7 @@ function fdmdv_demod(rawfilename, nbits, NumCarriers, errorpatternfilename, symb rx_baseband = fdm_downconvert(rx_fdm, nin); rx_filt = rx_filter(rx_baseband, nin); - [rx_symbols rx_timing] = rx_est_timing(rx_filt, rx_baseband, nin); + [rx_symbols rx_timing] = rx_est_timing(rx_filt, nin); rx_timing_log = [rx_timing_log rx_timing]; nin = M; @@ -126,7 +126,7 @@ function fdmdv_demod(rawfilename, nbits, NumCarriers, errorpatternfilename, symb else rx_symbols_log = [rx_symbols_log rx_symbols]; endif - [rx_bits sync f_err pd] = psk_to_bits(prev_rx_symbols, rx_symbols, modulation); + [rx_bits sync_bit f_err pd] = psk_to_bits(prev_rx_symbols, rx_symbols, modulation); % optionally save output symbols @@ -163,16 +163,11 @@ function fdmdv_demod(rawfilename, nbits, NumCarriers, errorpatternfilename, symb snr_est_log = [snr_est_log snr_est]; foff -= 0.5*f_err; prev_rx_symbols = rx_symbols; - sync_log = [sync_log sync]; % freq est state machine - [entered_track track fest_state bad_sync] = freq_state(sync, fest_state, bad_sync); - track_log = [track_log track]; - if (entered_track == 1) - sync_track = 1; - end - entered_track_log = [entered_track_log entered_track]; + [sync reliable_sync_bit fest_state fest_timer sync_mem] = freq_state(sync_bit, fest_state, fest_timer, sync_mem); + sync_log = [sync_log sync]; % count bit errors if we find a test frame @@ -254,7 +249,7 @@ function fdmdv_demod(rawfilename, nbits, NumCarriers, errorpatternfilename, symb subplot(212) plot(xt, foff_log, '-;freq offset;') hold on; - plot(xt, track_log*75, 'r;course-fine;'); + plot(xt, sync_log*75, 'r;course-fine;'); hold off; title('Freq offset (Hz)'); grid diff --git a/codec2-dev/octave/fdmdv_demod_c.m b/codec2-dev/octave/fdmdv_demod_c.m index d63f8510..98b571b3 100644 --- a/codec2-dev/octave/fdmdv_demod_c.m +++ b/codec2-dev/octave/fdmdv_demod_c.m @@ -91,7 +91,7 @@ function fdmdv_demod_c(dumpfilename, bits) subplot(212) plot(xt, foff_log_c(1:frames), '-;freq offset;') hold on; - plot(xt, coarse_fine_log_c(1:frames)*75, 'r;course-fine;'); + plot(xt, sync_log_c(1:frames)*75, 'r;course-fine;'); hold off; title('Freq offset (Hz)'); grid diff --git a/codec2-dev/octave/fdmdv_ut.m b/codec2-dev/octave/fdmdv_ut.m index 19b8c0b0..398c8223 100644 --- a/codec2-dev/octave/fdmdv_ut.m +++ b/codec2-dev/octave/fdmdv_ut.m @@ -14,7 +14,7 @@ fdmdv; % load modem code frames = 100; EbNo_dB = 7.3; -Foff_hz = 10; +Foff_hz = -100; modulation = 'dqpsk'; hpa_clip = 150; diff --git a/codec2-dev/src/fdmdv.c b/codec2-dev/src/fdmdv.c index 835b514c..aba53114 100644 --- a/codec2-dev/src/fdmdv.c +++ b/codec2-dev/src/fdmdv.c @@ -1380,7 +1380,7 @@ void fdmdv_demod(struct FDMDV *fdmdv, int rx_bits[], /* baseband processing */ - down_convert_and_rx_filter(rx_filt, fdmdv->Nc, rx_fdm, fdmdv->rx_fdm_mem, fdmdv->phase_rx, fdmdv->freq, + down_convert_and_rx_filter(rx_filt, fdmdv->Nc, rx_fdm_fcorr, fdmdv->rx_fdm_mem, fdmdv->phase_rx, fdmdv->freq, fdmdv->freq_pol, *nin); fdmdv->rx_timing = rx_est_timing(rx_symbols, fdmdv->Nc, rx_filt, fdmdv->rx_filter_mem_timing, env, *nin); diff --git a/codec2-dev/src/fdmdv_mod.c b/codec2-dev/src/fdmdv_mod.c index 22318db8..de2d578d 100644 --- a/codec2-dev/src/fdmdv_mod.c +++ b/codec2-dev/src/fdmdv_mod.c @@ -53,6 +53,8 @@ int main(int argc, char *argv[]) int bits_per_codec_frame; int bytes_per_codec_frame; int Nc; + COMP foff_phase_rect; + float foff; if (argc < 3) { printf("usage: %s InputBitFile OutputModemRawFile [Nc]\n", argv[0]); @@ -100,6 +102,9 @@ int main(int argc, char *argv[]) tx_bits = (int*)malloc(sizeof(int)*bits_per_codec_frame); assert(tx_bits != NULL); + foff = -100; + foff_phase_rect.real = 1.0; foff_phase_rect.imag = 0.0; + frames = 0; while(fread(packed_bits, sizeof(char), bytes_per_codec_frame, fin) == bytes_per_codec_frame) { @@ -126,6 +131,10 @@ int main(int argc, char *argv[]) fdmdv_mod(fdmdv, &tx_fdm[FDMDV_NOM_SAMPLES_PER_FRAME], &tx_bits[bits_per_fdmdv_frame], &sync_bit); assert(sync_bit == 0); + /* optional frequency offset */ + + fdmdv_freq_shift(tx_fdm, tx_fdm, foff, &foff_phase_rect, 2*FDMDV_NOM_SAMPLES_PER_FRAME); + /* scale and save to disk as shorts */ for(i=0; i<2*FDMDV_NOM_SAMPLES_PER_FRAME; i++)