Vector Network Analyzer

I’ve built one TFD antenna with 800 ohm termination + a 16:1 balun to match the 50 ohm low loss coax. The antenna is at about 2.8 m from the ground, temporarily held by 2" PVC pipes + vents. Will replace with bigger wood poles in the future.
The RX is a LimeSDR and I’ve built also a 15-30 MHz bandpass filter to shut-up the FM stations…

For the antenna I’ve followed the instructions published by Dave Typinski for the TFD array (4 TFD antennas to get left and right polarization).
I currently have just one TFD but hope to step up to 2 in a crossed dipole and then possibly to the full 4 elements configuration. Time availability is the real issue…



I’m struggling to get this running on Windows 10. I’m attempting to build cyLimeLib which fails with the following:

D:\Download\LMS7002M\pyLMS7002M\cyLimeLib\win>python27 install
running install
running bdist_egg
running egg_info
writing cyLimeLib.egg-info\PKG-INFO
writing top-level names to cyLimeLib.egg-info\top_level.txt
writing dependency_links to cyLimeLib.egg-info\dependency_links.txt
reading manifest file 'cyLimeLib.egg-info\SOURCES.txt'
writing manifest file 'cyLimeLib.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_ext
cythoning cyLimeLib.pyx to cyLimeLib.cpp
warning: cyLimeLib.pyx:33:16: local variable '_devStr' referenced before assignment
warning: cyLimeLib.pyx:34:12: local variable '_devStr' referenced before assignment
warning: cyLimeLib.pyx:35:40: local variable '_devStr' referenced before assignment
building 'cyLimeLib' extension
creating build
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Users\Allen\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Sync\Dev\Python27\include -IC:\Sync\Dev\Python27\PC /TpcyLimeLib.cpp /Fobuild\temp.win32-2.7\Release\cyLimeLib.obj -O2
d:\download\lms7002m\pylms7002m\cylimelib\win\pstdint.h(444) : error C2371: 'uint32_t' : redefinition; different basic types
        cyLimeLib.cpp(238) : see declaration of 'uint32_t'
error: command 'C:\\Users\\Allen\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

I’ve given up on trying to get LimeAPI working (see above) and switched over to libusb which at least allows me to run the scripts. I have made several passes against a chinese 900MHz-ish dipole and the results I’m seeing don’t appear to be working correctly. Specifically, my SWR and Smith charts are all over the place, and S11 > 0 near what should be the antenna’s tuned freq.

Hardware Setup

  • LimeSDR USB:
    Searching for LimeSDR…
    LimeSDR info:
    FW_VER : 4
    DEV_TYPE : 14
    HW_VER : 4
    EXP_BOARD : 1

    LMS7002M info:
    VER : 7
    REV : 1
    MASK : 1

  • Chinese-grade 0Ω SMA short

  • Mini Circuits ZFDC-15-5-S

  • LimeSDR RX1_L wired to CPL

  • LimeSDR TX2_1 wired to 10dba attenuator to OUT

  • Short and DUT connected to IN

Software Setup

Sweep configuration in and

startFreq = 700e6
endFreq = 1100e6
nPoints = 401

Setup for TX low freq LNA in


Test Results

Feedback from a colleague:

"It seems that you have used TX and RX channels which are different than the ones in the example.

Changing channels is not trivial, and requires additional LMS7002M configuration.

To check that the setup is correct, please use the VNA example with connections as in documentation, just change start and stop frequencies."

Hope that helps.

First, thanks for the feedback! That is in fact true as I am working with 915MHz ISM band equipment (LoRa radios), so with very little thought applied I changed the LNA to LNAL figuring that was an easy fix. I just ran the test using the stock settings (with changes outlined in the blog post) on a 2.4GHz wifi antenna and I see the results I would expect.

This then leads to the question - can your team offer any guidance as to how one might best perform the same function at 900MHz? The blog post suggests:

Is that to suggest that it simply can’t happen? Or that it needs a bunch of changes to the script to make it work?

edit: confirmed on the phase noise when running LNAH @ 900MHz:

I’m not sure if this is going to help my tune my antenna or tell my my horoscope :smiley:

1 Like

A new measurement script for 800 - 1000 MHz range has been uploaded to GitHub VNA example:

Documentation has also been updated to show the setup for new script:
In short, TX1_1 and RX1_L are used to transmit/receive.

Please try the new measurement script and post results.

1 Like


This new script works a lot better for the low range RX/TX. Plots actually make sense and the values are within the ranges I would expect.

This was a quick test running under less-than-ideal conditions (namely, antenna laying on my concrete floor in a room with several other active radios all blasting out traffic in the test frequency band), but given that I think I can actually use this as a tool moving forward.


1 Like

Great, I’m glad that it worked.
S11 and VSWR are consistent, but Smith chart plot looks a bit strange.
The trace on Smith chart is almost entirely outside of VSWR<2 circle, but according to VSWR plot the trace should go very close to the center.
Have you used the version of pySmithPlot linked in PDF document or a newer one?
Python 2 or 3?

