On 06/21/2011 05:33 PM, Tom Hendrick wrote:
Hello all, I am helping a colleague with the USRP center frequency tuning functionality and it is my understanding the signal must contain I and Q values centered at 0Hz.

A real valued signal is generated independently by another program and is fed to a GRC script. Is it easy/possible to make a GRC script downshift the signal to 0 Hz and convert to I and Q values or is there perhaps an example of this already?

Thank you in advance- Tom


I've attached an example that uses a narrow-band, real-only signal source, with everything running at an arbitrary sample rate of 150Ksps.

It uses a Hilbert transform, followed by a decimate-by-two bandpass filter.

Without the bandpass filter, there will still be a residual "image" frequency in the complex output of the Hilbert transform, and since we're
  decimating by two anyway, I thought I'd put in a bandpass filter.


--
Marcus Leech
Principal Investigator
Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org

Attachment: hilbert.grc
Description: application/gnuradio-grc

#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
# Title: Hilbert
# Generated: Tue Jun 21 21:11:31 2011
##################################################

from gnuradio import eng_notation
from gnuradio import gr
from gnuradio import window
from gnuradio.eng_option import eng_option
from gnuradio.gr import firdes
from gnuradio.wxgui import fftsink2
from grc_gnuradio import wxgui as grc_wxgui
from optparse import OptionParser
import wx

class hilbert(grc_wxgui.top_block_gui):

	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Hilbert")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = int(150e3)

		##################################################
		# Blocks
		##################################################
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
			self.GetWin(),
			baseband_freq=0,
			y_per_div=10,
			y_divs=10,
			ref_level=50,
			ref_scale=2.0,
			sample_rate=int(samp_rate/2),
			fft_size=1024,
			fft_rate=5,
			average=False,
			avg_alpha=0.250,
			title="FFT Plot",
			peak_hold=False,
		)
		self.Add(self.wxgui_fftsink2_0.win)
		self.gr_throttle_0 = gr.throttle(gr.sizeof_float*1, samp_rate)
		self.gr_sig_source_x_0 = gr.sig_source_f(samp_rate, gr.GR_SIN_WAVE, 1000, 1, 0)
		self.gr_hilbert_fc_0 = gr.hilbert_fc(256)
		self.band_pass_filter_0 = gr.fir_filter_ccc(2, firdes.complex_band_pass(
			1, samp_rate, 0.5, 50e3, 150, firdes.WIN_HAMMING, 6.76))

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_sig_source_x_0, 0), (self.gr_throttle_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.gr_hilbert_fc_0, 0))
		self.connect((self.gr_hilbert_fc_0, 0), (self.band_pass_filter_0, 0))
		self.connect((self.band_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))

	def get_samp_rate(self):
		return self.samp_rate

	def set_samp_rate(self, samp_rate):
		self.samp_rate = samp_rate
		self.gr_sig_source_x_0.set_sampling_freq(self.samp_rate)
		self.wxgui_fftsink2_0.set_sample_rate(int(self.samp_rate/2))
		self.band_pass_filter_0.set_taps(firdes.complex_band_pass(1, self.samp_rate, 0.5, 50e3, 150, firdes.WIN_HAMMING, 6.76))

if __name__ == '__main__':
	parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
	(options, args) = parser.parse_args()
	tb = hilbert()
	tb.Run(True)

_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to