# PSK modulation (along with packed vs unpacked bytes)

**URL:** <https://www.ruby-forum.com/t/psk-modulation-along-with-packed-vs-unpacked-bytes/227638>\
**Category:** GNU Radio\
**Created:** [March 22, 2013, 5:33am UTC](https://www.ruby-forum.com/t/psk-modulation-along-with-packed-vs-unpacked-bytes/227638 "2013-03-22T05:33:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![laserwhit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@laserwhit](https://www.ruby-forum.com/u/laserwhit)\
**Post date:** [March 22, 2013, 5:33am UTC](https://www.ruby-forum.com/t/psk-modulation-along-with-packed-vs-unpacked-bytes/227638/1 "2013-03-22T05:33:19Z")

</div>

Twoish questions:

I’ve done a lot of code reading the last 2 weeks and worked on a custom  
PSK  
modulator (basically hierarchical 2/4psk). I’ve tested it at baseband on  
everything seems good, so I’m hoping now to use something like  
benchmark{rx,tx} to test it ota.

I’ve built a couple of sample flowgraphs. The first one is a BPSK  
loopback:

> # flow graph
> 
> tb = gr.top\_block()  
> tb.connect(src, mod, demod, repacker, dst)  
> tb.run()  
> print dst.data()

It’s output is _almost_ correct:

> 207, 79, 208, 80, 209, 81, 210, 82, 211, 83, 212, 84, 213, 85, 214, 86,  
> 215, 87, 216, 88, 217, 89, 218, 90, 219, 91, 220, 92, 221, 93, 222, 94,  
> 223, 95, 224, 96, 225, 97, 226, 98, 227, 99, 228, 100, 229, 101, 230, 102,  
> 231, 103, 232, 104, 233, 105, 234, 106, 235, 107, 236, 108, 237, 109, 238,  
> 110, 239, 111, 240, 112, 241, 113, 242, 114, 243, 115, 244, 116, 245, 117,  
> 246, 118, 247, 119, 248, 120, 249, 121, 250, 122, 251)

The first few bytes are 0’s, which as I understand has to do with the  
RRC  
filters, frequency correction, and possibly agc filter. Then it starts  
at  
128, 0 and increments by 1. I think I would expect it it to go from  
0…255  
but it looks like something else that’s also incrementing by 1 is  
interleaved in there. Looking at the output before the repacker confirms  
that each byte appears repeated twice, but the first instance has the  
MSB  
set to 1.

Doing a similar loopback in GRC with PSK Mod/Demod results in what I  
would  
expect (non-repeated bytes with MSB not set to 1). Would this be the  
proper  
way of using these blocks?

A related question, where is the packing being done in the benchmark\_rx  
path? The generic\_demod does an unpack\_k\_bits, but doesn’t appear to  
pack  
them back up. In the benchmark\_rx callback it looks like the packet is  
already full of packed bytes, but I haven’t seen the unpacked\_to\_packed  
in  
pkt.py.

Thanks for any help,  
-Nathan

---

<div class="post-metadata">

**Author:** ![laserwhit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@laserwhit](https://www.ruby-forum.com/u/laserwhit)\
**Post date:** [March 22, 2013, 11:26pm UTC](https://www.ruby-forum.com/t/psk-modulation-along-with-packed-vs-unpacked-bytes/227638/2 "2013-03-22T23:26:17Z")

</div>

I’ve done a lot of code reading the last 2 weeks and worked on a custom  
PSK  
modulator (basically hierarchical 2/4psk). I’ve tested it at baseband on  
everything seems good, so I’m hoping now to use something like  
benchmark{rx,tx} to test it ota.

> > demod = digital.bpsk.bpsk\_demod()
> 
> > 190, 62, 191, 63, 192, 64, 193, 65, 194, 66, 195, 67, 196, 68, 197, 69,  
> > filters, frequency correction, and possibly agc filter. Then it starts at  
> > 128, 0 and increments by 1. I think I would expect it it to go from 0..255  
> > but it looks like something else that’s also incrementing by 1 is  
> > interleaved in there. Looking at the output before the repacker confirms  
> > that each byte appears repeated twice, but the first instance has the MSB  
> > set to 1.
> 
> It turns out that this was a synchronisation/filter initialisation issue.  
> The bytes are packed 1 bit off so that the MSB of each byte is the LSB  
> of  
> the previous byte. It alternates because the input data is counting by  
> 1s.  
> It just happens that for the particular set of filters in this path the  
> first bit is apparently eaten and at the end an extra bit is tacked on.

> A related question, where is the packing being done in the benchmark\_rx  
> path? The generic\_demod does an unpack\_k\_bits, but doesn’t appear to pack  
> them back up. In the benchmark\_rx callback it looks like the packet is  
> already full of packed bytes, but I haven’t seen the unpacked\_to\_packed in  
> pkt.py.

I think I found this in gr-digital/lib/digital\_framer\_sink\_1.cc. There’s  
some bit shifting to reassemble the payload in there.

Just posting an update so that no one spends needless time trying to  
help  
me and for anyone in the future that finds this in a search.

---

<div class="post-metadata">

**Author:** ![laserwhit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@laserwhit](https://www.ruby-forum.com/u/laserwhit)\
**Post date:** [March 23, 2013, 5:31pm UTC](https://www.ruby-forum.com/t/psk-modulation-along-with-packed-vs-unpacked-bytes/227638/3 "2013-03-23T17:31:05Z")

</div>

Thanks for the update Nathan, I’ve actually been trying to figure out  
where  
the payload reassembly occurs.

Al Fayez
