Skip to content

Commit

Permalink
Merge pull request #40 from ralph-group/dev/keithley2400
Browse files Browse the repository at this point in the history
* Adding docs to Keithley 2400 and cleaning up functions

* Major update to Keithley 2400

* Replaced output wording with source for consistency

* Syntax fixes in Keithley 2400

* Updated Yokogawa 7651 to be consistent with Keithley 2400

* Another syntax fix in Keithley 2400

* Added get and set process hook for Instrument.control and measurement

* Added Keithley buffer class to share buffer code between Keithley 2000 and Keithley 2400

* Updating Keithley 2400 controls and buffer inheretance

* Major update to Keithley 2000, new controls and consistent syntax

* Major update to Yokogawa7651, new controls and consistent syntax

* Updated IV examples with new instrument controls

* Updated syntax for applying current and voltage

* Simplified IV example imports

* Updated IV procedures for setting current

* Worker handles startup errors more gracefully
  • Loading branch information
cjermain committed Aug 23, 2016
2 parents 6b80147 + 0627d39 commit ba88c4f
Show file tree
Hide file tree
Showing 11 changed files with 1,333 additions and 581 deletions.
4 changes: 3 additions & 1 deletion docs/api/instruments/keithley/keithley2000.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ Keithley 2000 Multimeter

.. autoclass:: pymeasure.instruments.keithley.Keithley2000
:members:
:show-inheritance:
:show-inheritance:
:inherited-members:
:exclude-members: ask, control, clear, measurement, read, setting, values, write
4 changes: 3 additions & 1 deletion docs/api/instruments/keithley/keithley2400.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ Keithley 2400 SourceMeter

.. autoclass:: pymeasure.instruments.keithley.Keithley2400
:members:
:show-inheritance:
:show-inheritance:
:inherited-members:
:exclude-members: ask, control, clear, measurement, read, setting, values, write
42 changes: 16 additions & 26 deletions examples/Current-Voltage Measurements/iv_keithley.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,18 @@
log.addHandler(logging.NullHandler())

import sys
import random
import tempfile
import pyqtgraph as pg
from time import sleep
import numpy as np

from pymeasure.instruments.keithley import Keithley2000, Keithley2400
from pymeasure.instruments import Instrument
from pymeasure.log import console_log
from pymeasure.experiment import Results
from pymeasure.display.Qt import QtGui
from pymeasure.display.windows import ManagedWindow
from pymeasure.experiment import Procedure, IntegerParameter, Parameter, FloatParameter
from pymeasure.experiment import unique_filename
from pymeasure.experiment import (
Procedure, FloatParameter, unique_filename, Results
)

class K2000(Keithley2000):
""" Temporary fix for PyMeasure 0.4.1
"""
measure = Instrument.measurement(":read?", """""")
voltage = measure
current = measure

class IVProcedure(Procedure):

Expand All @@ -51,20 +42,16 @@ class IVProcedure(Procedure):

def startup(self):
log.info("Setting up instruments")
self.meter = K2000("GPIB::25")
# Number of power line cycles (NPLC)
# Medium = 1 NPLC, 20 ms
self.meter.config_measure_voltage(self.voltage_range, nplc=1)
self.meter = Keithley2000("GPIB::25")
self.meter.measure_voltage()
self.meter.voltage_range = self.voltage_range
self.meter.voltage_nplc = 1 # Integration constant to Medium

self.source = Keithley2400("GPIB::1")
#self.source.config_current_source(self.max_current*1e-3)
# Temporary fix for PyMeasure 0.4.1
self.source.write(":sour:func curr;"
":sour:curr:rang:auto 0;"
":sour:curr:rang %g;:sour:curr:lev %g;" % (
self.max_current*1e-3, self.min_current*1e-3))
self.source.write(":sens:volt:prot %g;" % self.voltage_range)
self.source.output = True
self.source.apply_current()
self.source.source_current_range = self.max_current*1e-3 # A
self.source.complinance_voltage = self.voltage_range
self.source.enable_source()
sleep(2)

