forked from johnrollinson/iv_characterization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keithley.py
76 lines (63 loc) · 2.28 KB
/
keithley.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
from pymeasure.instruments import Instrument
from time import sleep
import logging
log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())
class Keithley6487(Instrument):
"""
Keithley 6487 Picoammeter
"""
##############
# Properties #
##############
# sweep_state = Instrument.measurement(
# ":SOUR:VOLT:SWE:STAT?",
# """ Query if sweep running: 1 = sweep in progress. """
# )
buffer_size = Instrument.measurement(
":TRAC:POIN:ACT?",
""" Returns number of readings actually stored in buffer. """
)
###########
# Methods #
###########
def __init__(self, adapter, **kwargs):
super(Keithley6487, self).__init__(
adapter, "Keithley 6487", **kwargs
)
def reset(self):
self.write("*RST")
def configure_sweep(self, start, stop, step, delay, nplc, polarity):
self.write('SYST:ZCH OFF')
log.info("Zero-checking turned off")
self.write('AVER:COUN {:d}'.format(3))
self.write('AVER:TCON {:s}'.format('rep'))
self.write('AVER ON')
self.write('SENS:CURR:NPLC {:0.2f}'.format(nplc))
self.write('SOUR:VOLT:SWE:STAR {:0.1f}'.format(start))
log.info("Sweep start value set")
if polarity == 'Anode':
self.write('SOUR:VOLT:SWE:STOP {:0.1f}'.format(-stop))
if polarity == 'Cathode':
self.write('SOUR:VOLT:SWE:STOP {:0.1f}'.format(stop))
self.write('SOUR:VOLT:SWE:STEP {:0.2f}'.format(step))
self.write('SOUR:VOLT:SWE:DEL {:0.3f}'.format(delay/1e3))
self.write('FORM:ELEM ALL') # Include all elements in the trace data
self.write('FORM:SREG ASC') # Set output format of status register to ascii (decimal)
self.write('ARM:COUN {:d}'.format(int(abs((stop-start)/step)+1)))
def start_sweep(self):
self.write("SOUR:VOLT:SWE:INIT")
self.write("INIT")
def sweep_state(self):
self.write("*CLS")
try:
resp = int(self.ask("*STB?"))
resp = resp & 0x80
except:
resp = 1
return resp
if __name__ == "__main__":
from pymeasure.adapters import VISAAdapter
adapter = VISAAdapter("GPIB0::22::INSTR", '@py')
ammeter = Keithley6487(adapter)
ammeter.reset()