-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTT075.py
More file actions
158 lines (117 loc) · 5.26 KB
/
TT075.py
File metadata and controls
158 lines (117 loc) · 5.26 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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
from slab.instruments import SerialInstrument
import time
class TT075(SerialInstrument):
def __init__(self,name="hemt_power_supply",address='COM3',enabled=True,timeout=1):
SerialInstrument.__init__(self,name,address,enabled,timeout)
self.read_sleep=0.01
def set_slot(self, slot, verbose=False):
"""
Set the slot you want to set
Valid arguments are 1 or 2, power on default is 1
"""
if verbose:
self.read() # clear buffer
if int(slot) in [1, 2]:
cmd = 'S' + str(int(slot)) + ';'
self.write(cmd)
else: print('Slot should be 1 or 2')
if verbose:
rep = self.read()
if rep[:-1] == 'S' + str(int(slot)) + '!':
print('Slot set on: %i'%slot)
else:
print('Slot could not be set')
def set_channel(self, channel, verbose=False):
"""
Set the channel you want to set
Valid arguments are 1 or 2, power on default is 1
"""
if verbose:
self.read() # clear buffer
if int(channel) in [1, 2]:
cmd = 'C' + str(int(channel)) + ';'
self.write(cmd)
else: print('Channel should be 1 or 2')
if verbose:
rep = self.read()
if rep[:-1] == 'C' + str(int(channel)) + '!':
print('Channel set on: %i'%channel)
else:
print('Channel could not be set')
def get_drain_voltage(self, channel, slot=1):
"""Get the drain voltage on the active channel and slot"""
self.set_channel(channel)
self.set_slot(slot)
self.read() # clear buffer
cmd = 'd;'
self.write(cmd)
V_in_volt = float(self.read()[1:-2])/1e3
print('Drain voltage set to: %.3f V'%V_in_volt)
def get_gate_voltage(self, channel, slot=1):
"""Get the gate voltage on the active channel and slot"""
self.set_channel(channel)
self.set_slot(slot)
self.read() # clear buffer
cmd = 'g;'
self.write(cmd)
V_in_volt = float(self.read()[1:-2])/1e3
print('Gate voltage set to: %.3f V'%V_in_volt)
def get_drain_current(self, channel, slot=1):
"""Get the gate voltage on the active channel and slot"""
self.set_channel(channel)
self.set_slot(slot)
self.read() # clear buffer
cmd = 'i;'
self.write(cmd)
I_in_mA = float(self.read()[1:-2])/1e3
print('Drain current set to: %.3f mA'%I_in_mA)
def set_drain_voltage(self, voltage, channel, slot=1, verbose=False, mesure=False):
""" Set the drain voltage on the active channel and slot"""
self.set_channel(channel, verbose)
self.set_slot(slot, verbose)
cmd = 'D%.1f;'%(voltage*1e3)
self.write(cmd)
if mesure:
self.get_drain_voltage(channel, slot)
def set_gate_voltage(self, voltage, channel, slot=1, verbose=False, measure=False):
""" Set the gate voltage on the active channel and slot"""
self.set_channel(channel, verbose)
self.set_slot(slot, verbose)
cmd = 'G%.1f;'%(voltage*1e3)
self.write(cmd)
if measure:
self.get_gate_voltage(channel, slot)
def on(self):
""" Switch on the active channel and slot"""
cmd = 'N;'
self.write(cmd)
def off(self):
""" Switch off the active channel and slot"""
cmd = 'F;'
self.write(cmd)
def switch_on(self, slot=1, channel=1, drain_voltage=0, gate_voltage=0, verbose=True):
"""
Recommended way to switch on the active channel and slot
It set the drain and gate voltage and then switch on the channel
"""
self.set_drain_voltage(drain_voltage, channel, slot, verbose)
self.set_gate_voltage(gate_voltage, channel, slot, verbose=False)
self.on()
if verbose:
print('Channel switched on')
self.get_drain_voltage(channel, slot)
self.get_gate_voltage(channel, slot)
def switch_off(self, slot=1, channel=1, verbose=True):
"""
Recommended way to switch off the active channel and slot
It switch off the channel and then set the drain and gate voltage to 0
"""
self.set_slot(slot, verbose)
self.set_channel(channel, verbose)
self.off()
self.set_drain_voltage(0, slot, channel, verbose)
self.set_gate_voltage(0, slot, channel, verbose)
if verbose:
print('Channel switched off')
self.get_drain_voltage(channel, slot)
self.get_gate_voltage(channel, slot)