pyLMS7002Soapy Problems

Hi All,

I have a Windows 10 computer with winpython 3 and spyder. I would like to use the pyLMS7002Soapy code to use my LimeMINI like a vector network analyzer (to measure S12 in fact, not S11 like in the example).

My problems are related to the installation.

I followed the install instructions via the windows command window, where the installation worked and > > > from pyLMS7002Soapy import * worked, too.

Question 1: the same commands fail via the spyder interpreter.

from pyLMS7002Soapy import *

Traceback (most recent call last):

File “”, line 1, in
from pyLMS7002Soapy import *

File “C:\user\programs\pyLMS7002Soapy-master\pyLMS7002Soapy-master\build\lib\pyLMS7002Soapy\pyLMS7002Soapy.py”, line 1, in
import SoapySDR

File “C:\Program Files\PothosSDR\lib\python3.6\site-packages\SoapySDR.py”, line 17, in
_SoapySDR = swig_import_helper()

File “C:\Program Files\PothosSDR\lib\python3.6\site-packages\SoapySDR.py”, line 16, in swig_import_helper
return importlib.import_module(’_SoapySDR’)

File “C:\user\programs\WPy-3670\python-3.6.7.amd64\lib\importlib_init_.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)

ImportError: DLL load failed: The specified module could not be found.

Question 2: in the very beginning of the code, what is the meaning of

if len(sys.argv)!=2:
print(“Usage: python measureVNA.py measurementName”)
exit(1)

because I find sys.argv = [’’] which makes the code fail.

Any help or insights are much appreciated.

Thanks in advance.

This looks like a Soapy related problem.
I don’t know whether Soapy works with Spider, maybe you should ask Soapy developers.

As for measuring transmission parameters, it should be possible by changing the provided example.

Thanks for the quick reply.

So if I dont use Spider but just the windows command window, there should be no soapySDR problem?

What is the role of the following?

And for measuring transmission parameters, is there a need to change the code? I thought I’d just connect things different physically (one transmit and one receive port).

If you have Soapy installed, it should work from command prompt.

The code snippet checks if Python script is called with one argument - file name to save results.

Transmission parameters can in principle measured with the same script.
I would recommend using attenuators on both RX and TX side, and maybe reduce TX and RX gain.
You would have to experiment to see whether you’re getting valid measurements or is RX in saturation.

Hi drugjic,

Thanks for those details.

I have run into the followng issue:

I have installed pyLMS7002Soapy via the cmd prompt in windows 10 and importing it in there works fine.

However, when I try to execute the measureVNA.py code, I get the attached error that pyLMS7002Soapy is not defined

Any ideas or hints where I went wrong / what is missing?

It looks like the pyLMS7002Soapy is not installed.
Have you run python setup.py install in the package root directory to install the package?

Yes, I think so, otherwise the “from pyLMS7002Soapy import*” command would produce an error (right?) which it does not…

I had previously installed pyLMS7002Soapy via the cmd prompt by going into the folder pyLMS7002Soapy-master and then “python.exe setup.py install”

Please try to run a provided example (measureSNA or measureVNA) to see whether it will work.

They yield the same error of pyLMS7002Soapy not being defined on line 159 which reads limeSDR = pyLMS7002Soapy(0)

I agree it does look like pyLMS7002Soapy is not properly installed, but I did install it. I tried it on two different windows computers with python 3 and got the same error.

Python version might be a problem.
We are developing and testing with Python 2.7.
Please try with Python 2.7.

Ok. So I uninstalled Pothos, installed winpython 2.7, added it to the cmd prompt path, reinstalled Pothos with the python 2 bindings, and then reinstalled pyLMS7002Soapy; however, now even the simple “from pyLMS7002Soapy import*” fails (even there was no error message upon installation):

The screen shot you have provided says that the problem is with SoapySDR.
The error occurs when pyLMS7002Soapy tries to import SoapySDR.
Try
import SoapySDR
and it will give you the same error.
In short, this problem is related to installation of SoapySDR.
Please consult Soapy forums on how to install SoapySDR.

First, I confirm that I had a SoapySDR issue. Brief summary in case other windows 10 users struggle: use python 2.7 (not python 3!) and install Pothos not in a custom directory but in the default one C:\Program Files.

Now, I would like to ask a few more conceptual questions about the VNA measurement with pyLMS7002Soapy.

Like I said, I am interested in measuring transmissions S12 between 2 antennas (e.g. to measure a wireless link channel).

  1. My setup does not require neither attenuator nor directional coupler right? (attenuator I think is not necessary because |S12| is small anyway for free space transmission between two antennas)

  2. Any thoughts on what the calibration procedure should be like? Connecting a short to both RX and TX ports? But then no signal would exit RX and no signal would enter TX so the measurement seems pointless. Is a through measurement a better idea?

  3. Imagine I would like to do a series of S12 transmission measurements (e.g. to see how S12 changes over time due to moving antenna, or whatever), then there are certain parts of the pyLMS7002Soapy code that I do not need to repeat for every additional S12 measurement, in particular the ‘short’ calibration. What exactly should I include in every loop of S12 measurement? I mainly wonder about the following lines between saving the ‘short’ data and starting the ‘DUT’ part. Could you provide

