-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHall_sweep.py~
393 lines (285 loc) · 10.4 KB
/
Hall_sweep.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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# This script runs a Hall sweep using a QD Dynacool PPMS cryostat
# and Keithley electronics. The Keithleys are controlled directly,
# while the cryostat is controlled through MultiVu via QD scripts
# in the PythonControl library.
import numpy as np
import pandas as pd
#import matplotlib.pyplot as plt
import os
from time import sleep, time
from datetime import datetime
from pymeasure.display import plotter
from pymeasure.adapters import VISAAdapter
from pymeasure.experiment import Procedure, Results, Worker
from pymeasure.experiment import IntegerParameter, FloatParameter, Parameter
import ngcmeas.current_voltage as cv
import ngcmeas.switch_matrix as sm
import MultiVu_talk_ngc as mv
from PythonControl.parse_inputs import inputs
class HallSweep(Procedure):
def __init__(self, host, port, maxb, ramprate):
self.host = host
self.port = port
self.maxb = maxb
self.ramprate = ramprate
super().__init__()
iterations = IntegerParameter('Measurement Number')
high_current = FloatParameter('Max Current', units='A', default=1.e-6)
delta = FloatParameter('Delta', units='s', default=1.e-3)
swpct1 = IntegerParameter('Sweep Count 1', default=10)
swpct2 = IntegerParameter('Sweep Count 2', default=1)
swpct3 = IntegerParameter('Sweep Count 3', default=10)
nplc = IntegerParameter('Num Power Line Cycles', default=3)
rvng = FloatParameter('Voltmeter Range', default=1.e-5)
date = Parameter('Date Time', default='')
#DATA_COLUMNS = ['Time', 'Temperature', '\g(m)\-(0)H', 'R vdp 1', \
# 'R vdp 2', 'R Hall 1', 'R Hall 2']
#DATA_COLUMNS = ['Time', 'Temperature', '\g(m)\-(0)H', 'R bridge 1', \
# 'R bridge 2', 'R bridge 3', 'R bridge 4']
DATA_COLUMNS = ['Time', 'Temperature', '\g(m)\-(0)H', 'R bridge 1']
#DATA_COLUMNS = ['Time', 'Temperature', '\g(m)\-(0)H', 'R vdp 1', \
# 'R vdp 2', 'R Hall 1', 'R Hall 2', 'R vdp 12', \
# 'R vdp 22', 'R Hall 12', 'R Hall 22']
#DATA_COLUMNS = ['Time', 'Temperature', '\g(m)\-(0)H', 'R bridge 1', \
# 'R bridge 2']
def resistance_measure(self, config):
print('in resistance_measure', config)
if config == 'vdp1':
self.switch.clos_vdp1()
if config == 'vdp2':
self.switch.clos_vdp2()
if config == 'Hall1':
self.switch.clos_Hall1()
if config == 'Hall2':
self.switch.clos_Hall2()
if config == 'vdp12':
self.switch.clos_vdp12()
if config == 'vdp22':
self.switch.clos_vdp22()
if config == 'Hall12':
self.switch.clos_Hall12()
if config == 'Hall22':
self.switch.clos_Hall22()
if config == 'c1':
self.switch.clos_custom1()
if config == 'c2':
self.switch.clos_custom2()
if config == 'cust1':
self.switch.clos_custom(4, 3, 5, 1) #5, 1, 6, 2
if config == 'cust2':
self.switch.clos_custom(5, 2, 3, 7)
if config == 'cust3':
self.switch.clos_custom(5, 2, 6, 1) #5, 1, 6, 2
if config == 'cust4':
self.switch.clos_custom(5, 2, 1, 4)
sleep(0.36)
volt, vstd = self.currentsource.min_inloop_delta()
self.switch.open_all()
return volt/self.high_current
def startup(self):
print('Starting Up')
KE6221adapter = VISAAdapter("GPIB0::12")
KE7001adapter = VISAAdapter("GPIB0::7")
self.currentsource = cv.myKeithley6221(KE6221adapter)
self.switch = sm.Keithley7001(KE7001adapter, "SwitchMatrix")
print('instruments mapped')
self.currentsource.reset()
self.currentsource.arm_preloop_delta(self.high_current, self.delta, self.swpct1, \
self.swpct2, self.swpct3, self.nplc, self.rvng, \
self.swpct1)
#self.currentsource.arm_preloop_delta(self.high_current, delta, swpct1, \
# swpct2, swpct3, npld, rvng, \
# swpct1)
print('Done Startup')
sleep(0.1)
def in_loop(self, configs):
ress = []
# get_temp and get_field from Dynacool
temp = mv.query_temp(self.host, self.port)[0]
bfield = mv.query_field(self.host, self.port)
print(bfield)
tim = time() - self.starttime
#print('Temp ', temp, 'Field ', bfield)
# This is where comment starts for bridges
'''
for c in configs:
ress.append(self.resistance_measure(c))
print(ress[-1])
print('about to emit', tim)
self.emit('results', {
'Time': tim, \
'Temperature': temp, \
'\g(m)\-(0)H': bfield[0], \
'R vdp 1': ress[0], \
'R vdp 2': ress[1], \
'R Hall 1': ress[2], \
'R Hall 2': ress[3], \
'R vdp 12': ress[4], \
'R vdp 22': ress[5], \
'R Hall 12': ress[6], \
'R Hall 22': ress[7] \
})
sleep(0.01)
# comment out last 4 in emit for 1 vdp
'''
for c in configs:
ress.append(self.resistance_measure(c))
print(ress[-1])
print('about to emit', tim)
self.emit('results', {
'Time': tim, \
'Temperature': temp, \
'\g(m)\-(0)H': bfield[0], \
#'\g(phi)': self.angle,\
'R bridge 1': ress[0]#, \
#'R bridge 2': ress[1], \
#'R bridge 3': ress[2],\
#'R bridge 4': ress[3]
})
sleep(0.01)
# Comment with 3 commas above for other config
print('done emitting')
return bfield
def execute(self):
#self.maxb = 100000.
self.switch.set_pins(3,1,2,4) #1,3,4,2
print('set some pins')
rate = self.ramprate
self.switch.set_pins2(7,5,6,8)
print('set all pins')
#configs = ['vdp1', 'vdp2', 'Hall1', 'Hall2', 'vdp12', 'vdp22', 'Hall12', 'Hall22']
#configs = ['c1', 'c2']
configs = ['cust1']#, 'cust2', 'cust3', 'cust4']
ress = []
ts = []
bs = []
self.starttime = time()
self.stable_field = r'"Holding (Driven)"'
#for i in range(self.iterations):
mv.set_field(self.host, self.port, self.maxb, rate)
sleep(1.8)
bfld = 0.
done = False
print('about to measure')
#while bfld < 0.999*self.maxb:
while not done:
print('Doing done loop in Hall')
bfield = self.in_loop(configs)
print("bfield here ", bfield)
bfld = bfield[0]
done = bfield[1] == self.stable_field
print('Result ', bfield[1], done)
mv.set_field(self.host, self.port, -self.maxb, rate)
sleep(1.8)
done = False
while not done:
bfield = self.in_loop(configs)
print(bfield)
bfld = bfield[0]
done = bfield[1] == self.stable_field
print(bfield[1], done)
print('About to set field to zero.')
mv.set_field(self.host, self.port, 0.0, rate)
sleep(1.8)
done = False
while not done:
print('In last leg of sweep.')
bfield = self.in_loop(configs)
print(bfield)
bfld = bfield[0]
done = bfield[1] == self.stable_field
print(bfield[1], done)
'''
# get_temp and get_field from Dynacool
temp = mv.query_temp(self.host, self.port)
bfield = mv.query_field(self.host, self.port)
tim = time() - starttime
#print('Temp ', temp, 'Field ', bfield)
for c in configs:
ress.append(self.resistance_measure(c))
#print(ress)
print('about to emit', tim)
self.emit('results', {
'Time': tim, \
'Temperature': temp, \
'\g(m)\-(0)H': bfield, \
'R vdp 1': ress[0], \
'R vdp 2': ress[1], \
'R Hall 1': ress[2], \
'R Hall 2': ress[3], \
})
sleep(0.01)
print('done emitting')
'''
#This is where the comment goes for bridges
#Turn off Current
self.currentsource.waveform_abort()
#if self.should_stop():
# break
def field_ramp(host, port, maxb):
flds = []
mv.set_field(host, port, maxb, 600.)
sleep(0.48)
fld = 0.
while fld < 0.99999*maxb:
fld = mv.query_field(host, port)
print(fld)
flds.append(fld)
sleep(1.0)
mv.set_field(host, port, -1*maxb, 600.)
sleep(0.48)
while fld > -0.99999*maxb:
fld = mv.query_field(host, port)
print(fld)
flds.append(fld)
sleep(1.0)
mv.set_field(host, port, 0., 600.)
sleep(0.48)
while fld < -0.10:
fld = mv.query_field(host, port)
print(fld)
flds.append(fld)
sleep(1.0)
return flds
def main():
host = "128.104.184.130"
port = 5000
#print('about to set field')
#flds = field_ramp(host, port, 2000.)
#print('field set')
#plt.plot(flds)
#plt.show()
#start editing
directory = r'C:\Users\maglab\Documents\Python Scripts\data\BPBO\B015\220718'
os.chdir(directory)
data_filename = 'rho_v_B_300K_0.5T_B015_0.csv'
setpoint = 10000 # max B in Oe
ramprate = 100 # field ramp in Oe/sec
procedure = HallSweep(host, port, setpoint, ramprate)
procedure.iterations = 1
procedure.high_current = 50.0e-6 # Amps
# Stop editing
procedure.delta = 1.e-3
procedure.swpct1 = 10
procedure.swpct2 = 1
procedure.swpct2 = 1
procedure.swpct3 = 10
procedure.nplc = 3
procedure.rvng = 1.e1
now = datetime.now()
#procedure.date = now.strftime("%m/%d/%Y, %H:%M:%s")
#print('Params: ', procedure.parameter_objects())
#procedure.startup()
#procedure.execute()
#hs = HallSweep(host, port)
#hs.startup()
#print('Hall sweep started up')
#'''
results = Results(procedure, data_filename)
worker = Worker(results)
print('Starting worker to run Hall Sweep')
worker.start()
worker.join(timeout=120) # wait at most 2 min
#'''
if __name__ == '__main__':
main()