How send random values to selector every n-times

Hi everybody,
I need to “switch” randomly 5 different signal generator via selector
block
every [say] 3 seconds…

So , in GRC, I’ve a vector_source with values coming from
[random.randint(0, 4) for p in range(0,4)]. This put some random values
displayed right.

Now how I can scan the vector, a values at time sending this index to
selector, every n-seconds ???

I’m not with a USRP , simple sound card.

Tnx in advance for any answer!

Victor

Hi,

Please go through the tutorial [1].

Short version,

  1. Use one 5in-1out selector block
  2. Use on “Function Probe” block
  3. Set the “Poll Rate” based on your delay
  4. Generate python file using “Generate flowgraph” button
  5. Set your selector’s input index in the function probe

Sample function probe

def _fn_probe_probe():
while True:
try:

self.blks2_selector_0.set_input_index(random.randint(0,4))

           except AttributeError:
               pass
           time.sleep(1.0 / (0.3))

6.Run your python code

[1]
https://gnuradio.org/redmine/projects/gnuradio/wiki/Guided_Tutorial_GNU_Radio_in_Python#315-Modifying-the-GRC-Generated-Python-File

Sreeraj

Thanks Sreeraj,

just a quick test without success :frowning:

I’ve tested the example in the tutorial and it work, so I’ve to read
carefully the section to understand how put hand on my code.

Next days I’ll be away for my job so next tests maybe done during next
weekend.

I’ll report results :wink:

Byebye,

Victor

2014-12-08 15:11 GMT+01:00 sreeraj r [email protected]: