EEVblog Electronics Community Forum
Products => Test Equipment => Topic started by: piranha32 on August 14, 2021, 05:44:33 am
-
Hello,
I would like to ask if anyone has experience with using PyVISA with USB devices, and can help me debug this problem.
I try to connect to Siglent's SPD 3303C power supply, the package can see the instrument, can open it as a TMC device, but most of the times reading from it fails on timeout. Sending commands not returning any output also works only from time to time (write() fail silently, unlike commands reading back).
I can control the power supply using Siglent's Windows application, so the USB interface works. PyVISA has no problems connecting to RTB2004 in TMC mode, so this part also works. The firmware is upgraded to the latest version available on Siglent's web site (1.02.01.01.03R6). TImeout is set to ~2s, so there should be enough time to deceive the data.
Initially I planned to get much smaller power supply, but decided to buy SPD3303C only because it can be controlled using VISA interface, so this is extremely frustrating.
Attached images show screenshots of a successful execution of "*IDN?" query (after 25 failures), and a failure on the next run.
-
There may be some guidance here:
https://siglentna.com/operating-tip/spd-programming-tips/
-
Thanks!
This helped. Apparently the problem is with SPD3303C requiring a delay between operations. Even issuing a read() directly after sending "*IDN?" leads to a timeout. Inserting 0.1 second delay is sufficient to avoid it.
-
A quick update for those looking for help in the future:
Siglent in the linked post says that query() will not work because it does not wait between sending the command and reading results. Current implementation of query() accepts delay argument, addressing this issue.
The following command works fine:
print(inst.query("*IDN?", delay=0.1))
The same effect can be achieved by setting query_delay property (no need to add delay to each query):
inst.query_delay = 0.1
print(inst.query("*IDN?"))
Delay also has to be added after each command. If another command is sent too quickly, it will cancel execution of the preceding one.
This code does not work:
inst.write("CH1:VOLTage 11.03") # this command will not be executed
print(inst.query("CH1:VOLTage?"))
After adding a delay after write, the commands work as expected:
inst.write("CH1:VOLTage 11.03")
time.sleep(0.1)
print(inst.query("CH1:VOLTage?"))