diff options
Diffstat (limited to 'gr-digital/lib')
-rw-r--r-- | gr-digital/lib/CMakeLists.txt | 3 | ||||
-rw-r--r-- | gr-digital/lib/digital_constellation.cc | 13 | ||||
-rw-r--r-- | gr-digital/lib/digital_constellation_receiver_cb.cc | 11 |
3 files changed, 22 insertions, 5 deletions
diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt index bd4f1a500..155a10098 100644 --- a/gr-digital/lib/CMakeLists.txt +++ b/gr-digital/lib/CMakeLists.txt @@ -22,6 +22,7 @@ ######################################################################## include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} + ${GR_ANALOG_INCLUDE_DIRS} ${GR_DIGITAL_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}/../include ) @@ -146,4 +147,4 @@ add_library(gnuradio-digital SHARED ${gr_digital_sources}) target_link_libraries(gnuradio-digital ${digital_libs}) GR_LIBRARY_FOO(gnuradio-digital RUNTIME_COMPONENT "digital_runtime" DEVEL_COMPONENT "digital_devel") -add_dependencies(gnuradio-digital digital_generated_includes digital_generated_swigs) +add_dependencies(gnuradio-digital digital_generated_includes digital_generated_swigs gnuradio-analog) diff --git a/gr-digital/lib/digital_constellation.cc b/gr-digital/lib/digital_constellation.cc index d9a53c493..da79f2caa 100644 --- a/gr-digital/lib/digital_constellation.cc +++ b/gr-digital/lib/digital_constellation.cc @@ -49,6 +49,17 @@ digital_constellation::digital_constellation (std::vector<gr_complex> constellat d_rotational_symmetry(rotational_symmetry), d_dimensionality(dimensionality) { + // Scale constellation points so that average magnitude is 1. + float summed_mag = 0; + unsigned int constsize = d_constellation.size(); + for (unsigned int i=0; i<constsize; i++) { + gr_complex c = d_constellation[i]; + summed_mag += sqrt(c.real()*c.real() + c.imag()*c.imag()); + } + d_scalefactor = constsize/summed_mag; + for (unsigned int i=0; i<constsize; i++) { + d_constellation[i] = d_constellation[i]*d_scalefactor; + } if (pre_diff_code.size() == 0) d_apply_pre_diff_code = false; else if (pre_diff_code.size() != constellation.size()) @@ -293,6 +304,8 @@ digital_constellation_rect::digital_constellation_rect (std::vector<gr_complex> n_real_sectors(real_sectors), n_imag_sectors(imag_sectors), d_width_real_sectors(width_real_sectors), d_width_imag_sectors(width_imag_sectors) { + d_width_real_sectors *= d_scalefactor; + d_width_imag_sectors *= d_scalefactor; find_sector_values(); } diff --git a/gr-digital/lib/digital_constellation_receiver_cb.cc b/gr-digital/lib/digital_constellation_receiver_cb.cc index b9239962a..faaa760fd 100644 --- a/gr-digital/lib/digital_constellation_receiver_cb.cc +++ b/gr-digital/lib/digital_constellation_receiver_cb.cc @@ -47,13 +47,13 @@ digital_make_constellation_receiver_cb(digital_constellation_sptr constell, fmin, fmax)); } -static int ios[] = {sizeof(char), sizeof(float), sizeof(float), sizeof(float)}; +static int ios[] = {sizeof(char), sizeof(float), sizeof(float), sizeof(float), sizeof(gr_complex)}; static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); digital_constellation_receiver_cb::digital_constellation_receiver_cb (digital_constellation_sptr constellation, float loop_bw, float fmin, float fmax) : gr_block ("constellation_receiver_cb", gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signaturev (1, 4, iosig)), + gr_make_io_signaturev (1, 5, iosig)), gri_control_loop(loop_bw, fmax, fmin), d_constellation(constellation), d_current_const_point(0) @@ -93,10 +93,12 @@ digital_constellation_receiver_cb::general_work (int noutput_items, gr_complex sample, nco; float *out_err = 0, *out_phase = 0, *out_freq = 0; - if(output_items.size() == 4) { + gr_complex *out_symbol; + if(output_items.size() == 5) { out_err = (float *) output_items[1]; out_phase = (float *) output_items[2]; out_freq = (float *) output_items[3]; + out_symbol = (gr_complex*)output_items[4]; } while((i < noutput_items) && (i < ninput_items[0])) { @@ -109,10 +111,11 @@ digital_constellation_receiver_cb::general_work (int noutput_items, out[i] = sym_value; - if(output_items.size() == 4) { + if(output_items.size() == 5) { out_err[i] = phase_error; out_phase[i] = d_phase; out_freq[i] = d_freq; + out_symbol[i] = sample; } i++; } |