-
Notifications
You must be signed in to change notification settings - Fork 1
/
AgilentE3631A.py
89 lines (71 loc) · 3.45 KB
/
AgilentE3631A.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
import serial
AaptosDummyMode = False
if AaptosDummyMode:
from DummySCPI import DummySCPI as AgilentSCPI
from DummyInstrument import DummyInstrument as AgilentInstrument
else:
from AgilentSCPI import AgilentSCPI
from AgilentInstrument import AgilentInstrument
class AgilentE3631A(AgilentSCPI):
"""Agilent E3631A Triple Output DC Power Supply"""
def __init__(self,port='/dev/usb/ttyUSB0', baudrate=9600, parity=serial.PARITY_NONE, bytesize=serial.EIGHTBITS):
AgilentSCPI.__init__(self,port,baudrate,parity,bytesize)
self.setRemote()
self.reset()
assert "E3631A" in self.identity(), "Error: improper device: "+self.identity()+"\n Expecting E3631A"
self.instruments_ = { "P6V":AgilentInstrument(1,"P6V",self), "P25V":AgilentInstrument(2,"P25V",self), "N25V":AgilentInstrument(3,"N25V",self) }
self.labels_ = { 1:"P6V", 2:"P25V", 3:"N25V" }
self.enableDisplay()
self.displayMessage("AAPTOS READY")
self.beep()
self.selectInstrument(index=1)
def selectInstrument(self, label=None, index=None):
"""This command selects the output to be programmed among three outputs"""
self.getInstrument(label,index).makeCurrent()
def getCurrentInstrument(self):
"""Returns the current instrument"""
return self.instruments_[self.getSelected()]
def getInstrument(self, label=None, index=None):
if label in self.instruments_:
return self.instruments_[label]
elif index in self.labels_:
return self.instruments_[self.labels_[index]]
else:
raise Exception("No such instrument:",label, index)
def getSelected(self):
"""This query returns the currently selected output by the INSTrument"""
currentInstrument = self.question("INSTRUMENT:SELECT?")
assert currentInstrument in self.instruments_, "Error: unknown current instrument"
return currentInstrument
def setRemote(self, locked=False):
self.setLocal() # needed to eventually unlock
if(locked):
self.write("SYSTEM:RWLOCK")
else:
self.write("SYSTEM:REMOTE")
def setLocal(self):
self.write("SYSTEM:LOCAL")
def applySettings(self,instrument,voltage,current):
"""The values of voltage and the current of the specified output are changed as soon as the command is executed"""
self.write("APPLY "+instrument+", "+str(voltage)+", "+str(current))
def readSettings(self,instrument):
"""This command queries the power supply's present voltage and current values for each output and returns a quoted string"""
return map(float,self.question("APPLY? "+instrument)[1:-1].split(","))
def couple(self,instrumentList=[]):
"""This command defines a coupling between various logical outputs of the power supply"""
if len(intrumentList)==0: instruments = "NONE"
elif set(instrumentList)==set(labels_.values()): instruments = "ALL"
else: instruments = reduce(lambda s,t: s+","+t,set(instrumentList))
self.write("INSTRUMENT:COUPLE:TRIGGER "+instruments)
def getCoupledOutputs(self):
"""This query returns the currently coupled output. Returns "ALL", "NONE", or a list"""
return self.question("INSTRUMENT:COUPLE:TRIGGER?")
def setTrackState(self, state=True):
"""This command enables or disables the power supply to operate in the track mode"""
if state:
self.write("OUTPUT:TRACK:STATE ON")
else:
self.write("OUTPUT:TRACK:STATE OFF")
def trackState(self):
"""This command queries the track mode state of the power supply"""
return self.question("OUTPUT:TRACK:STATE?")