Forum: GNU Radio Complex signal to square wave

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
23272b99cdcd7420e24e90c1fde60538?d=identicon&s=25 Marco Bottino (Guest)
on 2009-02-16 22:29
(Received via mailing list)
Hello all!

I wrote a script in python that takes a binary file (output of the
usrp_rx_cfile.py), convert it in a sequence of complex values and
applies a
variable threshold in order to convert that complex sequence in a square
wave.
The complex sequence already represent a square wave, but with a noise
and
distortions that I want to clean.
Now I would like to merge what I've done with the gnuradio language, and
this is
what I tried:

class my_top_block(gr.top_block):

    def __init__(self):
        gr.top_block.__init__(self)

        def block_cplx_to_sq (matrice):
            output1 = []
            d = ds = 0;
            de = len(matrice);
            while (d < de):

            [sequence of 'if..else' to find the correct value of
[min,max]]

                threshold = mean(matrice[min,max]);
                stad = std(matrice[min_std,max_std]);

                if stad <= 50:
                    threshold = threshold - 100;
                soglia_f.append(threshold);

                if abs(matrice[d]) >= threshold:
                    output1.append(1);
                else:
                    output1.append(0);

                d = d + 1;
            return output1;

        src = gr.file_source(gr.complex, "Acq_petit", TRUE)
        BLCK = block_cplx_to_sq ();
        self.connect(src, BLCK)

The problem is that the program still requires something as input of
block_cplx_to_sq (and it should be the output of the file_source...).
Does anyone have any idea to help me? (maybe some gnuradio function that
I don't
know that does something like this)

Thank you in advance,
Kind regards,
Marco
This topic is locked and can not be replied to.