First of all, I'm a New to the Forum, New to Python and the only programming I have done was in the 80's and 90's in GWBASIC. I managed to follow a couple YouTube tutorials and saw some progress. All three of my instruments work fine individually (Power Supply, DMM and Scope). I have full control of each individually and all SCPI commands work as expected.
When I try to put a second instruments into one script is when the issues arise. The code runs fine until it reaches a command to the second instrument.
Thanks for your help.
import pyvisa
import time
rm = pyvisa.ResourceManager('@py')
print(rm.list_resources())
ps = rm.open_resource('ASRL8::INSTR')
dmm = rm.open_resource('ASRL10::INSTR')
print(ps.query("*IDN?"))
ps.write("*RST") # Runs fine up to this line
print(dmm.query("*IDN?")) # Errors here
dmm.write("*RST")
rm.close()
Error:
PS C:\Users\thoma\Desktop\Python> c:; cd 'c:\Users\thoma\Desktop\Python'; & 'C:\Users\thoma\AppData\Local\Programs\Python\Python311\python.exe' 'c:\Users\thoma\.vscode\extensions\ms-python.python-2023.8.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '54189' '--' 'c:\Users\thoma\Desktop\Python\multiple_instruments.py'
('ASRL3::INSTR', 'ASRL1::INSTR', 'ASRL10::INSTR', 'ASRL5::INSTR', 'ASRL8::INSTR', 'ASRL4::INSTR')
KORAD KWR102 V2.2 SN:000003280943
Traceback (most recent call last):
File "c:\Users\thoma\Desktop\Python\multiple_instruments.py", line 9, in <module>
print(dmm.query("*IDN?"))
^^^^^^^^^^^^^^^^^^
File "C:\Users\thoma\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\resources\messagebased.py", line 648, in query
return self.read()
^^^^^^^^^^^
File "C:\Users\thoma\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\resources\messagebased.py", line 486, in read
message = self._read_raw().decode(enco)
^^^^^^^^^^^^^^^^
File "C:\Users\thoma\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\resources\messagebased.py", line 442, in _read_raw
chunk, status = self.visalib.read(self.session, size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\thoma\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa_py\highlevel.py", line 519, in read
return data, self.handle_return_value(session, status_code)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\thoma\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyvisa\highlevel.py", line 251, in handle_return_value
raise errors.VisaIOError(rv)
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
PS C:\Users\thoma\Desktop\Python>
buran write May-30-2023, 01:41 PM:Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See
BBcode help for more info.