measuring BER from pilots in Octave OK
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 17 Feb 2017 19:38:37 +0000 (19:38 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 17 Feb 2017 19:38:37 +0000 (19:38 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3038 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/cohpsk.m
codec2-dev/octave/tcohpsk.m

index cc948f475e09fed9a024fee4a8bd1ba6ca884885..4aeb73339cff1f48292b0336b66def178fe756b9 100644 (file)
@@ -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
index fc78d6bac074d865db6f4332e45d7b53788bb1e6..0674af2f953e8cd70ad36b831efbaf165fbc624a 100644 (file)
@@ -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