mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-21 06:13:41 +00:00
Simple python script for demonstrating SCPI programming
This commit is contained in:
parent
aebe92111b
commit
9db83a608d
3 changed files with 132 additions and 0 deletions
|
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import time
|
||||
from libreVNA import libreVNA
|
||||
|
||||
# Create the control instance
|
||||
vna = libreVNA('localhost', 19542)
|
||||
|
||||
# Quick connection check (should print "LibreVNA-GUI")
|
||||
print(vna.query("*IDN?"))
|
||||
|
||||
# Make sure we are connecting to a device (just to be sure, with default settings the LibreVNA-GUI auto-connects)
|
||||
vna.cmd(":DEV:CONN")
|
||||
dev = vna.query(":DEV:CONN?")
|
||||
if dev == "Not connected":
|
||||
print("Not connected to any device, aborting")
|
||||
exit(-1)
|
||||
else:
|
||||
print("Connected to "+dev)
|
||||
|
||||
# Simple generator demo
|
||||
|
||||
# switch to generator
|
||||
vna.cmd(":DEV:MODE GEN")
|
||||
|
||||
# set the output level
|
||||
vna.cmd(":GEN:LVL -20")
|
||||
|
||||
# set initial frequency and enable port 1
|
||||
print("Generating signal with 1GHz at port 1")
|
||||
vna.cmd(":GEN:FREQ 1000000000")
|
||||
vna.cmd(":GEN:PORT 1")
|
||||
|
||||
try:
|
||||
while True:
|
||||
time.sleep(2)
|
||||
print("Setting frequency to 1.5GHz")
|
||||
vna.cmd(":GEN:FREQ 1500000000")
|
||||
time.sleep(2)
|
||||
print("Setting frequency to 1.0GHz")
|
||||
vna.cmd(":GEN:FREQ 1000000000")
|
||||
except KeyboardInterrupt:
|
||||
# turn off generator
|
||||
vna.cmd(":GEN:PORT 0")
|
||||
exit(0)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue