Difference between revisions of "GNU Radio Notes"

From SpenchWiki
Jump to: navigation, search
Line 1: Line 1:
* gr_fft_vcc (gr_fft_vcc_fftw): '''shift''' parameter swaps two halves of frequency-domain data. Enabled by default, so forward transform ends up having DC in centre of array (like in FFT Sink), which would otherwise be in the first element, and first negative would be in the last element.
+
== gr_fft_vcc ==
  
* gr_diff_phasor_cc.cc:
+
gr_fft_vcc_fftw.cc: '''shift''' parameter swaps two halves of frequency-domain data. Enabled by default, so forward transform ends up having DC in centre of array (like in FFT Sink), which would otherwise be in the first element, and first negative would be in the last element.
  
 +
== gr_diff_phasor_cc ==
 +
 +
gr_diff_phasor_cc.cc:
 +
 +
<syntaxhighlight lang="cpp">
 
  out[i] = in[i] * conj(in[i-1]);
 
  out[i] = in[i] * conj(in[i-1]);
 +
</syntaxhighlight>
  
* gr_quadrature_demod_cf.cc:
+
== gr_quadrature_demod_cf ==
  
 +
gr_quadrature_demod_cf.cc:
 +
 +
<syntaxhighlight lang="cpp">
 
  gr_complex product = in[i] * conj (in[i-1]);
 
  gr_complex product = in[i] * conj (in[i-1]);
 
  out[i] = d_gain * gr_fast_atan2f(imag(product), real(product));
 
  out[i] = d_gain * gr_fast_atan2f(imag(product), real(product));
 +
</syntaxhighlight>
 +
 +
== Random Source ==
  
* Random Source:
 
 
** When '''Byte''', full range (min/max) is 0-255.
 
** When '''Byte''', full range (min/max) is 0-255.
  
* GLFSR Source:
+
== GLFSR Source ==
 +
 
 
** Outputs unpacked bytes (1 bit per byte), so need to use ''Unpacked to Packed'' to re-assemble bytes.
 
** Outputs unpacked bytes (1 bit per byte), so need to use ''Unpacked to Packed'' to re-assemble bytes.
 
** '''Degree''' defines length of sequence before repeating as 2^degree-1. Also selects pre-defined polynomial bit-mask of same degree if '''Mask''' is 0.
 
** '''Degree''' defines length of sequence before repeating as 2^degree-1. Also selects pre-defined polynomial bit-mask of same degree if '''Mask''' is 0.
Line 53: Line 65:
 
   0x80000057 // x^32 + x^7 + x^5 + x^3 + x^2 + x^1 + 1
 
   0x80000057 // x^32 + x^7 + x^5 + x^3 + x^2 + x^1 + 1
  
* 8psk_mod (8psk.py): Last block is
+
== 8psk_mod ==
 +
 
 +
8psk.py: Last block is
 
  r.unpack_k_bits_bb(self.bits_per_symbol())
 
  r.unpack_k_bits_bb(self.bits_per_symbol())
 
so each output symbol is unpacked into 1-bit per byte. Re-assembly with baz.unpacked_to_packed_bb(1, <bits per symbol>)
 
so each output symbol is unpacked into 1-bit per byte. Re-assembly with baz.unpacked_to_packed_bb(1, <bits per symbol>)
  
* gr_cpfsk_bc: Expects 1-bit per byte input stream.
+
== gr_cpfsk_bc ==
 +
 
 +
Expects 1-bit per byte input stream.
 +
 
 +
<syntaxhighlight lang="cpp">
 
  d_freq = k*M_PI/samples_per_sym;
 
  d_freq = k*M_PI/samples_per_sym;
