Skip to content

Commit 826efa9

Browse files
committed
New ERM200 PyVisa example
1 parent f39f7b9 commit 826efa9

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""
2+
ERM200_SCPI
3+
Example Date of Creation: 2025-08-25
4+
Example Date of Last Modification on Github: 2025-08-25
5+
Version of Python: 3.13
6+
Version of the Thorlabs SDK used: -
7+
Tested with ERM210
8+
==================
9+
Example Description: The example shows how to use SCPI commands in Python with pyvisa
10+
"""
11+
12+
import pyvisa
13+
import time
14+
15+
def main():
16+
rm = None
17+
device = None
18+
try:
19+
#Opens a resource manager
20+
rm = pyvisa.ResourceManager()
21+
22+
23+
#Opens the connection to the device. The variable instr is the handle for the device.
24+
# !!! In the USB number the serial number (M01...) and PID (0x8032) needs to be changed to the one of the connected device.
25+
#Check with the Windows DEvice Manager
26+
instr = rm.open_resource('USB0::0x1313::0x8032::M01099532::INSTR')
27+
28+
29+
#print the device information
30+
print(instr.query("*IDN?"))
31+
32+
result = instr.query("MEAS?")
33+
er, phi = result.split(",")
34+
print("Measured ER: ", er)
35+
print("Measured Phi: ", phi)
36+
37+
finally:
38+
#Close device in any case
39+
if device is not None:
40+
try:
41+
device.close()
42+
except Exception:
43+
pass
44+
45+
#Close resource manager in any case
46+
if rm is not None:
47+
try:
48+
instr.close()
49+
except Exception:
50+
pass
51+
52+
#close out session
53+
rm.close()
54+
55+
56+
import sys
57+
print(sys.version)
58+
59+
if __name__ == "__main__":
60+
main()

Python/Thorlabs ERM2xx Extinction Ratio Meters/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ Please note that the code connects to the first available ERM2xx device. If you
88

99
lib.TLERM200_getRsrcName(erm_handle, 0, resource)
1010

11+
### ERM200_PyVisa.py
12+
This sample code shows how you can control a Thorlabs ERM200, ERM210 or ERM220 extinction ratio meter in Python with SCPI commands and PyVisa.
13+
Use Visa drivers to run the example.
14+

0 commit comments

Comments
 (0)