Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d84064e
add NPLC config function to fluke 8846a driver
Overlord360 Nov 15, 2024
f7bf00c
add NPLC config function to Keithley DMM driver
Overlord360 Nov 15, 2024
abaa0d5
add function to get min, max and avg for a set amount of samples in b…
Overlord360 Nov 15, 2024
4d00493
Updated keithley and fluke nplc settings to the lower common denomina…
Overlord360 Nov 25, 2024
21ee0e5
Add nplc context manager to let test scripts use the "with" statement
Overlord360 Nov 26, 2024
661ef47
add tests for NPLC and min_avg_max functions
Overlord360 Nov 26, 2024
d4a7595
move common DMM code to helper to remove duplicate code
Overlord360 Nov 26, 2024
1b0fcf0
Update tests for keithely DMM
Overlord360 Nov 27, 2024
4bd69b0
change min_avg_max function to return a dataclass instead of a dictio…
Overlord360 Nov 27, 2024
1fdc57f
Simplify exception check in helper.py
Overlord360 Dec 3, 2024
b781b40
move original_nplc to context manager entry instead of init.
Overlord360 Dec 3, 2024
4da962e
add cleanup commands to fluke driver to disable math function and res…
Overlord360 Dec 3, 2024
f657fa2
Parameterize tests to test over multiple modes of the DMMs
Overlord360 Dec 4, 2024
43b8675
removed error checks from nplc context manager as they're redundant
Overlord360 Dec 4, 2024
43a2997
Merge branch 'PyFixate:main' into DMM-NPLC-command
Overlord360 Dec 6, 2024
52a49ec
update incorrect comment about return values
Overlord360 Dec 6, 2024
5d96f54
remove ability to set NPCL for diode measurements from keithley (for …
Overlord360 Dec 6, 2024
3dfa2a1
update release notes
Overlord360 Dec 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/fixate/drivers/dmm/fluke_8846a.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ def __init__(self, instrument, *args, **kwargs):
"continuity": "CONF:CONTinuity",
"diode": "CONF:DIODe",
}
self._nplc_modes = [
"resistance",
"fresistance",
"voltage_dc",
"current_dc",
"temperature",
"ftemperature",
]
self._nplc_settings = [0.02, 0.2, 1, 10, 100]
self._default_nplc = 10 # Default NPLC setting as per Fluke 8846A manual
self._init_string = "" # Unchanging

@property
Expand Down Expand Up @@ -101,6 +111,25 @@ def measurements(self):
with self.lock:
return self._read_measurements()

def min_avg_max(self, samples=1, sample_time=1):
"""
automatically samples the DMM for a given number of samples and returns the min, max, and average values
:param samples: number of samples to take
:param sample_time: time to wait for the DMM to take the samples
return: min, avg, max values as floats
"""

self._write(f"SAMP:COUN {samples}")
self._write("CALC:FUNC AVER")
self._write("CALC:STAT ON")
self._write("INIT")
time.sleep(sample_time)
_min = self.instrument.query_ascii_values("CALC:AVER:MIN?")[0]
_avg = self.instrument.query_ascii_values("CALC:AVER:AVER?")[0]
_max = self.instrument.query_ascii_values("CALC:AVER:MAX?")[0]

return _min, _avg, _max

def reset(self):
"""
Checks for errors and then returns DMM to power up state
Expand Down Expand Up @@ -222,6 +251,22 @@ def _set_measurement_mode(self, mode, _range=None, suffix=None):
)
self._is_error()

def set_nplc(self, nplc=None, reset=False):
if reset is True or nplc is None:
nplc = self._default_nplc
elif nplc not in self._nplc_settings:
raise ParameterError(f"Invalid NPLC setting {nplc}")

if self._mode not in self._nplc_modes:
raise ParameterError(f"NPLC setting not available for mode {self._mode}")

mode_str = f"{self._modes[self._mode]}"

# Remove the CONF: from the start of the string
mode_str = mode_str.replace("CONF:", "")

self._write(f"{mode_str}:NPLC {nplc}") # e.g. VOLT:DC:NPLC 10

def voltage_ac(self, _range=None):
self._set_measurement_mode("voltage_ac", _range)

Expand Down
48 changes: 47 additions & 1 deletion src/fixate/drivers/dmm/keithley_6500.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ def __init__(self, instrument, *args, **kwargs):
"continuity": "CONT",
"diode": "DIOD",
}

self._nplc_modes = [
"voltage_dc",
"current_dc",
"resistance",
"fresistance",
"diode",
"temperature",
]
self._nplc_min = 0.0005 # Minimum NPLC setting for the DMM
self._nplc_max = 12 # Maximum NPLC setting for the DMM
self._init_string = "" # Unchanging

# Adapted for different DMM behaviour
Expand Down Expand Up @@ -138,6 +147,31 @@ def measurements(self):
with self.lock:
return self._read_measurements()

def min_avg_max(self, samples=1, sample_time=1):
"""
automatically samples the DMM for a given number of samples and returns the min, max, and average values
:param samples: number of samples to take
:param sample_time: time to wait for the DMM to take the samples
return: min, avg, max values as floats
"""

self._write(f'TRAC:MAKE "TempTable", {samples}')
self._write(f"SENS:COUNt {samples}")

# we don't actually want the results, this is just to tell the DMM to start sampling
_tmp = self.instrument.query_ascii_values('READ? "TempTable"')[0]
time.sleep(sample_time)

_avg = self.instrument.query_ascii_values('TRAC:STAT:AVER? "TempTable"')[0]
_min = self.instrument.query_ascii_values('TRAC:STAT:MIN? "TempTable"')[0]
_max = self.instrument.query_ascii_values('TRAC:STAT:MAX? "TempTable"')[0]

# cleanup
self._write("SENS:COUNt 1")
self._write('TRAC:DEL "TempTable"')

return _min, _avg, _max

def reset(self):
"""
Checks for errors and then returns DMM to power up state
Expand Down Expand Up @@ -255,6 +289,18 @@ def _set_measurement_mode(self, mode, _range=None, suffix=None):
self._write(f":COUN {self.samples}")
self._is_error()

def set_nplc(self, nplc=None, reset=False):
if reset is True or nplc is None:
nplc = "DEF" # keithley supports sending the "DEF" string to reset the NPLC value
elif nplc <= self._nplc_min or nplc >= self._nplc_max:
raise ParameterError(f"NPLC setting out of range for Keithley 6500")

if self._mode not in self._nplc_modes:
raise ParameterError(f"NPLC setting not available for mode {self._mode}")

mode_str = f"{self._modes[self._mode]}"
self._write(f":SENS:{mode_str}:NPLC {nplc}")

def voltage_ac(self, _range=None):
self._set_measurement_mode("voltage_ac", _range)

Expand Down