discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] how to use if statement in GNU radio


From: Brian Padalino
Subject: Re: [Discuss-gnuradio] how to use if statement in GNU radio
Date: Fri, 12 Sep 2008 10:33:22 -0400

On Fri, Sep 12, 2008 at 10:19 AM, Pu, Di <address@hidden> wrote:
> Hi All,
>
> I was trying to combine two signals in GNU radio. One is a sinusoid wave, and 
> the other is a constant wave. The amplitude of the sine wave is higher than 
> that of the constant wave. What I want to do is to truncate the top part of 
> the sinusoid wave: when the sine wave is higher than the constant wave, let 
> it be the constant wave. I don't know whether it is feasible with IF 
> statement in GNU radio.
>
> The IF part of my code:
>        self.siggen = gr.sig_source_f (self.usb_freq (),
>                                       gr.GR_SIN_WAVE,
>                                       self.waveform_freq,
>                                       self.waveform_ampl,
>                                       self.waveform_offset)
>
>        self.siggen1 = gr.sig_source_f (self.usb_freq (),
>                                       gr.GR_CONST_WAVE,
>                                       self.waveform_freq,
>                                       0.5*self.waveform_ampl,
>                                       self.waveform_offset)
>
>        if self.siggen < self.siggen1:
>             self.connect (self.siggen, self.src)
>        else:
>             self.connect (self.siggen1, self.src)
>
> If it is not doable, could you provide me with some methods to do this? Thank 
> you very much!

You can't really do comparisons against the objects and expect an
attribute of the object to hold true.  In this case you have two
objects which provide streams of data and you are trying to compare
the streams to each other.

The idea behind the Python interface is that it supplies the glue to
your flowgraph and all the real work is done in C++.

I believe what you want to do is clip your sine wave - is that
correct?  If a block doesn't exist to perform said clipping, you
should think about writing your own clipping block.  There are
tutorials on how to write your own C++ gnuradio blocks, and
(obviously) many examples of blocks currently in place.

If you run into a problem or are stumped, the Wiki is a great resource
as well as old list posts.

Hope this helps!

Brian




reply via email to

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