Skip to content

Commit

Permalink
Merge pull request #181 from Jasper-Harvey0/DMM-Driver-Improvements
Browse files Browse the repository at this point in the history
Dmm driver improvements
  • Loading branch information
clint-lawrence authored May 28, 2024
2 parents cec3e96 + 30b6434 commit d37cb5c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 36 deletions.
3 changes: 2 additions & 1 deletion docs/source/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ Release Date XX/XX/XX

New Features
############
-

Improvements
############
- Add logging of computer name to log file.
- Update DMM driver with optional measurement delay to improve DMM model compatibility.


*************
Version 0.6.1
Expand Down
2 changes: 0 additions & 2 deletions src/fixate/drivers/dmm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@


def open() -> DMM:

for DMM in (Fluke8846A, Keithley6500):

instrument = find_instrument_by_id(DMM.REGEX_ID)
if instrument is not None:
# We've found a configured instrument so try to open it
Expand Down
36 changes: 10 additions & 26 deletions src/fixate/drivers/dmm/fluke_8846a.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from threading import Lock
from pyvisa import constants
from fixate.core.exceptions import InstrumentError, ParameterError
from fixate.core.common import mode_builder, deprecated
from fixate.drivers.dmm.helper import DMM
import time

Expand All @@ -11,6 +9,8 @@ class Fluke8846A(DMM):
INSTR_TYPE = "VISA"

def __init__(self, instrument, *args, **kwargs):
# Delay between call to self.measurement() and querying the DMM.
self.measurement_delay = 0
self.instrument = instrument
instrument.rtscts = 1
self.lock = Lock()
Expand Down Expand Up @@ -42,28 +42,8 @@ def __init__(self, instrument, *args, **kwargs):
"continuity": "CONF:CONTinuity",
"diode": "CONF:DIODe",
}
self._filters = {
"voltage_ac": "SENS:VOLT:AC",
"voltage_dc": "SENS:VOLT:DC",
"current_ac": "SENS:CURR:AC",
"current_dc": "SENS:CURR:DC",
"resistance": "SENS:RES",
"fresistance": "SENS:FRES",
None: "",
}
self._init_string = "" # Unchanging

self._resolution = {
"voltage_ac": "VOLT:RES",
"voltage_dc": "VOLT:RES",
"current_ac": "CURR:AC:RES",
"current_dc": "CURR:DC:RES",
"resistance": "RES:RES",
"fresistance": "RES:RES",
"capacitance": "CAP:RES",
None: "",
}

@property
def samples(self):
return self._samples
Expand Down Expand Up @@ -100,11 +80,18 @@ def trigger(self):
self._write("*TRG") # Send trigger to instrument
self._is_error() # Catch errors. This might slow things down

def measurement(self):
def measurement(self, delay=None):
"""
Sets up DMM triggering, creates list of measurements from the read buffer
delay: If not set, will wait for self.measurement_delay seconds before triggering a measurement. If set, will wait for delay seconds before triggering a measurement.
returns: a single value as a float
"""
if delay is None:
delay = self.measurement_delay

if delay > 0:
time.sleep(delay)
return self.measurements()[0]

def measurements(self):
Expand Down Expand Up @@ -214,7 +201,6 @@ def _set_measurement_mode(self, mode, _range=None, suffix=None):
resistance, fresistance. Reduces previous duplicate code.
:param mode:
:param _range:
:param _resolution:
:return:
"""
self.mode = mode
Expand Down Expand Up @@ -282,7 +268,6 @@ def diode(self, low_current=True, high_voltage=False):
"""
Writes configuration string for diode to the DMM
param _range: value set for the range
param _resolution: value set for the resolution
"""
self._set_measurement_mode(
"diode",
Expand All @@ -293,7 +278,6 @@ def continuity(self):
"""
Writes configuration string for continuity to the DMM
param _range: value set for the range
param _resolution: value set for the resolution
"""
self._set_measurement_mode("continuity")

Expand Down
8 changes: 7 additions & 1 deletion src/fixate/drivers/dmm/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ def trigger(self):
"""
raise NotImplementedError

def measurement(self):
def measurement(self, delay=None):
"""
Trigger and return measurement from the instrument buffer.
delay: If True, waits for self.measurement_delay seconds then triggers a measurement.
returns: a single value as a float
"""
raise NotImplementedError

def voltage_ac(self, _range=None):
Expand Down
19 changes: 13 additions & 6 deletions src/fixate/drivers/dmm/keithley_6500.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from threading import Lock
from pyvisa import constants
from fixate.core.exceptions import InstrumentError, ParameterError
from fixate.core.common import mode_builder, deprecated
from fixate.drivers.dmm.helper import DMM
import time

Expand All @@ -11,6 +9,8 @@ class Keithley6500(DMM):
INSTR_TYPE = "VISA"

def __init__(self, instrument, *args, **kwargs):
# Delay between call to self.measurement() and querying the DMM.
self.measurement_delay = 0.2
self.instrument = instrument
instrument.rtscts = 1
self.lock = Lock()
Expand Down Expand Up @@ -80,10 +80,10 @@ def local(self):
# So just set up a trigger loop. Requires *TRG to be sent to drop it out of the loop (call to remote()).
self.samples = 1
self._write("TRIG:LOAD 'EMPTY'") # Load empty model
self._write(f"TRIG:BLOC:MDIG 1, 'defbuffer1', 1")
self._write(f"TRIG:BLOC:DEL:CONS 2, 0.1")
self._write("TRIG:BLOC:MDIG 1, 'defbuffer1', 1")
self._write("TRIG:BLOC:DEL:CONS 2, 0.1")
self._write("TRIG:BLOC:BRAN:EVEN 3, COMM, 5")
self._write(f"TRIG:BLOC:BRAN:ALW 4, 1")
self._write("TRIG:BLOC:BRAN:ALW 4, 1")
self._write("TRIG:BLOC:BUFF:CLE 5")
self._write("TRAC:CLE")
self._write("INIT")
Expand Down Expand Up @@ -117,11 +117,18 @@ def trigger(self):
self._write("INIT; *WAI")
self._is_error()

def measurement(self):
def measurement(self, delay=None):
"""
Sets up DMM triggering, creates list of measurements from the read buffer
delay: If not set, will wait for self.measurement_delay seconds before triggering a measurement. If set, will wait for delay seconds before triggering a measurement.
returns: a single value as a float
"""
if delay is None:
delay = self.measurement_delay

if delay > 0:
time.sleep(delay)
return self.measurements()[0]

def measurements(self):
Expand Down

0 comments on commit d37cb5c

Please sign in to comment.