Skip to content
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

NanoVNA connection syntax out of date in example Measuring a 4-Port With The 1.5-Port NanoVNA V2 #1054

Open
kpobrien opened this issue Apr 17, 2024 · 1 comment

Comments

@kpobrien
Copy link

Describe the bug
The example https://scikit-rf.readthedocs.io/en/latest/examples/metrology/NanoVNA_V2_4port-splitter.html#Measuring-a-4-Port-With-The-1.5-Port-NanoVNA-V2 is out of date and uses no longer functional syntax for operating the NanoVNA.

To Reproduce
Steps to reproduce the behavior:

>>> from skrf.vi import vna
>>> nanovna = skrf.vi.vna.NanoVNAv2('ASRL/dev/ttyACM0::INSTR')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'skrf.vi.vna' has no attribute 'NanoVNAv2'

Expected behavior
I expect to be able to successfully connect to the NanoVNA. Using the syntax from the comment at the end of #901, I'm able to connect successfully as in the example below:

from skrf.vi.vna import nanovna
instr = nanovna.NanoVNA('ASRL/dev/ttyACM0::INSTR')

System

  • OS: Linux
  • scikit-rf version: 0.32.0
  • NanoVNA version: NanoVNA v2 Plus 4

Additional context
I'll submit a PR to update this example when I get a chance. Thanks!

@kpobrien
Copy link
Author

kpobrien commented Apr 17, 2024

The current (not working) version of the data acquisition portion of the example is:

import skrf
from skrf.vi import vna

# connect to NanoVNA on /dev/ttyACM0 (Linux)
nanovna = skrf.vi.vna.NanoVNAv2('ASRL/dev/ttyACM0::INSTR')

# for Windows users: ASRL1 for COM1
# nanovna = skrf.vi.vna.NanoVNAv2('ASRL1::INSTR')

# configure frequency sweep (for example 1 MHz to 4.4 GHz in 1 MHz steps)
f_start = 1e6
f_stop = 4.4e9
f_step = 1e6
num = int(1 + (f_stop - f_start) / f_step)
nanovna.set_frequency_sweep(f_start, f_stop, num)

# measure all 12 combinations of the 4-port
n_ports = 4
for i_src in range(n_ports):
    for i_sink in range(n_ports):
        if i_sink != i_src:
            input('Connect vna_p1 -> dut_p{}, vna_p2 -> dut_p{} and press ENTER:'.format(i_src + 1, i_sink + 1))
            nw_raw = nanovna.get_snp_network(ports=(0, 1)
            nw_raw.write_touchstone('./data_MiniCircuits_splitter/dut_raw_{}{}'.format(i_sink + 1, i_src + 1))

The latest acquisition code doesn't have the get_snp_network function, so I use get_s11_s21 then assemble the network manually. I tested the code below on a NanoVNA v2 plus 4 with scikit-rf 0.32.0 and it works.

import skrf
from skrf.vi.vna import nanovna
from skrf import Frequency

# connect to NanoVNA on /dev/ttyACM0 (Linux)
instr = nanovna.NanoVNA('ASRL/dev/ttyACM0::INSTR')

# for Windows users: ASRL1 for COM1
# instr = nanovna.NanoVNA('ASRL1::INSTR')

# configure frequency sweep (for example 1 MHz to 4.4 GHz in 1 MHz steps)
f_start = 1e6
f_stop = 4.4e9
freq = Frequency(start=f_start, stop=f_stop, npoints=1024,unit='hz')
instr.frequency = freq

# measure all 12 combinations of the 4-port
n_ports = 4
for i_src in range(n_ports):
    for i_sink in range(n_ports):
        if i_sink != i_src:
            input('Connect vna_p1 -> dut_p{}, vna_p2 -> dut_p{} and press ENTER:'.format(i_src + 1, i_sink + 1))
            s11, s21 = instr.get_s11_s21()
            nw_raw = skrf.network.four_oneports_2_twoport(s11, s21, s21, s11)
            nw_raw.write_touchstone('./data_MiniCircuits_splitter/dut_raw_{}{}'.format(i_sink + 1, i_src + 1))

A few questions:

  1. Is this a reasonable way to generate the network?
  2. An alternative is to implement get_snp_network in nanovna.py. I'm happy to do that once I understand (3).
  3. Is my understanding that skrf/vi/vna/nanovna_v2.py is not functional (see the example in the bug report) and we should be using skrf/vi/vna/nanovna/nanovna.py for both v1 and v2? If that's correct, then I can port functionality such as get_snp_network from nanovna_v2.py to nanovna.py then delete nanovna_v2.py to avoid confusion.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants