Search code examples
c++gnuradiognuradio-companion

Phase modulation with residual carrier


I'm currently implementing a phase modulation scheme with a residual carrier. This modulation scheme is mostly used in deep space communications. I have already derived the I-Q components as follows

I(t) = Power_total * sin(h) * d(t)

Q(t) = -1 * Power_total * cos(h)

where h is modulation scheme and d(t) is the input data (bitstream). Note that when h = 90 degrees then we have a phase modulation scheme with suppressed carrier a.k.a BPSK. The modulation index determines how power is shared between the residual carrier and the data carrier. This simplifies synchronisation since the receiver can track the residual unmodulated carrier.

Below is my code in GNU Radio. Unfortunately, this code crashes whenever I assign the input data, in[i] to oi and oq (in-phase and quadrature factors for data and residual carrier components). Any suggestions, references or links that could help me to eliminate the problem will be highly appreciated. Thanks in advance.

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <gnuradio/io_signature.h>
#include "phase_mod_impl.h"
#include <gnuradio/sincos.h>
#include <math.h>
namespace gr {
  namespace GS {

phase_mod::sptr
phase_mod::make(float mod_index)
{
  return gnuradio::get_initial_sptr
    (new phase_mod_impl(mod_index));
}

/*
 * The private constructor
 */
phase_mod_impl::phase_mod_impl(float mod_index)
  : gr::sync_block("phase_mod",
          gr::io_signature::make(1, 1, sizeof(float)),
           gr::io_signature::make(1, 1, sizeof(gr_complex))),
h(mod_index)
{}

/*
 * Our virtual destructor.
 */
phase_mod_impl::~phase_mod_impl()
{
}

int
phase_mod_impl::work(int noutput_items,
    gr_vector_const_void_star &input_items,
    gr_vector_void_star &output_items)
{
  const float *in = (const float *) input_items[0];
  gr_complex *out = (gr_complex *) output_items[0];
  // Do <+signal processing+>
  for(int i = 0; i < noutput_items; i++) {
     float oq, oi;
     gr::sincosf(h,&oi, &oq);
     oi *= in[i];
     oq *= -1;
     out[i] = gr_complex(oi,oq);
  }
  // Tell runtime system how many output items we produced.
     return noutput_items;
}
/*


   } /* namespace GS */
} /* namespace gr */code here

Solution

  • I found out the problem was with the gnuradio flowgraph I was using to test the code. Basically one of the blocks was generating numbers in the order of 10^34. That is what caused the crashes. Otherwise, the phase modulation block is working as expected –