Module Documentation¶
hp3478a_async¶
This is an asyncIO library for the Hewlett Packard 3478A DMM. It includes all functions of DMM including some hidden function to read the non-volatile RAM and calibration constants of the device.
- class hp3478a_async.HP_3478A(connection: AsyncGpib | AsyncPrologixGpibController)[source]¶
The driver for the HP 3478A 5.5 digit multimeter. It supports both linux-gpib and the Prologix GPIB adapters.
- __init__(connection: AsyncGpib | AsyncPrologixGpibController) None [source]¶
Create an HP 3478A with the GPIB connection given.
- Parameters:
connection (AsyncGpib or AsyncPrologixGpibController) – The GPIB connection
- async connect() None [source]¶
Connect the GPIB connection and configure the GPIB device for the DMM. This function must be called from the loop and takes care of connecting the GPIB adapter.
- property connection: AsyncGpib | AsyncPrologixGpibController¶
The GPIB connection.
- async device_clear() None [source]¶
Send the Selected Device Clear (SDC) event. This will trigger the self-test routine and reset the device to its power on state.
- async disconnect() None [source]¶
Disconnect the GPIB device and release any lock on the front panel of the device if held.
- async get_cal_ram() bytes [source]¶
An undocumented function. Read the internal calibration memory from the NVRAM. It can be used to backup the calibration memory in case the internal battery fails. See Examples for an example on how to read the memory and convert it to meaningful data.
- Returns:
The contents of the calibration ram.
- Return type:
bytes
- async get_error_register() ErrorFlags [source]¶
Get the contents of the error register, which is the result of the power on self-test. See page 62 of the manual for details.
- Returns:
The error register
- Return type:
- async get_front_rear_switch_position() FrontRearSwitchPosition [source]¶
Check whether the front or rear panel binding posts are active.
- Returns:
The position of the front/rear switch
- Return type:
- async static get_id() tuple[str, str, str, str] [source]¶
The HP 3478A does not support an ID request, so this function returns the constant “HEWLETT-PACKARD”, “3478A”, “0”, “0” to emulate the *IDN? SCPI command. The method is not async, but for compatibility reasons with other drivers, it is declared async.
- Returns:
A SCPI compliant id string
- Return type:
tuple of str
- async get_status() DmmStatus [source]¶
Read the binary status register of the device. See page 61 of the manual for details.
- Returns:
The current status of the DMM
- Return type:
- async read(length: int | None = None) Decimal | bytes [source]¶
Read a single value from the device. If length’ is given, read `length bytes, else read until a line break
b"\n"
.- Parameters:
length (int, optional) – The number of bytes to read. Omit to read a line.
- Returns:
Either a Decimal value or a number of bytes as defined by length.
- Return type:
Decimal or bytes
- Raises:
OverflowError – If the instrument input is overloaded, i.e. returns +9.99999E+9.
- async read_all(length: int | None = None) AsyncGenerator[Decimal | bytes, None] [source]¶
Read all values from the device. If length’ is given, read `length bytes, else read until a line break
b"\n"
, then yield the result.- Parameters:
length (int, optional) – The number of bytes to read. Omit to read a line.
- Returns:
Either a Decimal value or a number of bytes as defined by length.
- Return type:
Iterator[Decimal or bytes]
- Raises:
OverflowError – If the instrument input is overloaded, i.e. returns +9.99999E+9.
DeviceError – If the device is not ready for read.
asyncio.TimeoutError – If the GPIB controller does not respond in time.
- async reset() None [source]¶
Place the device in DCV, autorange, autozero, single trigger, 4.5 digits mode and erase any output stored in the buffers.
- async serial_poll() SerialPollFlags [source]¶
Serial poll the device/GPIB controller. Use this in combination with the SRQ mask to determine, if the instrument triggered the SRQ and requests service.
- Returns:
The status register of the device
- Return type:
- async set_autozero(enable: bool) None [source]¶
Change the auto-zero mode of the DMM. If enabled, the DMM will auto-zero between readings.
- Parameters:
enable (bool) – True to enable auto-zeroing.
- async set_cal_ram(data: bytes) None [source]¶
Write to the internal NVRAM. Warning: This can brick the device until a valid calibration configuration is written to the NVRAM. This function only works, if the front panel CAL switch is enabled.
- Parameters:
data (bytes) – The data to be written to the calibration memory.
- async set_display(value: DisplayType, text: str = '') None [source]¶
Sets a custom display text or display measurands. See page 12 of the manual for details.
- Parameters:
value (DisplayType) – The type of text to display on the front panel tft. If set to
DisplayType.NORMAL
, no text will be set.text (str) – The text to display if value is not set to
DisplayType.NORMAL
. There is no need to terminate the string with"\r"
or"\n"
.
- async set_function(value: FunctionType) None [source]¶
Put the device in a certain measurement mode of either DVC, ACV, Ohms, 4-W Ohms, DCI, ACI or the extended ohms mode. See page 55 of the manual for details on the extended ohms mode.
- Parameters:
value (FunctionType) – The function type to be measured.
- set_ntc_parameters(a: float, b: float, c: float, d: float, rt25: float)[source]¶
Set the parameters used when in mode
FunctionType.NTC
orFunctionType.NTCF
. The parameters can be found in the datasheet of the thermistor. The formula for converting resistance values to temperature is:1/T=a+b*Log(Rt/R25)+c*Log(Rt/R25)**2+d*Log(Rt/R25)**3
See Wikipedia: Steinhart–Hart equation for more details.
- Parameters:
a (float) – The parameters of the NTC thermistor used
b (float) – The parameters of the NTC thermistor used
c (float) – The parameters of the NTC thermistor used
d (float) – The parameters of the NTC thermistor used
rt25 (float) – The resistance of the NTC at 25 °C
- async set_number_of_digits(value: int) None [source]¶
Set the number of digits returned by the DMM. This has an influence on the integration time. See page 15 of the manual for details.
- Parameters:
value ({4, 5, 6}) – A value between 4 and 6.
- async set_range(value: Range) None [source]¶
Sets the measurement range. The range, that can be selected depend on the measurement mode.
- Parameters:
value (Range) – The measurement range.
- async set_srq_mask(value: SrqMask) None [source]¶
Set the service interrupt mask. This will determine, when the GPIB SRQ is triggered by the instrument. The
SrqMask.DATA_READY
flag is useful, when reading with long conversion times. See Examples for an example and page 46 of the manual for details.- Parameters:
value (SrqMask) – The service request register setting.
- async set_trigger(value: TriggerType) None [source]¶
Set the DMM trigger. See page 53 of the manual for details.
- Parameters:
value (TriggerType) – The trigger type used when taking measurements.
Dataclasses¶
- class hp3478a_async.hp_3478a_helper.CalramEntry(data_block: list[int] | tuple[int, ...])[source]¶
One out of 19 calibration memory entries, that contain the gain, offset and checksum.
- checksum: int¶
- gain: float¶
- is_valid: bool¶
- offset: int¶
- class hp3478a_async.DmmStatus(function: FunctionType, range: Range, ndigits: int, status: StatusFlags, srq_flags: SerialPollFlags, error_flags: ErrorFlags, dac_value: int)[source]¶
The device status of them DMM
- dac_value: int¶
- error_flags: ErrorFlags¶
- function: FunctionType¶
- ndigits: int¶
- srq_flags: SerialPollFlags¶
- status: StatusFlags¶
- class hp3478a_async.NtcParameters(a: float, b: float, c: float, d: float, rt25: float)[source]¶
The Steinhart-Hart coefficient of an NTC thermistor. The formula to calculate the temperature from the resistance is as follows:
1/T=a+b*Log(Rt/R25)+c*Log(Rt/R25)**2+d*Log(Rt/R25)**3
See Wikipedia: Steinhart–Hart equation for more details.
- a: float¶
- b: float¶
- c: float¶
- d: float¶
- rt25: float¶
Enums and Flags¶
Flags are used for the status registers returned by the device.
- class hp3478a_async.flags.ErrorFlags(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
The error register flags. See page 62 of the manual for details.
- AD_LINK_FAILURE = 32¶
- AD_SELFTEST_FAILURE = 16¶
- AD_SLOPE_CONVERGENCE = 8¶
- CAL_RAM_CHECKSUM = 1¶
- NONE = 0¶
- RAM_FAILURE = 2¶
- ROM_FAILURE = 4¶
- class hp3478a_async.flags.SerialPollFlags(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
The serial poll flags as returned by SPOLL. See page 50 of the manual for details.
- NONE = 0¶
- SRQ_ON_CAL_FAILURE = 32¶
- SRQ_ON_DATA_READY = 1¶
- SRQ_ON_HARDWARE_ERROR = 8¶
- SRQ_ON_HAS_SRQ = 64¶
- SRQ_ON_POWER_ON = 128¶
- SRQ_ON_SRQ_BUTTON = 16¶
- SRQ_ON_SYNTAX_ERROR = 4¶
- class hp3478a_async.flags.SrqMask(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
The service interrupt register flags. See page 47 of the manual for details.
- CALIBRATION_FAILURE = 32¶
- DATA_READY = 1¶
- FRONT_PANEL_SRQ = 16¶
- HARDWARE_ERROR = 8¶
- NONE = 0¶
- SYNTAX_ERROR = 4¶
- class hp3478a_async.flags.StatusFlags(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
The device status register flags. See page 61 of the manual for details.
- AUTO_RANGE_ENABLED = 2¶
- AUTO_ZERO_ENABLED = 4¶
- CAL_RAM_ENABLED = 32¶
- EXTERNAL_TRIGGER_ENABLED = 64¶
- FRONT_SWITCH_ENABLED = 16¶
- INTERNAL_TRIGGER_ENABLED = 1¶
- LINE_FREQUENCY_50_HZ = 8¶
- NONE = 0¶
Enums are used to represent the device functions and settings.
- class hp3478a_async.enums.DisplayType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
The front panel display settings. See page 12 of the manual for details.
- NORMAL = 1¶
- SHOW_TEXT = 2¶
- SHOW_TEXT_AND_FREEZE = 3¶
- class hp3478a_async.enums.FrontRearSwitchPosition(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
The position of the front/rear binding posts switch on the front panel.
- FRONT = 1¶
- REAR = 0¶
- class hp3478a_async.enums.FunctionType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
The measurement functions. See page 55 of the extended ohms setting.
- ACI = 6¶
- ACV = 2¶
- DCI = 5¶
- DCV = 1¶
- NTC = 8¶
- NTCF = 9¶
- OHM = 3¶
- OHMF = 4¶
- OHM_EXT = 7¶
- class hp3478a_async.enums.Range(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
The measurement range of the device. See page 20 of the manual for details.
- RANGE_3 = 0¶
- RANGE_30 = 1¶
- RANGE_300 = 2¶
- RANGE_300M = -1¶
- RANGE_300k = 5¶
- RANGE_30M = -2¶
- RANGE_30MEG = 7¶
- RANGE_30k = 4¶
- RANGE_3MEG = 6¶
- RANGE_3k = 3¶
- RANGE_AUTO = 'A'¶
Errors¶
Custom errors raised by the HP 3478A.
Helper functions¶
Helper functions to encode and decode data formats used by the HP 3478A.
- hp3478a_async.hp_3478a_helper.decode_cal_data(encoded_data: str | bytes) tuple[bool, tuple[CalramEntry, ...]] [source]¶
The calibration data is stored as nibbles (4 bit, half-bytes). This function decodes the contents of the calibration ram and returns the status of the calibration switch.
- Returns:
True if the calibration switch is enabled and the calibration constants as a tuple of CalramEntry.
- Return type:
tuple[bool, tuple[CalramEntry]]
- hp3478a_async.hp_3478a_helper.encode_cal_data(cal_enable: bool, data_blocks: tuple[CalramEntry, ...] | list[CalramEntry]) bytes [source]¶
The calibration data is stored as nibbles (4 bit, half-bytes). This function encodes a dictionary with the calibration constants to bytes.
- Parameters:
data_blocks (list[CalramEntry] or tuple[CalramEntry]) – The calibration data
cal_enable – Set to True, to write the calibration data to the NVRAM.
- hp3478a_async.hp_3478a_helper.format_cal_string(data: bytes) str [source]¶
Convert the calibration memory to a unicode string containing only printable, non-whitespace ASCII characters.
- Parameters:
data (bytes) – The calram contents
- Returns:
A human readable string of ASCII characters.
- Return type:
str