|
From: | intermilan |
Subject: | [Discuss-gnuradio] a question about a new PI/4 DQPSK demodulation block |
Date: | Tue, 10 May 2011 16:25:36 +0800 |
Hi all: I recently write a pi/4 dqpsk modulation and demodulation block in the gnuradio. My modulation block works fine,but there is a question about my demodulation block.In my demodulation block, first I compute the angle of the input I/Q signal,then do something to the computed angle,finally output the sine and cosine of the angle.Then use a slicer block to decide the value of the data(if x>0,x=0;else,x=1).Besides I did not add the synchronization and RRC block to the modulation and demodulation block for now. Here is the code for the demod_cf.cc(demodulation): #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <pi4_demod_cf.h> #include <gr_io_signature.h> #include <stdexcept> #include <cmath> #include <stdlib.h> #include <gr_math.h> pi4_demod_cf_sptr pi4_make_demod_cf () { return pi4_demod_cf_sptr (new pi4_demod_cf ()); } static const int MIN_IN = 1; // mininum number of input streams static const int MAX_IN = 1; // maximum number of input streams static const int MIN_OUT = 1; // minimum number of output streams static const int MAX_OUT = 1; // maximum number of output streams pi4_demod_cf::pi4_demod_cf () : gr_block ("demod_cf", gr_make_io_signature (MIN_IN, MAX_IN, sizeof (gr_complex)), gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (float))) { // nothing else required in this example } void pi4_demod_cf::forecast (int noutput_items, gr_vector_int &ninput_items_required) { int input_required = (0.5) * noutput_items ; unsigned ninputs = ninput_items_required.size(); for (unsigned int i = 0; i < ninputs; i++) { ninput_items_required[i] = input_required; } } pi4_demod_cf::~pi4_demod_cf () { } int pi4_demod_cf::general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { float xw = 0; const gr_complex *in = (const gr_complex *) input_items[0]; float *out = (float *) output_items[0]; for (int i = 0; i <(noutput_items/2); i++) { float w = gr_fast_atan2f(in[i]); float dw = w-xw; dw = fmod(dw,2*M_PI); *out++ = sin(dw); *out++ = cos(dw); xw = w; } consume_each ((0.5)*noutput_items); // Tell runtime system how many output items we produced. return noutput_items; } The flow graph I used to test the block is : vector_source ->thrttole ->pi4_mod_fc->pi_demod_cf->slicer->file_sink. The problem is when I run the flow graph,in the file which I use to receive the demodulated data there are several 1(output of the demod block is 0) before the correct demodulated data.In my opinion,that means the demodulation block did not work at first. then it work correct to output the demodulation data(Am I right about it?).So I thought there is something wrong with my code of the demodulation block.But I have checked it over and over again, and still not know where I should change. I hope someone can help me to figure it out. Thank you in advance. Inter. |
[Prev in Thread] | Current Thread | [Next in Thread] |