def execute(self):
Expand All @@ -77,9 +64,13 @@ def execute(self):
log.info("Starting to sweep through current")
for i, current in enumerate(currents):
log.debug("Measuring current: %g mA" % current)

self.source.source_current = current
# Or use self.source.ramp_to_current(current, delay=0.1)
sleep(self.delay*1e-3)

voltage = self.meter.voltage

if abs(current) <= 1e-10:
resistance = np.nan
else:
Expand All @@ -96,8 +87,7 @@ def execute(self):
break

def shutdown(self):
self.source.source_current = 0
self.source.output = False
self.source.shutdown()
log.info("Finished")


Expand Down
35 changes: 16 additions & 19 deletions examples/Current-Voltage Measurements/iv_yokogawa.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,19 @@
log.addHandler(logging.NullHandler())

import sys
import random
import tempfile
import pyqtgraph as pg
from time import sleep
import numpy as np

from pymeasure.instruments.keithley import Keithley2000
from pymeasure.instruments.yokogawa import Yokogawa7651
from pymeasure.instruments import Instrument
from pymeasure.log import console_log
from pymeasure.experiment import Results
from pymeasure.display.Qt import QtGui
from pymeasure.display.windows import ManagedWindow
from pymeasure.experiment import Procedure, IntegerParameter, Parameter, FloatParameter
from pymeasure.experiment import unique_filename
from pymeasure.experiment import (
Procedure, FloatParameter, unique_filename, Results
)

class K2000(Keithley2000):
""" Temporary fix for PyMeasure 0.4.1 """
measure = Instrument.measurement(":read?", """""")
voltage = measure
current = measure

class IVProcedure(Procedure):

Expand All @@ -51,14 +43,16 @@ class IVProcedure(Procedure):

def startup(self):
log.info("Setting up instruments")
self.meter = K2000("GPIB::25")
# Number of power line cycles (NPLC)
# Medium = 1 NPLC, 20 ms
self.meter.config_measure_voltage(self.voltage_range, nplc=1)
self.meter = Keithley2000("GPIB::25")
self.meter.measure_voltage()
self.meter.voltage_range = self.voltage_range
self.meter.voltage_nplc = 1 # Integration constant to Medium

self.source = Yokogawa7651("GPIB::4")
self.source.config_current_source(self.max_current*1e-3)

self.source.apply_current()
self.source.source_current_range = self.max_current*1e-3 # A
self.source.complinance_voltage = self.voltage_range
self.source.enable_source()
sleep(1)

def execute(self):
Expand All @@ -71,8 +65,11 @@ def execute(self):
log.info("Starting to sweep through current")
for i, current in enumerate(currents):
log.debug("Measuring current: %g mA" % current)
self.source.current = current

self.source.source_current = current
# Or use self.source.ramp_to_current(current, delay=0.1)
sleep(self.delay*1e-3)

voltage = self.meter.voltage
if abs(current) <= 1e-10:
resistance = np.nan
Expand All @@ -90,7 +87,7 @@ def execute(self):
break

def shutdown(self):
self.source.current = 0
self.source.shutdown()
log.info("Finished")


Expand Down
14 changes: 13 additions & 1 deletion pymeasure/experiment/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,19 @@ def run(self):
log.info("Worker started running an instance of %r" % (self.procedure.__class__.__name__))
self.update_status(Procedure.RUNNING)
self.emit('progress', 0.)
self.procedure.startup()
# Try to run the startup method
try:
self.procedure.startup()
except Exception as e:
log.warning("Error in startup method caused Worker to stop prematurely")
self.handle_exception(e)
self.update_status(Procedure.FAILED)
self.recorder_queue.put(None)
self.monitor_queue.put(None)
self.stop()
del self.recorder
return
# If all has gone well, run the execute method
try:
self.procedure.execute()
except (KeyboardInterrupt, SystemExit):
Expand Down
Loading

0 comments on commit ba88c4f

Please sign in to comment.