global passes;
global fails;
passes = fails = 0;
-frames = 25;
+frames = 35;
prev_tx_symbols = ones(Nc+1,1);
prev_rx_symbols = ones(Nc+1,1);
foff_phase_rect = 1;
% adjust this if the screen is getting a bit cluttered
global no_plot_list;
-no_plot_list = [];
+no_plot_list = [1 2 3 4 5 6 7 8 11 12 13 14 15 16];
for f=1:frames
end
nin_log = [nin_log nin];
- [rx_bits sync_bit f_err pd] = psk_to_bits(prev_rx_symbols, rx_symbols, 'dqpsk');
+ [rx_bits sync_bit foff_fine pd] = psk_to_bits(prev_rx_symbols, rx_symbols, 'dqpsk');
phase_difference_log = [phase_difference_log pd];
+ foff_fine_log = [foff_fine_log foff_fine];
+ foff -= 0.5*foff_fine;
+ foff_log = [foff_log foff];
+
[sig_est noise_est] = snr_update(sig_est, noise_est, pd);
sig_est_log = [sig_est_log sig_est];
noise_est_log = [noise_est_log noise_est];
prev_rx_symbols = rx_symbols;
rx_bits_log = [rx_bits_log rx_bits];
- foff_fine_log = [foff_fine_log foff_fine];
sync_bit_log = [sync_bit_log sync_bit];
- foff -= 0.5*f_err;
- foff_log = [foff_log foff];
% freq est state machine
/*---------------------------------------------------------------------------*\
- FUNCTION....: fdm_downconvert()
+ FUNCTION....: fdm_downconvert
AUTHOR......: David Rowe
DATE CREATED: 22/4/2012
float windback_phase, mag;
COMP windback_phase_rect;
COMP rx_baseband[NFILTER+M];
- TIMER_VAR(windback_start, downconvert_start, filter_start);
+ COMP f_rect;
+
+ //TIMER_VAR(windback_start, downconvert_start, filter_start);
/* update memory of rx_fdm */
phase continuity.
*/
- TIMER_SAMPLE(windback_start);
+ //TIMER_SAMPLE(windback_start);
windback_phase = -freq_pol[c]*NFILTER;
windback_phase_rect.real = cosf(windback_phase);
windback_phase_rect.imag = sinf(windback_phase);
phase_rx[c] = cmult(phase_rx[c],windback_phase_rect);
- TIMER_SAMPLE_AND_LOG(downconvert_start, windback_start, " windback");
+ //TIMER_SAMPLE_AND_LOG(downconvert_start, windback_start, " windback");
/* down convert all samples in buffer */
st -= nin-1; /* first new sample */
st -= NFILTER; /* first sample used in filtering */
- for(i=st; i<NFILTER+M; i++) {
- phase_rx[c] = cmult(phase_rx[c], freq[c]);
+ /* freq shift per dec_rate step is dec_rate times original shift */
+
+ f_rect = freq[c];
+ for(i=0; i<dec_rate-1; i++)
+ f_rect = cmult(f_rect,freq[c]);
+
+ for(i=st; i<NFILTER+M; i+=dec_rate) {
+ phase_rx[c] = cmult(phase_rx[c], f_rect);
rx_baseband[i] = cmult(rx_fdm_mem[i],cconj(phase_rx[c]));
}
- TIMER_SAMPLE_AND_LOG(filter_start, downconvert_start, " downconvert");
+ //TIMER_SAMPLE_AND_LOG(filter_start, downconvert_start, " downconvert");
/* now we can filter this carrier's P symbols */
rx_filt[c][k].imag = fir_filter(&rx_baseband[st+i].imag, (float*)gt_alpha5_root, dec_rate);
#endif
}
- TIMER_SAMPLE_AND_LOG2(filter_start, " filter");
+ //TIMER_SAMPLE_AND_LOG2(filter_start, " filter");
/* normalise digital oscilators as the magnitude can drift over time */
float foff_coarse, foff_fine;
COMP rx_fdm_fcorr[M+M/P];
COMP rx_fdm_filter[M+M/P];
+ COMP rx_fdm_bb[M+M/P];
COMP rx_filt[NC+1][P+1];
COMP rx_symbols[NC+1];
float env[NT*P];
/* shift down to complex baseband */
- fdmdv_freq_shift(rx_fdm, rx_fdm, -FDMDV_FCENTRE, &fdmdv->fbb_phase_rx, *nin);
+ fdmdv_freq_shift(rx_fdm_bb, rx_fdm, -FDMDV_FCENTRE, &fdmdv->fbb_phase_rx, *nin);
/* freq offset estimation and correction */
TIMER_SAMPLE(demod_start);
- foff_coarse = rx_est_freq_offset(fdmdv, rx_fdm, *nin);
+ foff_coarse = rx_est_freq_offset(fdmdv, rx_fdm_bb, *nin);
TIMER_SAMPLE_AND_LOG(fdmdv_freq_shift_start, demod_start, " rx_est_freq_offset");
if (fdmdv->sync == 0)
fdmdv->foff = foff_coarse;
- fdmdv_freq_shift(rx_fdm_fcorr, rx_fdm, -fdmdv->foff, &fdmdv->foff_phase_rect, *nin);
+ fdmdv_freq_shift(rx_fdm_fcorr, rx_fdm_bb, -fdmdv->foff, &fdmdv->foff_phase_rect, *nin);
TIMER_SAMPLE_AND_LOG(down_convert_and_rx_filter_start, fdmdv_freq_shift_start, " fdmdv_freq_shift");
/* baseband processing */