This tunable O-band laser source from Thorlabs can be controlled via serial communication using USB or RS-232 ports.
Please install the PySerial package by running the following command:
pip install pyserial
Also install the Thorlabs software if you are using the USB communication.
import time
from tlx3 import TLX3
def main():
port = "COM3" # Replace with the appropriate COM port for your TLX3
tlx3 = TLX3(port)
# Connect to the TLX3
tlx3.connect()
# Set and get the wavelength
wavelength = 1550000 # in pm
tlx3.set_wavelength(wavelength)
print(f"Set wavelength to {wavelength} pm")
current_wavelength = tlx3.get_wavelength()
print(f"Current wavelength: {current_wavelength} pm")
# Set laser power on
tlx3.set_laser_on(1)
print("Laser power on")
# Wait for 5 seconds
time.sleep(5)
# Get laser status and power
laser_status = tlx3.get_laser_status()
laser_power = tlx3.get_laser_power()
print(f"Laser status: {laser_status}, Laser power: {laser_power}")
# Set laser power off
tlx3.set_laser_on(0)
print("Laser power off")
# Disconnect from the TLX3
tlx3.disconnect()
if __name__ == "__main__":
main()
This example code does the following:
Imports the necessary modules and the TLX3 class from the tlx3.py file provided.
Defines a main function that:
Make sure to replace the port variable with the appropriate COM port for your TLX3. See 'Tutorials' section for more details.