discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] error with import


From: Eric Blossom
Subject: Re: [Discuss-gnuradio] error with import
Date: Wed, 1 Aug 2007 10:23:29 -0700
User-agent: Mutt/1.5.9i

On Wed, Aug 01, 2007 at 01:47:55PM +0200, Aadil Volkwin wrote:
> Hi,
> 
> when running this file, tvrx_total_power.py (attached) I run into the
> following problem, output shown below, and the pc hangs. I have not
> encountered this previously and am at a loss.
> other usrp related examples from the examples folder do run.
> I would appreciate some advice if you have any ideas.
> 
> thanks,


To limit the number of samples collected you should use gr.head.

See the handling of the --nsamples option in
gnuradio-examples/python/usrp/usrp_rx_cfile.py


Eric



> 
> address@hidden:~/gnuradio-3.0.2/gnuradio-examples/python/usrp$
> ./tvrx_total_power.py
> from: can't read /var/mail/gnuradio
> 

> from gnuradio import gr, gru, usrp
> import usrp_dbid
> from gnuradio import audio
> from gnuradio import blks
> import os
> import time
> import struct
> 
> 
> fg=gr.flow_graph()
> 
> ### Create the USRP ###
> u = usrp.source_c(decim_rate=32)         # decimation is even values in range 
> [4, 256].
>                                         # 4 can only be used with 4 bit 
> sampling
> width = 8
> shift = 8
> format = u.make_format(width, shift)
> #r = u.set_format(format)               # Uncomment to enable 8-bit sampling
> #print "set_format =", r                # Uncomment to enable 8-bit sampling
> 
> usrp_rate = u.adc_freq() / u.decim_rate()
> 
> 
> ### determine the daughterboard subdevice we're using ###
> rx_subdev_spec = usrp.pick_subdev(u, (usrp_dbid.TV_RX,))
> u.set_mux(usrp.determine_rx_mux_value(u, rx_subdev_spec))
> subdev = usrp.selected_subdev(u, rx_subdev_spec)
> 
> 
> ### Change the baseband lowpass filter on daughterboard to reduce bandwidth.
> ### Can be set anywhere from 4 to 33MHz ###
> #subdev.set_bw(1e6)
> 
> 
> #### set initial values
> 
> # Set gain to max
> # Gain is 0 to 104, in steps of 1
> g_range = subdev.gain_range()
> subdev.set_gain(0)
> 
> 
> # Set frequency to mid-point
> # Frequency is 500MHz to 2.6GHZ, in steps of 1MHz
> f_range = subdev.freq_range()
> freq = 100e6                        # frequency to tune to
> r = u.tune(0, subdev, freq)         # 0 is DDC channel
> 
> 
> #Complex to Float Conversion
> c2f=gr.complex_to_float()
> 
> #Multiplier
> multiplier = gr.multiply_ff ()
> multiplier1 = gr.multiply_ff ()
> 
> #Adder
> adder = gr.add_ff()
> 
> 
> #Vector sink
> sink = gr.file_sink(gr.sizeof_float, "temp_power.dat")
> 
> #Wiring it all together
> fg.connect(u,c2f)
> 
> fg.connect((c2f,0),(multiplier,0))
> fg.connect((c2f,0),(multiplier,1))
> 
> fg.connect((c2f,1),(multiplier1,0))
> fg.connect((c2f,1),(multiplier1,1))
> 
> fg.connect(multiplier,(adder,0))
> fg.connect(multiplier1,(adder,1))
> 
> fg.connect(adder, sink)
> 
> fg.start()
> 
> 
> #Set number of samples
> num_samples = 1000
> repeat = 20                 #repeat 20 times
> 
> #Run graph until correct number of samples written to file
> while os.path.getsize("temp_power.dat") < num_samples * (repeat+1) * 
> gr.sizeof_float:
>         time.sleep(0.0001)
> 
> #Stop the graph
> fg.stop()
> 
> #Read in num_samples at a time, and display the average
> fin = open("temp_power.dat", 'rb')
> total_sum = 0
> 
> #Dump the first set of samples as they will be erroneous (bug in USRP)
> fin.read(num_samples * gr.sizeof_float)
> 
> 
> for i in range(repeat):
>     
>     # Read in first set of samples to a list
>     data = struct.unpack(str(num_samples) + 'f' ,fin.read(num_samples * 
> gr.sizeof_float))
>     
>     #Now average out the data and print the result
>     sum = 0
>     for val in data: sum += val
>     print sum / num_samples * 1.0
>     
>     total_sum += sum / num_samples * 1.0
>     
> #Now print average of all samples
> print "Overall Average: " , total_sum/repeat * 1.0
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/discuss-gnuradio





reply via email to

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