hp3478a-async


Namehp3478a-async JSON
Version 1.4.5 PyPI version JSON
download
home_pageNone
SummaryPython3 AsyncIO HP3478A driver
upload_time2024-06-22 14:38:07
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseGNU General Public License v3 (GPLv3)
keywords hp3478a gpib api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![pylint](https://github.com/PatrickBaus/pyAsyncHP3478A/actions/workflows/pylint.yml/badge.svg)](https://github.com/PatrickBaus/pyAsyncHP3478A/actions/workflows/pylint.yml)
[![PyPI](https://img.shields.io/pypi/v/hp3478a_async)](https://pypi.org/project/hp3478a_async/)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hp3478a_async)
![PyPI - Status](https://img.shields.io/pypi/status/hp3478a_async)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](LICENSE)
[![code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
# hp3478a_async
Python3 AsyncIO HP3478A driver. This library requires Python
[asyncio](https://docs.python.org/3/library/asyncio.html) and 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 Hardware
|Device|Supported|Tested|Comments|
|--|--|--|--|
|[AsyncIO Prologix GPIB library](https://github.com/PatrickBaus/pyAsyncPrologixGpib)|:heavy_check_mark:|:heavy_check_mark:|  |
|[AsyncIO linux-gpib wrapper](https://github.com/PatrickBaus/pyAsyncGpib)|:heavy_check_mark:|:heavy_check_mark:|  |

Tested using Linux, should work for Mac OSX, Windows and any OS with Python support.

## Documentation
The full documentation can be found on GitHub Pages:
[https://patrickbaus.github.io/pyAsyncHP3478A/](https://patrickbaus.github.io/pyAsyncHP3478A/). I use the
[Numpydoc](https://numpydoc.readthedocs.io/en/latest/format.html) style for documentation and
[Sphinx](https://www.sphinx-doc.org/en/master/index.html) for compiling it.

# Setup
To install the library in a virtual environment (always use venvs with every project):
```bash
python3 -m venv env  # virtual environment, optional
source env/bin/activate  # only if the virtual environment is used
pip install hp3478a-async
```

All examples assume that a GPIB library is installed as well. Either run
```bash
pip install prologix-gpib-async    # or alternatively
# pip install async-gpib
```

## Usage
The library uses an asynchronous context manager to make cleanup easier. You can use either the
context manager syntax or invoke the calls manually:

```python
async with HP_3478A(connection=gpib_device) as hp3478a:
    # Add your code here
    ...
```

```python
try:
    hp3478a = HP_3478A(connection=gpib_device)
    await hp3478a.connect()
    # your code
finally:
    await hp3478a.disconnect()
```

A more complete example for reading voltages:
```python
import asyncio
import logging

from hp3478a_async import HP_3478A, FunctionType, TriggerType, Range

from pyAsyncPrologixGpib import AsyncPrologixGpibEthernetController, 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)


async def main():
    """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.
        async with HP_3478A(connection=gpib_device) as hp3478a:
            await asyncio.gather(
                hp3478a.set_function(FunctionType.DCV),  # Set to 4-wire ohm
                hp3478a.set_range(Range.RANGE_30),  # Set to 30 kOhm range
                hp3478a.set_trigger(TriggerType.INTERNAL),  # Enable free running trigger
                hp3478a.set_autozero(True),  # Enable Autozero
                hp3478a.set_number_of_digits(6),  # Set the resolution to 5.5 digits
                hp3478a.connection.timeout(700),  # The maximum reading rate @ 50 Hz line freq. is 1.9 rds/s
            )

            # Take the measurements until Ctrl+C is pressed
            async for result in hp3478a.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)
except KeyboardInterrupt:
    # The loop will be canceled on a KeyboardInterrupt by the run() method, we just want to suppress the exception
    pass
```

See [examples/](https://github.com/PatrickBaus/pyAsyncHP3478A/tree/master/examples/) for more working examples.

# Unit Tests
There are unit tests available for the calram encoder and decoder.
```bash
source env/bin/activate  # only if the virtual environment is used
pytest
```

## Thanks
Special thanks goes to [fenugrec](https://github.com/fenugrec/hp3478a_utils) and
[Steve Matos](https://github.com/steve1515/hp3478a-calibration) for their work on deciphering the calram function.

## Versioning
I use [SemVer](http://semver.org/) for versioning. For the versions available, see the
[tags on this repository](https://github.com/PatrickBaus/pyAsyncHP3478A/tags).

## Authors
* **Patrick Baus** - *Initial work* - [PatrickBaus](https://github.com/PatrickBaus)

## License
This project is licensed under the GPL v3 license - see the
[LICENSE](https://github.com/PatrickBaus/pyAsyncHP3478A/tree/master/LICENSE) file for details

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "hp3478a-async",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "HP3478A, GPIB, API",
    "author": null,
    "author_email": "Patrick Baus <patrick.baus@physik.tu-darmstadt.de>",
    "download_url": "https://files.pythonhosted.org/packages/df/9f/f353ec83e014206de528f703c2cdb3a74c4907bfa596570724999cbc6462/hp3478a_async-1.4.5.tar.gz",
    "platform": null,
    "description": "[![pylint](https://github.com/PatrickBaus/pyAsyncHP3478A/actions/workflows/pylint.yml/badge.svg)](https://github.com/PatrickBaus/pyAsyncHP3478A/actions/workflows/pylint.yml)\n[![PyPI](https://img.shields.io/pypi/v/hp3478a_async)](https://pypi.org/project/hp3478a_async/)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hp3478a_async)\n![PyPI - Status](https://img.shields.io/pypi/status/hp3478a_async)\n[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](LICENSE)\n[![code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n# hp3478a_async\nPython3 AsyncIO HP3478A driver. This library requires Python\n[asyncio](https://docs.python.org/3/library/asyncio.html) and AsyncIO library for the GPIB adapter. It also supports\nseveral undocumented functions for reading status registers and reading, modifying and writing the calibration memory.\n\nThe library is fully type-hinted.\n\n## Supported GPIB Hardware\n|Device|Supported|Tested|Comments|\n|--|--|--|--|\n|[AsyncIO Prologix GPIB library](https://github.com/PatrickBaus/pyAsyncPrologixGpib)|:heavy_check_mark:|:heavy_check_mark:|  |\n|[AsyncIO linux-gpib wrapper](https://github.com/PatrickBaus/pyAsyncGpib)|:heavy_check_mark:|:heavy_check_mark:|  |\n\nTested using Linux, should work for Mac OSX, Windows and any OS with Python support.\n\n## Documentation\nThe full documentation can be found on GitHub Pages:\n[https://patrickbaus.github.io/pyAsyncHP3478A/](https://patrickbaus.github.io/pyAsyncHP3478A/). I use the\n[Numpydoc](https://numpydoc.readthedocs.io/en/latest/format.html) style for documentation and\n[Sphinx](https://www.sphinx-doc.org/en/master/index.html) for compiling it.\n\n# Setup\nTo install the library in a virtual environment (always use venvs with every project):\n```bash\npython3 -m venv env  # virtual environment, optional\nsource env/bin/activate  # only if the virtual environment is used\npip install hp3478a-async\n```\n\nAll examples assume that a GPIB library is installed as well. Either run\n```bash\npip install prologix-gpib-async    # or alternatively\n# pip install async-gpib\n```\n\n## Usage\nThe library uses an asynchronous context manager to make cleanup easier. You can use either the\ncontext manager syntax or invoke the calls manually:\n\n```python\nasync with HP_3478A(connection=gpib_device) as hp3478a:\n    # Add your code here\n    ...\n```\n\n```python\ntry:\n    hp3478a = HP_3478A(connection=gpib_device)\n    await hp3478a.connect()\n    # your code\nfinally:\n    await hp3478a.disconnect()\n```\n\nA more complete example for reading voltages:\n```python\nimport asyncio\nimport logging\n\nfrom hp3478a_async import HP_3478A, FunctionType, TriggerType, Range\n\nfrom pyAsyncPrologixGpib import AsyncPrologixGpibEthernetController, EosMode\n\n# The default GPIB address is 27. The ip address of the prologix controller needs to be changed.\nip_address = \"127.0.0.1\"\ngpib_device = AsyncPrologixGpibEthernetController(ip_address, pad=27, timeout=1000, eos_mode=EosMode.APPEND_NONE)\n\n\nasync def main():\n    \"\"\"This example will print voltage data to the console\"\"\"\n    try:\n        # No need to explicitly bring up the GPIB connection. This will be done by the instrument.\n        async with HP_3478A(connection=gpib_device) as hp3478a:\n            await asyncio.gather(\n                hp3478a.set_function(FunctionType.DCV),  # Set to 4-wire ohm\n                hp3478a.set_range(Range.RANGE_30),  # Set to 30 kOhm range\n                hp3478a.set_trigger(TriggerType.INTERNAL),  # Enable free running trigger\n                hp3478a.set_autozero(True),  # Enable Autozero\n                hp3478a.set_number_of_digits(6),  # Set the resolution to 5.5 digits\n                hp3478a.connection.timeout(700),  # The maximum reading rate @ 50 Hz line freq. is 1.9 rds/s\n            )\n\n            # Take the measurements until Ctrl+C is pressed\n            async for result in hp3478a.read_all():\n                print(result)\n    except (ConnectionError, ConnectionRefusedError):\n        logging.getLogger(__name__).error(\n            \"Could not connect to remote target. Connection refused. Is the device connected?\"\n        )\n\n\ntry:\n    asyncio.run(main(), debug=False)\nexcept KeyboardInterrupt:\n    # The loop will be canceled on a KeyboardInterrupt by the run() method, we just want to suppress the exception\n    pass\n```\n\nSee [examples/](https://github.com/PatrickBaus/pyAsyncHP3478A/tree/master/examples/) for more working examples.\n\n# Unit Tests\nThere are unit tests available for the calram encoder and decoder.\n```bash\nsource env/bin/activate  # only if the virtual environment is used\npytest\n```\n\n## Thanks\nSpecial thanks goes to [fenugrec](https://github.com/fenugrec/hp3478a_utils) and\n[Steve Matos](https://github.com/steve1515/hp3478a-calibration) for their work on deciphering the calram function.\n\n## Versioning\nI use [SemVer](http://semver.org/) for versioning. For the versions available, see the\n[tags on this repository](https://github.com/PatrickBaus/pyAsyncHP3478A/tags).\n\n## Authors\n* **Patrick Baus** - *Initial work* - [PatrickBaus](https://github.com/PatrickBaus)\n\n## License\nThis project is licensed under the GPL v3 license - see the\n[LICENSE](https://github.com/PatrickBaus/pyAsyncHP3478A/tree/master/LICENSE) file for details\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3 (GPLv3)",
    "summary": "Python3 AsyncIO HP3478A driver",
    "version": "1.4.5",
    "project_urls": {
        "Bug Tracker": "https://github.com/PatrickBaus/pyAsyncHP3478A/issues",
        "Documentation": "https://patrickbaus.github.io/pyAsyncHP3478A/",
        "Download": "https://github.com/PatrickBaus/pyAsyncHP3478A/releases",
        "Homepage": "https://github.com/PatrickBaus/pyAsyncHP3478A"
    },
    "split_keywords": [
        "hp3478a",
        " gpib",
        " api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ac6aec3236355ab870ff6ba0033c0075407f3193f56e57360cd9f0ae7e7fd00e",
                "md5": "e1add26e6d27f7ae35245a946a2abca2",
                "sha256": "3b22390d8cfb79c3d6a9c4ee1a428049691e14ec876b74ffd6d7310472c81b16"
            },
            "downloads": -1,
            "filename": "hp3478a_async-1.4.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e1add26e6d27f7ae35245a946a2abca2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 28559,
            "upload_time": "2024-06-22T14:38:06",
            "upload_time_iso_8601": "2024-06-22T14:38:06.097396Z",
            "url": "https://files.pythonhosted.org/packages/ac/6a/ec3236355ab870ff6ba0033c0075407f3193f56e57360cd9f0ae7e7fd00e/hp3478a_async-1.4.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "df9ff353ec83e014206de528f703c2cdb3a74c4907bfa596570724999cbc6462",
                "md5": "91134cef5364ef8e722763af969b96df",
                "sha256": "f2dfa4c79cbc6247279476e54a717a2b6c4146a32a1b7ba9db2665d3e32113a2"
            },
            "downloads": -1,
            "filename": "hp3478a_async-1.4.5.tar.gz",
            "has_sig": false,
            "md5_digest": "91134cef5364ef8e722763af969b96df",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 30524,
            "upload_time": "2024-06-22T14:38:07",
            "upload_time_iso_8601": "2024-06-22T14:38:07.887368Z",
            "url": "https://files.pythonhosted.org/packages/df/9f/f353ec83e014206de528f703c2cdb3a74c4907bfa596570724999cbc6462/hp3478a_async-1.4.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-22 14:38:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PatrickBaus",
    "github_project": "pyAsyncHP3478A",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "hp3478a-async"
}
        
Elapsed time: 0.29573s