Skip to content

Commit d883a61

Browse files
author
Davis
committed
JDavis misc changes
1 parent 3b56f3a commit d883a61

File tree

13 files changed

+1268
-38
lines changed

13 files changed

+1268
-38
lines changed
Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,41 @@
1+
## Object Type
2+
M
3+
#O Model
4+
TL2500
5+
#Address
6+
179.29.100.100::12345
7+
##
8+
19
## Object Type
210
M
311
#O Model
412
Keysight8164B_Laser
513
#Address
6-
GPIB0::1::INSTR
14+
GPIB0::20::INSTR
715
##
816

917
## Object Type
1018
M
1119
#O Model
1220
Keysight8164B_PowerMeter
1321
#Address
14-
GPIB0::1::INSTR
22+
GPIB0::20::INSTR
1523
#Numbering of Channels
1624
1:1;2:2
17-
##
25+
##
26+
27+
## Object Type
28+
#M
29+
#O Model
30+
#EXFOT100HP_Laser
31+
#Address
32+
#GPIB0::2::INSTR
33+
##
34+
35+
## Object Type
36+
M
37+
#O Model
38+
EXFOT100_Laser
39+
#Address
40+
GPIB0::3::INSTR
41+
##

ProberControl/laserSweep1.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
##get_o_spectrum_0:
2+
1501.0 -43.2760465352
3+
4+
5+
##get_o_spectrum_0:
6+
1509.0 -36.4708130008
7+
8+
##get_o_spectrum_1:
9+
1500.0 0.242220526355
10+
1501.0 0.25293050514
11+
1502.0 0.25293050514
12+
1503.0 0.25293050514
13+
1504.0 0.254458484579
14+
1505.0 0.251402465073
15+
1506.0 0.254458484579
16+
1507.0 0.260564555962
17+
1508.0 0.261327271114
18+
1509.0 0.265138363286
19+
20+
21+
##get_o_spectrum_0:
22+
1509.0 -36.4708130008
23+
24+
##get_o_spectrum_1:
25+
1500.0 0.242220526355
26+
1501.0 0.25293050514
27+
1502.0 0.25293050514
28+
1503.0 0.25293050514
29+
1504.0 0.254458484579
30+
1505.0 0.251402465073
31+
1506.0 0.254458484579
32+
1507.0 0.260564555962
33+
1508.0 0.261327271114
34+
1509.0 0.265138363286
35+
36+
Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
import time
2+
import visa
3+
4+
class EXFOT100HP_Laser(object):
5+
'''
6+
This class models the EXFO T100S-HP laser. There is a
7+
1260-1360 nm and a 1500-1630 nm version.
8+
9+
.. note:: When using any laser command, remember to send shut-off-laser command at the end of each sweep command set.
10+
For Trigger Sweep, send shut-off-laser command after sweep ends (sweep end condition noted in TriggerSweepSetup function)
11+
Note that these lasers do not have trigger inputs or outputs.
12+
'''
13+
14+
def __init__(self, res_manager, address='GPIB0::2::INSTR'):
15+
'''
16+
Constructor method
17+
18+
:param res_manager: PyVisa resource manager
19+
:type res_manager: PyVisa resourceManager object
20+
:param address: SCPI address of instrument
21+
:type address: string
22+
'''
23+
24+
self.active = False
25+
26+
self.gpib = res_manager.open_resource(address)
27+
28+
self.gpib.write ('*IDN?')
29+
info = self.gpib.read()
30+
print ('Connection Successful: %s' % info)
31+
32+
#Ensure Output is OFF
33+
self.gpib.write ('DISABLE')
34+
35+
#Default Laser Power Unit to dBm
36+
self.gpib.write ('DBM')
37+
38+
#Set system operation to constant power models
39+
self.gpib.write ('APCON')
40+
41+
#Get min and max wavelengths
42+
self.get_min_wavelength()
43+
self.get_max_wavelength()
44+
45+
def whoAmI(self):
46+
''':returns: reference to device'''
47+
return 'Laser'
48+
49+
def change_state(self):
50+
51+
if self.active == True:
52+
self.active = False
53+
else:
54+
self.active = True
55+
print 'state = ', self.active
56+
57+
def get_max_wavelength(self): # Updated 9/20/2019 Jim Davis
58+
'''
59+
Queries the maximum allowed wavelength
60+
61+
:returns: Float
62+
'''
63+
self.gpib.write ('L? MAX')
64+
65+
self.max_wavelength = float(self.gpib.read()[2:])
66+
print 'Wavelength Max: ', self.max_wavelength, 'nm'
67+
return self.max_wavelength
68+
69+
def get_min_wavelength(self): # Updated 9/20/2019 Jim Davis
70+
'''
71+
Queries the minimum allowed wavelength
72+
73+
:returns: Float
74+
'''
75+
self.gpib.write ('L? MIN')
76+
self.min_wavelength = float(self.gpib.read()[2:])
77+
print 'Wavelength Min: ', self.min_wavelength, 'nm'
78+
return self.min_wavelength
79+
80+
def setwavelength(self, wavelength):
81+
'''
82+
Loads a single wavelength and sets output on
83+
84+
:param waveLength: Specified wavelength
85+
:type waveLength: Integer
86+
'''
87+
self.outputOFF()
88+
89+
if wavelength < self.min_wavelength or wavelength > self.max_wavelength:
90+
print ('Specified Wavelength Out of Range: ' +str(wavelength))
91+
else :
92+
# Execute setting of wavelength
93+
self.gpib.write('L = ' + str(wavelength))
94+
print(str(wavelength))
95+
time.sleep(0.55)
96+
self.gpib.write('L?')
97+
info = self.gpib.read()
98+
print ('Wavelength Sent: %s' % info)
99+
100+
#self.gpib.write('SOURCE0:CHAN1:POW:STATE 1')
101+
self.outputON()
102+
103+
104+
def sweepWavelengthsContinuous (self, start, end, power):
105+
'''
106+
Executes a continuous sweep, not for use with triggered PowerMeters
107+
108+
:param start: Specified wavelength between 1260-1360 nm, or 1500-1630 nm
109+
:type start: Float
110+
:param end: Specified wavelength between 1260-1360 nm, or 1500-1630 nm
111+
:type end: Float
112+
:param power: Specified power for sweep
113+
:type power: Float
114+
:Note: motor_speed is calculated from end - start to be < 2 seconds
115+
:to avoid a timeout from PyVisa before laser scan completes
116+
'''
117+
118+
self.outputOFF()
119+
120+
# time to wait before checking OPC = operation complete bit
121+
sleepTime = 0.01
122+
123+
# Calcualte motor speed to key scan time < 2 s
124+
wavelength_span = (end - start)
125+
max_scan_time = 2.0 #s
126+
#reverse ordered to make search easy
127+
motor_speed_list = [100,67,50,40,33,29,25,22,20,18,17,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1]
128+
for x in motor_speed_list:
129+
scan_time = wavelength_span /x
130+
if scan_time < max_scan_time:
131+
new_scan_time = scan_time
132+
print ' new_scan_time',new_scan_time
133+
print 'speed = ',
134+
motor_speed = wavelength_span / new_scan_time
135+
print 'scan motor_speed = ', motor_speed
136+
print 'scan_time = ', new_scan_time
137+
138+
if (start < self.min_wavelength
139+
or start > self.max_wavelength
140+
or end < self.min_wavelength
141+
or end > self.max_wavelength
142+
or end <= start):
143+
print ('Specified Wavelengths Out of Range')
144+
145+
else:
146+
while not self.checkOPC():
147+
time.sleep(sleepTime)
148+
else:
149+
self.setpower(power)
150+
151+
while not self.checkOPC():
152+
time.sleep(sleepTime)
153+
else:
154+
self.setwavelength(start)
155+
156+
while not self.checkOPC():
157+
time.sleep(sleepTime)
158+
else:
159+
self.gpib.write('MOTOR_SPEED ' +str(motor_speed))
160+
161+
while not self.checkOPC():
162+
time.sleep(sleepTime)
163+
else:
164+
self.gpib.write('ACTCTRLON')
165+
166+
while not self.checkOPC():
167+
time.sleep(sleepTime)
168+
else:
169+
self.setwavelength(end)
170+
print 'setwavelength(end)'
171+
172+
# maximum motor speed to return
173+
while not self.checkOPC():
174+
print 'INSIDE not self.checkOPC'
175+
time.sleep(sleepTime)
176+
else:
177+
self.gpib.write('MOTOR_SPEED = ' + '100')
178+
self.gpib.write('MOTOR_SPEED?')
179+
print 'MOTOR_SPEED = ', self.gpib.read()
180+
181+
while not self.checkOPC():
182+
time.sleep(sleepTime)
183+
else:
184+
self.gpib.write('ACTCTRLOFF')
185+
186+
def checkOPC(self):
187+
# check OPC bit of STB status bit. Mask out other bits with &
188+
return (int(self.gpib.write ('*STB?')[0] & 1))
189+
190+
def outputON(self):
191+
'''
192+
Turns output of laser source ON
193+
'''
194+
self.gpib.write('ENABLE')
195+
196+
def outputOFF(self):
197+
'''
198+
Turns output of laser source OFF
199+
200+
'''
201+
self.gpib.write('DISABLE')
202+
203+
def getwavelength(self):
204+
'''
205+
Queries wavelength of the laser
206+
207+
:returns: Float
208+
'''
209+
self.gpib.write('L?')
210+
return float(self.gpib.read()[2:])
211+
212+
def setpower(self, power = 0.0 ):
213+
'''
214+
Sets power in dbm
215+
216+
:param power: Specified power to set the laser to in dbm
217+
:type power: Float
218+
'''
219+
power = float(power)
220+
if (power < -6.99) or (power > 13.4):
221+
print 'Power setting out of -6.99 to +13.4 dBm range'
222+
else:
223+
self.gpib.write('P = ' + str(power))
224+
225+
def getpower(self):
226+
'''
227+
Gets output power in dbm
228+
229+
:returns: Float
230+
'''
231+
self.gpib.write('P?')
232+
self.power = self.gpib.read()
233+
print 'power read as: ', type(self.power), self.power
234+
if self.power[0:2] == 'P=':
235+
print 'Laser ENABLED'
236+
self.power = float(self.power[2:])
237+
else:
238+
print 'Laser DISABLED'
239+
self.power = 'DISABLED'
240+
241+
return self.power
242+
243+
def close(self):
244+
'''
245+
Release resources
246+
'''
247+
self.outputOFF()
248+
self.gpib.close()
249+
250+
251+
#if __name__ == "__main__":
252+
253+
'''
254+
Copyright (C) 2017 Robert Polster
255+
This program is free software: you can redistribute it and/or modify
256+
it under the terms of the GNU General Public License as published by
257+
the Free Software Foundation, either version 3 of the License, or
258+
(at your option) any later version.
259+
260+
This program is distributed in the hope that it will be useful,
261+
but WITHOUT ANY WARRANTY; without even the implied warranty of
262+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
263+
GNU General Public License for more details.
264+
265+
You should have received a copy of the GNU General Public License
266+
along with this program. If not, see <http://www.gnu.org/licenses/>.
267+
'''

0 commit comments

Comments
 (0)