cohpsk_ch cmd line channel simulator partially written and working as expected with...
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 28 May 2015 09:16:22 +0000 (09:16 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 28 May 2015 09:16:22 +0000 (09:16 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2158 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/make_hilb.m [new file with mode: 0644]
codec2-dev/octave/tcohpsk.m
codec2-dev/src/CMakeLists.txt
codec2-dev/src/codec2_cohpsk.h
codec2-dev/src/cohpsk_ch.c [new file with mode: 0644]
codec2-dev/src/cohpsk_demod.c
codec2-dev/src/cohpsk_mod.c
codec2-dev/src/cohpsk_put_test_bits.c
codec2-dev/src/ht_coeff.h [new file with mode: 0644]
codec2-dev/unittest/test_cohpsk_ch.c

diff --git a/codec2-dev/octave/make_hilb.m b/codec2-dev/octave/make_hilb.m
new file mode 100644 (file)
index 0000000..35d4e55
--- /dev/null
@@ -0,0 +1,51 @@
+% make_hilb.m
+% David Rowe May 2015
+%
+% creates Hilber Transformer FIR coeffs
+
+graphics_toolkit ("gnuplot");
+
+ht_n = 100;
+imp = [1 zeros(1,ht_n-1)];
+ht_coeff = fftshift(hilbert(imp)) .* hanning(ht_n)';
+
+figure(1)
+subplot(211)
+plot(real(ht_coeff))
+subplot(212)
+plot(imag(ht_coeff))
+
+figure(2)
+plot(20*log10(abs(fft(ht_coeff))))
+
+% test it
+
+n=1:8000;
+w = 2*pi/4;
+x = cos(n*w);
+figure(3)
+y = filter(ht_coeff,1,x);
+figure(3)
+subplot(211)
+plot(y(800:8000))
+subplot(212)
+plot(20*log10(abs(fft(y(800:8000)))))
+
+% save coeffs to a C header file
+
+f=fopen("../src/ht_coeff.h","wt");
+fprintf(f,"/* Hilbert Transform FIR filter coeffs */\n");
+fprintf(f,"/* Generated by make_hilb Octave script */\n");
+
+fprintf(f,"\n#define HT_N %d\n\n", ht_n);
+
+fprintf(f,"COMP ht_coeff[]={\n");
+for r=1:ht_n
+  if r < ht_n
+    fprintf(f, "  {%f,%f},\n",  real(ht_coeff(r)), imag(ht_coeff(r)));
+  else
+    fprintf(f, "  {%f,%f}\n};", real(ht_coeff(r)), imag(ht_coeff(r)));
+  end
+end
+
+fclose(f);
index 5da70d68cf7e99e6602a948280cf5f16f9339cc6..9f565a5652fe43af4b71699b2423840e0f2422f7 100644 (file)
 %      + however other filters may have other effects, should test this, 
 %        e.g. scatter plots, some sort of BER metric?
 %  [ ] pilot based EsNo estimation
+%  [ ] filter reqd with compression?
+%      + make sure not too much noise passed into noise floor
 %  [ ] different diversity combination
+%  [ ] histogram of bit errors
+%      + lot of data
+%      + ssb filter
+%      + compression
+%      + make sure it's flat with many errors
 
 graphics_toolkit ("gnuplot");
 more off;
@@ -57,14 +64,14 @@ randn('state',1);
 % select which test  ----------------------------------------------------------
 
 %test = 'compare to c';
-%test = 'awgn';
-test = 'fading';
+test = 'awgn';
+%test = 'fading';
 
 % some parameters that can be over ridden, e.g. to disable parts of modem
 
 initial_sync = 0;  % setting this to 1 put us straight into sync w/o freq offset est
 ftrack_en    = 1;  % set to 1 to enable freq tracking
-ssb_tx_filt  = 1;  % set to 1 to to simulate SSB tx filter with passband ripple
+ssb_tx_filt  = 0;  % set to 1 to to simulate SSB tx filter with passband ripple
 Fs           = 7500;
 
 % predefined tests ....
@@ -84,10 +91,10 @@ end
 % should be BER around 0.015 to 0.02
 
 if strcmp(test, 'awgn')
-  frames = 100;
+  frames = 10;
   foff =  0;
   dfoff = -0/Fs;
-  EsNodB = 8;
+  EsNodB = 80;
   fading_en = 0;
   hf_delay_ms = 2;
   compare_with_c = 0;
@@ -350,6 +357,8 @@ while tin < length(ch_fdm_frame_log)
 end
 ch_fdm_frame_log = ch_fdm_frame_log_out(1:tout-1);
 
+%ch_fdm_frame_log = real(ch_fdm_frame_log);
+
 % Now run demod ----------------------------------------------------------------
 
 ch_fdm_frame_log_index = 1;
index 30b26513eae182b9b56e30f5af3b25e5bf98bb49..fbf7e3e6f08504c58a8e14ea2e9b5b124fae8e93 100644 (file)
@@ -287,6 +287,9 @@ target_link_libraries(cohpsk_get_test_bits ${CMAKE_REQUIRED_LIBRARIES} codec2)
 add_executable(cohpsk_put_test_bits cohpsk_put_test_bits.c)
 target_link_libraries(cohpsk_put_test_bits ${CMAKE_REQUIRED_LIBRARIES} codec2)
 
+add_executable(cohpsk_ch cohpsk_ch.c)
+target_link_libraries(cohpsk_ch ${CMAKE_REQUIRED_LIBRARIES} codec2)
+
 install(TARGETS codec2 EXPORT codec2-config
     LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
index aa1ccbb2e9d351a8422b2b004d0f5598a4a3ae96..387e75a62d02faf1000d2d873798a4cefcf78571 100644 (file)
@@ -35,7 +35,6 @@
 #define COHPSK_FS               7500              /* note this is a wierd value to get an integer oversampling rate */
 
 #include "comp.h"
-#include "codec2_fdmdv.h"
 
 struct COHPSK;
 
diff --git a/codec2-dev/src/cohpsk_ch.c b/codec2-dev/src/cohpsk_ch.c
new file mode 100644 (file)
index 0000000..78f36c1
--- /dev/null
@@ -0,0 +1,283 @@
+/*---------------------------------------------------------------------------*\
+                                                                             
+  FILE........: cohpsk_ch.c
+  AUTHOR......: David Rowe  
+  DATE CREATED: May 2015
+                                                                             
+  Channel impairment program for testing command line versions of
+  cohpsk modem.
+     
+  TODO: 
+    [ ] measure and prints pwrs to check, prints warning
+    [ ] SNR in 3000Hz input
+    [ ] example operation with sox for sample rate change
+    [ ] way to calibrate for different input pwrs
+    [ ] HT to do real->complex
+        [ ] check no BER hit just through HT
+        [ ] unit test HT
+    [ ] clipping detect
+
+\*---------------------------------------------------------------------------*/
+
+/*
+  Copyright (C) 2015 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_cohpsk.h"
+#include "comp_prim.h"
+#include "../unittest/noise_samples.h"
+#include "ht_coeff.h"
+#include "codec2_fdmdv.h"
+
+#define BUF_N        160
+#define HF_DELAY_MS  2.0
+
+/* This file gets generated using the function write_noise_file in tcohpsk.m.  You have to run
+   tcohpsk first (any variant) to load the function into Octave, e.g.:
+
+  octave:17> tcohpsk
+  octave:18> write_noise_file("../raw/fading_samples.float", 7500, 7500*60)
+*/
+
+#define FADING_FILE_NAME "../../raw/fading_samples.float"
+
+int main(int argc, char *argv[])
+{
+    FILE          *fin, *ffading, *fout;
+    float          EsNodB, foff_hz;
+    int            fading_en, nhfdelay;
+
+    short          buf[BUF_N];
+    float          htbuf[HT_N+BUF_N];
+    COMP           ch_in[BUF_N];
+    COMP           ch_fdm[BUF_N];
+                                           
+    COMP           phase_ch;
+    int            noise_r, noise_end;
+    float          EsNo, variance;
+    COMP           scaled_noise;
+    float          hf_gain;
+    COMP          *ch_fdm_delay, aspread, aspread_2ms, delayed, direct;
+    float          tx_pwr, rx_pwr, noise_pwr;
+    int            frames, i, j, k, ret;
+    float          sam;
+
+    if (argc == 6) {
+        if (strcmp(argv[1], "-")  == 0) fin = stdin;
+        else if ( (fin = fopen(argv[1],"rb")) == NULL ) {
+            fprintf(stderr, "Error opening input modem raw file: %s: %s.\n",
+                    argv[1], strerror(errno));
+            exit(1);
+        }
+
+        if (strcmp(argv[2], "-") == 0) fout = stdout;
+        else if ( (fout = fopen(argv[2],"wb")) == NULL ) {
+            fprintf(stderr, "Error opening output modem raw file: %s: %s.\n",
+                    argv[2], strerror(errno));
+            exit(1);
+        }
+
+        EsNodB = atof(argv[3]);
+        foff_hz = atof(argv[4]);
+        fading_en = atoi(argv[5]);
+    }
+    else {
+        fprintf(stderr, "usage: %s InputRealModemRawFileFs7500Hz OutputRealModemRawFileFs7500Hz SNR3000Hz FoffHz FadingEn\n", argv[0]);
+        exit(1);
+    }
+    fprintf(stderr, "EsNodB: %4.2f foff: %4.2f Hz fading: %d\n", EsNodB, foff_hz, fading_en);
+    
+    phase_ch.real = 1.0; phase_ch.imag = 0.0; 
+    noise_r = 0; 
+    noise_end = sizeof(noise)/sizeof(COMP);
+
+    /*  each carrier has power = 2, total power 2Nc, total symbol rate
+        NcRs, noise BW B=Fs Es/No = (C/Rs)/(N/B), N = var =
+        2NcFs/NcRs(Es/No) = 2Fs/Rs(Es/No) */
+
+    EsNo = pow(10.0, EsNodB/10.0);
+    variance = 2.0*COHPSK_FS/(COHPSK_RS*EsNo);
+    
+    tx_pwr = rx_pwr = noise_pwr = 0.0;
+
+    /* init HF fading model */
+
+    if (fading_en) {
+        ffading = fopen(FADING_FILE_NAME, "rb");
+        if (ffading == NULL) {
+            printf("Can't find fading file: %s\n", FADING_FILE_NAME);
+            exit(1);
+        }
+        nhfdelay = floor(HF_DELAY_MS*COHPSK_FS/1000);
+        ch_fdm_delay = (COMP*)malloc((nhfdelay+COHPSK_SAMPLES_PER_FRAME)*sizeof(COMP));
+        assert(ch_fdm_delay != NULL);
+        for(i=0; i<nhfdelay+COHPSK_SAMPLES_PER_FRAME; i++) {
+            ch_fdm_delay[i].real = 0.0;
+            ch_fdm_delay[i].imag = 0.0;
+        }
+
+        /* first values in file are HF gains */
+
+        for (i=0; i<4; i++)
+            ret = fread(&hf_gain, sizeof(float), 1, ffading);
+        fprintf(stderr, "hf_gain: %f\n", hf_gain);
+    }
+
+    for(i=0; i<HT_N; i++) {
+        htbuf[i] = 0.0;
+    }
+
+    /* --------------------------------------------------------*\
+                                 Main Loop
+    \*---------------------------------------------------------*/
+    
+    while(fread(buf, sizeof(short), BUF_N, fin) == BUF_N) {
+       frames++;
+
+        /* Hilbert Transform to produce complex signal so we can do
+           single sided freq shifts.  Allows us to use real signal I/O
+           which is handy */
+
+        for(i=0, j=HT_N; i<BUF_N; i++,j++) {
+
+            /* 
+               Hilbert Transform to produce complex signal so we can do
+               single sided freq shifts.  Essential filters out negative
+               freqencies.
+            */
+
+            htbuf[j] = (float)buf[i]/FDMDV_SCALE;
+
+            /* FIR filter with HT to get imag, just delay to get real */
+
+            ch_in[i].real = 0.0;
+            ch_in[i].imag = 0.0;
+            for(k=0; k<HT_N; k++) {
+                ch_in[i].real += htbuf[j-k]*ht_coeff[k].real;
+                ch_in[i].imag += htbuf[j-k]*ht_coeff[k].imag;
+            }
+            //printf("%d %f %f\n", i, ch_in[i].real, ch_in[i].imag);
+        }
+        assert(j <= (BUF_N+HT_N));
+        
+        /* update HT memory */
+
+        for(i=0; i<HT_N; i++)
+           htbuf[i] = htbuf[i+BUF_N];
+
+        for(i=0; i<BUF_N; i++) {
+            //printf("%d %f %f\n", i, ch_in[i].real, ch_in[i].imag);
+            tx_pwr += pow(ch_in[i].real, 2.0) + pow(ch_in[i].imag, 2.0);
+        }
+
+        /* +3dB factor is beacuse we ouput a real signal, this has half
+           the power of the complex version but as the noise reflects
+           across from the -ve side the same noise power. */
+
+        for(i=0; i<BUF_N; i++) {
+            ch_in[i] = fcmult(sqrt(2.0), ch_in[i]);
+        }
+
+       /* --------------------------------------------------------*\
+                                 Channel
+       \*---------------------------------------------------------*/
+
+        fdmdv_freq_shift(ch_fdm, ch_in, foff_hz, &phase_ch, BUF_N);
+
+        /* optional HF fading -------------------------------------*/
+
+        if (fading_en) {
+
+            /* update delayed signal buffer */
+
+            for(i=0; i<nhfdelay; i++)
+                ch_fdm_delay[i] = ch_fdm_delay[i+BUF_N];
+            for(j=0; j<BUF_N; i++, j++)
+                ch_fdm_delay[i] = ch_fdm[j];
+
+            /* combine direct and delayed paths, both multiplied by
+               "spreading" (doppler) functions */
+
+            for(i=0; i<BUF_N; i++) {
+                ret = fread(&aspread, sizeof(COMP), 1, ffading);
+                assert(ret == 1);
+                ret = fread(&aspread_2ms, sizeof(COMP), 1, ffading);
+                assert(ret == 1);
+                //printf("%f %f %f %f\n", aspread.real, aspread.imag, aspread_2ms.real, aspread_2ms.imag);
+                
+                direct    = cmult(aspread, ch_fdm[i]);
+                delayed   = cmult(aspread_2ms, ch_fdm_delay[i]);
+                ch_fdm[i] = fcmult(hf_gain, cadd(direct, delayed));
+            }
+        }
+
+        /* we only output the real signal, which is half the power. */
+
+        for(i=0; i<BUF_N; i++) {
+            rx_pwr += pow(ch_fdm[i].real, 2.0);
+        }
+
+        /* AWGN noise ------------------------------------------*/
+
+        for(i=0; i<BUF_N; i++) {
+            scaled_noise = fcmult(sqrt(variance), noise[noise_r]);
+            ch_fdm[i] = cadd(ch_fdm[i], scaled_noise);
+            noise_pwr += pow(noise[noise_r].real, 2.0) + pow(noise[noise_r].imag, 2.0);
+            noise_r++;
+            if (noise_r > noise_end) {
+                noise_r = 0;
+                //fprintf(stderr, "  [%d] noise wrap\n", f);            
+            }
+               
+        }
+
+       /* scale and save to disk as shorts */
+
+       for(i=0; i<BUF_N; i++) {
+            sam = FDMDV_SCALE * ch_fdm[i].real;
+            if (fabs(sam) > 32767.0)
+                fprintf(stderr,"clipping: %f\n", sam);
+           buf[i] = sam;
+        }
+
+       fwrite(buf, sizeof(short), BUF_N, fout);
+
+       /* if this is in a pipeline, we probably don't want the usual
+          buffering to occur */
+
+        if (fout == stdout) fflush(stdout);
+        if (fin == stdin) fflush(stdin);         
+    }
+
+    fclose(fin);
+    fclose(fout);
+
+    fprintf(stderr, "tx var: %f noise var: %f rx var: %f\n", 
+           tx_pwr/(frames*BUF_N), 
+           noise_pwr/(frames*BUF_N),
+           rx_pwr/(frames*BUF_N) 
+           );
+
+    return 0;
+}
+
index b4bbed3f8e4607a0ef40eb67264f10b818a3d0db..fdac1a9471ed8f845b826ab940f471696ef5628d 100644 (file)
@@ -34,6 +34,7 @@
 #include <errno.h>
 
 #include "codec2_cohpsk.h"
+#include "codec2_fdmdv.h"
 
 int main(int argc, char *argv[])
 {
@@ -42,7 +43,7 @@ int main(int argc, char *argv[])
     int           rx_bits[COHPSK_BITS_PER_FRAME];
     COMP          rx_fdm[COHPSK_SAMPLES_PER_FRAME];
     short         rx_fdm_scaled[COHPSK_SAMPLES_PER_FRAME];
-    int           frames, reliable_sync_bit;
+    int           frames, reliable_sync_bit, nin_frame;
     int           i;
 
     if (argc < 3) {
@@ -68,19 +69,21 @@ int main(int argc, char *argv[])
 
     frames = 0;
 
-    while(fread(rx_fdm_scaled, sizeof(short), COHPSK_SAMPLES_PER_FRAME, fin) == COHPSK_SAMPLES_PER_FRAME) {
+    nin_frame = COHPSK_SAMPLES_PER_FRAME;
+    while(fread(rx_fdm_scaled, sizeof(short), nin_frame, fin) == nin_frame) {
        frames++;
 
        /* scale and demod */
 
-       for(i=0; i<COHPSK_SAMPLES_PER_FRAME; i++) {
+       for(i=0; i<nin_frame; i++) {
            rx_fdm[i].real = rx_fdm_scaled[i]/FDMDV_SCALE;
             rx_fdm[i].imag = 0.0;
         }
 
-       cohpsk_demod(cohpsk, rx_bits, &reliable_sync_bit, rx_fdm);
+       cohpsk_demod(cohpsk, rx_bits, &reliable_sync_bit, rx_fdm, &nin_frame);
 
-       fwrite(rx_bits, sizeof(int), COHPSK_BITS_PER_FRAME, fout);
+       if (reliable_sync_bit)
+            fwrite(rx_bits, sizeof(int), COHPSK_BITS_PER_FRAME, fout);
 
        /* if this is in a pipeline, we probably don't want the usual
           buffering to occur */
index 2aa054e4514761dbf9505f874d81a742c41eba90..1cbe375a900c5c9b3c530b9665c4cc1461b26a2c 100644 (file)
@@ -35,6 +35,7 @@
 #include <errno.h>
 
 #include "codec2_cohpsk.h"
+#include "codec2_fdmdv.h"
 
 int main(int argc, char *argv[])
 {
@@ -73,6 +74,7 @@ int main(int argc, char *argv[])
        frames++;
 
        cohpsk_mod(cohpsk, tx_fdm, tx_bits);
+        cohpsk_clip(tx_fdm);
 
        /* scale and save to disk as shorts */
 
index 7b369e897d202a552b5d18a6c49378ccd1bbadc4..3a2d85e0e658340f19356d591b5723209ef73f04 100644 (file)
@@ -42,8 +42,11 @@ int main(int argc, char *argv[])
     FILE         *fin;
     int           rx_bits[COHPSK_BITS_PER_FRAME];
     int           *ptest_bits_coh, *ptest_bits_coh_end;
-    int           state, next_state, i, nbits, nerrors;
-    float         corr;
+    int           state, next_state, i, nbits, errors, nerrors;
+    int           error_positions_hist[COHPSK_BITS_PER_FRAME];
+
+    for(i=0; i<COHPSK_BITS_PER_FRAME; i++)
+        error_positions_hist[i] = 0;
 
     if (argc < 2) {
        printf("usage: %s InputOneBitPerIntFile\n", argv[0]);
@@ -62,9 +65,13 @@ int main(int argc, char *argv[])
 
     while (fread(rx_bits, sizeof(int), COHPSK_BITS_PER_FRAME, fin) ==  COHPSK_BITS_PER_FRAME) {
 
-        corr = 0.0;
+        errors = 0;
         for(i=0; i<COHPSK_BITS_PER_FRAME; i++) {
-            corr += (1.0 - 2.0*(rx_bits[i] & 0x1)) * (1.0 - 2.0*ptest_bits_coh[i]);
+            errors += (rx_bits[i] & 0x1) ^ ptest_bits_coh[i];
+            if (state == 1) {
+                if ((rx_bits[i] & 0x1) ^ ptest_bits_coh[i])
+                    error_positions_hist[i]++;
+            }
         }
 
         /* state logic */
@@ -72,17 +79,16 @@ int main(int argc, char *argv[])
         next_state = state;
 
         if (state == 0) {
-            fprintf(stderr, "corr %f\n", corr);            
-            if (corr == COHPSK_BITS_PER_FRAME) {
+            if (errors < 4) {
                 next_state = 1;
                 ptest_bits_coh += COHPSK_BITS_PER_FRAME;
-                nerrors = COHPSK_BITS_PER_FRAME - corr;
+                nerrors = errors;
                 nbits = COHPSK_BITS_PER_FRAME;
             }
         }
 
         if (state == 1) {
-            nerrors += COHPSK_BITS_PER_FRAME - corr;
+            nerrors += errors;
             nbits   += COHPSK_BITS_PER_FRAME;
             ptest_bits_coh += COHPSK_BITS_PER_FRAME;
             if (ptest_bits_coh >= ptest_bits_coh_end) {
@@ -96,7 +102,7 @@ int main(int argc, char *argv[])
     }
 
     fclose(fin);
-    printf("BER: %3.2f Nbits: %d Nerrors: %d\n", (float)nerrors/nbits, nbits, nerrors);
+    printf("BER: %4.3f Nbits: %d Nerrors: %d\n", (float)nerrors/nbits, nbits, nerrors);
 
     return 0;
 }
diff --git a/codec2-dev/src/ht_coeff.h b/codec2-dev/src/ht_coeff.h
new file mode 100644 (file)
index 0000000..98c5c6e
--- /dev/null
@@ -0,0 +1,107 @@
+/* Hilbert Transform FIR filter coeffs */
+/* Generated by make_hilb Octave script */
+
+#define HT_N 100
+
+COMP ht_coeff[]={
+  {0.000000,0.000000},
+  {-0.000000,-0.000001},
+  {0.000000,0.000000},
+  {-0.000000,-0.000017},
+  {0.000000,0.000000},
+  {0.000000,-0.000079},
+  {0.000000,0.000000},
+  {0.000000,-0.000217},
+  {0.000000,0.000000},
+  {0.000000,-0.000461},
+  {0.000000,0.000000},
+  {-0.000000,-0.000842},
+  {0.000000,0.000000},
+  {-0.000000,-0.001391},
+  {0.000000,0.000000},
+  {-0.000000,-0.002140},
+  {0.000000,0.000000},
+  {-0.000000,-0.003121},
+  {0.000000,0.000000},
+  {0.000000,-0.004371},
+  {0.000000,0.000000},
+  {0.000000,-0.005928},
+  {0.000000,0.000000},
+  {-0.000000,-0.007839},
+  {0.000000,0.000000},
+  {-0.000000,-0.010159},
+  {0.000000,0.000000},
+  {-0.000000,-0.012957},
+  {0.000000,0.000000},
+  {-0.000000,-0.016327},
+  {0.000000,0.000000},
+  {0.000000,-0.020399},
+  {0.000000,0.000000},
+  {-0.000000,-0.025364},
+  {0.000000,0.000000},
+  {0.000000,-0.031512},
+  {0.000000,0.000000},
+  {0.000000,-0.039319},
+  {0.000000,0.000000},
+  {0.000000,-0.049610},
+  {0.000000,0.000000},
+  {-0.000000,-0.063952},
+  {0.000000,0.000000},
+  {-0.000000,-0.085722},
+  {0.000000,0.000000},
+  {0.000000,-0.123718},
+  {0.000000,0.000000},
+  {0.000000,-0.210249},
+  {0.000000,0.000000},
+  {-0.000000,-0.636250},
+  {0.999748,0.000000},
+  {0.000000,0.634969},
+  {0.000000,0.000000},
+  {0.000000,0.208979},
+  {0.000000,0.000000},
+  {0.000000,0.122467},
+  {0.000000,0.000000},
+  {-0.000000,0.084502},
+  {0.000000,0.000000},
+  {0.000000,0.062771},
+  {0.000000,0.000000},
+  {0.000000,0.048477},
+  {0.000000,0.000000},
+  {0.000000,0.038242},
+  {0.000000,0.000000},
+  {-0.000000,0.030497},
+  {0.000000,0.000000},
+  {0.000000,0.024418},
+  {0.000000,0.000000},
+  {0.000000,0.019527},
+  {0.000000,0.000000},
+  {-0.000000,0.015532},
+  {0.000000,0.000000},
+  {0.000000,0.012242},
+  {0.000000,0.000000},
+  {-0.000000,0.009524},
+  {0.000000,0.000000},
+  {-0.000000,0.007285},
+  {0.000000,0.000000},
+  {-0.000000,0.005454},
+  {0.000000,0.000000},
+  {-0.000000,0.003973},
+  {0.000000,0.000000},
+  {0.000000,0.002796},
+  {0.000000,0.000000},
+  {-0.000000,0.001882},
+  {0.000000,0.000000},
+  {-0.000000,0.001196},
+  {0.000000,0.000000},
+  {-0.000000,0.000701},
+  {0.000000,0.000000},
+  {0.000000,0.000367},
+  {0.000000,0.000000},
+  {0.000000,0.000160},
+  {0.000000,0.000000},
+  {0.000000,0.000051},
+  {0.000000,0.000000},
+  {-0.000000,0.000008},
+  {0.000000,0.000000},
+  {0.000000,0.000000}
+};
\ No newline at end of file
index 6f9ae139b2f322eee7e5f748a2a250aec9877c61..82530265997c07b81c76bcc31007d4d39035171c 100644 (file)
@@ -88,7 +88,7 @@ int main(int argc, char *argv[])
     int            ch_buf_n;
     float          tx_pwr, rx_pwr, noise_pwr;
     int            error_positions_hist[COHPSK_BITS_PER_FRAME];
-    int            log_data_r, c, j, tmp;
+    int            log_data_r, c, j, tmp, ret;
 
     for(i=0; i<COHPSK_BITS_PER_FRAME; i++)
         error_positions_hist[i] = 0;
@@ -218,8 +218,8 @@ int main(int argc, char *argv[])
             }
         }
 
-        for(r=0; r<COHPSK_SAMPLES_PER_FRAME; r++) {
-            rx_pwr += pow(ch_fdm[r].real, 2.0) + pow(ch_fdm[r].imag, 2.0);
+        for(i=0; i<COHPSK_SAMPLES_PER_FRAME; i++) {
+            rx_pwr += pow(ch_fdm[i].real, 2.0) + pow(ch_fdm[i].imag, 2.0);
         }
 
         /* AWGN noise ------------------------------------------*/