Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit fe9d314

Browse files
committed
synced
1 parent 4102ade commit fe9d314

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

pymeasure/instruments/keithley/keithley2600.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,29 +70,28 @@ def error(self):
7070
warn("Deprecated to use `error`, use `next_error` instead.", FutureWarning)
7171
return self.next_error
7272

73+
7374
class Channel:
75+
7476
def __init__(self, instrument, channel):
7577
self.instrument = instrument
7678
self.channel = channel
7779

7880
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})'))
8082

8183
def write(self, cmd):
82-
self.instrument.write(f"smu{self.channel}.{cmd}")
84+
self.instrument.write(f'smu{self.channel}.{cmd}')
8385

8486
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,
8688
passing on any key-word arguments.
8789
"""
88-
return self.instrument.values(f"print(smu{self.channel}.{cmd})")
90+
return self.instrument.values(f'print(smu{self.channel}.{cmd})')
8991

9092
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)
9695

9796
def check_errors(self):
9897
return self.instrument.check_errors()
@@ -116,12 +115,11 @@ def check_errors(self):
116115
)
117116

118117
measure_nplc = Instrument.control(
119-
"measure.nplc",
120-
"measure.nplc=%f",
118+
'measure.nplc', 'measure.nplc=%f',
121119
""" Property controlling the nplc value """,
122120
validator=truncated_range,
123121
values=[0.001, 25],
124-
map_values=True,
122+
map_values=True
125123
)
126124

127125
###############
@@ -217,7 +215,7 @@ def check_errors(self):
217215
#######################
218216

219217
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.
221219
:param nplc: Number of power line cycles (NPLC) from 0.001 to 25
222220
:param voltage: Upper limit of voltage in Volts, from -200 V to 200 V
223221
: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):
237235
:param current: Upper limit of current in Amps, from -1.5 A to 1.5 A
238236
:param auto_range: Enables auto_range if True, else uses the set current
239237
"""
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()')
242240
self.write('measure.nplc=%f' % nplc)
243241
if auto_range:
244242
self.write('measure.autorangei=1')
@@ -247,22 +245,23 @@ def measure_current(self, nplc=1, current=1.05e-4, auto_range=True):
247245
self.check_errors()
248246

249247
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')
253252
else:
254-
self.write("source.autorangev=1")
253+
self.write('source.autorangev=1')
255254

256255
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
258257
uses an auto range unless a current range is specified.
259258
The compliance voltage is also set.
260259
:param compliance_voltage: A float in the correct range for a
261260
:attr:`~.Keithley2600.compliance_voltage`
262261
:param current_range: A :attr:`~.Keithley2600.current_range` value or None
263262
"""
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'
266265
if current_range is None:
267266
self.auto_range_source()
268267
else:
@@ -279,8 +278,8 @@ def apply_voltage(self, voltage_range=None,
279278
:attr:`~.Keithley2600.compliance_current`
280279
:param voltage_range: A :attr:`~.Keithley2600.voltage_range` value or None
281280
"""
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'
284283
if voltage_range is None:
285284
self.auto_range_source()
286285
else:

0 commit comments

Comments
 (0)