This MX10B Reference Transmitter from Thorlabs can be controlled via serial communication.
Please install the PySerial package by running the following command:
pip install pyserial
Below, we provide an example showing you how to communicate with your digital reference transmitter. The API issues serial commands to communicate with the instrument.
import time
from mx10b import MX10B
def main():
port = "COM3" # Replace with the appropriate COM port for your MX10B
mx10b = MB10B(port)
# Set and get the ITU channel number. ITU Channel are defined using a 50 MHz grid.
itu_channel_number = 32
mx10b.set_ITU_channel_number(itu_channel_number)
print(f"Set ITU channel number to {itu_channel_number}")
current_itu_channel_number = mx10b.get_ITU_channel_number()
print(f"Current ITU channel number: {current_itu_channel_number}")
# Set laser power on
mx10b.set_laser_power_on()
print("Laser power on")
# Wait for 5 seconds
time.sleep(5)
# Get measured optical output power in dBm
optical_output_power_dBm = mx10b.get_measured_optical_output_power_dBm()
print(f"Measured optical output power: {optical_output_power_dBm} dBm")
# Set laser power off
mx10b.set_laser_power_off()
print("Laser power off")
if __name__ == "__main__":
main()
This example code does the following:
Imports the necessary modules and the MX10B class from the mx10b.py file provided.
Defines a main function that:
Make sure to replace the port variable with the appropriate COM port for your MX10B. Please visit the 'Tutorials' section to find appropriate COM port.