diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2023-06-19 23:23:29 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2023-06-19 23:23:29 -0400 |
commit | 567ccf02bf6a8072760827479dc02cbd61f45684 (patch) | |
tree | 34a865ba76f42f02befb75dc36ec5a1c5e201e9f /qolab/hardware | |
parent | b694f0cc161889ddc7e1cc36cace3a94803ae34b (diff) | |
download | qolab-567ccf02bf6a8072760827479dc02cbd61f45684.tar.gz qolab-567ccf02bf6a8072760827479dc02cbd61f45684.zip |
hp_34401 seems to work
Diffstat (limited to 'qolab/hardware')
-rw-r--r-- | qolab/hardware/multimeter/hp_34401.py | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/qolab/hardware/multimeter/hp_34401.py b/qolab/hardware/multimeter/hp_34401.py index 468e966..326c162 100644 --- a/qolab/hardware/multimeter/hp_34401.py +++ b/qolab/hardware/multimeter/hp_34401.py @@ -2,6 +2,7 @@ from qolab.hardware.basic import BasicInstrument from qolab.hardware.multimeter import MultimeterSCPI from qolab.hardware.scpi import SCPI_PROPERTY from pyvisa import constants as pyvisa_constants +import time class HP_34401(MultimeterSCPI): """ HP 34401 multimeter (same as Agilent) """ @@ -17,6 +18,8 @@ class HP_34401(MultimeterSCPI): self.resource.data_bits = 8 self.resource.parity = pyvisa_constants.Parity.none self.resource.stop_bits = pyvisa_constants.StopBits.one + self.resource.timeout = 5000 + self.switchTime = 0.5 # switch time in seconds for Function/Measurement change self.deviceProperties.update({'Function'}) Function = SCPI_PROPERTY(scpi_prfx='SENSe:FUNCtion', ptype=str, doc=""" @@ -39,13 +42,51 @@ class HP_34401(MultimeterSCPI): """ ) - def toRemote(): + def toRemote(self): self.write("SYSTem:REMote") - def toLocal(): + def toLocal(self): self.write("SYSTem:LOCal") - Reading = SCPI_PROPERTY(scpi_prfx='SYSTem:REMote\n read', ptype=float, doc='Report current measurement', no_setter=True) + def isSensing(self, test): + return test == self.Function + + Reading = SCPI_PROPERTY(scpi_prfx='SYSTem:REMote; :READ', ptype=float, doc='Report current measurement', no_setter=True) + + # HP 34401 is tricky + # when reading over serial interface the value of measurement/function, + # the device need to be switched to REMOTE mode, but this leaves screen blank and unusable + # so we have to do the dance with toRemote and toLocal + def getReadingWithSettingFunction(self, desired_function_string, function_internal_name): + """ + Get the reading but first check if we are set to do specific function/measurement. + If the instrument set to do different function, set to desired one + Note: the function name should be in quotes, i.e. '"Volt"' + """ + if not self.isSensing(function_internal_name): + # print(f"function {self.Function} switching function to {desired_function_string}") + self.Function=desired_function_string + time.sleep(self.switchTime) + # self.toRemote() # this is done inside of Reading + ret = self.Reading + self.toLocal() + return ret + + def getVdc(self): + return self.getReadingWithSettingFunction('"VOLTage:DC"', '"VOLT"') + def getVac(self): + return self.getReadingWithSettingFunction('"VOLTage:AC"', '"VOLT:AC"') + def getAdc(self): + return self.getReadingWithSettingFunction('"CURRent:DC"', '"CURR"') + def getAac(self): + return self.getReadingWithSettingFunction('"CURRent:AC"', '"CURR:AC"') + + + # Vdc = SCPI_PROPERTY(scpi_prfx='SENSe:FUNCtion "VOLTage:DC"; :SYSTem:REMote\n read', ptype=float, doc='Report DC Voltage', no_setter=True) + # Vac = SCPI_PROPERTY(scpi_prfx='SENSe:FUNCtion "VOLTage:AC"; :SYSTem:REMote\n read', ptype=float, doc='Report AC Voltage', no_setter=True) + # Adc = SCPI_PROPERTY(scpi_prfx='SENSe:FUNCtion "CURRent:DC"; :SYSTem:REMote\n read', ptype=float, doc='Report DC Current', no_setter=True) + # Aac = SCPI_PROPERTY(scpi_prfx='SENSe:FUNCtion "CURRent:AC"; :SYSTem:REMote\n read', ptype=float, doc='Report AC Current', no_setter=True) + if __name__ == '__main__': import pyvisa |