Optical Path Calibration

This example script demonstrates an optical path calibration. Before the calibration of each lane, the script pauses and prompts the user to connect a calibration signal to the fiber from a fixture's optical lane and to enter the average optical power of the signal.

Example Script

Copy
optical-calibration.py
#******************************************************************************
#    MIT License
#    Copyright(c) 2023 Keysight Technologies
#    Permission is hereby granted, free of charge, to any person obtaining a copy
#    of this software and associated documentation files (the "Software"), to deal
#    in the Software without restriction, including without limitation the rights
#    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#    copies of the Software, and to permit persons to whom the Software is
#    furnished to do so, subject to the following conditions:
#    The above copyright notice and this permission notice shall be included in all
#    copies or substantial portions of the Software.
#    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#    SOFTWARE.
#******************************************************************************

import pyvisa as visa
rm = visa.ResourceManager(r'C:\WINDOWS\system32\visa64.dll')
FlexOTO = rm.open_resource('TCPIP0::localhost::hislip0,4880::INSTR')
FlexOTO.timeout = 20000  # Set connection timeout to 20s
FlexOTO.read_termination = '\n'
FlexOTO.write_termination = '\n'
FlexOTO.write(':CALibrate:OPTical:STARt')
FlexOTO.write(':CALibrate:OPTical:MATTenuation ' + '29.4')
while True:
    message = FlexOTO.query(':CALibrate:OPTical:SDONe?')
    message = message.replace('.  ','.\n')
    if 'Calibration has completed' in message:
        break
    step = FlexOTO.query(':CALibrate:OPTical:STEP?')
    print('Step ' + step + '.  ' + message)
    power = input('\t\tEnter average optical power in mW ("2.0e-3" maximum): ')
    FlexOTO.write(':CALibrate:OPTical:OPOWer ' + power)
    FlexOTO.write(':CALibrate:OPTical:CONTinue')

filename = FlexOTO.query(':CALibrate:OPTical:LOAD:FNAMe?')
print('\n' + message + '\n\t\t' + filename + '\n\n')
FlexOTO.write(':CALibrate:OPTical:CONTinue')
pwrloss = FlexOTO.query(':CALibrate:OPTical:PLOSs?')
pwrlosslst = list(pwrloss.split(';'))
for path in pwrlosslst:
    print('Measured path power loss: ' + path)
FlexOTO.write(':SYSTem:GTLocal')
FlexOTO.close()