first pass at file based rx
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 29 Apr 2017 23:55:31 +0000 (23:55 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 29 Apr 2017 23:55:31 +0000 (23:55 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3112 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/ofdm_rx.m [new file with mode: 0644]

diff --git a/codec2-dev/octave/ofdm_rx.m b/codec2-dev/octave/ofdm_rx.m
new file mode 100644 (file)
index 0000000..7adc63b
--- /dev/null
@@ -0,0 +1,55 @@
+% ofdm_rx.m
+% David Rowe April 2017
+%
+% OFDM file based rx.
+
+
+function ofdm_rx(filename)
+  ofdm_lib;
+  Ts = 0.018; Tcp = 0.002; Rs = 1/Ts; bps = 2; Nc = 16; Ns = 8;
+  states = ofdm_init(bps, Rs, Tcp, Ns, Nc);
+  ofdm_load_const;
+
+  % fixed test frame of tx bits
+
+  rand('seed', 100);
+  tx_bits = rand(1,Nbitsperframe) > 0.5;
+
+  % load real samples from file
+
+  frx=fopen(filename,"rb"); rx = fread(frx, Inf, "short"); fclose(frx);
+
+  Nsam = length(rx); Nframes = floor(Nsam/Nsamperframe);
+  prx = 1;
+  rx_bits = []; rx_np = []; timing_est_log = []; delta_t_log = []; foff_est_hz_log = [];
+  phase_est_pilot_log = [];
+
+  for f=1:Nframes
+
+    % insert samples at end of buffer, set to zero if no samples
+    % available to disable phase estimation on future pilots on last
+    % frame of simulation
+
+    lnew = min(Nsam-prx,states.nin);
+    rxbuf_in = zeros(1,states.nin);
+
+    if lnew
+      rxbuf_in(1:lnew) = rx(prx:prx+lnew-1);
+    end
+    prx += states.nin;
+
+    [arx_bits states aphase_est_pilot_log arx_np] = ofdm_demod(states, rxbuf_in);
+
+    rx_bits = [rx_bits arx_bits]; rx_np = [rx_np arx_np];
+    timing_est_log = [timing_est_log states.timing_est];
+    delta_t_log = [delta_t_log states.delta_t];
+    foff_est_hz_log = [foff_est_hz_log states.foff_est_hz];
+    phase_est_pilot_log = [phase_est_pilot_log; aphase_est_pilot_log];
+  end
+
+  figure(1); clf; 
+  plot(rx_np,'+');
+  %axis([-2 2 -2 2]);
+  title('Scatter');
+
+endfunction