Multiple instruments with python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Multiple instruments with python (/thread-40077.html) |
Multiple instruments with python - thomaswfirth - May-30-2023 I'm putting together a small, automated test system with two instruments at this time. Python errors out when I try to assign the second instrument. Will Python allow multiple instruments/addresses? Help will be greatly appreciated. RE: Multiple instruments with python - deanhystad - May-30-2023 You need to provide more information. Can you post an example that works with one instrument. RE: Multiple instruments with python - buran - May-30-2023 (May-30-2023, 12:43 AM)thomaswfirth Wrote: Python errors out when I try to assign the second instrument.This is not very helpful description of a problem. Please, post minimal reproducible example of your code and the full traceback you get. RE: Multiple instruments with python - thomaswfirth - May-30-2023 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()
RE: Multiple instruments with python - thomaswfirth - May-30-2023 Ok I did say I was new to Python, now let me add the code for the baud rate. I did have to install two additional modules to get to the previous point but just overlooked establishing the baud rate. So please disregard the previous post. here is where I am now. import pyvisa import time rm = pyvisa.ResourceManager('@py') print(rm.list_resources()) ps = rm.open_resource('ASRL8::INSTR') ps.baud_rate = 115200 dmm = rm.open_resource('ASRL10::INSTR') dmm.baud_rate = 115200 print(ps.query("*IDN?")) ps.write("*RST") print(dmm.query("*IDN?")) dmm.write("*RST") rm.close()
|