Replies: 1 comment 5 replies
-
There is an example script which does pretty much what you want to do: https://github.com/jankae/LibreVNA/blob/master/Documentation/UserManual/SCPI_Examples/retrieve_trace_data.py Please try if that works. If you are using version 1.5.1 be sure that you also checkout this script (and, more importantly, the LibreVNA.py) from the v1.5.1 tag. There is some work on master which changes the SCPI behavior a little bit. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm writing a python program that gets data from the VNA but im having an issue with the data not being received.
import sys
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?"))
def safe_query(query, vna, timeout=None):
try:
response = vna.query(query, timeout=timeout)
print(f"Query: {query}, Response: {response}")
return response
except Exception as e:
print(f"Error during query '{query}': {e}")
return None # Allow the script to continue
def safe_cmd(cmd, vna, check=False, timeout=None):
try:
vna.cmd(cmd, check=check, timeout=timeout)
print(f"Command: {cmd} executed successfully")
except Exception as e:
print(f"Error during command '{cmd}': {e}")
Quick connection check (should print "LibreVNA-GUI")
idn_response = safe_query("*IDN?", vna)
dev = safe_query(":DEV:CONN?", vna)
if dev is None or "ERROR" in dev or "Not connected" in dev:
print("Device is not connected properly. Aborting")
sys.exit(-1)
else:
print(f"Connected to {dev}")
Simple trace data extraction
Switch to VNA mode, setup the sweep parameters
print("Setting up sweep parameters...")
safe_cmd(":DEV:MODE VNA", vna)
time.sleep(0.5)
safe_cmd(":VNA:SWEEP FREQUENCY", vna)
time.sleep(0.5)
safe_cmd(":VNA:STIM:LVL -10", vna)
time.sleep(0.5)
safe_cmd(":VNA:ACQ:IFBW 10000", vna)
time.sleep(0.5)
safe_cmd(":VNA:ACQ:AVG 2", vna)
time.sleep(0.5)
safe_cmd(":VNA:ACQ:POINTS 501", vna)
time.sleep(0.5)
safe_cmd(":VNA:FREQuency:START 250000000", vna)
time.sleep(0.5)
safe_cmd(":VNA:FREQuency:STOP 350000000", vna)
time.sleep(0.5)
Manually check status
print("Manual status check...")
status = safe_query("*ESR?", vna)
if status is None or "Not connected" in status:
print("Device status check failed. Continuing without status check.")
time.sleep(0.5)
Wait for the sweep to finish
print("Waiting for the sweep to finish...")
try:
while safe_query(":VNA:ACQ:FIN?", vna) == "FALSE":
time.sleep(0.5)
except Exception as e:
print(f"Error during sweep acquisition: {e}")
Grab the data of trace S11
print("Reading trace data...")
data = safe_query(":VNA:TRACE:DATA? S11", vna)
time.sleep(0.5)
if data:
try:
S11 = vna.parse_VNA_trace_data(data)
time.sleep(0.5)
for x in S11:
print(x)
except Exception as e:
print(f"Error reading trace data: {e}")
else:
print("No data received for trace S11.")`
The output in console I'm getting
LibreVNA,LibreVNA-GUI,dummy_serial,1.5.1
Query: *IDN?, Response: LibreVNA,LibreVNA-GUI,dummy_serial,1.5.1
Query: :DEV:CONN?, Response: 205E35C43750
Connected to 205E35C43750
Setting up sweep parameters...
Command: :DEV:MODE VNA executed successfully
Command: :VNA:SWEEP FREQUENCY executed successfully
Command: :VNA:STIM:LVL -10 executed successfully
Command: :VNA:ACQ:IFBW 10000 executed successfully
Command: :VNA:ACQ:AVG 2 executed successfully
Command: :VNA:ACQ:POINTS 501 executed successfully
Command: :VNA:FREQuency:START 250000000 executed successfully
Command: :VNA:FREQuency:STOP 350000000 executed successfully
Manual status check...
Query: *ESR?, Response:
Waiting for the sweep to finish...
Query: :VNA:ACQ:FIN?, Response:
Reading trace data...
Query: :VNA:TRACE:DATA? S11, Response:
No data received for trace S11.
I have the firmware on the VNA as 1.5.1. From the output everything is working but "Query: :VNA:TRACE:DATA? S11, Response:
No data received for trace S11." I don't know how I could fix this.
Beta Was this translation helpful? Give feedback.
All reactions