From bf99a4cb3cda6332a231b199b8148f97ee1a7f85 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 17 Feb 2017 19:38:37 +0000 Subject: [PATCH] measuring BER from pilots in Octave OK git-svn-id: https://svn.code.sf.net/p/freetel/code@3038 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/octave/cohpsk.m | 14 ++++++++++++++ codec2-dev/octave/tcohpsk.m | 8 ++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/codec2-dev/octave/cohpsk.m b/codec2-dev/octave/cohpsk.m index cc948f47..4aeb7333 100644 --- a/codec2-dev/octave/cohpsk.m +++ b/codec2-dev/octave/cohpsk.m @@ -282,6 +282,7 @@ function [rx_symb rx_bits rx_symb_linear amp_ phi_ sig_rms noise_rms cohpsk] = q % and finally optional diversity combination and make decn on data and pilot bits + tx_pilot_bits = rx_pilot_bits = zeros(Npilotsframe*Nc,1); for c=1:Nc for r=1:Nsymbrowpilot div_symb = rx_symb(r,c); @@ -289,12 +290,25 @@ function [rx_symb rx_bits rx_symb_linear amp_ phi_ sig_rms noise_rms cohpsk] = q div_symb += rx_symb(r,c + Nc*d); end if r > Npilotsframe + % data symbols, ouput of demod i = (c-1)*Nsymbrow + r - Npilotsframe; rx_bits((2*(i-1)+1):(2*i)) = qpsk_demod(div_symb); + else + % demodulated pilot symbols, which we can use to estimate BER + %printf("%d %d (%f %f) (%f %f)\n", r, c, real(div_symb), imag(div_symb), real(cohpsk.pilot(r,c)), imag(cohpsk.pilot(r,c))); + i = (c-1)*Npilotsframe + r; + tx_pilot_bits((2*(i-1)+1):(2*i)) = qpsk_demod(cohpsk.pilot(r,c)); + rx_pilot_bits((2*(i-1)+1):(2*i)) = qpsk_demod(div_symb); end end end + % estimate BER from pilot bits + + cohpsk.npilotbits += Npilotsframe*Nc; + nerr = sum(xor(tx_pilot_bits, rx_pilot_bits)); + cohpsk.npilotbiterrors += nerr; + % Estimate noise power from demodulated symbols. One method is to % calculate the distance of each symbol from the average symbol % position. However this is complicated by fading, which means the diff --git a/codec2-dev/octave/tcohpsk.m b/codec2-dev/octave/tcohpsk.m index fc78d6ba..0674af2f 100644 --- a/codec2-dev/octave/tcohpsk.m +++ b/codec2-dev/octave/tcohpsk.m @@ -199,6 +199,8 @@ acohpsk.do_write_pilot_file = 1; % enable this to dump pilot symbols to C . acohpsk = symbol_rate_init(acohpsk); acohpsk.Ndft = 1024; acohpsk.f_est = afdmdv.Fcentre; +acohpsk.npilotbits = 0; +acohpsk.npilotbiterrors = 0; ch_fdm_frame_buf = zeros(1, Nsw*acohpsk.Nsymbrowpilot*afdmdv.M); @@ -490,7 +492,7 @@ for f=1:frames; % if we are in sync complete demodulation with symbol rate processing if (next_sync == 1) || (sync == 1) - [rx_symb rx_bits rx_symb_linear amp_ phi_ sig_rms noise_rms] = qpsk_symbols_to_bits(acohpsk, acohpsk.ct_symb_ff_buf); + [rx_symb rx_bits rx_symb_linear amp_ phi_ sig_rms noise_rms acohpsk] = qpsk_symbols_to_bits(acohpsk, acohpsk.ct_symb_ff_buf); rx_symb_log = [rx_symb_log; rx_symb]; rx_amp_log = [rx_amp_log; amp_]; rx_phi_log = [rx_phi_log; phi_]; @@ -545,7 +547,9 @@ for f=1:frames; end ber = Nerrs/Tbits; -printf("\nOctave EsNodB: %4.1f ber..: %4.3f Nerrs..: %d Tbits..: %d\n", EsNodB, ber, Nerrs, Tbits); +printf("\nOctave EsNodB: %4.1f BER......: %4.3f Nerrs..: %d Tbits..: %d\n", EsNodB, ber, Nerrs, Tbits); +pilot_ber = acohpsk.npilotbiterrors/acohpsk.npilotbits; +printf(" Pilot BER: %4.3f Nerrs..: %d Tbits..: %d\n", pilot_ber, acohpsk.npilotbiterrors, acohpsk.npilotbits); if compare_with_c -- 2.25.1