Octave compatable ofdm_get_test_bits.c, and a few minor omment tweaks
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 20 Mar 2018 22:57:49 +0000 (22:57 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 20 Mar 2018 22:57:49 +0000 (22:57 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3423 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/ofdm_rx.m
codec2-dev/octave/ofdm_tx.m
codec2-dev/src/ofdm_get_test_bits.c [new file with mode: 0644]
codec2-dev/src/ofdm_internal.h

index a04602c5d842bbf71ae3b0d8d7f047d999b1c1c4..ba9f3a33eb004f1b0d7c8e8fa5a7f3bb6d5213df 100644 (file)
@@ -36,7 +36,7 @@ function ofdm_rx(filename, error_pattern_filename)
 
   % OK re-generate tx frame for BER calcs
 
-  rand('seed', 100);
+  rand('seed', 1);
   tx_bits = round(rand(1,Nbitsperframe));
 
   % init logs and BER stats
@@ -173,7 +173,7 @@ function ofdm_rx(filename, error_pattern_filename)
 
   figure(4); clf;
   plot(foff_est_hz_log)
-  mx = max(abs(foff_est_hz_log));
+  mx = max(abs(foff_est_hz_log))+1;
   axis([1 max(Nframes,2) -mx mx]);
   title('Fine Freq');
   ylabel('Hz')
index 3b09d3abd9d09810a5574d400a5d3cb0643c04bf..174743e5a4e72695a55510566eb23a9a2836c585 100644 (file)
@@ -30,7 +30,7 @@ function ofdm_tx(filename, Nsec, EbNodB=100, channel='awgn', freq_offset_Hz=0)
 
   Nrows = Nsec*Rs;
   Nframes = floor((Nrows-1)/Ns);
-  rand('seed', 100);
+  rand('seed', 1);
   tx_bits = round(rand(1,Nbitsperframe));
 
   tx = [];
diff --git a/codec2-dev/src/ofdm_get_test_bits.c b/codec2-dev/src/ofdm_get_test_bits.c
new file mode 100644 (file)
index 0000000..2ee037d
--- /dev/null
@@ -0,0 +1,85 @@
+/*---------------------------------------------------------------------------*\
+
+  FILE........: ofdm_get_test_bits.c
+  AUTHOR......: David Rowe
+  DATE CREATED: Mar 2018
+
+  Generates frames of test bits, useful for input to ofdm_mod.
+
+\*---------------------------------------------------------------------------*/
+
+
+/*
+  Copyright (C) 2018 David Rowe
+
+  All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License version 2, as
+  published by the Free Software Foundation.  This program is
+  distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+  License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <errno.h>
+
+#include "codec2_ofdm.h"
+#include "ofdm_internal.h"
+#include "test_bits_ofdm.h"
+
+int main(int argc, char *argv[])
+{
+    struct OFDM  *ofdm;
+    FILE         *fout;
+    int           Nsec, Nrows, Nframes, i,n;
+
+    if (argc < 2) {
+       printf("usage: %s OutputOneCharPerBitFile numSecs\n", argv[0]);
+       exit(1);
+    }
+
+    if (strcmp(argv[1], "-") == 0) fout = stdout;
+    else if ( (fout = fopen(argv[1],"wb")) == NULL ) {
+       fprintf(stderr, "Error opening output file: %s: %s.\n",
+         argv[1], strerror(errno));
+       exit(1);
+    }
+
+    ofdm = ofdm_create(OFDM_CONFIG_700D);
+    assert(ofdm != NULL);
+    int Nbitsperframe = ofdm_get_bits_per_frame(ofdm);
+    char  tx_bits_char[Nbitsperframe];
+    ofdm_destroy(ofdm);
+
+    for(i=0; i<Nbitsperframe; i++) {
+        tx_bits_char[i] = test_bits_ofdm[i];
+    }
+    
+    Nsec = atoi(argv[2]);
+    Nrows = Nsec*OFDM_RS;
+    Nframes = floor((Nrows-1)/OFDM_NS);
+
+    for(n=0; n<Nframes; n++) {
+
+       fwrite(tx_bits_char, sizeof(char), Nbitsperframe, fout);
+
+       /* if this is in a pipeline, we probably don't want the usual
+          buffering to occur */
+
+        if (fout == stdout) fflush(stdout);
+    }
+
+    fclose(fout);
+
+    return 0;
+}
index 1a1c576f2f8548453cf5ccf014cd3d636917daf7..2aa3b9d8031e1a1352100de64ec397bc9e961916 100644 (file)
@@ -48,14 +48,14 @@ extern "C" {
 #define OFDM_RS     (1.0f / OFDM_TS)         /* Symbol rate */
 #define OFDM_FS     8000.0f                  /* Sample rate */
 #define OFDM_BPS    2                        /* Bits per symbol */
-#define OFDM_TCP    0.002f                   /* ? */
-#define OFDM_NS     8                        /*  */
+#define OFDM_TCP    0.002f                   /* Cyclic prefix duration */
+#define OFDM_NS     8                        /* NS-1 data symbols between pilots  */
 #define OFDM_CENTRE 1500.0f                  /* Center frequency */
 
 /* To prevent C99 warning */
 
-#define OFDM_M      144                      /* Samples per bare symbol (?) */
-#define OFDM_NCP    16                       /* Samples per cyclic prefix */
+#define OFDM_M      144                      /* duration of each symbol in samples */
+#define OFDM_NCP    16                       /* duration of CP in samples */
 
 #ifdef OLD_STYLE
 /* This will produce a warning in C99 as (int) makes these variable */
@@ -91,6 +91,7 @@ struct OFDM {
     int verbose;
     int sample_point;
     int timing_est;
+    float coarse_foff_est_hz;
     int nin;
 
     bool timing_en;