A little work towards FSK4 fine timing estimation
authorbaobrien <baobrien@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 13 Oct 2015 17:49:19 +0000 (17:49 +0000)
committerbaobrien <baobrien@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 13 Oct 2015 17:49:19 +0000 (17:49 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2439 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/fsk4.m

index 03c654f41ba25fe65e28d370d099350e2df4fbae..72b1430010341edb34cba8862a26b547d39df344 100644 (file)
@@ -153,10 +153,20 @@ endfunction
 
 %incoherent demod loosly based on another paper. Works, more or less.
 % Paper is titled "Design and Implementation of a Fully Digital 4FSK Demodulator"
-function [bits err] = fsk4_demod_fmrid(fsk4_states, rx)
+function [bits err rxphi] = fsk4_demod_fmrid(fsk4_states, rx)
 
   rxd = analog_fm_demod(fsk4_states.fm_states,rx);
 
+  rxest = rxd.^2;
+  figure(11);
+  plot(20*log10(abs(fft(rxest))));
+  figure(12);
+  plot(rxest);
+  w = 2*pi*(12051/48000);
+  rxest = rxest .* exp(-j*w*(0:length(rxest)-1));
+  rxest = sum(rxest)
+  rxphi = angle(rxest)
+
   M = fsk4_states.M;
   fine_timing = 51;
   
@@ -174,10 +184,10 @@ function [bits err] = fsk4_demod_fmrid(fsk4_states, rx)
   % A little cheating to demap the symbols
   % Take a histogram of the sampled symbols, find the center of the largest distribution,
   % and correct the symbol map to match it
-  [a b] = hist(sym,50)
-  [a ii] = max(a)
-  grmax = abs(b(ii))
-  grmax = (grmax<.65)*.65 + (grmax>=.65)*grmax
+  [a b] = hist(sym,50);
+  [a ii] = max(a);
+  grmax = abs(b(ii));
+  grmax = (grmax<.65)*.65 + (grmax>=.65)*grmax;
 
   dmsyms = rot90(fsk4_states.symmap*grmax)
 
@@ -199,7 +209,7 @@ endfunction
 % Bit error rate test
 % for a noise-free channel
 % now supports noisy channels
-function [ber thrcoh thrncoh] = nfbert(aEsNodB)
+function [ber thrcoh thrncoh rxphi] = nfbert(aEsNodB,timing_offset = 1)
   global dmr_info;
   global nxdn_info;
   global nflt_info;
@@ -224,7 +234,10 @@ function [ber thrcoh thrncoh] = nfbert(aEsNodB)
   nsam = length(tx);
   noise = sqrt(variance/2)*(randn(1,nsam) + j*randn(1,nsam));
   rx    = tx*exp(j*pi/2) + noise;
-  rx_bits = fsk4_demod_fmrid(fsk4_states,rx);
+
+  rx    = rx(timing_offset:length(rx));
+
+  [rx_bits biterr rxphi] = fsk4_demod_fmrid(fsk4_states,rx);
   ber = 1;
   
   %thing to account for offset from input data to output data
@@ -265,6 +278,16 @@ function [ber thrcoh thrncoh] = nfbert(aEsNodB)
   %plot((1:1000),rx_bits(1:1000),(1:1000),rx_err(1:1000));
 endfunction
 
+function fsk4_rx_phi
+  pkg load parallel
+  offrange = [1:100];
+  [a,b,c,phi] = pararrayfun(floor(1.25*nproc()),@nfbert,100.*ones(1,length(offrange)),offrange);
+  close all;
+  figure(1);
+  clf;
+  plot(offrange,phi);
+endfunction
+
 
 function fsk4_ber_curves
   EbNodB = 1:20;