# Question on DQPSK Modulation - issue with output

**URL:** <https://www.ruby-forum.com/t/question-on-dqpsk-modulation-issue-with-output/220230>\
**Category:** GNU Radio\
**Created:** [June 3, 2012, 1:21am UTC](https://www.ruby-forum.com/t/question-on-dqpsk-modulation-issue-with-output/220230 "2012-06-03T01:21:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 3, 2012, 1:21am UTC](https://www.ruby-forum.com/t/question-on-dqpsk-modulation-issue-with-output/220230/1 "2012-06-03T01:21:25Z")

</div>

Dear all,

I am currently trying to implement a pi/4 dqpsk modulator and  
demodulator. I  
have tried two approaches, one uses the CQPSK.py (included in osmocom’s  
TETRA project) and the other uses digital.qpsk.dqpsk\_mod. Both of these  
approaches have failed to return the same string of bits after the  
process  
of modulations-\>demodulation. The input comes from a .dat file and is a  
string of bits (tried different sizes, from 2 bits to 32 bits), then the  
output of modulation is written to a sink.dat as gr\_complex. This file  
is  
then fed to a demodulator which saves the output to a final.dat. I have  
attached important bits of the code which uses qpsk.dqpsk\_mod/demod. I  
would  
greatly appreciate any advice.  
Also, could anyone please confirm that what I can achieve a  
–PI/4–DQPSK  
using the dqpsk\_mod?

Best Regards,

## Vahid

Modulator:

.  
.  
.  
sample\_rate = options.sample\_rate  
symbol\_rate = 18000  
sps = 2

```
IN = gr.file_source(gr.sizeof_gr_complex, options.input_file, repeat 

```

=  
False)  
#IN = (1,0,0,0,1,1,0,0)  
src = gr.vector\_source\_b (IN)  
MOD = digital.qpsk.dqpsk\_mod( samples\_per\_symbol = sps,  
excess\_bw=0.35,  
log=options.log, gray\_coded=True,

```
                             verbose=options.verbose)

self.connect(src,MOD)
    OUT = gr.file_sink(gr.sizeof_gr_complex, options.output_file)

self.sink1 = gr.vector_sink_f()
self.sink2 = gr.vector_sink_f()

real = gr.complex_to_real()
imag = gr.complex_to_imag()
self.connect(MOD,real)
self.connect(MOD,imag)

self.connect(real,self.sink1)
self.connect(imag,self.sink2)
self.connect(MOD,OUT)
def print_data(self):
print "data in sink1 is: ",self.sink1.data()
print "data in sink2 is: ",self.sink2.data()

```

## . . .

Demodulator:

sample\_rate = options.sample\_rate  
symbol\_rate = 18000  
sps = 2  
# output rate will be 36,000  
ntaps = 11 \* sps  
new\_sample\_rate = symbol\_rate \* sps

```
    channel_taps = gr.firdes.low_pass(1.0, sample_rate,

```

options.low\_pass, options.low\_pass \* 0.1, gr.firdes.WIN\_HANN)

```
    FILTER = gr.freq_xlating_fir_filter_ccf(1, channel_taps,

```

options.calibration, sample\_rate)  
IN = gr.file\_source(gr.sizeof\_gr\_complex, options.input\_file)  
#IN = (1,1,0,1,1,1,0,0)  
#src = gr.vector\_source\_b (IN)  
DEMOD = digital.qpsk.dqpsk\_demod( samples\_per\_symbol = sps,  
excess\_bw=0.35, gray\_coded=True,  
log=options.log,

```
                             verbose=options.verbose)

OUT = gr.file_sink(gr.sizeof_char, options.output_file)

self.sink1 = gr.vector_sink_b()

    r = float(sample_rate) / float(new_sample_rate)

    INTERPOLATOR = gr.fractional_interpolator_cc(0, r)

    self.connect(IN, FILTER, INTERPOLATOR, DEMOD, OUT)
self.connect(DEMOD,self.sink1)
def print_data(self):
print "data in sink1 is: ",self.sink1.data()

```

–  
View this message in context:  
[http://old.nabble.com/Question-on-DQPSK-Modulation---issue-with-output-tp33950307p33950307.html](http://old.nabble.com/Question-on-DQPSK-Modulation---issue-with-output-tp33950307p33950307.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Vahid\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/c68b51/32.png) [@Vahid\_B](https://www.ruby-forum.com/u/Vahid_B)\
**Post date:** [June 4, 2012, 1:37am UTC](https://www.ruby-forum.com/t/question-on-dqpsk-modulation-issue-with-output/220230/2 "2012-06-04T01:37:16Z")

</div>

Hi Vahid,

First I’d try using a much longer string of bits and see if that help.

Second I’d find an example in gnuradio  
(gr-digital/python/qa\_constellation.py should have a working dqpsk  
test) and then work from there.

Thirdly if you want pi/4-dqpsk you won’t be able to use the standard  
dqpsk\_mod and dqpsk\_demod, but will need to define a two-dimensional  
constellation and use the generic\_mod and generic\_demod blocks. The  
two-dimensional constellation would be defined something like:

normal\_qpsk\_points = [blah, blah, blah, blah]  
rotated\_qpsk\_points = [blah, blah, blah, blah]  
two\_d\_points = []  
for p in normal\_qpsk\_points:  
for q in rotated\_qpsk\_points:  
two\_d\_points += [p, q]  
pi4dqpsk\_constellation = digital.constellation\_calcdist(two\_d\_points,  
[], 4, 2)

Cheers,  
Ben

---

<div class="post-metadata">

**Author:** ![Vahid\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/c68b51/32.png) [@Vahid\_B](https://www.ruby-forum.com/u/Vahid_B)\
**Post date:** [June 4, 2012, 3:00am UTC](https://www.ruby-forum.com/t/question-on-dqpsk-modulation-issue-with-output/220230/3 "2012-06-04T03:00:13Z")

</div>

On Sun, Jun 3, 2012 at 4:31 PM, Ben R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> constellation and use the generic\_mod and generic\_demod blocks. The  
> two-dimensional constellation would be defined something like:
> 
> normal\_qpsk\_points = [blah, blah, blah, blah]  
> rotated\_qpsk\_points = [blah, blah, blah, blah]  
> two\_d\_points =   
> for p in normal\_qpsk\_points:  
> for q in rotated\_qpsk\_points:  
> two\_d\_points += [p, q]  
> pi4dqpsk\_constellation = digital.constellation\_calcdist(two\_d\_points, , 4, 2)

Just checked the code and it looks like multi-dimensional  
constellations aren’t supported yet by generic\_mod and generic\_demod.  
Another way might be to edit digital.constellation\_receiver\_cb so that  
it shifts the phase back and forth by pi/4.
