Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 14 additions & 1 deletion docs/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@
Release Notes
==================================

*************
Version 0.6.5
*************
Release Date xx/xx/xx

New Features
############

Improvements
############
- DMM current mode functions now raise an exception when an incompatible port and range combination is used. The range and port parameters are now required parameters.


*************
Version 0.6.4
*************
Release Date 14/01/25

New Features
############
- DMM drivers now have a new function to set NPLC (Number of Power Line Cycles) for the DMM.
- DMM drivers now have a new function to set NPLC (Number of Powr Line Cycles) for the DMM.
- DMM drivers now have a new function to use the DMM's internal statistics function to take multiple measurements and return the mean, minimum and maximum values.

Improvements
Expand Down
35 changes: 33 additions & 2 deletions src/fixate/drivers/dmm/fluke_8846a.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from fixate.core.exceptions import InstrumentError, ParameterError
from fixate.drivers.dmm.helper import DMM
import time
from typing import Literal


class Fluke8846A(DMM):
Expand Down Expand Up @@ -54,6 +55,10 @@ def __init__(self, instrument, *args, **kwargs):
self._default_nplc = 10 # Default NPLC setting as per Fluke 8846A manual
self._init_string = "" # Unchanging

# High and low current port definition. Each definition encodes the maximum current able to
# be measured by the port (in amps)
self._current_ports = {"HIGH": 10, "LOW": 400e-3}

@property
def samples(self):
return self._samples
Expand Down Expand Up @@ -268,10 +273,36 @@ def voltage_dc(self, _range=None, auto_impedance=False):
command = "; :SENS:VOLT:DC:IMP:AUTO OFF"
self._set_measurement_mode("voltage_dc", _range, suffix=command)

def current_ac(self, _range=None):
def current_ac(self, _range, port):
"""
Set the measurement mode on the DMM to AC current.

If the range and port selection are not compatible, i.e. someone has requested to measure
1 A on the low range port with a maximum capability of 400 mA, an exception is raised.

If the range requested can be measured by the low port, but the high port is selected, an
exception is raised.
"""

# Check the port and range combination is compatible for the instrument:
self._check_current_port_range(_range, port)

self._set_measurement_mode("current_ac", _range)

def current_dc(self, _range=None):
def current_dc(self, _range, port: Literal["HIGH", "LOW"]):
"""
Set the measurement mode on the DMM to DC current.

If the range and port selection are not compatible, i.e. someone has requested to measure
1A on the low range port with a maximum capability of 400 mA, an exception is raised.

If the range requested can be measured by the low port, but the high port is selected, an
exception is raised.
"""

# Check the port and range combination is compatible for the instrument:
self._check_current_port_range(_range, port)

self._set_measurement_mode("current_dc", _range)

def resistance(self, _range=None):
Expand Down
39 changes: 35 additions & 4 deletions src/fixate/drivers/dmm/helper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dataclasses import dataclass
from typing import Literal


class DMM:
Expand Down Expand Up @@ -60,13 +61,23 @@ def voltage_dc(self, _range=None, auto_impedance=False):
"""
raise NotImplementedError

def current_ac(self, _range):
def current_ac(self, _range, port: Literal["HIGH", "LOW"]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to introduce braking changes, maybe now is a good opportunity to make the not so private private _range not private anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did have this thought, then it annoyed me that only one function in the whole API uses the correct naming convention. I know it's wrong, but I almost prefer to have everything consistent? Let me know if you really want me to change it.

"""
Sets the DMM in AC current measurement mode.

Args:
_range: The measurement range to set on the instrument.
port: Informs the driver what physical port on the DMM is intended to be used for the measurement
"""
raise NotImplementedError

def current_dc(self, _range):
def current_dc(self, _range, port: Literal["HIGH", "LOW"]):
"""
Sets the DMM in DC current measurement mode and puts it in the range given
by the argument _range. Signals expected to be measured must be < _range.
Sets the DMM in DC current measurement mode.

Args:
_range: The measurement range to set on the instrument.
port: Informs the driver what physical port on the DMM is intended to be used for the measurement
"""
raise NotImplementedError

Expand Down Expand Up @@ -129,3 +140,23 @@ def __exit__(self, exc_type, exc_val, exc_tb):

def nplc(self, nplc=None):
return self._nplc_context_manager(self, nplc)

def _check_current_port_range(self, range, port):
"""
Checks that the requested port and range are going to be compatible for the instrument.
Raises:
ValueError
Returns:
None
"""
# Check the requested range is not more than the port capability:
if range > self._current_ports[port]:
raise ValueError(
"The selected port and range combination is not available for this instrument. Consider using a different multimeter"
)

# Raise an error if the high port is selected when the low port should be used:
if range < self._current_ports["LOW"] and port == "HIGH":
raise ValueError(
"High range port selected when the low range port should be used! Consider using a different multimeter."
)
32 changes: 30 additions & 2 deletions src/fixate/drivers/dmm/keithley_6500.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def __init__(self, instrument, *args, **kwargs):
self._nplc_default = 1
self._init_string = "" # Unchanging

# High and low current port definition. Each definition encodes the maximum current able to
# be measured by the port (in amps)
self._current_ports = {"HIGH": 10, "LOW": 3}

# Adapted for different DMM behaviour
@property
def display(self):
Expand Down Expand Up @@ -303,10 +307,34 @@ def voltage_dc(self, _range=None, auto_impedance=False):
command = "; :SENS:VOLT:DC:INP MOHM10"
self._set_measurement_mode("voltage_dc", _range, suffix=command)

def current_ac(self, _range=None):
def current_ac(self, _range, port):
"""
Set the measurement mode on the DMM to AC current.

If the range and port selection are not compatible, i.e. someone has requested to measure
1A on the low range port with a maximum capability of 400 mA, an exception is raised.

If the range requested can be measured by the low port, but the high port is selected, an
exception is raised.
"""
# Check the port and range combination is compatible for the instrument:
self._check_current_port_range(_range, port)

self._set_measurement_mode("current_ac", _range)

def current_dc(self, _range=None):
def current_dc(self, _range, port):
"""
Set the measurement mode on the DMM to DC current.

If the range and port selection are not compatible, i.e. someone has requested to measure
1A on the low range port with a maximum capability of 400 mA, an exception is raised.

If the range requested can be measured by the low port, but the high port is selected, an
exception is raised.
"""
# Check the port and range combination is compatible for the instrument:
self._check_current_port_range(_range, port)

self._set_measurement_mode("current_dc", _range)

def resistance(self, _range=None):
Expand Down
Loading