Ric
Ric

Reputation: 581

How does a gnuradio source block know how many samples to output?

I'm trying to understand how gnuradio source blocks work. I know how to make a simple one that outputs a constant and I understand what sample rate means, but I'm not sure how (or where) to combine the two.

Is the source block in charge of regulating the amount of data to output? Or does the amount that it outputs depend upon other blocks in the flow graph and how much they consume? Some source blocks take sample_rate as an input, which makes me think it's the former. But other blocks don't, which makes me think it's the later.

If a source block is in charge of its sample rate, how does it regulate it? Do they check the system clock and output samples based upon that?

Upvotes: 3

Views: 2408

Answers (1)

Manos
Manos

Reputation: 2186

Do they check the system clock and output samples based upon that?

Definitely not. All GNU Radio blocks operate at the maximum speed the processor can give.

However, GNU Radio relies on the fact that each flowgraph may have a source and/or sink device (e.g USRP, other SDR device, sound card) that produces/consumes samples in a constant rate. Consequently, the flowgraph is throttled at the rate of the hardware.

In order to avoid CPU saturation, if none of these hardware devices exist, GNU Radio provides the Throttle block that tries (it is not so accurate) to throttle the samples per second at the given rate, by sleeping for suitable amount of time between each sample that passes through the Throttle block.

As far the sample_rate parameter concerns, excluding the Throttle and device specific blocks, it is used only for graphical representation or internal calculations.

Upvotes: 7

Related Questions