You are absolutely correct in that I have the 2.0 version of pySmithPlot installed. I downloaded the linked release and I cannot seem to get that running under Python 3.6.5 on Windows. I spun up a new Win 10 VM, installed python-3.6.5-amd64.exe into C:\Python36, ran on the pySmithPlot release linked above (which worked), downloaded the latest pyLMS7002M-master branch, ran there (also worked), then attempted to run against the test data from the measurements shown above. I also ran this on my existing PYthon 3.6 installation, and have tried it in a new venv before spinning up the VM all in attempt to start from a “clean” environment. In all cases, I get the following error when attempting to execute “python vna_test900-01 plot”:

C:\Download\pyLMS7002M\examples\VNA>python vna_test900-01 plot
Traceback (most recent call last):
  File "", line 25, in <module>
    import smithplot
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "C:\Python36\lib\site-packages\pysmithplot-0.1.0-py3.6.egg\smithplot\", line 2, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 951, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 894, in _find_spec
  File "<frozen importlib._bootstrap_external>", line 1157, in find_spec
  File "<frozen importlib._bootstrap_external>", line 1131, in _get_spec
  File "<frozen importlib._bootstrap_external>", line 1112, in _legacy_get_spec
  File "<frozen importlib._bootstrap>", line 441, in spec_from_loader
  File "<frozen importlib._bootstrap_external>", line 544, in spec_from_file_location
  File "C:\Python36\lib\site-packages\pysmithplot-0.1.0-py3.6.egg\smithplot\", line 1262
    def _moebius_xy((x, y)):
SyntaxError: invalid syntax

pip list returns the following:

cycler (0.10.0)
Cython (0.28.1)
kiwisolver (1.0.1)
matplotlib (2.2.2)
numpy (1.14.2)
pip (9.0.3)
pylms7002m (1.2.0)
pyparsing (2.2.0)
pyserial (3.4)
pysmithplot (0.1.0)
python-dateutil (2.7.2)
pytz (2018.4)
pyusb (1.0.2)
setuptools (39.0.1)
six (1.11.0)

I’ll see if the process fares any better under Ubuntu 16.04 LTS.

edit: build results under 16.04 gives the same error for the same line while building the suggested release of pySmithPlot via python3 install:

byte-compiling build/bdist.linux-x86_64/egg/smithplot/ to smithaxes.cpython-34.pyc
  File "build/bdist.linux-x86_64/egg/smithplot/", line 1262
    def _moebius_xy((x, y)):
SyntaxError: invalid syntax

Executing on that 16.04 instance yields an error nearly identical to the Windows version:

~/pyLMS7002M/examples/VNA$ python3 test900-01 save
Traceback (most recent call last):
  File "", line 25, in <module>
    import smithplot
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
  File "/usr/local/lib/python3.5/dist-packages/pysmithplot-0.1.0-py3.5.egg/smithplot/", line 2, in <module>
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 954, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 896, in _find_spec
  File "<frozen importlib._bootstrap_external>", line 1139, in find_spec
  File "<frozen importlib._bootstrap_external>", line 1115, in _get_spec
  File "<frozen importlib._bootstrap_external>", line 1096, in _legacy_get_spec
  File "<frozen importlib._bootstrap>", line 444, in spec_from_loader
  File "<frozen importlib._bootstrap_external>", line 533, in spec_from_file_location
  File "/usr/local/lib/python3.5/dist-packages/pysmithplot-0.1.0-py3.5.egg/smithplot/", line 1262
    def _moebius_xy((x, y)):
SyntaxError: invalid syntax

Python modules:

:~/pyLMS7002M/examples/VNA$ pip3 list
chardet (2.3.0)
command-not-found (0.3)
cycler (0.10.0)
kiwisolver (1.0.1)
language-selector (0.1)
matplotlib (2.2.2)
numpy (1.14.2)
pip (8.1.1)
pycurl (7.43.0)
pygobject (3.20.0)
pyLMS7002M (1.2.0)
pyparsing (2.2.0)
pyserial (3.4)
pysmithplot (0.1.0)
python-apt (1.1.0b1+ubuntu0.16.4.1)
python-dateutil (2.7.2)
python-debian (0.1.27)
python-systemd (231)
pytz (2018.4)
pyusb (1.0.2)
requests (2.9.1)
setuptools (20.7.0)
six (1.10.0)
ssh-import-id (5.5)
ufw (0.35)
unattended-upgrades (0.1)
urllib3 (1.13.1)
virtualenv (15.0.1)
wheel (0.29.0)

Here is the source data if it would be of any help:

The VNA code has been developed and tested with Python 2.7 and the pySmithPlot library linked in the PDF file.
Please use these versions, as this is known to work.

