# Frequency modulating block

**URL:** <https://www.ruby-forum.com/t/frequency-modulating-block/61892>\
**Category:** GNU Radio\
**Created:** [May 29, 2006, 1:11pm UTC](https://www.ruby-forum.com/t/frequency-modulating-block/61892 "2006-05-29T13:11:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![seph\_004](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5daacb/32.png) [@seph\_004](https://www.ruby-forum.com/u/seph_004)\
**Post date:** [May 29, 2006, 1:11pm UTC](https://www.ruby-forum.com/t/frequency-modulating-block/61892/1 "2006-05-29T13:11:11Z")

</div>

Hi

I just had a few questions regarding the frequency modulatig block. The  
current input sample is used in conjuction with the sensitivity  
parameter to determine the new phase value. Is this correct? I’m just a  
bit confused as to how the phase calculations and the sensitivity  
parameter relate to the instantaneous frequency output.

Secondly, I suppose this is a more general question about the vector and  
file source blocks. At what rate are they producing data? For a non  
repeating vector source of n values, how can I detemine the exact amount  
of time it takes for all the values to be used?

Regards

Lance

---

<div class="post-metadata">

**Author:** ![seph\_004](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5daacb/32.png) [@seph\_004](https://www.ruby-forum.com/u/seph_004)\
**Post date:** [May 29, 2006, 8:27pm UTC](https://www.ruby-forum.com/t/frequency-modulating-block/61892/2 "2006-05-29T20:27:00Z")

</div>

On Mon, 2006-05-29 at 04:09 -0700, seph 004 wrote:

> Secondly, I suppose this is a more general question about the vector  
> and file source blocks. At what rate are they producing data? For a  
> non repeating vector source of n values, how can I detemine the exact  
> amount of time it takes for all the values to be used?

As little as possible. There’s no concept of “rate” in the gnuradio  
core. You push samples in, blocks process them, and they come out. You  
will always be limited either by I/O speed or CPU speed. (Now, when you  
have, e.g. 2 sound cards, and you get stuff from one and push it to the  
other, it becomes a much trickier problem since they are under different  
clock domains. But I don’t think that this is what you are asking  
about.)

Now, there would be nothing stopping you from writing a block that  
artificially introduced delays between samples as they were being fed  
into the system, e.g. have a separate thread running, give it a rate to  
send stuff out at, and every so many ms, it feeds gnuradio with a new  
sample.

---

<div class="post-metadata">

**Author:** ![seph\_004](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5daacb/32.png) [@seph\_004](https://www.ruby-forum.com/u/seph_004)\
**Post date:** [May 29, 2006, 11:09pm UTC](https://www.ruby-forum.com/t/frequency-modulating-block/61892/3 "2006-05-29T23:09:10Z")

</div>

On Mon, May 29, 2006 at 04:09:17AM -0700, seph 004 wrote:

> Hi

> I just had a few questions regarding the frequency modulatig  
> block. The current input sample is used in conjuction with the  
> sensitivity parameter to determine the new phase value. Is this  
> correct?

Yes.

> I’m just a bit confused as to how the phase calculations and the  
> sensitivity parameter relate to the instantaneous frequency output.

The instantaneous frequency would be d(d\_phase)/dt.

If you feed the modulator a constant value, you’ll get a constant  
frequency out.

int  
gr\_frequency\_modulator\_fc::work (int noutput\_items,  
gr\_vector\_const\_void\_star &input\_items,  
gr\_vector\_void\_star &output\_items)  
{  
const float \*in = (const float \*) input\_items[0];  
gr\_complex \*out = (gr\_complex \*) output\_items[0];

for (int i = 0; i \< noutput\_items; i++){  
d\_phase = d\_phase + d\_sensitivity \* in[i];  
float oi, oq;  
gr\_sincosf (d\_phase, &oq, &oi);  
out[i] = gr\_complex (oi, oq);  
}

// Limit the phase accumulator to [-16_pi,16_pi]  
// to avoid loss of precision in the addition above.

if (fabs (d\_phase) \> 16 \* M\_PI){  
double ii = trunc (d\_phase / (2 \* M\_PI));  
d\_phase = d\_phase - (ii \* 2 \* M\_PI);  
}

return noutput\_items;  
}

> Secondly, I suppose this is a more general question about the vector  
> and file source blocks. At what rate are they producing data? For a  
> non repeating vector source of n values, how can I detemine the  
> exact amount of time it takes for all the values to be used?

They produce data at whatever rate the downstream blocks consume it.  
No part of GNU Radio has any a priori knowledge of sample rate. It’s  
just samples in / samples out. Sources or sinks that are tied to  
external hardware such as an audio card or USRP will consume or  
produce at the rate that they’re configured to run at.

Eric

---

<div class="post-metadata">

**Author:** ![seph\_004](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5daacb/32.png) [@seph\_004](https://www.ruby-forum.com/u/seph_004)\
**Post date:** [May 30, 2006, 12:37am UTC](https://www.ruby-forum.com/t/frequency-modulating-block/61892/4 "2006-05-30T00:37:27Z")

</div>

Eric B. wrote:

> On Mon, May 29, 2006 at 04:09:17AM -0700, seph 004 wrote:
> 
> > Secondly, I suppose this is a more general question about the vector  
> > and file source blocks. At what rate are they producing data?
> 
> They produce data at whatever rate the downstream blocks consume it.  
> No part of GNU Radio has any a priori knowledge of sample rate. It’s  
> just samples in / samples out.

I guess it could be called asynchronous, as it is not synchronized by  
some central clock. Blocks are FIFOs, the flow graph connects them  
together with sensible buffers, and scedules the blocks (possibly on  
multiple processors) so that no buffer is empty at any time.  
Is that correct?

## Patrick

Engineers motto: cheap, good, fast: choose any two  
Patrick S.   
Student of Telematik, Techn. University Graz, Austria
