Skip to content

Commit

Permalink
Additions to Python instrument control
Browse files Browse the repository at this point in the history
1. Include IDN? query with instrument write example.
2. Include example how to use the list_resources() function.
  • Loading branch information
jbrown1234 committed Oct 18, 2023
1 parent fbda278 commit 3bf576a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
This script provides an example of how a programmer might issue
a query for an instrument's identification string as well as
a simple command write.
"""
import pyvisa
rm = pyvisa.ResourceManager()

# Start communicating with the target instrument with the name inst_1
SMU2450 = rm.open_resource("USB0::0x05E6::0x2450::04509653::INSTR")

# Try querying the command for the first time. The response
# should contain the instrument manufacturer name, model,
# serial number, and firmware version in answer.
answer = SMU2450.query("*IDN?")

# Display the response.
print(answer)

# Issue a universal instrument reset.
SMU2450.write("*RST")

# Close communication with the device and the resource manager.
SMU2450.close()
rm.close()
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
This script shows the programmer how they might use the
Visa Resource Manager to list the instrument resource
strings for all connected devices.
"""
import pyvisa

# Instantiate a resource manager object.
rm = pyvisa.ResourceManager()

# Returns all resources (matching ?*::INSTR) retrieved by rm.
print(rm.list_resources())

rm.close()

0 comments on commit 3bf576a

Please sign in to comment.