commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r3614 - gnuradio/branches/developers/jcorgan/pager/gr-


From: jcorgan
Subject: [Commit-gnuradio] r3614 - gnuradio/branches/developers/jcorgan/pager/gr-pager/src
Date: Fri, 22 Sep 2006 11:12:16 -0600 (MDT)

Author: jcorgan
Date: 2006-09-22 11:12:15 -0600 (Fri, 22 Sep 2006)
New Revision: 3614

Modified:
   gnuradio/branches/developers/jcorgan/pager/gr-pager/src/flex_demod.py
   
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/pager_flex_deinterleave.cc
   gnuradio/branches/developers/jcorgan/pager/gr-pager/src/pager_flex_sync.cc
   gnuradio/branches/developers/jcorgan/pager/gr-pager/src/pageri_bch3221.cc
   gnuradio/branches/developers/jcorgan/pager/gr-pager/src/usrp_flex.py
Log:
Work in progress.  The new sync and deinterleave blocks
appear to be generating proper output in the sense that
the FLEX blocks appear to be properly boundary aligned
and visible idle codewords show up in the right places.


Modified: gnuradio/branches/developers/jcorgan/pager/gr-pager/src/flex_demod.py
===================================================================
--- gnuradio/branches/developers/jcorgan/pager/gr-pager/src/flex_demod.py       
2006-09-22 07:39:12 UTC (rev 3613)
+++ gnuradio/branches/developers/jcorgan/pager/gr-pager/src/flex_demod.py       
2006-09-22 17:12:15 UTC (rev 3614)
@@ -23,7 +23,7 @@
 from math import pi
 import pager_swig
 
