-
Notifications
You must be signed in to change notification settings - Fork 0
/
INST_6050A.py
47 lines (38 loc) · 1.49 KB
/
INST_6050A.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
import pyvisa, time
class INST_6050A:
def __init__(self, Addr):
self.ADDR = Addr
self.visa_rm = pyvisa.ResourceManager()
self.inst = self.visa_rm.open_resource('GPIB0::'+str(self.ADDR)+'::INSTR')
def identify(self):
self.inst.write("*IDN?")
return self.inst.read()
def enable(self, Channel):
self.inst.write("CHAN "+str(Channel))
self.inst.write("INPUT ON")
def disable(self, Channel):
self.inst.write("CHAN "+str(Channel))
self.inst.write("INPUT OFF")
def set(self, Channel, Mode, Value):
self.inst.write("CHAN "+str(Channel))
if Mode.upper() == "CC":
self.inst.write("MODE:CURR")
self.inst.write("CURR {:0.4f}".format(Value))
elif Mode.upper() == "CV":
self.inst.write("MODE:VOLT")
self.inst.write("VOLT {:0.4f}".format(Value))
elif Mode.upper() == "CR":
self.inst.write("MODE:RES")
self.inst.write("RES {:0.4f}".format(Value))
def getVoltage(self, Channel):
self.inst.write("CHAN "+str(Channel))
self.inst.write("MEAS:VOLT?")
return float(self.inst.read())
def getCurrent(self, Channel):
self.inst.write("CHAN "+str(Channel))
self.inst.write("MEAS:CURR?")
return float(self.inst.read())
def getPower(self, Channel):
self.inst.write("CHAN "+str(Channel))
self.inst.write("MEAS:POW?")
return float(self.inst.read())