I’ve plotted your measurement data with code from GitHub, and the Smith chart now makes sense.
Maybe there is a bug in new version of pySmithPlot?


That’s exactly what I was hoping to see from this! I’ll keep working on my side trying to sort this out and I’ll report back when I have it working. I bought the LimeSDR as a test/measurement device and this is my number one use case, and I’m thrilled to see it actually generating usable output. I really appreciate all your help here!

1 Like

Scripts generate Touchstone file (.s1p) which can be viewed in online S parameter tool, such as
This could save you the trouble of figuring out why the new version of pySmithPlot is not producing correct results.

1 Like

Allright I finally have this working under Windows and Python 2.7.13 and pySmithPlot 0.1.0. The problem I eventually ran into was related to matplotlib: version 2.2.x has removed support for axes.color_cycle (deprecated in 1.5.0) which is used in pysmithplot, and so things were failing until I reverted to an older version via pip install matplotlib==2.1.2. This appears to be the last version of matplotlib that will work with pysmithplot 0.1.0. matplotlib 2.2.0 is also noted to be the last version that will support python 2.7.

So, with Python 2.7, matplotlib 2.1.2, and pysmithplot 0.1.0 this collection of scripts works as expected. Thanks again for your guidance here, I think I have what I need!


Really good to see this work! I’m looking forward to testing it myself.

Just a comment - I’m trying to learn some of the pyLMS7002M usage, but it’s tough sledding.
For instance - the script has:

# Make ADC and DAC clocks equal
#in CGEN Control Diagram, forward divider
# and CGEN config memory, 0x0086 bits 11:
# EN_ADCCLKH_CLKGN: Selects if F_CLKH or F_CLKL is connected to FCLK_ADC
# (F_CLKH and F_CLKL are the two internally generated clocks.
# A MUX will connect one of them to FCLK_ADC and the other to FCLK_DAC.).
# 0 – FCLK_ADC from F_CLKH / FCLK_DAC from F_CLKL
# 1 – FCLK_ADC from F_CLKL / FCLK_DAC from F_CLKH (default)
# in CGEN same forward divider
# and CGEN config memory, 0x0089, bits 12-11
# CLKH_OV_CLKL_CGEN[1:0]: FCLKL here is ADC clock. FCLKH is the clock to the DAC and if no division is added to the ADC as well.
# Default: 0

The first option switches DAC/ADC from FCLKL/FCLKH easy enough.
The 2nd looks like it’s setting FCLKL to FCLKH / 4 ? I don’t see how that makes them equal.

You can see that in the GUI also not equal but in a different way:

Which leads to the next comment - it’s going to be sort of limiting if we have to hire an LMS7002M programmer to have the LimeSDR do what we want, whereas the popular but expensive NI gear you just use it :slight_smile:

python code lms7002.CGEN.CLKH_OV_CLKL_CGEN = 2 uses chip register value (as in 0,1,2,3), while in GUI the combobox displays values of 2^CLKH_OV_CLKL (as in 1,2,4,8)

Ok thanks - I see that in the source now:

txtFrequencyCLKL->SetValue(wxString::Format(_("%.3f"), cgenFreq / pow(2.0, cmbCLKH_OV_CLKL_CGEN->GetSelection())));


For a positive note, what I was attracted to in the LimeSDR is you really get a lot for your $$, or this thing has more nerd knobs than I have brain cells left.

Will continue digging in and putting the puzzle pieces together.

1 Like

Getting the hang of this and it’s really working great. I designed a small PCB for a 1090MHz bandpass SAW filter and being able to test with the LimeSDR really makes a difference (surprisingly, the filter appears to work). Using a 10dB filter here, but looks like I should be using 20dB so further testing is on hold until that arrives.


Now my question would be will this work with the Limesdr mini?

First step would be pyLMS7002M support:

Hello @andrewback .
I just ported the package to Python 3.
The repository is available here:

Most of the changes (95%) have been made automatically running (standard python) and few others directly by me. Most of them are about module imports.

Please note that like many others I’m using Python 3.x, Jupyter notebooks and several scientific packages that benefit from lots of new stuff available in Python 3.x.

IMHO, you should consider this upgrade to this important package ever since it would enlarge the involved user base.
There’s a big movement around the push to phase out python 2.7…

Another important topic:

I would kindly ask your team to check if it can be possible to leverage inside the same tuning operations that allow soapy_power and the various radio listening sw (GQRX, SDR Console, etc) to tune below the 240 MHz limit. With those programs it is possible to listen AM, HF, FM and air frequencies…

Being able to test filters and antennas at HF (but not only) would be a real plus.

I already have 4 devices to test and… I can’t because of this limitation… I remember that in the past also other forum members like @M0GLO , @marukqs , @Axeman were asking questions about this topic…

I’ve seen lots of changes/improvements/refactoring in the release notes … I’m wondering if those could be leveraged in the VNA scripts…