Package: hp3478a-async
hp3478a_asyncPython3 AsyncIO HP3478A driver. This library requires Pythonasyncioand AsyncIO library for the GPIB adapter. It also supports
several undocumented functions for reading status registers and reading, modifying and writing the calibration memory.The library is fully type-hinted.Supported GPIB HardwareDeviceSupportedTestedCommentsAsyncIO Prologix GPIB library:heavy_check_mark::heavy_check_mark:AsyncIO linux-gpib wrapper:heavy_check_mark::heavy_check_mark:Tested using Linux, should work for Mac OSX, Windows and any OS with Python support.DocumentationThe full documentation can be found on GitHub Pages:https://patrickbaus.github.io/pyAsyncHP3478A/. I use theNumpydocstyle for documentation andSphinxfor compiling it.SetupTo install the library in a virtual environment (always use venvs with every project):python3-mvenvenv# virtual environment, optionalsourceenv/bin/activate# only if the virtual environment is usedpipinstallhp3478a-asyncUsageAll examples assume, that a GPIB library is installed as well. Either runpipinstallprologix-gpib-async# or alternatively# pip install async-gpibor download the source code from the git repository and copy it to the root folder yourself.The library uses an asynchronous context manager to make cleanup easier. You can use either the
context manager syntax or invoke the calls manually:asyncwithHP_3478A(connection=gpib_device)ashp3478a:# Add your code here...try:hp3478a=HP_3478A(connection=gpib_device)awaithp3478a.connect()# your codefinally:awaithp3478a.disconnect()A more complete example for reading voltages:importasyncioimportloggingfromhp3478a_asyncimportHP_3478A,FunctionType,TriggerType,RangefrompyAsyncPrologixGpibimportAsyncPrologixGpibEthernetController,EosMode# The default GPIB address is 27. The ip address of the prologix controller needs to be changed.ip_address="127.0.0.1"gpib_device=AsyncPrologixGpibEthernetController(ip_address,pad=27,timeout=1000,eos_mode=EosMode.APPEND_NONE)asyncdefmain():"""This example will print voltage data to the console"""try:# No need to explicitly bring up the GPIB connection. This will be done by the instrument.asyncwithHP_3478A(connection=gpib_device)ashp3478a:awaitasyncio.gather(hp3478a.set_function(FunctionType.DCV),# Set to 4-wire ohmhp3478a.set_range(Range.RANGE_30),# Set to 30 kOhm rangehp3478a.set_trigger(TriggerType.INTERNAL),# Enable free running triggerhp3478a.set_autozero(True),# Enable Autozerohp3478a.set_number_of_digits(6),# Set the resolution to 5.5 digitshp3478a.connection.timeout(700),# The maximum reading rate @ 50 Hz line freq. is 1.9 rds/s)# Take the measurements until Ctrl+C is pressedasyncforresultinhp3478a.read_all():print(result)except(ConnectionError,ConnectionRefusedError):logging.getLogger(__name__).error("Could not connect to remote target. Connection refused. Is the device connected?")try:asyncio.run(main(),debug=False)exceptKeyboardInterrupt:# The loop will be canceled on a KeyboardInterrupt by the run() method, we just want to suppress the exceptionpassSeeexamples/for more working examples.Unit TestsThere are unit tests available for the calram encoder and decoder.sourceenv/bin/activate# only if the virtual environment is usedpytestThanksSpecial thanks goes tofenugrecandSteve Matosfor their work on deciphering the calram function.VersioningI useSemVerfor versioning. For the versions available, see thetags on this repository.AuthorsPatrick Baus-Initial work-PatrickBausLicenseThis project is licensed under the GPL v3 license - see theLICENSEfile for details