Debian Codegraph @

pymeasure/instruments/keithley/keithley2400.py

raw
1 #
2 # This file is part of the PyMeasure package.
3 #
4 # Copyright (c) 2013-2024 PyMeasure Developers
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 # THE SOFTWARE.
23 #
24
25 import logging
26 import time
27 from warnings import warn
28
29 import numpy as np
30
31 from pymeasure.instruments import Instrument, SCPIMixin
32 from pymeasure.errors import RangeException
33 from pymeasure.instruments.validators import truncated_range, strict_discrete_set
34
35 from .buffer import KeithleyBuffer
36
37
38 log = logging.getLogger(__name__)
39 log.addHandler(logging.NullHandler())
40
41
42 class Keithley2400(KeithleyBuffer, SCPIMixin, Instrument):
43 """ Represents the Keithley 2400 SourceMeter and provides a
44 high-level interface for interacting with the instrument.
45
46 .. code-block:: python
47
48 keithley = Keithley2400("GPIB::1")
49
50 keithley.apply_current() # Sets up to source current
51 keithley.source_current_range = 10e-3 # Sets the source current range to 10 mA
52 keithley.compliance_voltage = 10 # Sets the compliance voltage to 10 V
53 keithley.source_current = 0 # Sets the source current to 0 mA
54 keithley.enable_source() # Enables the source output
55
56 keithley.measure_voltage() # Sets up to measure voltage
57
58 keithley.ramp_to_current(5e-3) # Ramps the current to 5 mA
59 print(keithley.voltage) # Prints the voltage in Volts
60
61 keithley.shutdown() # Ramps the current to 0 mA and disables output
62
63 """
64
65 source_mode = Instrument.control(
66 ":SOUR:FUNC?", ":SOUR:FUNC %s",
67 """ A string property that controls the source mode, which can
68 take the values 'current' or 'voltage'. The convenience methods
69 :meth:`~.Keithley2400.apply_current` and :meth:`~.Keithley2400.apply_voltage`
70 can also be used. """,
71 validator=strict_discrete_set,
72 values={'current': 'CURR', 'voltage': 'VOLT'},
73 map_values=True
74 )
75
76 source_enabled = Instrument.control(
77 "OUTPut?", "OUTPut %d",
78 """A boolean property that controls whether the source is enabled, takes
79 values True or False. The convenience methods :meth:`~.Keithley2400.enable_source` and
80 :meth:`~.Keithley2400.disable_source` can also be used.""",
81 validator=strict_discrete_set,
82 values={True: 1, False: 0},
83 map_values=True
84 )
85
86 auto_output_off = Instrument.control(
87 ":SOUR:CLE:AUTO?", ":SOUR:CLE:AUTO %d",
88 """ A boolean property that enables or disables the auto output-off.
89 Valid values are True (output off after measurement) and False (output
90 stays on after measurement). """,
91 values={True: 1, False: 0},
92 map_values=True,
93 )
94
95 source_delay = Instrument.control(
96 ":SOUR:DEL?", ":SOUR:DEL %g",
97 """ A floating point property that sets a manual delay for the source
98 after the output is turned on before a measurement is taken. When this
99 property is set, the auto delay is turned off. Valid values are
100 between 0 [seconds] and 999.9999 [seconds].""",
101 validator=truncated_range,
102 values=[0, 999.9999],
103 )
104
105 source_delay_auto = Instrument.control(
106 ":SOUR:DEL:AUTO?", ":SOUR:DEL:AUTO %d",
107 """ A boolean property that enables or disables auto delay. Valid
108 values are True and False. """,
109 values={True: 1, False: 0},
110 map_values=True,
111 )
112
113 auto_zero = Instrument.control(
114 ":SYST:AZER:STAT?", ":SYST:AZER:STAT %s",
115 """ A property that controls the auto zero option. Valid values are
116 True (enabled) and False (disabled) and 'ONCE' (force immediate). """,
117 values={True: 1, False: 0, "ONCE": "ONCE"},
118 map_values=True,
119 )
120
121 line_frequency = Instrument.control(
122 ":SYST:LFR?", ":SYST:LFR %d",
123 """ An integer property that controls the line frequency in Hertz.
124 Valid values are 50 and 60. """,
125 validator=strict_discrete_set,
126 values=[50, 60],
127 cast=int,
128 )
129
130 line_frequency_auto = Instrument.control(
131 ":SYST:LFR:AUTO?", ":SYST:LFR:AUTO %d",
132 """ A boolean property that enables or disables auto line frequency.
133 Valid values are True and False. """,
134 values={True: 1, False: 0},
135 map_values=True,
136 )
137
138 measure_concurent_functions = Instrument.control(
139 ":SENS:FUNC:CONC?", ":SENS:FUNC:CONC %d",
140 """ A boolean property that enables or disables the ability to measure
141 more than one function simultaneously. When disabled, volts function
142 is enabled. Valid values are True and False. """,
143 values={True: 1, False: 0},
144 map_values=True,
145 )
146
147 ###############
148 # Current (A) #
149 ###############
150
151 current = Instrument.measurement(
152 ":READ?",
153 """ Reads the current in Amps, if configured for this reading.
154 """
155 )
156 current_range = Instrument.control(
157 ":SENS:CURR:RANG?", ":SENS:CURR:RANG:AUTO 0;:SENS:CURR:RANG %g",
158 """ A floating point property that controls the measurement current
159 range in Amps, which can take values between -1.05 and +1.05 A.
160 Auto-range is disabled when this property is set. """,
161 validator=truncated_range,
162 values=[-1.05, 1.05]
163 )
164 current_nplc = Instrument.control(
165 ":SENS:CURR:NPLC?", ":SENS:CURR:NPLC %g",
166 """ A floating point property that controls the number of power line cycles
167 (NPLC) for the DC current measurements, which sets the integration period
168 and measurement speed. Takes values from 0.01 to 10, where 0.1, 1, and 10 are
169 Fast, Medium, and Slow respectively. """
170 )
171 compliance_current = Instrument.control(
172 ":SENS:CURR:PROT?", ":SENS:CURR:PROT %g",
173 """ A floating point property that controls the compliance current
174 in Amps. """,
175 validator=truncated_range,
176 values=[-1.05, 1.05]
177 )
178 source_current = Instrument.control(
179 ":SOUR:CURR?", ":SOUR:CURR:LEV %g",
180 """ A floating point property that controls the source current
181 in Amps. """,
182 validator=truncated_range,
183 values=[-1.05, 1.05]
184 )
185 source_current_range = Instrument.control(
186 ":SOUR:CURR:RANG?", ":SOUR:CURR:RANG:AUTO 0;:SOUR:CURR:RANG %g",
187 """ A floating point property that controls the source current
188 range in Amps, which can take values between -1.05 and +1.05 A.
189 Auto-range is disabled when this property is set. """,
190 validator=truncated_range,
191 values=[-1.05, 1.05]
192 )
193
194 ###############
195 # Voltage (V) #
196 ###############
197
198 voltage = Instrument.measurement(
199 ":READ?",
200 """ Reads the voltage in Volts, if configured for this reading.
201 """
202 )
203 voltage_range = Instrument.control(
204 ":SENS:VOLT:RANG?", ":SENS:VOLT:RANG:AUTO 0;:SENS:VOLT:RANG %g",
205 """ A floating point property that controls the measurement voltage
206 range in Volts, which can take values from -210 to 210 V.
207 Auto-range is disabled when this property is set. """,
208 validator=truncated_range,
209 values=[-210, 210]
210 )
211 voltage_nplc = Instrument.control(
212 ":SENS:VOLT:NPLC?", ":SENS:VOLT:NPLC %g",
213 """ A floating point property that controls the number of power line cycles
214 (NPLC) for the DC voltage measurements, which sets the integration period
215 and measurement speed. Takes values from 0.01 to 10, where 0.1, 1, and 10 are
216 Fast, Medium, and Slow respectively. """
217 )
218 compliance_voltage = Instrument.control(
219 ":SENS:VOLT:PROT?", ":SENS:VOLT:PROT %g",
220 """ A floating point property that controls the compliance voltage
221 in Volts. """,
222 validator=truncated_range,
223 values=[-210, 210]
224 )
225 source_voltage = Instrument.control(
226 ":SOUR:VOLT?", ":SOUR:VOLT:LEV %g",
227 """ A floating point property that controls the source voltage
228 in Volts. """
229 )
230 source_voltage_range = Instrument.control(
231 ":SOUR:VOLT:RANG?", ":SOUR:VOLT:RANG:AUTO 0;:SOUR:VOLT:RANG %g",
232 """ A floating point property that controls the source voltage
233 range in Volts, which can take values from -210 to 210 V.
234 Auto-range is disabled when this property is set. """,
235 validator=truncated_range,
236 values=[-210, 210]
237 )
238
239 ####################
240 # Resistance (Ohm) #
241 ####################
242
243 resistance = Instrument.measurement(
244 ":READ?",
245 """ Reads the resistance in Ohms, if configured for this reading.
246 """
247 )
248 resistance_range = Instrument.control(
249 ":SENS:RES:RANG?", ":SENS:RES:RANG:AUTO 0;:SENS:RES:RANG %g",
250 """ A floating point property that controls the resistance range
251 in Ohms, which can take values from 0 to 210 MOhms.
252 Auto-range is disabled when this property is set. """,
253 validator=truncated_range,
254 values=[0, 210e6]
255 )
256 resistance_nplc = Instrument.control(
257 ":SENS:RES:NPLC?", ":SENS:RES:NPLC %g",
258 """ A floating point property that controls the number of power line cycles
259 (NPLC) for the 2-wire resistance measurements, which sets the integration period
260 and measurement speed. Takes values from 0.01 to 10, where 0.1, 1, and 10 are
261 Fast, Medium, and Slow respectively. """
262 )
263 wires = Instrument.control(
264 ":SYSTEM:RSENSE?", ":SYSTEM:RSENSE %d",
265 """ An integer property that controls the number of wires in
266 use for resistance measurements, which can take the value of
267 2 or 4.
268 """,
269 validator=strict_discrete_set,
270 values={4: 1, 2: 0},
271 map_values=True
272 )
273
274 buffer_points = Instrument.control(
275 ":TRAC:POIN?", ":TRAC:POIN %d",
276 """ An integer property that controls the number of buffer points. This
277 does not represent actual points in the buffer, but the configuration
278 value instead. """,
279 validator=truncated_range,
280 values=[1, 2500],
281 cast=int
282 )
283 means = Instrument.measurement(
284 ":CALC3:FORM MEAN;:CALC3:DATA?;",
285 """ Reads the calculated means (averages) for voltage,
286 current, and resistance from the buffer data as a list. """
287 )
288 maximums = Instrument.measurement(
289 ":CALC3:FORM MAX;:CALC3:DATA?;",
290 """ Returns the calculated maximums for voltage, current, and
291 resistance from the buffer data as a list. """
292 )
293 minimums = Instrument.measurement(
294 ":CALC3:FORM MIN;:CALC3:DATA?;",
295 """ Returns the calculated minimums for voltage, current, and
296 resistance from the buffer data as a list. """
297 )
298 standard_devs = Instrument.measurement(
299 ":CALC3:FORM SDEV;:CALC3:DATA?;",
300 """ Returns the calculated standard deviations for voltage,
301 current, and resistance from the buffer data as a list. """
302 )
303
304 ###########
305 # Trigger #
306 ###########
307
308 trigger_count = Instrument.control(
309 ":TRIG:COUN?", ":TRIG:COUN %d",
310 """ An integer property that controls the trigger count,
311 which can take values from 1 to 9,999. """,
312 validator=truncated_range,
313 values=[1, 2500],
314 cast=int
315 )
316 trigger_delay = Instrument.control(
317 ":TRIG:SEQ:DEL?", ":TRIG:SEQ:DEL %g",
318 """ A floating point property that controls the trigger delay
319 in seconds, which can take values from 0 to 999.9999 s. """,
320 validator=truncated_range,
321 values=[0, 999.9999]
322 )
323
324 ###########
325 # Filters #
326 ###########
327
328 filter_type = Instrument.control(
329 ":SENS:AVER:TCON?", ":SENS:AVER:TCON %s",
330 """ A String property that controls the filter's type.
331 REP : Repeating filter
332 MOV : Moving filter""",
333 validator=strict_discrete_set,
334 values=['REP', 'MOV'],
335 map_values=False)
336
337 filter_count = Instrument.control(
338 ":SENS:AVER:COUNT?", ":SENS:AVER:COUNT %d",
339 """ A integer property that controls the number of readings that are
340 acquired and stored in the filter buffer for the averaging""",
341 validator=truncated_range,
342 values=[1, 100],
343 cast=int)
344
345 filter_state = Instrument.control(
346 ":SENS:AVER?", ":SENS:AVER %s",
347 """ A string property that controls if the filter is active.""",
348 validator=strict_discrete_set,
349 values=['ON', 'OFF'],
350 map_values=False)
351
352 #####################
353 # Output subsystem #
354 #####################
355
356 output_off_state = Instrument.control(
357 ":OUTP:SMOD?", ":OUTP:SMOD %s",
358 """ Select the output-off state of the SourceMeter.
359 HIMP : output relay is open, disconnects external circuitry.
360 NORM : V-Source is selected and set to 0V, Compliance is set to 0.5%
361 full scale of the present current range.
362 ZERO : V-Source is selected and set to 0V, compliance is set to the
363 programmed Source I value or to 0.5% full scale of the present current
364 range, whichever is greater.
365 GUAR : I-Source is selected and set to 0A""",
366 validator=strict_discrete_set,
367 values=['HIMP', 'NORM', 'ZERO', 'GUAR'],
368 map_values=False)
369
370 ####################
371 # Methods #
372 ####################
373
374 def __init__(self, adapter, name="Keithley 2400 SourceMeter", **kwargs):
375 super().__init__(
376 adapter, name,
377 **kwargs
378 )
379
380 def enable_source(self):
381 """ Enables the source of current or voltage depending on the
382 configuration of the instrument. """
383 self.write("OUTPUT ON")
384
385 def disable_source(self):
386 """ Disables the source of current or voltage depending on the
387 configuration of the instrument. """
388 self.write("OUTPUT OFF")
389
390 def measure_resistance(self, nplc=1, resistance=2.1e5, auto_range=True):
391 """ Configures the measurement of resistance.
392
393 :param nplc: Number of power line cycles (NPLC) from 0.01 to 10
394 :param resistance: Upper limit of resistance in Ohms, from -210 MOhms to 210 MOhms
395 :param auto_range: Enables auto_range if True, else uses the set resistance
396 """
397 log.info("%s is measuring resistance." % self.name)
398 self.write(":SENS:FUNC 'RES';"
399 ":SENS:RES:MODE MAN;"
400 ":SENS:RES:NPLC %f;:FORM:ELEM RES;" % nplc)
401 if auto_range:
402 self.write(":SENS:RES:RANG:AUTO 1;")
403 else:
404 self.resistance_range = resistance
405 self.check_errors()
406
407 def measure_voltage(self, nplc=1, voltage=21.0, auto_range=True):
408 """ Configures the measurement of voltage.
409
410 :param nplc: Number of power line cycles (NPLC) from 0.01 to 10
411 :param voltage: Upper limit of voltage in Volts, from -210 V to 210 V
412 :param auto_range: Enables auto_range if True, else uses the set voltage
413 """
414 log.info("%s is measuring voltage." % self.name)
415 self.write(":SENS:FUNC 'VOLT';"
416 ":SENS:VOLT:NPLC %f;:FORM:ELEM VOLT;" % nplc)
417 if auto_range:
418 self.write(":SENS:VOLT:RANG:AUTO 1;")
419 else:
420 self.voltage_range = voltage
421 self.check_errors()
422
423 def measure_current(self, nplc=1, current=1.05e-4, auto_range=True):
424 """ Configures the measurement of current.
425
426 :param nplc: Number of power line cycles (NPLC) from 0.01 to 10
427 :param current: Upper limit of current in Amps, from -1.05 A to 1.05 A
428 :param auto_range: Enables auto_range if True, else uses the set current
429 """
430 log.info("%s is measuring current." % self.name)
431 self.write(":SENS:FUNC 'CURR';"
432 ":SENS:CURR:NPLC %f;:FORM:ELEM CURR;" % nplc)
433 if auto_range:
434 self.write(":SENS:CURR:RANG:AUTO 1;")
435 else:
436 self.current_range = current
437 self.check_errors()
438
439 def auto_range_source(self):
440 """ Configures the source to use an automatic range.
441 """
442 if self.source_mode == 'current':
443 self.write(":SOUR:CURR:RANG:AUTO 1")
444 else:
445 self.write(":SOUR:VOLT:RANG:AUTO 1")
446
447 def apply_current(self, current_range=None,
448 compliance_voltage=0.1):
449 """ Configures the instrument to apply a source current, and
450 uses an auto range unless a current range is specified.
451 The compliance voltage is also set.
452
453 :param compliance_voltage: A float in the correct range for a
454 :attr:`~.Keithley2400.compliance_voltage`
455 :param current_range: A :attr:`~.Keithley2400.current_range` value or None
456 """
457 log.info("%s is sourcing current." % self.name)
458 self.source_mode = 'current'
459 if current_range is None:
460 self.auto_range_source()
461 else:
462 self.source_current_range = current_range
463 self.compliance_voltage = compliance_voltage
464 self.check_errors()
465
466 def apply_voltage(self, voltage_range=None,
467 compliance_current=0.1):
468 """ Configures the instrument to apply a source voltage, and
469 uses an auto range unless a voltage range is specified.
470 The compliance current is also set.
471
472 :param compliance_current: A float in the correct range for a
473 :attr:`~.Keithley2400.compliance_current`
474 :param voltage_range: A :attr:`~.Keithley2400.voltage_range` value or None
475 """
476 log.info("%s is sourcing voltage." % self.name)
477 self.source_mode = 'voltage'
478 if voltage_range is None:
479 self.auto_range_source()
480 else:
481 self.source_voltage_range = voltage_range
482 self.compliance_current = compliance_current
483 self.check_errors()
484
485 def beep(self, frequency, duration):
486 """ Sounds a system beep.
487
488 :param frequency: A frequency in Hz between 65 Hz and 2 MHz
489 :param duration: A time in seconds between 0 and 7.9 seconds
490 """
491 self.write(f":SYST:BEEP {frequency:g}, {duration:g}")
492
493 def triad(self, base_frequency, duration):
494 """ Sounds a musical triad using the system beep.
495
496 :param base_frequency: A frequency in Hz between 65 Hz and 1.3 MHz
497 :param duration: A time in seconds between 0 and 7.9 seconds
498 """
499 self.beep(base_frequency, duration)
500 time.sleep(duration)
501 self.beep(base_frequency * 5.0 / 4.0, duration)
502 time.sleep(duration)
503 self.beep(base_frequency * 6.0 / 4.0, duration)
504
505 display_enabled = Instrument.control(
506 ":DISP:ENAB?", ":DISP:ENAB %d",
507 """ A boolean property that controls whether or not the display of the
508 sourcemeter is enabled. Valid values are True and False. """,
509 values={True: 1, False: 0},
510 map_values=True,
511 )
512
513 @property
514 def error(self):
515 warn("Deprecated to use `error`, use `next_error` instead.", FutureWarning)
516 return self.next_error
517
518 def reset(self):
519 """ Resets the instrument and clears the queue. """
520 self.write("status:queue:clear;*RST;:stat:pres;:*CLS;")
521
522 def ramp_to_current(self, target_current, steps=30, pause=20e-3):
523 """ Ramps to a target current from the set current value over
524 a certain number of linear steps, each separated by a pause duration.
525
526 :param target_current: A current in Amps
527 :param steps: An integer number of steps
528 :param pause: A pause duration in seconds to wait between steps
529 """
530 currents = np.linspace(
531 self.source_current,
532 target_current,
533 steps
534 )
535 for current in currents:
536 self.source_current = current
537 time.sleep(pause)
538
539 def ramp_to_voltage(self, target_voltage, steps=30, pause=20e-3):
540 """ Ramps to a target voltage from the set voltage value over
541 a certain number of linear steps, each separated by a pause duration.
542
543 :param target_voltage: A voltage in Amps
544 :param steps: An integer number of steps
545 :param pause: A pause duration in seconds to wait between steps
546 """
547 voltages = np.linspace(
548 self.source_voltage,
549 target_voltage,
550 steps
551 )
552 for voltage in voltages:
553 self.source_voltage = voltage
554 time.sleep(pause)
555
556 def trigger(self):
557 """ Executes a bus trigger, which can be used when
558 :meth:`~.trigger_on_bus` is configured.
559 """
560 return self.write("*TRG")
561
562 def trigger_immediately(self):
563 """ Configures measurements to be taken with the internal
564 trigger at the maximum sampling rate.
565 """
566 self.write(":ARM:SOUR IMM;:TRIG:SOUR IMM;")
567
568 def trigger_on_bus(self):
569 """ Configures the trigger to detect events based on the bus
570 trigger, which can be activated by :meth:`~.trigger`.
571 """
572 self.write(":ARM:COUN 1;:ARM:SOUR BUS;:TRIG:SOUR BUS;")
573
574 def set_trigger_counts(self, arm, trigger):
575 """ Sets the number of counts for both the sweeps (arm) and the
576 points in those sweeps (trigger), where the total number of
577 points can not exceed 2500
578 """
579 if arm * trigger > 2500 or arm * trigger < 0:
580 raise RangeException("Keithley 2400 has a combined maximum "
581 "of 2500 counts")
582 if arm < trigger:
583 self.write(":ARM:COUN %d;:TRIG:COUN %d" % (arm, trigger))
584 else:
585 self.write(":TRIG:COUN %d;:ARM:COUN %d" % (trigger, arm))
586
587 def sample_continuously(self):
588 """ Causes the instrument to continuously read samples
589 and turns off any buffer or output triggering
590 """
591 self.disable_buffer()
592 self.disable_output_trigger()
593 self.trigger_immediately()
594
595 def set_timed_arm(self, interval):
596 """ Sets up the measurement to be taken with the internal
597 trigger at a variable sampling rate defined by the interval
598 in seconds between sampling points
599 """
600 if interval > 99999.99 or interval < 0.001:
601 raise RangeException("Keithley 2400 can only be time"
602 " triggered between 1 mS and 1 Ms")
603 self.write(":ARM:SOUR TIM;:ARM:TIM %.3f" % interval)
604
605 def trigger_on_external(self, line=1):
606 """ Configures the measurement trigger to be taken from a
607 specific line of an external trigger
608
609 :param line: A trigger line from 1 to 4
610 """
611 cmd = ":ARM:SOUR TLIN;:TRIG:SOUR TLIN;"
612 cmd += ":ARM:ILIN %d;:TRIG:ILIN %d;" % (line, line)
613 self.write(cmd)
614
615 def output_trigger_on_external(self, line=1, after='DEL'):
616 """ Configures the output trigger on the specified trigger link
617 line number, with the option of supplying the part of the
618 measurement after which the trigger should be generated
619 (default to delay, which is right before the measurement)
620
621 :param line: A trigger line from 1 to 4
622 :param after: An event string that determines when to trigger
623 """
624 self.write(":TRIG:OUTP %s;:TRIG:OLIN %d;" % (after, line))
625
626 def disable_output_trigger(self):
627 """ Disables the output trigger for the Trigger layer
628 """
629 self.write(":TRIG:OUTP NONE")
630
631 @property
632 def mean_voltage(self):
633 """ Returns the mean voltage from the buffer """
634 return self.means[0]
635
636 @property
637 def max_voltage(self):
638 """ Returns the maximum voltage from the buffer """
639 return self.maximums[0]
640
641 @property
642 def min_voltage(self):
643 """ Returns the minimum voltage from the buffer """
644 return self.minimums[0]
645
646 @property
647 def std_voltage(self):
648 """ Returns the voltage standard deviation from the buffer """
649 return self.standard_devs[0]
650
651 @property
652 def mean_current(self):
653 """ Returns the mean current from the buffer """
654 return self.means[1]
655
656 @property
657 def max_current(self):
658 """ Returns the maximum current from the buffer """
659 return self.maximums[1]
660
661 @property
662 def min_current(self):
663 """ Returns the minimum current from the buffer """
664 return self.minimums[1]
665
666 @property
667 def std_current(self):
668 """ Returns the current standard deviation from the buffer """
669 return self.standard_devs[1]
670
671 @property
672 def mean_resistance(self):
673 """ Returns the mean resistance from the buffer """
674 return self.means[2]
675
676 @property
677 def max_resistance(self):
678 """ Returns the maximum resistance from the buffer """
679 return self.maximums[2]
680
681 @property
682 def min_resistance(self):
683 """ Returns the minimum resistance from the buffer """
684 return self.minimums[2]
685
686 @property
687 def std_resistance(self):
688 """ Returns the resistance standard deviation from the buffer """
689 return self.standard_devs[2]
690
691 def status(self):
692 return self.ask("status:queue?;")
693
694 def RvsI(self, startI, stopI, stepI, compliance, delay=10.0e-3, backward=False):
695 num = int(float(stopI - startI) / float(stepI)) + 1
696 currRange = 1.2 * max(abs(stopI), abs(startI))
697 # self.write(":SOUR:CURR 0.0")
698 self.write(":SENS:VOLT:PROT %g" % compliance)
699 self.write(":SOUR:DEL %g" % delay)
700 self.write(":SOUR:CURR:RANG %g" % currRange)
701 self.write(":SOUR:SWE:RANG FIX")
702 self.write(":SOUR:CURR:MODE SWE")
703 self.write(":SOUR:SWE:SPAC LIN")
704 self.write(":SOUR:CURR:STAR %g" % startI)
705 self.write(":SOUR:CURR:STOP %g" % stopI)
706 self.write(":SOUR:CURR:STEP %g" % stepI)
707 self.write(":TRIG:COUN %d" % num)
708 if backward:
709 currents = np.linspace(stopI, startI, num)
710 self.write(":SOUR:SWE:DIR DOWN")
711 else:
712 currents = np.linspace(startI, stopI, num)
713 self.write(":SOUR:SWE:DIR UP")
714 self.connection.timeout = 30.0
715 self.enable_source()
716 data = self.values(":READ?")
717
718 self.check_errors()
719 return zip(currents, data)
720
721 def RvsIaboutZero(self, minI, maxI, stepI, compliance, delay=10.0e-3):
722 data = []
723 data.extend(self.RvsI(minI, maxI, stepI, compliance=compliance, delay=delay))
724 data.extend(self.RvsI(minI, maxI, stepI, compliance=compliance, delay=delay, backward=True))
725 self.disable_source()
726 data.extend(self.RvsI(-minI, -maxI, -stepI, compliance=compliance, delay=delay))
727 data.extend(self.RvsI(-minI, -maxI, -stepI, compliance=compliance, delay=delay,
728 backward=True))
729 self.disable_source()
730 return data
731
732 def use_rear_terminals(self):
733 """ Enables the rear terminals for measurement, and
734 disables the front terminals. """
735 self.write(":ROUT:TERM REAR")
736
737 def use_front_terminals(self):
738 """ Enables the front terminals for measurement, and
739 disables the rear terminals. """
740 self.write(":ROUT:TERM FRON")
741
742 def shutdown(self):
743 """ Ensures that the current or voltage is turned to zero
744 and disables the output. """
745 log.info("Shutting down %s." % self.name)
746 if self.source_mode == 'current':
747 self.ramp_to_current(0.0)
748 else:
749 self.ramp_to_voltage(0.0)
750 self.stop_buffer()
751 self.disable_source()
752 super().shutdown()