Hi-

I have a python app which seems to corrupt points when I use it to demodulate a data stream stored in a file and write the de-modulated result back to a file. I've attached the python code, and an image of the problem can be seen at

www.nd.edu/~ematlis/z.gnuradio/waveform.jpg

The modulated waveform is shown in the top plot and the demodulated output in the bottom plot.

The signal was acquired with a Lecroy digital oscilloscope; it's a 100 kHz sine AM modulated at 10 kHz.

As you can see from the image, while the original modulated data shows no corruption in 10002 points, the demodulated data has the first 875-900 points incorrectly set to close to zero. This is repeatable.

Could it have anything to do with the fact that I'm generating a gui? Could the time it takes to generate the gui window interfere with the operation of the demodulation? If I were to make this just a script, ie with no scope or fft sink, and no gui box, would it affect things? (And p.s., how would I do that?)

thanks,
eric

************************************
Eric H. Matlis, Ph.D.
Aerospace & Mechanical Engineering Dept.
120 Hessert Center for Aerospace Research
University of Notre Dame
Notre Dame, IN 46556-5684
Phone: (574) 631-6054
Fax:   (574) 631-8355
#!/usr/bin/env python

from gnuradio import gr, gru
from gnuradio.wxgui import stdgui, fftsink, scopesink, form, slider
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import sys
import os
import wx
import scopesink_mod as scopesink

plot1 = 0
plot2 = 0
plot3 = 0
record = 1

class app_flow_graph (stdgui.gui_flow_graph):
    def __init__(self, frame, panel, vbox, argv):
        stdgui.gui_flow_graph.__init__ (self, frame, panel, vbox, argv)

        usage = "usage: %prog filename \n Demodulates AM from filename "
        parser = OptionParser (option_class=eng_option, usage=usage)
        parser.add_option("-N", "--nsamples", type="eng_float", default=2000,
                          help="number of samples to collect [default=+inf]")
        (options, args) = parser.parse_args ()

        if len (args) != 1:
          parser.print_help ()
          sys.exit (1)

        FILENAME = args[0]
        SHOW = True

        sampling_freq = 5e6
       
        filename = argv[1]
        lpf_coeffs = gr.firdes.low_pass (1,           # gain
                                            sampling_freq,   # sampling rate
                                            150e3,        # passband cutoff
                                            10e3,       # width of transition 
band
                                            gr.firdes.WIN_HANN)
        self.lpf =  gr.fir_filter_fff (1,lpf_coeffs)
        
        # file is our source.
        self.src = gr.file_source (gr.sizeof_float, filename, 1)
        self.throttle = gr.throttle(gr.sizeof_float,sampling_freq)
        self.head = gr.head(gr.sizeof_float, int(options.nsamples))         
        self.recording = gr.file_sink(gr.sizeof_float, "test.bin")
        
        if plot1:
          self.pre_demod = fftsink.fft_sink_f (self, panel, title="Source 
Spectrum", fft_size=8192, sample_rate=sampling_freq, size=(50,100))
          self.connect (self.src, self.pre_demod)
          vbox.Add (self.pre_demod.win, 1, wx.EXPAND)

        # demodulate AM
        self.hilb_filt = gr.firdes_hilbert (201, gr.firdes.WIN_BLACKMAN)
        self.hilb_delay = gr.filter_delay_fc (self.hilb_filt)

        self.mag = gr.complex_to_mag ()

        self.connect (self.src,  (self.hilb_delay,0))
        self.connect ((self.hilb_delay,0),self.mag)
        self.connect (self.mag, self.lpf)

        if record:
            self.connect (self.lpf,self.head,self.recording)
            #self.connect (self.lpf,self.recording)
            #self.connect (self.mag,self.head,self.recording)
        
        if plot2:
            self.src_fft = fftsink.fft_sink_f (self, panel, title="FFT", 
fft_size=4096,sample_rate=sampling_freq, size=(50,100))
            self.connect (self.lpf, self.src_fft)
            vbox.Add (self.src_fft.win, 1, wx.EXPAND)

        if plot3:
            self.scope = scopesink.scope_sink_f(self, panel, title="Time 
Series", sample_rate=sampling_freq, 
            size=(50,100), t_scale=1.0e-3, v_scale=None)
            self.connect(self.lpf, self.scope)
            vbox.Add (self.scope.win, 1, wx.EXPAND)
        
def main ():
    app = stdgui.stdapp(app_flow_graph, "Plasma Probe Spectrum", nstatus=1)
    app.MainLoop()

if __name__ == '__main__':
    main ()
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to