def create_usbtmc(self): """ Use USBTMC to create a connection to the thorlabs pm100usb on linux. """ self.inst = USBTMC(device="/dev/usbtmc0") power_meter = ThorlabsPM100(inst=self.inst) power_meter.sense.correction.wavelength = 785.0 return power_meter
def __init__(self, my_usb): if "/dev" in my_usb: subprocess.call(['sudo', 'chown', 'vfurtula:vfurtula', my_usb]) inst = USBTMC(device=my_usb) self.power_meter = ThorlabsPM100(inst=inst) else: rm = visa.ResourceManager() print(rm.list_resources()) inst = rm.open_resource(my_usb, write_termination='\n', timeout=1) self.power_meter = ThorlabsPM100(inst=inst)
def __init__(self): # Open first found LabJack try: USBTMC(device="/dev/usbtmc0") inst = USBTMC(device="/dev/usbtmc0") self.Handle = ThorlabsPM100(inst=inst) except OSError, er0: print('er0:%s' % er0) if er0.errno == 13: # ==> Permission denied: '/dev/usbtmc0' os.system('sudo chmod 777 /dev/usbtmc0') inst = USBTMC(device="/dev/usbtmc0") self.Handle = ThorlabsPM100(inst=inst) elif er0.errno == 2: # ==> [Errno 2] No such file or directory: '/dev/usbtmc0' try: USBTMC(device="/dev/usbtmc1") inst = USBTMC(device="/dev/usbtmc1") self.Handle = ThorlabsPM100(inst=inst) except OSError, er1: print('er1:%s' % er1) if er1.errno == 13: # ==> Permission denied: '/dev/usbtmc1' os.system('sudo chmod 777 /dev/usbtmc1') inst = USBTMC(device="/dev/usbtmc1") self.Handle = ThorlabsPM100(inst=inst) elif er1.errno == 2: # ==> [Errno 2] No such file or directory: '/dev/usbtmc1' try: USBTMC(device="/dev/usbtmc2") inst = USBTMC(device="/dev/usbtmc2") self.Handle = ThorlabsPM100(inst=inst) except OSError, er2: print('er2:%s' % er2) if er2.errno == 13: # ==> Permission denied: '/dev/usbtmc2' os.system('sudo chmod 777 /dev/usbtmc2') inst = USBTMC(device="/dev/usbtmc2") self.Handle = ThorlabsPM100(inst=inst) elif er2.errno == 2: # ==> [Errno 2] No such file or directory: '/dev/usbtmc2' self.Error = 1 print("Power meter is not connected! \n") return
from ThorlabsPM100 import ThorlabsPM100, USBTMC import matplotlib.pyplot as plt from time import sleep from datetime import datetime import os import glob import time import usbtmc #from zarizeni2 import pyf429 #keysigh voltmeter init instr = usbtmc.Instrument(0x2a8d, 0x1301) #address from usbtmc.list_devices() # PM init -- needs RW rights set for the device inst = USBTMC(device="/dev/usbtmc0") power_meter = ThorlabsPM100(inst=inst) power_meter.sense.correction.wavelength = 380 # dallas init base_dir = '/sys/bus/w1/devices/' device_folder = glob.glob(base_dir + '28*')[0] device_file = device_folder + '/w1_slave' #diode temp init #led = pyf429(dev='/dev/ttyACM0') def read_temp_raw(): f = open(device_file, 'r') lines = f.readlines()
from __future__ import print_function from time import sleep from numpy import array from ThorlabsPM100 import ThorlabsPM100, USBTMC inst = USBTMC() power_meter = ThorlabsPM100(inst=inst) power_meter.system.beeper.immediate() print("Measurement type :", power_meter.getconfigure) print("Current value :", power_meter.read) print("Wavelength :", power_meter.sense.correction.wavelength) print("Power range limit:", power_meter.sense.power.dc.range.upper) print("Set range auto and wait 500ms ...") sleep(.5) power_meter.sense.power.dc.range.auto = "ON" print("Power range limit:", power_meter.sense.power.dc.range.upper) print("Set bandwidth to High") power_meter.input.pdiode.filter.lpass.state = 0 print("Average per mesure :", power_meter.sense.average.count) print("Set average to 1 ...") power_meter.sense.average.count = 1