-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SoapyXTRX RX stream problem #60
Comments
So the issue is fist 3 samples right after stream activation are zero,
right?
…On Tue, Jul 2, 2019, 7:46 AM rmcleitao ***@***.***> wrote:
I'm using SoapySDR to configure and capture data and I'm getting something
strange in the data stream.
The first 3 samples (3x I+Q) from the readStream() come with 0+j0 but this
only happens in the first capture. Ignoring this first capture and making
the FFT (and FFT shift) of the data I get the following spectrum:
Without a signal:
[image: xtrx_soapy_problem]
<https://user-images.githubusercontent.com/52451242/60509934-0f8f0680-9cc6-11e9-85a3-ceaf2712a206.png>
With a DVB-T signal:
[image: xtrx_soapy_problem_with_signal]
<https://user-images.githubusercontent.com/52451242/60509940-1289f700-9cc6-11e9-8775-b1c700c23004.png>
I tried with three different wrappers: C, Go and Python. I also captured
the raw data and processed in Matlab/Octave with the same results.
If I use a LimeSDR with the same code everything is fine.
Here is the code used in Python:
import SoapySDR
from SoapySDR import * #SOAPY_SDR_ constants
import numpy as np
import time
import os
import numpy as no
import matplotlib.pyplot as plt
import scipy.fftpack
from numpy import array
#=======================
chan=0
ant='LNAL'
gain=15
numSamps = 4096
burstSize = 512
#=======================
#enumerate devices
results = SoapySDR.Device.enumerate()
for result in results: print(result)
#create device instance
#args can be user defined or from the enumeration result
args = dict(driver="xtrx")
sdr = SoapySDR.Device(args)
#query device info
print (sdr.listAntennas(SOAPY_SDR_RX, chan))
print "============================================="
sdr.setSampleRate(SOAPY_SDR_RX, chan, 40e6)
print("Actual Rx Rate %f Msps"%(sdr.getSampleRate(SOAPY_SDR_RX, chan)/1e6))
sdr.setFrequency(SOAPY_SDR_RX, chan, 800e6)
print("Actual Rx Freq %f MHz"%(sdr.getFrequency(SOAPY_SDR_RX, chan)/1e6))
sdr.setAntenna(SOAPY_SDR_RX,chan,ant)
print("Antenna on Channel %i is
%s"%(chan,sdr.getAntenna(SOAPY_SDR_RX,chan)))
sdr.setGain(SOAPY_SDR_RX,chan,gain)
print("Actual Rx Gain %f "%(sdr.getGain(SOAPY_SDR_RX, chan)))
sdr.setBandwidth(SOAPY_SDR_RX, chan, 40e6)
print("Actual Rx BW MHz %f "%(sdr.getBandwidth(SOAPY_SDR_RX, chan)/1e6))
print "============================================="
#create rx stream
rxStream = sdr.setupStream(SOAPY_SDR_RX, SOAPY_SDR_CF32, [chan])
#let things settle
time.sleep(1)
#start streaming
sdr.activateStream(rxStream, 0, 0, numSamps)
#create a re-usable buffer for rx samples
rxBuff = np.array([0]*burstSize, np.complex64)
#receive some samples (first samples have the zero)
sr = sdr.readStream(rxStream, [rxBuff], 512)
print rxBuff
#second capture
sr = sdr.readStream(rxStream, [rxBuff], 512)
#cleanup streams
print("Cleanup streams")
sdr.deactivateStream(rxStream) #stop streaming
sdr.closeStream(rxStream)
#print data
print rxBuff
n = len(rxBuff)
print n
#FFT
y = scipy.fftpack.fft(rxBuff)
yf = np.abs(scipy.fftpack.fftshift(y))
yf = 10*np.log10(yf)
xf = np.linspace(0.0, 1.0, n/2)
#plot FFT
fig, ax = plt.subplots()
ax.plot(yf)
plt.show()
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#60?email_source=notifications&email_token=AASAQW2ARRRQ72YZWT4UZWDP5M52DA5CNFSM4H425532YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G43TJXQ>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASAQW55DHWVCK7FKYE3YRLP5M52DANCNFSM4H42553Q>
.
|
That's one of the issues. The spectrum that I'm showing is from the second capture, maybe the issues are related. Can you test the script and see if you have the same problem? I forgot to mention that the example from libxtrx/examples/xtrx_fft/ and the osmocom block for GNU Radio are working fine. |
I noticed your sampling rate was 40MHz, have you tried lower sampling rates? |
I'm able to go higher than 40 Msps with other implementations (GNU Radio, gqrx, etc) and my workstation as an AMD Threadripper 1950X. But just to make sure I just ran the script with 10 Msps and the result is the same. |
So after finding this issue I checked the repositories and saw that I didn't had the latest versions. After updating everything the data stream seems right (the first samples are no longer zeros) but then I found out a problem with the gain function. And this issue might be the same as this one myriadrf/libxtrx#6 This happens in that python script and in C.
Specifying one of the three available gains (LNA, TIA or PGA) shows the same error:
Even with this errors the gain seems to change (not for all configurations) but not to the value that we what. It's complicated to validate the data collected from the stream (my original issue) if we can't control the gain. Edit: I will try to take a look at the SoapyXTRX source code. |
Using the setGain function (with no type name given), it will set only LNA gain. |
For exemple with this code in python: gain = 20
chan = 0
print("Set Rx Gain: %f "%(gain))
sdr.setGain(SOAPY_SDR_RX, chan, "LNA", gain)
sdr.setGain(SOAPY_SDR_RX, chan, "TIA", 0)
sdr.setGain(SOAPY_SDR_RX, chan, "PGA", 0)
print("Actual Rx LNA Gain %f "%(sdr.getGain(SOAPY_SDR_RX, chan, "LNA")))
print("Actual Rx TIA Gain %f "%(sdr.getGain(SOAPY_SDR_RX, chan, "TIA")))
print("Actual Rx PGA Gain %f "%(sdr.getGain(SOAPY_SDR_RX, chan, "PGA")))
print("Actual Rx Gain %f "%(sdr.getGain(SOAPY_SDR_RX, chan))) I get this output:
The TIA and PGA gains are correct but the LNA gain is 18 dB instead of 20 dB and the |
I reviewed the code. The issue seems to be in the LMS7002M_rfe_set_lna function and looks like expected behaviour. The max gain is 30 and the gain value is substracted by the given value. There is no value for 20, so it takes the next value, which is 18. https://github.com/myriadrf/LMS7002M-driver/blob/90cd8526ac2005ff2dd52e9b3c818b45497f439e/src/LMS7002M_rfe.c#L107-L108 However the Rx Gain is being calculated by adding all gains. Having a look at the implementation: https://github.com/pothosware/SoapySDR/blob/fe8dfd1879a8512aa305045ef1e6657a5a33f3b9/lib/Device.cpp#L313-L314 The issue seems to be this line : |
You are right, I was convinced that the gain was in 1 dB steps, but checking the datasheet of the LMS7002M it says:
|
I'm using SoapySDR to configure and capture data and I'm getting something strange in the data stream.
The first 3 samples (3x I+Q) from the readStream() come with 0+j0 but this only happens in the first capture. Ignoring this first capture and making the FFT (and FFT shift) of the data I get the following spectrum:
Without a signal:
With a DVB-T signal:
I tried with three different wrappers: C, Go and Python. I also captured the raw data and processed in Matlab/Octave with the same results.
If I use a LimeSDR with the same code everything is fine.
Here is the code used in Python:
The text was updated successfully, but these errors were encountered: