-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProbestation_via_classes.py
334 lines (221 loc) · 10.6 KB
/
Probestation_via_classes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
import os
import serial
import pyvisa
import matplotlib as mpl
from matplotlib import pyplot as plt
import pandas as pd
import numpy as np
import time
class Probestation_FETs(object):
def __init__(self, measurement_type):
self.measurement_type = measurement_type
def turn_on_keysight(self):
rm = pyvisa.ResourceManager(r'C:\\Windows\\System32\\visa64.dll')
self.my_inst = rm.open_resource(r'GPIB0::17::INSTR')
del self.my_inst.timeout
self.my_inst.query('*IDN?')
self.my_inst.write('*RST')
self.my_inst.write('*SRE 59')
self.my_inst.write('FMT 12,1')
self.my_inst.write('CN 101') # enables channel 101
self.my_inst.write('CN 201') # enables channel 201
self.my_inst.write('MM 2,101,201') # enables staircase sweep for channels 101 and 201
self.my_inst.write('CMM 101,1') # sets current measurement (1) for channel 101
self.my_inst.write('CMM 201,1') # sets current measurement(1) for channel 201
self.my_inst.write('RI 101,0') # sets auto-ranging (0) for channel 101
self.my_inst.write('RI 201,0') # sets auto-ranging (0) for channel 201
self.my_inst.write('AAD 101,1;AZ 0;AIT 1, 2, 10') # sets high resolution (1) for channel 101
self.my_inst.write('AAD 201,1;AZ 0;AIT 1, 2, 10') # sets high resolution (1) for channel 201
self.my_inst.write('AZ 0') # ADC zero function disabled (0)
self.my_inst.write('AIT 1, 2, 10')
self.my_inst.write('WAT 1,2,0.1')
self.my_inst.write('WAT 2,6,0.1')
self.my_inst.write('FL 1,101') # connect (1) to channel 101
self.my_inst.write('FL 1,201') # connect (1) to channel 201
self.my_inst.write('SSR 101,1') # turns on (1) resistor on channel 101
self.my_inst.write('SSR 201,0') # turns off (0) resistor on channel 201
self.my_inst.write('WT 1,0.1,0.1,0,0')
self.error_check()
def turn_on_drive(self):
self.drive = serial.Serial('COM3', baudrate=9600, write_timeout=2, timeout=2, rtscts=True)
def error_check(self):
k = self.my_inst.query('ERRX?')
if k.startswith('+0') == False:
print(k)
def measure(self, Vs1, Vs2, num_Vs, Vc, num_cycles):
self.data = np.zeros((num_Vs * len(Vc) * 2, 2 + 2 * num_cycles))
self.test_data = np.zeros((22*len(Vc)))
self.num_cycles = num_cycles
locmax = mpl.ticker.SymmetricalLogLocator(base=10.0, linthresh=1e-13, subs=(0.1, 1, 10, 100,))
locmin = mpl.ticker.SymmetricalLogLocator(base=10.0, linthresh=1e-13, subs=(0.2, 0.4, 0.6, 0.8, 1,))
fig, ax = plt.subplots(1, 2)
for i in range(0, len(Vc)):
status = ''
self.my_inst.write('DV 201,0,{},0.1,0,0'.format(Vc[i]))
self.error_check()
self.my_inst.write('WV 101,3,0,{},{},11,0.1,0.1'.format(Vs1, Vs2))
self.error_check()
self.my_inst.write('WM 1,1')
self.error_check()
self.my_inst.write('BC')
self.my_inst.write('XE')
self.my_inst.query('*OPC?')
self.my_inst.query('NUB?')
self.error_check()
data_raw = self.my_inst.read_ascii_values()
for k in range(0, 22):
self.test_data[2 * i * num_Vs + k, 0] = Vc[i]
self.test_data[2 * i * num_Vs + k, 1] = float(data_raw[3 * k + 2])
self.test_data[2 * i * num_Vs + k, 2] = float(data_raw[3 * k + 1])
self.test_data[2 * i * num_Vs + k, 3] = float(data_raw[3 * k])
if abs(np.mean(self.test_data[:, 2])) < 1e-11:
status = 'Non-conductive'
if abs(np.mean(self.test_data[:, 3])) > 1e-8:
status = 'Gate leak'
if abs(np.mean(self.test_data[:])) > 1e3:
status = 'Too high current'
if status != '':
for j in range(0, num_cycles):
self.my_inst.write('BC')
self.my_inst.write('WV 101,3,0,{},{},{},0.1,0.1'.format(Vs1, Vs2, num_Vs))
self.error_check()
self.my_inst.write('XE')
self.my_inst.query('*OPC?')
self.my_inst.query('NUB?')
self.error_check()
data_raw = self.my_inst.read_ascii_values()
for k in range(0, 2 * num_Vs):
self.data[2 * i * num_Vs + k, 0] = Vc[i]
self.data[2 * i * num_Vs + k, 1] = float(data_raw[3 * k + 2])
self.data[2 * i * num_Vs + k, 2 + 2 * j] = float(data_raw[3 * k + 1])
self.data[2 * i * num_Vs + k, 3 + 2 * j] = float(data_raw[3 * k])
# max_Isd = np.zeros((j + 1))
# min_Isd = np.zeros((j + 1))
# max_Ig = np.zeros((j + 1))
# min_Ig = np.zeros((j + 1))
#
# plt.clf()
#
# for k in range(0, j+1):
#
# ax[0].plot(self.data[2*i*num_Vs:2*(i+1)*num_Vs, 1],
# self.data[2*i*num_Vs:2*(i+1)*num_Vs, 2 + 2 * k] * np.sign(Vc[i]))
#
# max_Isd[k] = np.max(self.data[2*i*num_Vs:2*(i+1)*num_Vs, 2 + 2 * k] * np.sign(Vc[i]))
# min_Isd[k] = np.min(self.data[2*i*num_Vs:2*(i+1)*num_Vs, 2 + 2 * k] * np.sign(Vc[i]))
#
# ax[1].plot(self.data[2*i * num_Vs:2*(i + 1) * num_Vs, 1],
# self.data[2*i * num_Vs:2*(i + 1) * num_Vs, 3 + 2 * k])
#
# max_Ig[k] = np.max(self.data[2*i * num_Vs:2*(i + 1) * num_Vs, 3 + 2 * k])
# min_Ig[k] = np.min(self.data[2*i * num_Vs:2*(i + 1) * num_Vs, 3 + 2 * k])
#
# ax[1].suptitle('Vsd = {} V'.format(Vc[i]))
#
# ax[0].set_xlabel('Vg')
# ax[0].set_ylabel('Isd*sgn(Isd)')
#
# ax[1].set_xlabel('Vg')
# ax[1].set_ylabel('Ig')
#
# ax[0].yaxis.set_major_locator(locmax)
# ax[0].yaxis.set_minor_locator(locmin)
# ax[0].yaxis.set_minor_formatter(mpl.ticker.LogFormatter())
#
# ticks_Isd = np.array(list(ax[0].axes.get_yticks()))
# ticks_Isd = ticks_Isd[(abs(ticks_Isd) > 5 * 1e-14) | (ticks_Isd == 0)]
# ticks_Isd = ticks_Isd[ticks_Isd < max(max_Isd)]
# ticks_Isd = ticks_Isd[ticks_Isd > min(min_Isd)]
# ax[0].axes.set_yticks(ticks_Isd)
#
# ax[1].yaxis.set_major_locator(locmax)
# ax[1].yaxis.set_minor_locator(locmin)
# ax[1].yaxis.set_minor_formatter(mpl.ticker.LogFormatter())
#
# ticks_Ig = np.array(list(ax[1].axes.get_yticks()))
# ticks_Ig = ticks_Ig[(abs(ticks_Ig) > 5 * 1e-14) | (ticks_Ig == 0)]
# ticks_Ig = ticks_Ig[ticks_Ig < max(max_Ig)]
# ticks_Ig = ticks_Ig[ticks_Ig > min(min_Ig)]
# ax[1].axes.set_yticks(ticks_Ig)
#
# plt.show()
# Ask for any error
self.error_check()
if np.equal(self.data, 0).all():
self.data = self.test_data
def write_to_csv(self, filepath_kernel, current_x, current_y):
filepath = filepath_kernel + r'\\data'
os.makedirs(filepath, exist_ok=True)
df = pd.DataFrame(self.data)
header = []
if self.measurement_type == 'Isd-Vg':
header.append('Vsd')
header.append('Vg')
for i in range(0, self.num_cycles):
header.append('Isd%s' % (i + 1))
header.append('Ig%s' % (i + 1))
else:
header.append('Vg')
header.append('Vsd')
for i in range(0, self.num_cycles):
header.append('Ig%s' % (i + 1))
header.append('Isd%s' % (i + 1))
pd.DataFrame.to_csv(df, path_or_buf=filepath + r'\\fet_%s_%s.csv' % (current_x, current_y),
index = False, header = header)
def drive_commands_move(self, command_array):
k = self.drive.read_all()
# if k != b'':
#
# print('Initial: {}'.format(k))
time.sleep(0.05)
for item in command_array:
self.drive.write((item + '\r').encode())
print('Send: {}'.format((item + '\r').encode()))
time.sleep(0.05)
k = self.drive.read_all()
# if k != b'':
#
# print('Recieve: {}'.format(k))
time.sleep(0.05)
while item.encode() not in k:
k = self.drive.read_all()
# if k != b'':
#
# print('Recieve: {}'.format(k))
time.sleep(0.05)
while 'e'.encode() not in k:
k = self.drive.read_all()
# if k != b'':
#
# print('Final recieve: {}'.format(k))
time.sleep(0.05)
def move_xyz(self, x_dist, y_dist, cols, rows, current_x, current_y):
if current_x < cols:
arr = ['2', '3', '0', '0', '1600']
self.drive_commands_move(arr)
arr = ['2', '1', '0', '0']
arr.append(str(int(3.2 * x_dist)))
self.drive_commands_move(arr)
arr = ['2', '3', '1', '0', '1600']
self.drive_commands_move(arr)
else:
if current_y < rows:
arr = ['2', '3', '0', '0', '1600']
self.drive_commands_move(arr)
arr = ['2', '1', '1', '0']
arr.append(str(int(3.2*x_dist*(cols-1))))
self.drive_commands_move(arr)
arr = ['2', '2', '0', '0']
arr.append(str(int(3.2*y_dist)))
self.drive_commands_move(arr)
arr = ['2', '3', '1', '0', '1600']
self.drive_commands_move(arr)
def move_to_zero(self):
arr = ['4', '3']
self.drive_commands_move(arr)
arr = ['4', '2']
self.drive_commands_move(arr)
arr = ['4', '1']
self.drive_commands_move(arr)
self.drive.close()
self.drive.__exit__