-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additions to Python instrument control
1. Include IDN? query with instrument write example. 2. Include example how to use the list_resources() function.
- Loading branch information
1 parent
fbda278
commit 3bf576a
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...eneral/Instructables/Get_Started_with_Instr_Control_Python/idn_query_and_command_write.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
14 changes: 14 additions & 0 deletions
14
...nt_Examples/General/Instructables/Get_Started_with_Instr_Control_Python/list_resources.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |