-
Notifications
You must be signed in to change notification settings - Fork 0
/
DMM3146A.py
executable file
·63 lines (53 loc) · 1.81 KB
/
DMM3146A.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
import time
import pyvisa
class DMM3146A:
def __init__(self, ress):
self.ress = ress
def check(self, role, name, port):
#rep = self.ress.query("RV?")
#rep = rep.strip()
#TODO: finish this
if ("TODO" == name):
print("The " + role + " is connected on the port " + port)
else:
print("The " + role + " is not connected on the port " + port)
exit() #abortProcedure()
def readScreen(self, screen = 1):
if (screen == 1 or screen == 2):
self.ress.query("R" + str(screen))
val = self.ress.read()
self.ress.read() #empty the return of the command
val = val.strip()
return val
else:
print("Invalid screen choosen in for the 3146A DMM")
exit()
#abortProcedure()
def measureVoltage(self):
"""Special function for the 3146A"""
self.ress.query("S100") #DCV auto range
self.ress.read()
time.sleep(2)
return float(self.readScreen(1))
def measureCurrent(self):
"""Special function for the 3146A"""
self.mode = 1
self.ress.query("S147") #DCA max range
val = self.ress.read()
time.sleep(2.0)
return float(self.readScreen(1))
def removeHighestLowest(self, list):
list.remove(max(list))
list.remove(min(list))
return list
def measureCurrentAvrg(self, nbrReadings):
samples = []
for x in range(nbrReadings):
print("aq " + str(x))
samples.append(self.measureCurrent())
print(*samples)
if (nbrReadings > 3):
samples = self.removeHighestLowest()
avg = sum(samples)/len(samples)
print("Average " + str(avg))
return avg