0

I'm attempting to unpack bytes from an input file in GNU Radio Companion into a binary bitstream. My problem is that the Unpack K Bits block works at the same sample rate as the file source. So by the time the first bit of byte 1 is clocked out, byte 2 has already been loaded. How do I either slow down the file source or speed up the Unpack K Bits block? Is there a way I can tell GNU Radio Companion to repeat each byte from the file source 8 times?

Note that "after pack" is displaying 4 times as much data as "before pack".

flow graph

time domain graphs

watkipet
  • 959
  • 12
  • 23

2 Answers2

2

My problem is that the Unpack K Bits block works at the same sample rate as the file source

No it doesn't. Unpack K Bits is an interpolator block. In your case the interpolation is 8. For every bytes 8 new bytes are produced.

The result is right, but the time scale of your sink is wrong. You have to change the sampling rate at the second GUI Time Sink to fit the true sampling rate of the flowgraph after the Unpack K Bits.

So instead of 32e3 it should be 8*32e3.

Manos
  • 2,136
  • 17
  • 28
  • So maybe what I missed in the FAQ was this, "When meeting data streams between any hardware systems, we have to make sure that all resampling done leads to the same sampling rate when they meet". Or put another way, I have to adapt my sink's sampling rate to match the rate changes in the rest of my flow graph. – watkipet Dec 21 '15 at 19:35
2

Manos' answer is very good, but I want to add to this:

This is a common misunderstanding for people that just got in touch with doing digital signal processing down at the sample layer:

GNU Radio doesn't have a notion of sampling rate itself. The term sampling rate is only used by certain blocks to e.g. calculate the period of a sine (in the case of the signal source: Period = f_signal/f_sample), or to calculate times or frequencies that are written on display axes (like in your case).

"Slowing down" means "making the computer process samples slower", but doesn't change the signal.

All you need to do is match what you want the displaying sink to show as time units with what you configure it to do.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
  • I totally agree Marcus. This is a very common misconception that I try to clarify to new students in SDR development. Perhaps we could some how provide a tutorial-guide at the GNU Radio main page? – Manos Dec 19 '15 at 18:43
  • @Manos We should. Could you drop an email to tutorials~AT~gnuradio.org? I should still be on that, too, and I think we should a) be adding a prominent entry about that principle somewhere between "Intro" and "Working With GRC" in https://gnuradio.org/redmine/projects/gnuradio/wiki/Guided_Tutorials, as well as b) be promoting that more clearly – it's still not the ressource primarily found by new users. – Marcus Müller Dec 19 '15 at 20:06
  • @Manos: there's https://gnuradio.org/redmine/projects/gnuradio/wiki/Guided_Tutorial_Extras_Sample_Rates , but I think it might need expansion – Marcus Müller Dec 19 '15 at 20:07
  • I will give a look and I will send an email with comments. – Manos Dec 20 '15 at 13:35