adjusted ofdm levels to be the same as fdmdv - octave
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 24 Apr 2018 06:57:31 +0000 (06:57 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 24 Apr 2018 06:57:31 +0000 (06:57 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3523 01035d8c-6547-0410-b346-abe4f91aad63

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

index 870c18f288fc7e1b339bbc995eecb294435ec870..be80a8a9bec873b6ae6e188a4b4c28c8bbfc41e4 100644 (file)
@@ -39,8 +39,8 @@ function ofdm_ldpc_rx(filename, interleave_frames = 1, error_pattern_filename)
 
   % load real samples from file
 
-  Ascale= 2E5*1.1491/2.0;
-  frx=fopen(filename,"rb"); rx = fread(frx, Inf, "short")/Ascale; fclose(frx);
+  Ascale= states.amp_scale/2.0;  % /2 as real signal has half amplitude
+  frx=fopen(filename,"rb"); rx = 0.1*fread(frx, Inf, "short")/Ascale; fclose(frx);
   Nsam = length(rx); Nframes = floor(Nsam/Nsamperframe);
   prx = 1;
 
@@ -56,7 +56,7 @@ function ofdm_ldpc_rx(filename, interleave_frames = 1, error_pattern_filename)
   
   % OK generate tx frame for BER calcs
   %   We just use a single test frame of bits as it makes interleaver sync
-  %   easier than using a test fram eof bits that spans the entire interleaver
+  %   easier than using a test framof bits that spans the entire interleaver
   %   frame.  Doesn't affect operation with the speech codec operation.
   
   rand('seed', 1);
index 9790940c55e8e17db2462a11de25f88a05d8d832..071106a8c780c4dfea2ec0d55090d8775372e620 100644 (file)
@@ -196,7 +196,5 @@ function ofdm_ldpc_tx(filename, interleave_frames = 1, Nsec, EbNodB=100, channel
 
   % adjusted by experiment to match rms power of early test signals
 
-  Ascale = 2E5*1.1491;
-
-  frx=fopen(filename,"wb"); fwrite(frx, Ascale*rx, "short"); fclose(frx);
+  frx=fopen(filename,"wb"); fwrite(frx, states.amp_scale*rx, "short"); fclose(frx);
 endfunction
index 6dbbb091b45680064c491357dbe63caf03bb1147..b07d4d10d221f38741585078cae79475f2334696 100644 (file)
@@ -141,6 +141,11 @@ function states = ofdm_init(bps, Rs, Tcp, Ns, Nc)
   states.tx_uw = [1 0 0 1 0 1 0 0 1 0];
   assert(length(states.tx_uw) == states.Nuwbits);
 
+  % use this to scale tx output to 16 bit short.  Adjusted by experiment
+  % to have same RMS power as FDMDV waveform
+  
+  states.amp_scale = 2E5*1.1491/1.06;
   % generate same pilots each time
 
   rand('seed',1);
index c5eebf72c8bcffdfdff6658e8bc719cf13ecb67d..85458f935e354ec17e6c04c7d1deaa09c73c08a7 100644 (file)
@@ -18,7 +18,7 @@ function ofdm_rx(filename, error_pattern_filename)
 
   % load real samples from file
 
-  Ascale= 2E5*1.1491/2;
+  Ascale = states.amp_scale/2; % as input is a real valued signal
   frx=fopen(filename,"rb"); rx = fread(frx, Inf, "short")/Ascale; fclose(frx);
   Nsam = length(rx); Nframes = floor(Nsam/Nsamperframe);
   prx = 1;
@@ -31,7 +31,7 @@ function ofdm_rx(filename, error_pattern_filename)
 
   rx_bits = []; rx_np_log = []; timing_est_log = []; delta_t_log = []; foff_est_hz_log = [];
   phase_est_pilot_log = [];
-  Terrs = Tbits = Terrs_coded = Tbits_coded = Tpackets = Tpacketerrs = 0;
+  Terrs = Tbits = Terrs_coded = Tbits_coded = Tpackets = Tpacketerrs = frame_count = 0;
   Nbitspervocframe = 28;
   Nerrs_coded_log = Nerrs_log = [];
   error_positions = [];
@@ -63,11 +63,11 @@ function ofdm_rx(filename, error_pattern_filename)
     end
     prx += states.nin;
  
-    if strcmp(states.sync_state,'searching') 
+    if strcmp(states.sync_state,'search') 
       [timing_valid states] = ofdm_sync_search(states, rxbuf_in);
     end
     
-    if strcmp(states.sync_state,'synced') || strcmp(states.sync_state,'trial_sync')
+    if strcmp(states.sync_state,'synced') || strcmp(states.sync_state,'trial')
       [rx_bits states aphase_est_pilot_log arx_np arx_amp] = ofdm_demod(states, rxbuf_in);
       rx_uw = rx_bits(1:states.Nuwbits);
       
@@ -107,7 +107,7 @@ function ofdm_rx(filename, error_pattern_filename)
     end
   end
 
-  printf("\nBER..: %5.4f Tbits: %5d Terrs: %5d\n", Terrs/Tbits, Tbits, Terrs);
+  printf("\nBER..: %5.4f Tbits: %5d Terrs: %5d\n", Terrs/(Tbits+1E-12), Tbits, Terrs);
 
   % If we have enough frames, calc BER discarding first few frames where freq
   % offset is adjusting
@@ -149,7 +149,7 @@ function ofdm_rx(filename, error_pattern_filename)
   title('Errors/modem frame')
   axis([1 length(Nerrs_log) 0 Nbitsperframe*rate/2]);
 
-  if nargin == 3
+  if nargin == 2
     fep = fopen(error_pattern_filename, "wb");
     fwrite(fep, error_positions, "short");
     fclose(fep);
index 11fa112ec88faccac7361189937e102197fd8a90..c488bad1fad190f0742f1e8bf39e1ae2762e1079 100644 (file)
@@ -103,7 +103,5 @@ function ofdm_tx(filename, Nsec, EbNodB=100, channel='awgn', freq_offset_Hz=0, d
 
   % adjusted by experiment to match rms power of early test signals
 
-  Ascale = 2E5*1.1491;
-
-  frx=fopen(filename,"wb"); fwrite(frx, Ascale*rx, "short"); fclose(frx);
+  frx=fopen(filename,"wb"); fwrite(frx, states.amp_scale*rx, "short"); fclose(frx);
 endfunction