<syntaxhighlight lang="cpp">
+
 
 
for (int i = 0; i < noutput_items/d_samples_per_sym; i++) {
 
for (int i = 0; i < noutput_items/d_samples_per_sym; i++) {
 
     for (int j = 0; j < d_samples_per_sym; j++) {
 
     for (int j = 0; j < d_samples_per_sym; j++) {

Revision as of 15:01, 3 August 2011

gr_fft_vcc

gr_fft_vcc_fftw.cc: shift parameter swaps two halves of frequency-domain data. Enabled by default, so forward transform ends up having DC in centre of array (like in FFT Sink), which would otherwise be in the first element, and first negative would be in the last element.

gr_diff_phasor_cc

gr_diff_phasor_cc.cc:

 out[i] = in[i] * conj(in[i-1]);

gr_quadrature_demod_cf

gr_quadrature_demod_cf.cc:

 gr_complex product = in[i] * conj (in[i-1]);
 out[i] = d_gain * gr_fast_atan2f(imag(product), real(product));

Random Source

    • When Byte, full range (min/max) is 0-255.

GLFSR Source

    • Outputs unpacked bytes (1 bit per byte), so need to use Unpacked to Packed to re-assemble bytes.
    • Degree defines length of sequence before repeating as 2^degree-1. Also selects pre-defined polynomial bit-mask of same degree if Mask is 0.
    • Mask is XOR'd with shift register after each time LSBit that is shifted off is 1 (if 0, selects pre-defined polynomal based of Degree).
    • Seed sets initial state of shift register.
 0x00000000,
 0x00000001,			// x^1 + 1
 0x00000003,                   // x^2 + x^1 + 1
 0x00000005,                   // x^3 + x^1 + 1
 0x00000009,			// x^4 + x^1 + 1
 0x00000012,			// x^5 + x^2 + 1
 0x00000021,			// x^6 + x^1 + 1
 0x00000041,                   // x^7 + x^1 + 1
 0x0000008E,			// x^8 + x^4 + x^3 + x^2 + 1
 0x00000108,			// x^9 + x^4 + 1
 0x00000204,			// x^10 + x^4 + 1
 0x00000402,			// x^11 + x^2 + 1
 0x00000829,			// x^12 + x^6 + x^4 + x^1 + 1
 0x0000100D,			// x^13 + x^4 + x^3 + x^1 + 1
 0x00002015,			// x^14 + x^5 + x^3 + x^1 + 1
 0x00004001,			// x^15 + x^1 + 1
 0x00008016,			// x^16 + x^5 + x^3 + x^2 + 1
 0x00010004,			// x^17 + x^3 + 1
 0x00020013,			// x^18 + x^5 + x^2 + x^1 + 1
 0x00040013,			// x^19 + x^5 + x^2 + x^1 + 1
 0x00080004,			// x^20 + x^3 + 1
 0x00100002,			// x^21 + x^2 + 1
 0x00200001,			// x^22 + x^1 + 1
 0x00400010,			// x^23 + x^5 + 1
 0x0080000D,			// x^24 + x^4 + x^3 + x^1 + 1
 0x01000004,			// x^25 + x^3 + 1
 0x02000023,			// x^26 + x^6 + x^2 + x^1 + 1
 0x04000013,			// x^27 + x^5 + x^2 + x^1 + 1
 0x08000004,			// x^28 + x^3 + 1
 0x10000002,			// x^29 + x^2 + 1
 0x20000029,			// x^30 + x^4 + x^1 + 1
 0x40000004,			// x^31 + x^3 + 1
 0x80000057			// x^32 + x^7 + x^5 + x^3 + x^2 + x^1 + 1

8psk_mod

8psk.py: Last block is

r.unpack_k_bits_bb(self.bits_per_symbol())

so each output symbol is unpacked into 1-bit per byte. Re-assembly with baz.unpacked_to_packed_bb(1, <bits per symbol>)

gr_cpfsk_bc

Expects 1-bit per byte input stream.

 d_freq = k*M_PI/samples_per_sym;

for (int i = 0; i < noutput_items/d_samples_per_sym; i++) {
    for (int j = 0; j < d_samples_per_sym; j++) {
      if (in[i] == 1)
	d_phase += d_freq;
      else
	d_phase -= d_freq;
      
      while (d_phase > M_TWOPI)
	d_phase -= M_TWOPI;
      while (d_phase < -M_TWOPI)
	d_phase += M_TWOPI;
      
      *out++ = gr_expj(d_phase)*d_ampl;
    }
  }