Get control over Thorlabs PM100USB from python

3.1k Views Asked by At

I have Thorlabs PM100USB power meter connected to the computer and I want to get the current reading from python. From the following code, the measurement type shows "TEMP", which gives the current temperature from a temperature sensor. I printed out the list of resources and this is what I'm getting

rm.list_resources()
Out[7]: ('USB0::0x1313::0x80F8::M00495436::INSTR', 'ASRL1::INSTR', 'ASRL10::INSTR')

and I used it in my code

import visa
import pyvisa
from ThorlabsPM100 import ThorlabsPM100
rm = visa.ResourceManager()
rm.list_resources()
inst = rm.open_resource('USB0::0x1313::0x80F8::M00495436::INSTR')
power_meter = ThorlabsPM100(inst=inst)
inst.timeout = None

print("Measurement type :", power_meter.getconfigure)
print("Current value    :", power_meter.read)

print(inst.query("*IDN?"))
print(rm)
print(inst)

This is the output I'm getting

Measurement type : TEMP
Current value    : 24.350668
Thorlabs,TSP01,M00495436,1.2.0

Resource Manager of Visa Library at C:\WINDOWS\system32\visa64.dll
USBInstrument at USB0::0x1313::0x80F8::M00495436::INSTR

I want to get the power reading, not the temperature reading. Any lead would be appreciated

1

There are 1 best solutions below

0
On

Have a look at the example program on their github. https://github.com/clade/ThorlabsPM100/blob/master/example.py

It shows some ways of setting the type of measurment to read. Example:

power_meter.sense.power.dc.range.auto = "ON"

If you run these lines again it should change and show you what it's now measuring:

print("Measurement type :", power_meter.getconfigure)
print("Current value    :", power_meter.read)