-class flex_demod(gr.hier_block):
+class flex_demod:
     """
     FLEX protocol demodulation block.
 
@@ -47,20 +47,29 @@
     def __init__(self, fg, channel_rate):
         k = channel_rate/(2*pi*4800)        # 4800 Hz max deviation
         QUAD = gr.quadrature_demod_cf(k)
-
+       # Hack until fg converges back to one output and we can make a 
+       # hier_block again.
+       self.INPUT = QUAD 
+       
         taps = optfir.low_pass(1.0, channel_rate, 3200, 6400, 0.1, 60)
         LPF = gr.fir_filter_fff(1, taps)
         SLICER = pager_swig.slicer_fb(.001, .00001) # Attack, decay
        SYNC = pager_swig.flex_sync(channel_rate)
-       DEINTA = pager_swig.flex_deinterleave()
-       DEINTB = pager_swig.flex_deinterleave()
-       DEINTC = pager_swig.flex_deinterleave()
-       DEINTD = pager_swig.flex_deinterleave()
+       self.DEINTA = pager_swig.flex_deinterleave()
+       self.DEINTB = pager_swig.flex_deinterleave()
+       self.DEINTC = pager_swig.flex_deinterleave()
+       self.DEINTD = pager_swig.flex_deinterleave()
 
         fg.connect(QUAD, LPF, SLICER, SYNC)
-       fg.connect((SYNC, 0), DEINTA)
-       fg.connect((SYNC, 1), DEINTB)
-       fg.connect((SYNC, 2), DEINTC)
-       fg.connect((SYNC, 3), DEINTD)
-       
-        gr.hier_block.__init__(self, fg, QUAD, (DEINTA, DEINTB, DEINTC, 
DEINTD))
+       fg.connect((SYNC, 0), self.DEINTA)
+       fg.connect((SYNC, 1), self.DEINTB)
+       fg.connect((SYNC, 2), self.DEINTC)
+       fg.connect((SYNC, 3), self.DEINTD)
+
+       # Hack until fg converges back to one output and we can make a 
+       # hier_block again.
+       self.OUTPUTA = self.DEINTA
+       self.OUTPUTB = self.DEINTB
+       self.OUTPUTC = self.DEINTC
+       self.OUTPUTD = self.DEINTD
+               
\ No newline at end of file

Modified: 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/pager_flex_deinterleave.cc
===================================================================
--- 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/pager_flex_deinterleave.cc
  2006-09-22 07:39:12 UTC (rev 3613)
+++ 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/pager_flex_deinterleave.cc
  2006-09-22 17:12:15 UTC (rev 3614)
@@ -23,7 +23,8 @@
 #include "config.h"
 #endif
 
-#include "pager_flex_deinterleave.h"
+#include <pager_flex_deinterleave.h>
+#include <pageri_bch3221.h>
 #include <gr_io_signature.h>
 
 pager_flex_deinterleave_sptr pager_make_flex_deinterleave()
@@ -46,10 +47,19 @@
     const unsigned char *in = (const unsigned char *)input_items[0];
     gr_int32 *out = (gr_int32 *)output_items[0];    
 
+    // FLEX codewords are interleaved in blocks of 256 bits or 8, 32 bit
+    // codes.  To deinterleave we parcel each incoming bit into the MSB
+    // of each codeword, then switch to MSB-1, etc.  This is done by shifting
+    // in the bits from the right on each codeword as the bits come in.
+    // When we are done we have a FLEX block of eight codewords, ready for
+    // error correction.
+    //
+    // The data portion of a FLEX frame consists of 11 of these deinterleaved
+    // blocks.
+    //
     // set_output_multiple garauntees we have output space for at least
     // 8 codewords and 256 bits on input
-    //
-    // Codewords are transmitted MSB for each of 8, then MSB-1 for each, etc.
+
     int i, j;
 
     for (i = 0; i < 32; i++) {
@@ -59,9 +69,11 @@
        }
     }
 
-    // Now output codewords
-    for (j = 0; j < 8; j++)
-       *out = d_codewords[j];  
-
+    // Now output (error corrected) codewords.  
+    for (j = 0; j < 8; j++) {
+       pageri_bch3221(d_codewords[j]);
+       *out++ = d_codewords[j];        
+    }
+    
     return j;
 }

Modified: 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/pager_flex_sync.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/pager/gr-pager/src/pager_flex_sync.cc  
2006-09-22 07:39:12 UTC (rev 3613)
+++ gnuradio/branches/developers/jcorgan/pager/gr-pager/src/pager_flex_sync.cc  
2006-09-22 17:12:15 UTC (rev 3614)
@@ -25,6 +25,7 @@
 
 #include <pager_flex_sync.h>
 #include <pageri_flex_modes.h>
+#include <pageri_bch3221.h>
 #include <gr_io_signature.h>
 #include <gr_count_bits.h>
 
@@ -137,7 +138,7 @@
 {
     d_state = ST_SYNC1;
     d_end = d_index;
-    d_center = index_avg(d_start, d_end);
+    d_center = index_avg(d_start, d_end); // Center of goodness
     d_count = 0;
     printf("SYNC1=%08X ", flex_modes[d_mode].sync);
 }
@@ -153,9 +154,14 @@
     if (d_baudrate == 3200) {
         // Oversampling buffer just got halved
         d_center = d_center/2;
-        d_index = d_index/2-d_spb/2; // We're here at the center of a 1600 
baud bit
-        d_count = -1;                // So this hack gets us in the right 
place for 3200
-    }                               // I suspect this isn't quite right :(
+
+       // We're here at the center of a 1600 baud bit
+       // So this hack puts the index and bit counter
+       // in the right place for 3200 bps.
+       // I suspect this isn't quite right :(
+        d_index = d_index/2-d_spb/2;         
+       d_count = -1;                
+    }                               
 }
 
 void pager_flex_sync::enter_data()
@@ -177,6 +183,7 @@
 void print_fiw(gr_int32 fiw)
 {
     // Bits 31-28 are frame number related, but unknown function
+    // This might be a checksum
     int unknown2 = reverse_bits8((fiw >> 24) & 0xF0);
        
     // Cycle is bits 27-24, reversed
@@ -185,7 +192,8 @@
     // Frame is bits 23-17, reversed
     int frame = reverse_bits8((fiw >> 16) & 0xFE);
 
-    // Bits 16-11 are some sort of marker
+    // Bits 16-11 are some sort of marker, usually identical across
+    // many frames but sometimes changes between frames or modes
     int unknown1 = (fiw >> 11) & 0x3F;
        
     // Bits 10-0 are BCH 'parity' bits, ignored
@@ -198,7 +206,33 @@
 int pager_flex_sync::output_symbol(unsigned char sym)
 {
     // Here is where we output a 1 or 0 on each phase according
-    // to current FLEX mode and symbol value
+    // to current FLEX mode and symbol value.  Unassigned phases
+    // are zero from the enter_idle() initialization.
+    //
+    // FLEX can transmit the data portion of the frame at either
+    // 1600 bps or 3200 bps, and can use either two- or four-level
+    // FSK encoding.
+    //
+    // At 1600 bps, 2-level, a single "phase" is transmitted with bit
+    // value '0' using level '3' and bit value '1' using level '0'.
+    //
+    // At 1600 bps, 4-level, a second "phase" is transmitted, and the 
+    // di-bits are encoded with a gray code:
+    //
+    // Symbol  Phase 1  Phase 2
+    // ------   -------  -------
+    //   0         1        1
+    //   1         1        0
+    //   2         0        0
+    //   3         0        1
+    //
+    // At 1600 bps, 4-level, these are called PHASE A and PHASE B.
+    //
+    // At 3200 bps, the same 1 or 2 bit encoding occurs, except that
+    // additionally two streams are interleaved on alternating symbols.
+    // Thus, PHASE A (and PHASE B if 4-level) are decoded on one symbol,
+    // then PHASE C (and PHASE D if 4-level) are decoded on the next.
+    
     int bits = 0;
     
     if (d_baudrate == 1600) {
@@ -210,7 +244,6 @@
        *d_phase_b++ = d_bit_b;
        *d_phase_c++ = d_bit_c;
        *d_phase_d++ = d_bit_d;
-       printf("%i%i%i%i\n", d_bit_a, d_bit_b, d_bit_c, d_bit_d);
        bits++;
     }
     else {
@@ -230,7 +263,6 @@
            *d_phase_b++ = d_bit_b;
            *d_phase_c++ = d_bit_c;
            *d_phase_d++ = d_bit_d;
-           printf("%i%i%i%i\n", d_bit_a, d_bit_b, d_bit_c, d_bit_d);
            bits++;
        }
     }
@@ -258,27 +290,38 @@
     
         switch (d_state) {
             case ST_IDLE:
+               // Continually compare the received symbol stream
+               // against the known FLEX sync words.
                 if (test_sync(sym))
                     enter_syncing();
                 break;
     
             case ST_SYNCING:
+               // Wait until we stop seeing sync, then calculate
+               // the center of the bit period (d_center)
                 if (!test_sync(sym))
                     enter_sync1();
                 break;
     
             case ST_SYNC1:
+               // Skip 16 bits of dotting, then accumulate 32 bits
+               // of Frame Information Word.
                 if (d_index == d_center) {
                    d_fiw = (d_fiw << 1) | (sym > 1);
-                   // Skip 16 bits of dotting, then 32 bits FIW
                     if (++d_count == 48) {
+                       // FIW is accumulated, call BCH to error correct it
+                       pageri_bch3221(d_fiw);
                         print_fiw(d_fiw);
-                        enter_sync2();   // May jump to 3200 bps now
+                        enter_sync2();  
                    }
                 }
                 break;
     
             case ST_SYNC2:
+               // This part and the remainder of the frame are transmitted
+               // at either 1600 bps or 3200 bps based on the received
+               // FLEX sync word. The second SYNC header is 25ms of idle bits
+               // at either speed.
                 if (d_index == d_center) {
                     // Skip 25 ms = 40 bits @ 1600 bps, 80 @ 3200 bps
                     if (++d_count == d_baudrate/40)
@@ -287,9 +330,12 @@
                 break;
     
             case ST_DATA:
+               // The data portion of the frame is 1760 ms long at either 
+               // baudrate.  This is 2816 bits @ 1600 bps and 5632 bits @ 3200 
bps.
+               // The output_symbol() routine decodes and doles out the bits
+               // to each of the four transmitted phases of FLEX interleaved 
codes.
                 if (d_index == d_center) {
                    j += output_symbol(sym);                
-                   // Skip 1760 ms = 2816 bits @ 1600 bps, 5632 bits @ 3200 bps
                     if (++d_count == d_baudrate*1760/1000)
                         enter_idle();
                }
@@ -304,4 +350,3 @@
     consume_each(i);
     return j;
 }
-

Modified: 
gnuradio/branches/developers/jcorgan/pager/gr-pager/src/pageri_bch3221.cc
===================================================================
--- gnuradio/branches/developers/jcorgan/pager/gr-pager/src/pageri_bch3221.cc   
2006-09-22 07:39:12 UTC (rev 3613)
+++ gnuradio/branches/developers/jcorgan/pager/gr-pager/src/pageri_bch3221.cc   
2006-09-22 17:12:15 UTC (rev 3614)
@@ -25,6 +25,11 @@
 
 #include <pageri_bch3221.h>
 
+// Corrects supplied data word according to BCH3221 encoding and
+// returns the number of errors detected/corrected.
+//
+// Not implemented yet
+
 int pageri_bch3221(gr_int32 &data)
 {
     return 0;

Modified: gnuradio/branches/developers/jcorgan/pager/gr-pager/src/usrp_flex.py
===================================================================
--- gnuradio/branches/developers/jcorgan/pager/gr-pager/src/usrp_flex.py        
2006-09-22 07:39:12 UTC (rev 3613)
+++ gnuradio/branches/developers/jcorgan/pager/gr-pager/src/usrp_flex.py        
2006-09-22 17:12:15 UTC (rev 3614)
@@ -123,11 +123,11 @@
         self.connect(USRP, CHAN)
        self.connect(CHAN, RFSQL)
        self.connect(RFSQL, AGC)
-       self.connect(AGC, FLEX)
-       self.connect((FLEX, 0), SINKA)
-       self.connect((FLEX, 1), SINKB)
-       self.connect((FLEX, 2), SINKC)
-       self.connect((FLEX, 3), SINKD)
+       self.connect(AGC, FLEX.INPUT)
+       self.connect(FLEX.OUTPUTA, SINKA)
+       self.connect(FLEX.OUTPUTB, SINKB)
+       self.connect(FLEX.OUTPUTC, SINKC)
+       self.connect(FLEX.OUTPUTD, SINKD)
        
 def main():
     parser = OptionParser(option_class=eng_option)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]