discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to insert if...else logic between 2 blocks


From: Fabian Schwartau
Subject: Re: how to insert if...else logic between 2 blocks
Date: Sat, 5 Dec 2020 12:12:43 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Hi James,

I did not know about the "Python Block" block. Very interesting and
usefull :)
Although I don't fully understand the code you wrote to convert an index
into a frequency value, I think you are missing something: You need to
use different equations, depending on if the FFT size is even or odd.
Maybe that does not matter in your case as the fft size is always even,
but keep that in mind.

Best regards,
Fabian

Am 05.12.20 um 06:58 schrieb james jordan:
> Hi  Fabian,
> thanks for your help. i write a fft index to freq transform block. i put
> the source here for anyone need.
> 
> 
> 
> 
> <http://aka.ms/weboutlook>
> ------------------------------------------------------------------------
> *From:* Discuss-gnuradio
> <discuss-gnuradio-bounces+james.jordan.999=hotmail.com@gnu.org> on
> behalf of Fabian Schwartau <fabian@opencode.eu>
> *Sent:* Friday, December 4, 2020 9:28 PM
> *To:* discuss-gnuradio@gnu.org <discuss-gnuradio@gnu.org>
> *Subject:* Re: how to insert if...else logic between 2 blocks
>  
> Hi James,
> I cannot tell where you got that init function from, but you are passing
> 3 arguments to it (ignoring self). The first one has a default argument
> (1850e6), but the following don't. That's not allowed in python. If you
> want to give a default parameter for the center_freq, put the parameter
> at the end:
> def __init__(self, fft_size, freq_range, center_freq=1850e6):
> or give default values for all parameters:
> def __init__(self, center_freq=1850e6, fft_size=1024, freq_range=10e6):
> 
> I don't know if it is common (possble) to have an __init__ function in a
> "Python Module". I used it just to define a single function, just like
> in the example from the wiki.
> 
> Hope that helps, I am not a GNU Radio expert, especially on those more
> advanced topics like building your own modules.
> 
> Best regards,
> Fabian
> 
> Am 04.12.20 um 14:18 schrieb james jordan:
>> Hi Fabian,
>> thanks for your quick reply. i think python block is a good choice but
>> how to define the block param as what i want? i only see there is a
>> example param in the block. when i modify the code as below
>> def __init__(self, center_freq=1850e6, fft_size, freq_range):
>> grc can not interpret the source code. it shows "Param -
>> Code(_source_code): Can't interpret source code: non-default argument
>> follows default argument (<string>, line 16)"
>> how to deal with this?
>> 
>> 
>> <http://aka.ms/weboutlook>
>> ------------------------------------------------------------------------
>> *From:* Discuss-gnuradio
>> <discuss-gnuradio-bounces+james.jordan.999=hotmail.com@gnu.org> on
>> behalf of Fabian Schwartau <fabian@opencode.eu>
>> *Sent:* Friday, December 4, 2020 7:14 PM
>> *To:* discuss-gnuradio@gnu.org <discuss-gnuradio@gnu.org>
>> *Subject:* Re: how to insert if...else logic between 2 blocks
>>  
>> Hi James,
>> 
>> three options I can see:
>> 1) Quick& Dirty: Implement both algorithms in parallel and use the Peak
>> Detector block to generate a 0 or 1 depending on your condition. Then
>> invert the condition, multiply the outputs of the two algorithms with
>> the two condition outputs and add them.
>> 2) Depending on your condition and what you want to do, the Python
>> Module block may help. You can implement python function in it and use
>> them anywhere in your flow chart:
>> https://wiki.gnuradio.org/index.php/Python_Module
>> 3) Build your own module:
>> https://wiki.gnuradio.org/index.php/OutOfTreeModules
>> 
>> Best regards,
>> Fabian
>> 
>> Am 04.12.20 um 10:36 schrieb james jordan:
>>> Hi ALL,
>>> i want to compute process a block's output then pass the result to
>>> another block's input. the process is not a fix equation but like this
>>> if(output > a)... else... so is there any way to do this without making
>>> a new block by myself. can i modify the generated python code to insert
>>> this logic? if i have to make a new block then how to make?
>>> 
>>> 
>>> <http://aka.ms/weboutlook>
>> 
>> 
> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]