aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vorobiov <mvorobiov@wm.edu>2024-11-07 11:06:18 -0500
committerMichael Vorobiov <mvorobiov@wm.edu>2024-11-07 11:06:18 -0500
commit5f0a9493ea33bfbb482b60b2ab5a3dbe3d2c4676 (patch)
treed3b0c93df0e87fb48bcaf22ac8c0d3ed5a3075e3
parentdd971a450fc5d9f7d4f9391694fe70bf69983c57 (diff)
downloadqolab-5f0a9493ea33bfbb482b60b2ab5a3dbe3d2c4676.tar.gz
qolab-5f0a9493ea33bfbb482b60b2ab5a3dbe3d2c4676.zip
added method for changng number of power line cycles for A/D integration
-rw-r--r--qolab/hardware/multimeter/hp3457a.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/qolab/hardware/multimeter/hp3457a.py b/qolab/hardware/multimeter/hp3457a.py
index 226d1e2..51914bd 100644
--- a/qolab/hardware/multimeter/hp3457a.py
+++ b/qolab/hardware/multimeter/hp3457a.py
@@ -14,6 +14,7 @@ from qolab.hardware.basic import BasicInstrument
from ._basic import Multimeter
import pyvisa
+import numpy as np
class HP3457A(Multimeter):
"""
@@ -46,6 +47,9 @@ class HP3457A(Multimeter):
'PER'#(This is here for future work)
]
+ # Allowed number of power line cycles (defines A/D integration time)
+ NPLC = [0.0005, 0.005, .1, 1, 10, 100]
+
# DC Volts Spec (This is here for future work)
DCV_RES = {'30mv': {'6.5': 10e-9, '5.5': 100e-9, '4.5': 1e-6, '3.5': 10e-6},
'300mv': {'6.5': 100e-9, '5.5': 1e-6, '4.5': 10e-6, '3.5': 100e-6},
@@ -114,10 +118,10 @@ class HP3457A(Multimeter):
self.read = self.resource.read
self.write = self.resource.write
self.read_bytes = self.resource.read_bytes
- self.query = self.resource.query
self.switchTime = 0.5 # switch time in seconds for Function/Measurement change
self.deviceProperties.update({"Function"})
+ self.set_function('DCV')
def get_idn(self):
@@ -148,13 +152,15 @@ class HP3457A(Multimeter):
print(f'[ERROR!] Couldn\'t set reading format to {format}: {e}')
else:
print(f'[WARNING] Entered format is not allowed. Allowed formats: {self.FORMATS}')
-
+
+ @BasicInstrument.tsdb_append
def get_reading(self):
try:
self.write(f'TARM AUTO')
return float(self.read_bytes(16).decode().strip())
except pyvisa.VisaIOError as e:
print(f'[ERROR!] Error failed to get reading: {e}')
+ return np.nan()
def set_beeper_status(self, status='OFF'):
if status in self.BEEPER_STATUS:
@@ -183,6 +189,7 @@ class HP3457A(Multimeter):
print(f"[WARNING!] Invalid measurement function '{function}'. "
f"Valid functions are: {', '.join(self.FUNCTIONS)}")
+ @BasicInstrument.tsdb_append
def get_temperature(self):
try:
self.write("TEMP?")
@@ -192,6 +199,17 @@ class HP3457A(Multimeter):
except pyvisa.VisaIOError as e:
print(f"[ERROR!] Error retrieving DMM's internal temperature: {e}")
+ def get_memory_count(self):
+ """
+ Returns the total number of stored readings.
+ """
+ try:
+ self.write(f'MCOUNT?')
+ return float(self.read_bytes(16).decode().strip())
+ except pyvisa.VisaIOError as e:
+ print(f'[ERROR!] Error failed to get count of reading in memory: {e}')
+ return np.nan()
+
def enable_keyboard(self, status=True):
if status:
try:
@@ -206,7 +224,18 @@ class HP3457A(Multimeter):
except pyvisa.VisaIOError as e:
print(f"[ERROR!] Error locking the DMM's keyboard: {e}")
+ def set_nplc(self, nplc=10):
+ if nplc in self.NPLC:
+ try:
+ self.write(f"FUNC {nplc}")
+ print(f"[INFO] NPLC is set to {nplc}")
+ except pyvisa.VisaIOError as e:
+ print(f"[ERROR!] Error setting number of power line cycles (NPLC): {e}")
+ else:
+ print(f"[WARNING!] Invalid NPLC '{nplc}'. "
+ f"Valid NPLC values are: {', '.join(str(self.NPLC))}")
+
#-----------------------------------------------------------
# Methods to comply with other DMM QOLab module drivers
#-----------------------------------------------------------