Download This Notebook: VirtualInstruments.ipynb
Virtual Instruments
Introduction
Warning
The vi modules depends on PyVISA as well as some additional libraries. Make sure you’ve followed the instructions in the installation tutorial to ensure a working setup.
Additionally, PyVISA can use a number of different backends to communicate with instruments. The installation of these is up to the user, but there are further instructions in the PyVISA documentation By default, PyVISA uses it’s Python VISA implementation, but certain instrument configurations require their manufacturer’s specific VISA library be installed and used to communicate with instruments. For example, the Keysight IO libraries suite has to be used to communicate with their instruments over GPIB.
The virtual instrument module defines a consistent high-level interface for interacting with different types of instruments that can be controlled with SCPI (or other means). Primarily for scikit-rf, this is vector network analyzers (VNAs), but we are actively working on adding support for spectrum analyzers.
For information on specific instruments, consult the vi module’s documentation.
The currently supported instruments are (organized by manufacturer):
Keysight
NanoVNA
Tip
You can help grow scikit-rf by adding support for more instruments! It’s really not that complicated. Check out the vi module documentation to learn how.
Examples
Connecting to an instrument over an ethernet connection
from skrf.vi.vna.keysight import PNA
instr = PNA(address="TCPIP0::10.0.0.5::INSTR")
print(instr.id)
Changing the frequency settings of an instrument
from skrf.vi.vna.keysight import PNA
from skrf import Frequency
instr = PNA(address="TCPIP0::10.0.0.5::INSTR")
freq = Frequency(start="2.3 GHz", stop="2.6 GHz", npoints = 451, unit='hz')
instr.ch1.frequency = freq
Creating an S21 measurement on the instrument
from skrf.vi.vna.keysight import PNA
instr = PNA(address="TCPIP0::10.0.0.5::INSTR")
instr.ch1.create_measurement(name="SKRF S21", parameter="S21")
Getting a full 2-port network and plotting
from skrf.vi.vna.keysight import PNA
instr = PNA(address="TCPIP0::10.0.0.5::INSTR")
# Here we create temporary S11 and S22 to make sure ports 1 and 2 are driven
# This might change at some point to having get_snp_network do this
# automatically in the background
instr.ch1.create_measurement(name="Temp S11", parameter="S11")
instr.ch1.create_measurement(name="Temp S22", parameter="S22")
ntwk = instr.ch1.get_snp_network(ports=(1,2))
ntwk.plot_s_db()
instr.ch1.delete_measurement(name="Temp S11")
instr.ch1.delete_measurement(name="Temp S22")