Connecting to PM100USB by Thorlabs in Python
Instrument Card
The PM100USB Power and Energy Meter Interface is compatible with all our C-Series photodiode, thermal, and pyroelectric sensors except for the ES408C Fast Pyroelectric Sensor. Our C-Type standard photodiode, slim photodiode, integrating sphere, and fiber sensors can collectively measure optical powers from 100 pW to 20 W. Our thermal power sensors measure optical powers from 10 µW to 200 W. Compatible C-Series pyroelectric energy sensors can measure energies from 10 µJ to 15 J and repetition rates up to 2 kHz. Note that the ES408C sensor for repetition rates up to 10 kHz, also available below, is not recommended for use with the PM100USB interface, which supports a maximum repetition rate of 3 kHz. Alternatively, other unamplified anode- or cathode-grounded photodiodes with up to 5 mA photocurrent, thermal elements with a maximum output voltage of 1 V, or energy sensors with voltage outputs from 100 mV to 100 V may be used.
This interface can be operated and powered by a PC via the mini-USB port. A readout rate of 300 samples per second allows active signal monitoring while the interface is in use.
Device Specification: here
Manufacturer card: THORLABS
Thorlabs, Inc. is an American privately held optical equipment company headquartered in Newton, New Jersey. The company was founded in 1989 by Alex Cable, who serves as its current president and CEO. As of 2018, Thorlabs has annual sales of approximately $500 million.
- Headquarters: USA
- Yearly Revenue (millions, USD): 550
- Vendor Website: here
Connect to the PM100USB in Python
Read our guide for turning Python scripts into Flojoy nodes.
PROTOCOLS > SCPI
import loggingfrom pymeasure.instruments import Instrumentfrom pymeasure.instruments.validators import truncated_range
log = logging.getLogger(__name__)log.addHandler(logging.NullHandler())
class ThorlabsPM100USB(Instrument): """Represents Thorlabs PM100USB powermeter."""
def __init__(self, adapter, name="ThorlabsPM100USB powermeter", **kwargs): super().__init__(adapter, name, **kwargs) self._set_flags()
wavelength_min = Instrument.measurement( "SENS:CORR:WAV? MIN", "Measure minimum wavelength, in nm" )
wavelength_max = Instrument.measurement( "SENS:CORR:WAV? MAX", "Measure maximum wavelength, in nm" )
@property def wavelength(self): """Control the wavelength in nm.""" value = self.values("SENSE:CORR:WAV?")[0] return value
@wavelength.setter def wavelength(self, value): """Wavelength in nm.""" if self.wavelength_settable: # Store min and max wavelength to only request them once. if not hasattr(self, "_wavelength_min"): self._wavelength_min = self.wavelength_min if not hasattr(self, "_wavelength_max"): self._wavelength_max = self.wavelength_max
value = truncated_range( value, [self._wavelength_min, self._wavelength_max] ) self.write(f"SENSE:CORR:WAV {value}") else: raise AttributeError( f"{self.sensor_name} does not allow setting the wavelength." )
@property def power(self): """Measure the power in W.""" if self.is_power_sensor: return self.values("MEAS:POW?")[0] else: raise AttributeError(f"{self.sensor_name} is not a power sensor.")
@property def energy(self): """Measure the energy in J.""" if self.is_energy_sensor: return self.values("MEAS:ENER?")[0] else: raise AttributeError( f"{self.sensor_name} is not an energy sensor." )
def _set_flags(self): """Get sensor info and write flags.""" response = self.values("SYST:SENSOR:IDN?") if response[0] == "no sensor": raise OSError("No sensor connected.") self.sensor_name = response[0] self.sensor_sn = response[1] self.sensor_cal_msg = response[2] self.sensor_type = response[3] self.sensor_subtype = response[4] _flags_str = response[5]
# interpretation of the flags, see p. 49 of the manual: # https://www.thorlabs.de/_sd.cfm?fileName=17654-D02.pdf&partNumber=PM100D
# Convert to binary representation and pad zeros to 9 bit for sensors # where not all flags are present. _flags_str = format(int(_flags_str), "09b") # Reverse the order so it matches the flag order from the manual, i.e. # from decimal values from 1 to 256. _flags_str = _flags_str[::-1]
# Convert to boolean. self.flags = [x == "1" for x in _flags_str]
# setting the flags; _dn are unused; decimal values as comments ( self.is_power_sensor, # 1 self.is_energy_sensor, # 2 _d4, # 4 _d8, # 8 self.response_settable, # 16 self.wavelength_settable, # 32 self.tau_settable, # 64 _d128, # 128 self.has_temperature_sensor, # 256 ) = self.flags
This script defines a class ThorlabsPM100USB
that represents the Thorlabs PM100USB power meter. It inherits from the Instrument
class provided by Pymeasure.
The class has various properties and methods to interact with the power meter. Here’s a brief explanation of each:
-
wavelength_min
andwavelength_max
are measurement properties that retrieve the minimum and maximum wavelength values supported by the power meter, respectively. -
wavelength
is a property that allows you to control the wavelength in nm. It retrieves the current wavelength value from the power meter and can also be set to a new value. -
power
is a property that measures the power in W. It retrieves the power value from the power meter. -
energy
is a property that measures the energy in J. It retrieves the energy value from the power meter. -
_set_flags
is a method that retrieves sensor information and writes flags based on the response from the power meter.
To use this script, you would need to create an instance of the ThorlabsPM100USB
class and provide the appropriate adapter for communication with the power meter.