@@ -70,29 +70,28 @@ def error(self):
70
70
warn ("Deprecated to use `error`, use `next_error` instead." , FutureWarning )
71
71
return self .next_error
72
72
73
+
73
74
class Channel :
75
+
74
76
def __init__ (self , instrument , channel ):
75
77
self .instrument = instrument
76
78
self .channel = channel
77
79
78
80
def ask (self , cmd ):
79
- return float (self .instrument .ask (f" print(smu{ self .channel } .{ cmd } )" ))
81
+ return float (self .instrument .ask (f' print(smu{ self .channel } .{ cmd } )' ))
80
82
81
83
def write (self , cmd ):
82
- self .instrument .write (f" smu{ self .channel } .{ cmd } " )
84
+ self .instrument .write (f' smu{ self .channel } .{ cmd } ' )
83
85
84
86
def values (self , cmd , ** kwargs ):
85
- """Reads a set of values from the instrument through the adapter,
87
+ """ Reads a set of values from the instrument through the adapter,
86
88
passing on any key-word arguments.
87
89
"""
88
- return self .instrument .values (f" print(smu{ self .channel } .{ cmd } )" )
90
+ return self .instrument .values (f' print(smu{ self .channel } .{ cmd } )' )
89
91
90
92
def binary_values (self , cmd , header_bytes = 0 , dtype = np .float32 ):
91
- return self .instrument .binary_values (
92
- f"print(smu{ self .channel } .{ cmd } )" ,
93
- header_bytes ,
94
- dtype ,
95
- )
93
+ return self .instrument .binary_values ('print(smu%s.%s)' %
94
+ (self .channel , cmd ,), header_bytes , dtype )
96
95
97
96
def check_errors (self ):
98
97
return self .instrument .check_errors ()
@@ -116,12 +115,11 @@ def check_errors(self):
116
115
)
117
116
118
117
measure_nplc = Instrument .control (
119
- "measure.nplc" ,
120
- "measure.nplc=%f" ,
118
+ 'measure.nplc' , 'measure.nplc=%f' ,
121
119
""" Property controlling the nplc value """ ,
122
120
validator = truncated_range ,
123
121
values = [0.001 , 25 ],
124
- map_values = True ,
122
+ map_values = True
125
123
)
126
124
127
125
###############
@@ -217,7 +215,7 @@ def check_errors(self):
217
215
#######################
218
216
219
217
def measure_voltage (self , nplc = 1 , voltage = 21.0 , auto_range = True ):
220
- """C onfigures the measurement of voltage.
218
+ """ Configures the measurement of voltage.
221
219
:param nplc: Number of power line cycles (NPLC) from 0.001 to 25
222
220
:param voltage: Upper limit of voltage in Volts, from -200 V to 200 V
223
221
:param auto_range: Enables auto_range if True, else uses the set voltage
@@ -237,8 +235,8 @@ def measure_current(self, nplc=1, current=1.05e-4, auto_range=True):
237
235
:param current: Upper limit of current in Amps, from -1.5 A to 1.5 A
238
236
:param auto_range: Enables auto_range if True, else uses the set current
239
237
"""
240
- log .info ("%s is sourcing current." % self .channel )
241
- self .source_mode = 'current'
238
+ log .info ("%s is measuring current." % self .channel )
239
+ self .write ( 'measure.i()' )
242
240
self .write ('measure.nplc=%f' % nplc )
243
241
if auto_range :
244
242
self .write ('measure.autorangei=1' )
@@ -247,22 +245,23 @@ def measure_current(self, nplc=1, current=1.05e-4, auto_range=True):
247
245
self .check_errors ()
248
246
249
247
def auto_range_source (self ):
250
- """Configures the source to use an automatic range."""
251
- if self .source_mode == "current" :
252
- self .write ("source.autorangei=1" )
248
+ """ Configures the source to use an automatic range.
249
+ """
250
+ if self .source_mode == 'current' :
251
+ self .write ('source.autorangei=1' )
253
252
else :
254
- self .write (" source.autorangev=1" )
253
+ self .write (' source.autorangev=1' )
255
254
256
255
def apply_current (self , current_range = None , compliance_voltage = 0.1 ):
257
- """Configures the instrument to apply a source current, and
256
+ """ Configures the instrument to apply a source current, and
258
257
uses an auto range unless a current range is specified.
259
258
The compliance voltage is also set.
260
259
:param compliance_voltage: A float in the correct range for a
261
260
:attr:`~.Keithley2600.compliance_voltage`
262
261
:param current_range: A :attr:`~.Keithley2600.current_range` value or None
263
262
"""
264
- log .info (f" { self . channel } is sourcing current." )
265
- self .source_mode = " current"
263
+ log .info ("%s is sourcing current." % self . channel )
264
+ self .source_mode = ' current'
266
265
if current_range is None :
267
266
self .auto_range_source ()
268
267
else :
@@ -279,8 +278,8 @@ def apply_voltage(self, voltage_range=None,
279
278
:attr:`~.Keithley2600.compliance_current`
280
279
:param voltage_range: A :attr:`~.Keithley2600.voltage_range` value or None
281
280
"""
282
- log .info (f" { self . channel } is sourcing voltage." )
283
- self .source_mode = " voltage"
281
+ log .info ("%s is sourcing voltage." % self . channel )
282
+ self .source_mode = ' voltage'
284
283
if voltage_range is None :
285
284
self .auto_range_source ()
286
285
else :
0 commit comments