# Fading channel in GNURadio

**URL:** <https://www.ruby-forum.com/t/fading-channel-in-gnuradio/227626>\
**Category:** GNU Radio\
**Created:** [March 21, 2013, 8:46pm UTC](https://www.ruby-forum.com/t/fading-channel-in-gnuradio/227626 "2013-03-21T20:46:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manu\_T\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@Manu\_T\_S](https://www.ruby-forum.com/u/Manu_T_S)\
**Post date:** [March 21, 2013, 8:46pm UTC](https://www.ruby-forum.com/t/fading-channel-in-gnuradio/227626/1 "2013-03-21T20:46:32Z")

</div>

I’m trying to make a block for fading channel model using hierarchical  
block.

class channel(gr.hier\_block2):  
def **init** (self):  
gr.hier\_block2. **init** (self, “channel”,  
gr.io\_signature(1, 1, gr.sizeof\_float),  
gr.io\_signature(1, 1, gr.sizeof\_gr\_complex))

```
    self.taps = generate_taps()
    self.filt = filter.fir_filter_ccc(1, self.taps)
    self.connect(self, self.filt, self)

def generate_taps():
    n_taps = random.randint(1, 10)
    r_taps = random.rand(n_taps)
    i_taps = random.rand(n_taps)
    return r_taps + 1j*i_taps

```

I want the block to be able to update the channel filter taps in run  
time.  
Can I do that?  
Can I define a function in the class so that the filter taps are updated  
for every 5 seconds?

Thank you.

---

<div class="post-metadata">

**Author:** ![Manu\_T\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@Manu\_T\_S](https://www.ruby-forum.com/u/Manu_T_S)\
**Post date:** [March 21, 2013, 8:55pm UTC](https://www.ruby-forum.com/t/fading-channel-in-gnuradio/227626/2 "2013-03-21T20:55:53Z")

</div>

On 03/21/2013 03:45 PM, Manu T S wrote:

> ```
> self.taps = generate_taps()
> 
> ```
> 
> I want the block to be able to update the channel filter taps in run  
> time. Can I do that?  
> Can I define a function in the class so that the filter taps are  
> updated for every 5 seconds?

The set\_taps function gives you access to this from the top\_block level.  
In that case, your main thread would be updating the block’s taps using  
a while loop with sleep(5). You could also make a block class that  
inherits from fir\_filter\_ccc or channel\_model and change the taps within  
the work function every N seconds: every time (ninput\_items / samp\_rate)  
% N == 0. I hope that’s enough info to point you in the right direction.

> Thank you.
> 
> –  
> Manu T S
> 
> * * *
> 
> Discuss-gnuradio mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

* * *

_Sean M. Nowlan_  
Research Engineer I  
ICL/CNSD  
Georgia Tech Research Institute  
250 14th St NW, Suite 470  
Atlanta, GA 30318

404.407.7952  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Manu\_T\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@Manu\_T\_S](https://www.ruby-forum.com/u/Manu_T_S)\
**Post date:** [March 22, 2013, 10:41am UTC](https://www.ruby-forum.com/t/fading-channel-in-gnuradio/227626/3 "2013-03-22T10:41:15Z")

</div>

On Thu, Mar 21, 2013 at 03:54:48PM -0400, Sean Nowlan wrote:

> every N seconds: every time (ninput\_items / samp\_rate) % N == 0. I hope that’s  
> enough info to point you in the right direction.

Note that will change taps in wall time, not sample time.

MB

–  
Karlsruhe Institute of Technology (KIT)  
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin B.  
Research Associate

Kaiserstraße 12  
Building 05.01  
76131 Karlsruhe

Phone: +49 721 608-43790  
Fax: +49 721 608-46071  
www.cel.kit.edu

KIT – University of the State of Baden-Württemberg and  
National Laboratory of the Helmholtz Association
