-
Notifications
You must be signed in to change notification settings - Fork 20
Update dmm current modes #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
f89c849
2f2ae63
027a569
9a7efc7
9532f5c
ab363f1
087356c
a6cf2f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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): | ||
|
|
@@ -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 | ||
|
|
@@ -268,10 +273,54 @@ 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 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." | ||
|
||
| ) | ||
|
|
||
| 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 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." | ||
| ) | ||
|
|
||
| self._set_measurement_mode("current_dc", _range) | ||
|
|
||
| def resistance(self, _range=None): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| from dataclasses import dataclass | ||
| from typing import Literal | ||
|
|
||
|
|
||
| class DMM: | ||
|
|
@@ -60,10 +61,14 @@ 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"]): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 and puts it in the range given | ||
| by the argument _range. Signals expected to be measured must be < _range. | ||
| """ | ||
| 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. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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} | ||
Jasper-Harvey0 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Adapted for different DMM behaviour | ||
| @property | ||
| def display(self): | ||
|
|
@@ -303,10 +307,53 @@ 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 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." | ||
| ) | ||
|
|
||
| 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 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." | ||
| ) | ||
|
|
||
| # 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!" | ||
| ) | ||
|
|
||
| self._set_measurement_mode("current_dc", _range) | ||
|
|
||
| def resistance(self, _range=None): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these two sentences should be swapped.
Is this trying to say an incompatible port and range combination?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to make sense.