Get Control over Thorlabs Pm100Usb from Python

Get Control over Thorlabs Pm100Usb from Python

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 Answer

Have a look at the example program on their github.

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)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Chloe Bennett
Author

Chloe Bennett

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.