0

I want to add a delay to the messages in GNURadio. For example, when I click on a button, some action will not be triggered immediately but after specific delay.

I think this behavior can be accomplished in the following way:

Button (produce message) -> PDU -> Tagged stream -> Delay -> PDU -> Target block

The problem in the approach above is that I have no idea how to perform conversion between messages, PDUs and tagged streams (GNURadio docs are not perfect).

Maybe there are some more convenient ways to get the same result.

ALEX
  • 3
  • 2

1 Answers1

0

I was first a bit torn, because this felt so much like a programming problem, and not a signal processing problem.

But it really is a confusion about discrete-time signals, and their processing in general purpose computers. So, here goes an explanation:

You're approaching this the wrong way around. The "Delay" block in GNU Radio does not add a real-world delay!

But what does it do instead? It adds a delay in the discrete-time signal. In other words, it prepends zeros. Prepending a million zeros (or just 10) will take your computer microseconds – no matter what your signal's sampling rate is.

The speed of processing and the wall-clock-time-instant that a sample describes are totally independent in this kind of signal processing. I put that in bold because it's so crucial a concept that you must really get rid of any notion that your PC is processing your signal with any notion of "time". All the signal it is to GNU Radio is really a sequence of numbers, without anything like a notion of time or rate attached.

What you really want to happen is the following:

  1. Clicking that button will make a block, which sits in the chain of stream processing, take note of the index of the latest currently processed sample (say, it's the i=12345678. sample)
  2. That block then passes through samples (in the "old" way) until it reaches the sample that is supposed to come [delay] seconds later. For example, if you want a delay of 10 s, and you have a sampling rate of 10⁶ Samples/s, then you wait 10⁷ samples, i.e. until the i+10⁷ = 12345678 + 10⁷ = 22345678. sample comes by, and then changes its behaviour.

PDUs and tagged streams have nothing to do with that.

Marcus Müller
  • 30,525
  • 4
  • 34
  • 58