aquisition working with freq offsets up to +/-20Hz. A bit slow, but gd enough for...
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 3 May 2017 03:55:16 +0000 (03:55 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 3 May 2017 03:55:16 +0000 (03:55 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3119 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/ofdm_lib.m
codec2-dev/octave/ofdm_rx.m
codec2-dev/octave/ofdm_tx.m

index 3cdfa3c8b3d141162d7222e61b8c063872a23a20..ebc3f28979908aed323ab1a1a914774801f341e4 100644 (file)
@@ -1,10 +1,14 @@
 % ofdm_lib.m
 % David Rowe Mar 2017
-%
 
-% Library of functions that implement a BPSK/QPSK OFDM modem.  Rate Fs
-% verison of ofdm_rs.m with OFDM based up and down conversion, and all
-% those nasty real-world details like fine freq, timing.
+#{
+  Library of functions that implement a BPSK/QPSK OFDM modem.  Rate Fs
+  verison of ofdm_rs.m with OFDM based up and down conversion, and all
+  those nasty real-world details like fine freq, timing.
+
+  
+#}
+
 
 1;
 
@@ -36,6 +40,22 @@ endfunction
 % Also determines frequency offset at maximimum correlation.  Can be
 % used for acquisition (coarse timing a freq offset), and fine timing
 
+#{
+  TODO: 
+    [ ] attempt to speed up sync
+        + tis rather stateless, this current demod, which is nice
+        [ ] 0.5Hz grid and measure BER
+            + so run demod a bunch of times at different offsets
+            + Hmm cld also try +/- 20Hz multiples as it's aliased?
+            + might to use 
+            + need metric for sync, could be callback.
+        [ ] or refine freq offset using pilots
+        [ ] different error measure that 10% maybe soft dec
+            + 10% very high BER
+    [ ] simpler CPU/DFT for freq offset estimation
+        + more suitable for real time implementation
+#}
+
 function [t_est foff_est] = coarse_sync(states, rx, rate_fs_pilot_samples)
     Nsamperframe = states.Nsamperframe; Fs = states.Fs;
     Npsam = length(rate_fs_pilot_samples);
index e9c9b3d7df359fd58f6b93a61a1965dcafb4576c..dd275ff086c4144db44e3ec11ec5a47683ddc43f 100644 (file)
@@ -65,7 +65,7 @@ function ofdm_rx(filename)
     next_state = state;
 
     if strcmp(state,'searching')  
-      if Nerrs/Nbitsperframe < 0.1
+      if Nerrs/Nbitsperframe < 0.15
         next_state = 'synced';
       end
     end
@@ -88,7 +88,7 @@ function ofdm_rx(filename)
       % reset modem states
 
       states.sample_point = states.timing_est = 1;
-      states.foff_est_hz = 0;
+      states.foff_est_hz = foff_est;
 
     else
 
@@ -130,7 +130,8 @@ function ofdm_rx(filename)
 
   figure(4); clf;
   plot(foff_est_hz_log)
-  axis([1 max(Nframes,2) -3 3]);
+  mx = max(abs(foff_est_hz_log));
+  axis([1 max(Nframes,2) -mx mx]);
   title('Fine Freq');
 
   figure(5); clf;
index 903c7c8dee2c39a613e920682a17142bb6fad90a..7fd6acb57f2b04cb8d0aa983dcb05cd2d5dd9958 100644 (file)
@@ -4,6 +4,14 @@
 % File based ofdm tx.  Generate a file of ofdm samples, inclduing
 % optional channel simulation.
 
+#{
+  TODO: 
+    [ ] Optional LDPC code
+    [ ] measure and report raw and coded BER
+    [ ] maybe 10s worth of frames, sync up to any one automatically
+        + or start with maybe 10 frames
+        + measure BER match on each one
+#}
 
 function ofdm_tx(filename, Nsec, EbNodB=100, channel='awgn', freq_offset_Hz=0)
   ofdm_lib;
@@ -38,7 +46,7 @@ function ofdm_tx(filename, Nsec, EbNodB=100, channel='awgn', freq_offset_Hz=0)
   % mumble not understood very well mumble magic number.
 
   SNRdB = EbNodB + 10*log10(bps*Rs*Nc/Fs) + 3;
-  printf("EbNo: %3.1f SNR(3k): %3.1f foff: %3.1f\n", EbNodB, SNRdB, freq_offset_Hz);
+  printf("EbNo: %3.1f dB  SNR(3k): %3.1f dB  foff: %3.1fHz\n", EbNodB, SNRdB, freq_offset_Hz);
 
   % set up HF model ---------------------------------------------------------------
 
@@ -75,12 +83,13 @@ function ofdm_tx(filename, Nsec, EbNodB=100, channel='awgn', freq_offset_Hz=0)
 
   rx = rx .* exp(j*woffset*(1:Nsam));
 
-  % note variance/2 as we are using real() operator
+  % note variance/2 as we are using real() operator, mumble,
+  % reflection of -ve freq to +ve, mumble, hand wave
 
-  noise = sqrt(variance/2)*(0.5*randn(1,Nsam) + j*0.5*randn(1,Nsam));
-  rx += noise;
-  10*log10(var(tx)/var(noise))
+  noise = sqrt(variance/2)*0.5*randn(1,Nsam);
+  rx = real(rx) + noise;
+  printf("measured SNR: %3.2f dB\n", 10*log10(var(real(tx))/var(noise)));
 
   Ascale = 4E5;
-  frx=fopen(filename,"wb"); fwrite(frx, Ascale*real(rx), "short"); fclose(frx);
+  frx=fopen(filename,"wb"); fwrite(frx, Ascale*rx, "short"); fclose(frx);
 endfunction