lms7002.verbose = 0

lms7002.SX[‘T’].setFREQ(startFreq)

lms7002.SX[‘T’].PD_LOCH_T2RBUF = 0

syncPhase(lms7002)

TRF.PD_TXPAD_TRF = 1 # Turn off TXPAD while calibrating RX DC

cal.rxDCLO(‘A’, LNA, lnaGain=lnaGain, pgaGain=pgaGain)

calRSSI = RxTSP.RSSI

TRF.PD_TXPAD_TRF = 0 # Turn on TXPAD

refPhase = mcuPhase()

  1. The calibration essentially multiplies each S(f) with a complex valued C(f). That means if I am only interested in monochromatic S12 measurements, i.e. S12(f_0), and do not mind a global offset that is the same for every measurement in my S12 measurement series, then I can in fact just take the DUT data from measureVNA.py without applying any calibration calculations, right?

Thanks!

It certainly seems like I get saturation.

I’m trying to understand which gain parameters I should adjust to which value. On the RX side, there is lna and pga, and it seems lna is fixed to 6 and pga for every frequency point is individually adjusted until RSSI > 50e3.

  • Why is the gain changed for every frequency point?
  • In what units is RSSI (50e3 seems like a huge number)?.

calThreshold = 500 # RSSI threshold to trigger RX DC calibration

  • what is the meaning of calThreshold?

calRSSI = RxTSP.RSSI

  • what is calRSSI

What gain parameters are there on the TX side? I only see TBB which is set to 5 (dB?).

I’d be very grateful for any explanation to better understand the pyLMS7002Soapy code. And tips what gain settings I can try. Thanks.

The gain is not constant across the whole frequency band, and it is adjusted to get the maximum dynamic range.

Since your setup is two antennas, I’d recommend that you use measureSNA instead of measure VNA.
Measurements are faster with measureSNA and the code is much simpler.

You would need two measurements:

  1. Instead of measurement with SHORT, use through to get the reference power level.
  2. Measure DUT by connecting two antennas to RX and TX.

I would recommend using attenuators at both RX and TX because they will help with preventing saturation in through measurement.
If you have problems with saturation in through measurement please try to adjust rxGain, which is 20 dB by default.

meausureSNA script can be modified so that though measuements are reused.
The simplest way is to modify the code by putting the DUT measurement code in infinite loop:
while (True):
userConfirmation(“Connect DUT”)
(remaining code is also in infinite loop)

This will make repeated measurements.

Thanks for clarifying.

I would like to get phase and amplitude information. SNA only provides magnitude. Why does the SNA code discard the phase information of fft(buff), is it not meaningful?

Could you please explain the variable calRSSI? Because I see it varies for different frequencies, even if I fix the gain for all frequencies, and I would like to understand why?

Is it equally good to reduce the gain and not use attenuators? (I’m asking because I don’t have attenuators…)

Final question: What is physically the origin of the need for phase unwrapping? If I do single-frequency S-parameter measurements, I won’t be able to unwrap and the phase value will be meaningless?

Do you really need phase information?

Measuring phase is not trivial, and in standard setup you would need four directional couplers and four receive channels for phase measurement.
Phase measurement in VNA example is using features of LMS7002 as TDD mode etc. and it took us a lot of time to debug, so changing it will be anything but simple.
Again, if you don’t have a really good reason why you need phase, I would strongly suggest that you use SNA.

Reducing gain and using attenuators is not identical.
Using attenuators will reduce the signal level, but will also improve matching and reduce TX power variation with load.
You can try to measure without attenuators.

Variable calRSSI contains the value of RSSI reading after calibration (DC offset etc.) - residual RSSI.
Ideally it would be 0, but isn’t due to noise and imperfect calibration.

Yes. Well in fact I don’t mind a global phase offset across all measurements, but essentially I want to compare S12 measurements of different systems, and access to phase is very valuable for this comparison. A lot of information is lost if I only consider amplitude. But, like I said, a global phase error does not matter as long as it is the same for all measurements.

So should calRSSI be subtracted from RSSI - or is it more complicated than that? Although I guess if calRSSI<<RSSI, it doesn’t matter too much.

I absolutely appreciate that, that’s why I’m incredibly happy I found your code and “only” have to adapt it rather than starting from scratch.

If I’m doing repeated single frequency S12 measurements, is there a way to ensure the phase does not jump around (because I can’t unwrap the phase with a single frequency measurement) - I want the phase to change only if the DUT changed.

I’ve modified the measureVNA script so that it measures magnitude and phase at one frequency.
You can get the code from
https://pastebin.com/8V0s7jyp

Please change the operating frequency at line 8 to suit your needs and post if this is what you needed.

First tests suggest this works very well, including phase! When DUT does not change, both amplitude and phase appear stable, phase does not jump around.

And it is fast, less than 1 second per measurement point.

Thank you very much.

I’ll do some further tests and keep you posted.

1 Like