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