discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] still having trouble getting started


From: Eric Blossom
Subject: Re: [Discuss-gnuradio] still having trouble getting started
Date: Thu, 9 Jun 2005 12:12:26 -0700
User-agent: Mutt/1.5.6i

On Thu, Jun 09, 2005 at 02:49:09PM -0400, jmdaniel wrote:
> Hello,
> 
> I've had gnuradio up and running for about 2 weeks now and have been getting 
> through the examples with success.  I'm still a little fuzzy on somethings 
> though.  How exactly can I get a mc4020 source to right to a file.  I am 
> aware 
> of gr_file_sink but how do i use it?  Do I have to write something in c++, 
> compile it and access it from python or can I already import gr_file_sink 
> from 
> somewhere?  I have more questions but the answer to this one should set me in 
> the right direction.  Many thanks.
> 
> John Daniel
> Virginia Tech
> address@hidden

Hi John,

No need to compile anything.  The small bit of python below should
work for you.  It copies short samples from the mc4020 source into the
the file called 'output.dat' until you press the Enter key.
MCC_CH3_EN specifies that you want to use the 3rd input (zero based).
MCC_ALL_1V specifies that your input voltage is in +/- 1V.
MCC_ALL_5V is the other choice.

If you want to grab a specific number of samples, you can add the gr.head block.

#!/usr/bin/env python

from gnuradio import gr
from gnuradio import mc4020

def build_graph():
    fg = gr.flow_graph()
    input_rate = 20e6
    src = mc4020.source (input_rate, mc4020.MCC_CH3_EN | mc4020.MCC_ALL_1V)
    dst = gr.file_sink(gr.sizeof_short, 'output.dat')
    fg.connect (src, dst)
    return fg

def main():
    fg = build_graph()
    fg.start()
    raw_input('Press Enter to Exit: ')
    fg.stop()

if __name__ == '__main__':
    main()



# using head...

    nsamples = 2e6
    src = mc4020.source (input_rate, mc4020.MCC_CH3_EN | mc4020.MCC_ALL_1V)
    head = gr.head(gr.sizeof_short, int(nsamples))
    dst = gr.file_sink(gr.sizeof_short, 'output.dat')
    fg.connect (src, head, dst)

    




reply via email to

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