-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathkeithley_2700.py
More file actions
56 lines (45 loc) · 1.7 KB
/
keithley_2700.py
File metadata and controls
56 lines (45 loc) · 1.7 KB
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
""" Simple driver for Keithley Model 2700 """
from PyExpLabSys.drivers.scpi import SCPI
class Keithley2700(SCPI):
""" Simple driver for Keithley Model 2700 """
def __init__(self, interface, device=None, gpib_address=None):
if interface == 'serial':
SCPI.__init__(self, interface='serial', device=device, baudrate=9600)
self.scpi_comm('FORMAT:ELEMENTS READ') # Set short read-format
if interface == 'gpib':
SCPI.__init__(self, interface=interface, gpib_address=gpib_address)
def select_measurement_function(self, function):
"""Select a measurement function.
Keyword arguments:
Function -- A string stating the wanted measurement function.
"""
values = [
'CAPACITANCE',
'CONTINUITY',
'CURRENT',
'DIODE',
'FREQUENCY',
'RESISTANCE',
'FRESISTANCE',
'TEMPERATURE',
'VOLTAGE',
]
return_value = False
if function in values:
return_value = True
function_string = "FUNCTION " + "\"" + function + "\""
self.scpi_comm(function_string)
return return_value
def read(self):
""" Read a value from the device """
value_raw = self.scpi_comm("READ?").split(',')
value = float(value_raw[0][0:15])
timestamp = float(value_raw[1][0:10])
readings = int(value_raw[2][0:7])
return value, timestamp, readings
if __name__ == '__main__':
GPIB = 5
MUX = Keithley2700(interface='gpib', gpib_address=GPIB)
print(MUX.scpi_comm('ROUTE:SCAN?'))
MUX.select_measurement_function('VOLTAGE')
print(MUX.read())