Hi all,
I think I’m getting a similar problem (the discontinuities) with my LimeSDR; see figure below.
The frequency of the weird sawtooth is proportional to the sampling rate. The sawtooth doesn’t start up for about 50ms; prior to this point, the waveform looks relatively normal.
Forgive me if this is a stupid question (still pretty new to SDR), but how do I implement the above fix in GNU Radio? I assume I need to set a particular parameter in the osmocom source block, but I don’t know which one?
I’m using GNURadio v3.7.11.1, with the following code:
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio import blocks
from gnuradio import filter
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from optparse import OptionParser
from gnuradio import analog
from gnuradio import digital
import osmosdr
import sip
import sys
import time
import rfid
SINE_TEST = False
class reader_top_block(gr.top_block):
def __init__(self):
gr.top_block.__init__(self)
rt = gr.enable_realtime_scheduling()
######## Variables #########
self.dac_rate = 1e6 # DAC rate
self.adc_rate = 100e6/50 # ADC rate (2MS/s complex samples)
self.decim = 5 # Decimation (downsampling factor)
self.ampl = 0.6 # Output signal amplitude (signal power vary for different RFX900 cards)
self.freq = 910e6 # Modulation frequency (can be set between 902-920)
self.rx_gain = 20 # RX Gain (gain at receiver)
self.tx_gain = 0 # RFX900 no Tx gain option
# Each FM0 symbol consists of ADC_RATE/BLF samples (2e6/40e3 = 50 samples)
# 10 samples per symbol after matched filtering and decimation
self.num_taps = [1] * 25 # matched to half symbol period
######## File sinks for debugging (1 for each block) #########
self.file_sink_source = blocks.file_sink(gr.sizeof_gr_complex*1, "../misc/data/source", False)
self.file_sink_matched_filter = blocks.file_sink(gr.sizeof_gr_complex*1, "../misc/data/matched_filter", False)
self.file_sink_gate = blocks.file_sink(gr.sizeof_gr_complex*1, "../misc/data/gate", False)
self.file_sink_decoder = blocks.file_sink(gr.sizeof_gr_complex*1, "../misc/data/decoder", False)
self.file_sink_reader = blocks.file_sink(gr.sizeof_float*1, "../misc/data/reader", False)
if SINE_TEST :
#File to dump signal that we want to disconnect
self.file_sink_dump = blocks.file_sink(gr.sizeof_gr_complex*1, "../misc/data/dump", False)
######## Blocks #########
self.matched_filter = filter.fir_filter_ccf(self.decim, self.num_taps)
self.gate = rfid.gate(int(self.adc_rate/self.decim))
self.tag_decoder = rfid.tag_decoder(int(self.adc_rate/self.decim))
self.reader = rfid.reader(int(self.adc_rate/self.decim),int(self.dac_rate))
self.amp = blocks.multiply_const_ff(self.ampl)
self.to_complex = blocks.float_to_complex(1)
if SINE_TEST :
self.sine_source = analog.sig_source_c(self.dac_rate, analog.GR_SIN_WAVE, 440, .5, 0)
# Osmocom blocks
self.u_source = osmosdr.source(args="numchan=" + str(1) + " " + 'driver=lime,soapy=0' )
self.u_source.set_sample_rate(self.adc_rate)
self.u_source.set_center_freq(self.freq, 0)
self.u_source.set_freq_corr(0, 0)
#self.u_source.set_dc_offset_mode(0, 0)
self.u_source.set_iq_balance_mode(0, 0)
self.u_source.set_gain_mode(True, 0)
self.u_source.set_gain(self.rx_gain, 0)
self.u_source.set_if_gain(10, 0)
self.u_source.set_bb_gain(10, 0)
self.u_source.set_antenna("LNAL", 0)
self.u_source.set_bandwidth(0, 1000000)
self.u_sink = osmosdr.sink(args="numchan=" + str(1) + " " + 'driver=lime,soapy=0' )
self.u_sink.set_sample_rate(self.dac_rate)
self.u_sink.set_center_freq(self.freq, 0)
self.u_sink.set_freq_corr(0, 0)
self.u_sink.set_gain(self.tx_gain, 0)
self.u_sink.set_if_gain(15, 0)
self.u_sink.set_bb_gain(15, 0)
self.u_sink.set_antenna("BAND1", 0)
self.u_sink.set_bandwidth(0, 1000000)
######## Connections #########
self.connect(self.u_source, self.matched_filter)
self.connect(self.matched_filter, self.gate)
self.connect(self.gate, self.tag_decoder)
self.connect((self.tag_decoder,0), self.reader)
self.connect(self.reader, self.amp)
self.connect(self.amp, self.to_complex)
if SINE_TEST :
self.connect(self.to_complex, self.file_sink_dump)
self.connect(self.sine_source, self.u_sink)
else :
self.connect(self.to_complex, self.u_sink)
self.connect(self.u_source, self.file_sink_source)
self.connect(self.gate, self.file_sink_gate)
self.connect((self.tag_decoder,1), self.file_sink_decoder) # (Do not comment this line)
self.connect(self.reader, self.file_sink_reader)
self.connect(self.matched_filter, self.file_sink_matched_filter)
if __name__ == '__main__':
main_block = reader_top_block()
main_block.start()
while(1):
inp = raw_input("'Q' to quit \n")
if (inp == "q" or inp == "Q"):
break
main_block.reader.print_results()
main_block.stop()
Thanks a lot!
DasSidG
EDIT: Fixed code formatting