From c33bf3a93ce35ef1d9ed1cf69ca85419fb874452 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 20 Mar 2018 08:56:00 +0000 Subject: [PATCH] refactored ofdm rx a little, progressing towards better sync state machine git-svn-id: https://svn.code.sf.net/p/freetel/code@3421 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/octave/ofdm_dev.m | 3 ++- codec2-dev/octave/ofdm_rx.m | 17 +++++++++-------- codec2-dev/octave/ofdm_tx.m | 5 +++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/codec2-dev/octave/ofdm_dev.m b/codec2-dev/octave/ofdm_dev.m index 648e5e51..48059ade 100644 --- a/codec2-dev/octave/ofdm_dev.m +++ b/codec2-dev/octave/ofdm_dev.m @@ -943,7 +943,8 @@ endfunction 0 AWGN 10 1.00 0.98 0 HF 10 1.00 0.65 - -> Suggests we will sync up in 2-3 frames which is pretty cool. + -> Suggests we will sync up in 2-3 frames which is pretty cool. Would be good + to have freq est about as reliable as timing est..... #} function acquisition_histograms(fine_en = 0, foff) diff --git a/codec2-dev/octave/ofdm_rx.m b/codec2-dev/octave/ofdm_rx.m index 8d47e375..32d4c343 100644 --- a/codec2-dev/octave/ofdm_rx.m +++ b/codec2-dev/octave/ofdm_rx.m @@ -6,7 +6,7 @@ #{ TODO: - [ ] single frame based sync state machine + [X] single frame based sync state machine + that doesn't depend on payload data [ ] make robust to fading + what are win conditions? @@ -74,9 +74,14 @@ function ofdm_rx(filename, error_pattern_filename) prx += states.nin; [rx_bits states aphase_est_pilot_log arx_np arx_amp] = ofdm_demod(states, rxbuf_in); + + errors = xor(tx_bits, rx_bits); + Nerrs = sum(errors); + aber = Nerrs/Nbitsperframe; + frame_count++; - printf("f: %d state: %s frame_count: %d\n", f, state, frame_count); + printf("f: %d state: %s Nerrs: %d aber: %3.2f\n", f, state, Nerrs, aber); % If looking for sync: check raw BER on frame just received % against all possible positions in the interleaver frame. @@ -89,9 +94,7 @@ function ofdm_rx(filename, error_pattern_filename) % If looking for sync: check raw BER on frame just received % against all possible positions in the interleaver frame. - errors = xor(tx_bits, rx_bits); - Nerrs = sum(errors); - if Nerrs/Nbitsperframe < 0.1 + if aber < 0.1 next_state = 'synced'; % make sure we get an interleave frame with correct freq offset % note this introduces a lot of delay, a better idea would be to @@ -139,9 +142,7 @@ function ofdm_rx(filename, error_pattern_filename) % measure uncoded bit errors on modem frame - errors = xor(tx_bits, rx_bits); - Nerrs = sum(errors); - if Nerrs/Nbitsperframe < 0.2 + if aber < 0.2 Terrs += Nerrs; Nerrs_log = [Nerrs_log Nerrs]; Tbits += Nbitsperframe; diff --git a/codec2-dev/octave/ofdm_tx.m b/codec2-dev/octave/ofdm_tx.m index b40b978d..79edb597 100644 --- a/codec2-dev/octave/ofdm_tx.m +++ b/codec2-dev/octave/ofdm_tx.m @@ -37,7 +37,7 @@ function ofdm_tx(filename, Nsec, EbNodB=100, channel='awgn', freq_offset_Hz=0) for f=1:Nframes tx = [tx ofdm_mod(states, tx_bits)]; end - + Nsam = length(tx); % channel simulation @@ -59,7 +59,8 @@ function ofdm_tx(filename, Nsec, EbNodB=100, channel='awgn', freq_offset_Hz=0) dopplerSpreadHz = 1; path_delay_ms = 1; path_delay_samples = path_delay_ms*Fs/1000; - printf("Doppler Spread: %3.2f Hz Path Delay: %3.2f ms %d samples\n", dopplerSpreadHz, path_delay_ms, path_delay_samples); + printf("Doppler Spread: %3.2f Hz Path Delay: %3.2f ms %d samples\n", + dopplerSpreadHz, path_delay_ms, path_delay_samples); % generate same fading pattern for every run -- 2.25.1