# Purpose
To provide an easy-to-use, object-oriented instrument interface for the
[DATAQ DI-2008](https://www.dataq.com/products/di-2008/) from within any
Python environment.
The intent of this project is not to provide an API that will be useful in 100%
of use cases, but will target the 90%. In my experience, most of us need pretty
basic functionality and have only modest timing requirements when working with
such instrumentation. As a result of this, the API will attempt to abstract
away the lowest-level functionality which may result in a hiding or loss of
feature implementation available in the hardware. If this happens to you, feel
free to use the nuts and bolts exposed herein to inform your own development or,
better yet, send us a pull request!
Check out the [documentation](https://slightlynybbled.github.io/di2008/)!
## Installation
The hardware drivers must be installed before this package may be utilized. Hardware
drivers may be downloaded from the [manufacturer's product page](https://www.dataq.com/products/di-2008/).
Once drivers are installed:
$> pip install di2008
## Project Status and Future
The objects provided are tested and demonstrated to function well, however, there are still some features that have not been implemented.
Items marked out have already been completed. The list is in approximate order of priority and marked out items have been completed.
* ~~Implement Analog Scan List~~ complete
* ~~Read Thermocouples~~ complete
* ~~Read Analog Inputs~~ complete
* ~~Read Rate Input~~ complete
* Read Event Input
* Read Counter Input
* ~~Read Digital Input(s)~~ complete
* ~~Write to Digital Outputs~~ complete
* Better sample hardware timing control
* Hardware Synchronization
## Usage
Regarding the specifics of usage, it may be very helpful for the user to read the device documentation so that some of the concepts enshrined herein are more precisely interpreted. Specifically, the concept of a "scan list" is somewhat unique to the product and difficult to abstract. As the project matures, more of the hardware idiosyncrasies are expected to be exposed to the user.
## Deployment
When deploying using `pyinstaller` in a windows environment, the `pyusb` library doesn't
play well with `libusb-1.0.dll`, so you will need to package `libusb0.dll` into your
pyinsteller `*.spec` file using the following line:
datas=[('C:\\Windows\\System32\\libusb0.dll', '.'),],
### Hardware Setup
Place device into 'USB' mode, not COM mode!!!
1. Disconnect from USB
2. Wait 5 seconds
3. Connect to USB and press button on side rapidly until LED changes
The device setting is persistent and will not need to be changed again.
If you see a COM port in your device manager with the label `DATAQ DI-2008`
then the device is NOT in the correct mode!
### Software Setup
To read a few analog inputs, device setup is relatively simple.
1. Define the ports
2. Create the `Di2008` instance
3. Add the scan list
4. Start the scanning process
5. Read inputs at whatever timing is desired as the inputs will be updated "live"
Some sample code might be more illuminating. A simple script to set up the scan list and to print the values every second:
from time import sleep
from di2008 import AnalogPort, RatePort, Di2008
# create each of the inputs that need to be sampled
an0 = AnalogPort(1, analog_range=10.0, filter='average')
an1 = AnalogPort(2, thermocouple_type='j')
an2 = AnalogPort(3, thermocouple_type='j')
rate = RatePort(5000)
daq = Di2008()
daq.create_scan_list(
[an0, an1, an2, rate]
)
daq.start()
while True:
print(f'{an0.value:.02f}')
print(f'{an1.value:.02f}')
print(f'{an2.value:.02f}')
print(f'{rate.value:.02f}')
print()
sleep(1.0)
Raw data
{
"_id": null,
"home_page": "https://github.com/slightlynybbled/di2008",
"name": "di2008",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6.0",
"maintainer_email": "",
"keywords": "",
"author": "Jason R. Jones",
"author_email": "slightlynybbled@gmail.com",
"download_url": "",
"platform": null,
"description": "# Purpose\n\nTo provide an easy-to-use, object-oriented instrument interface for the \n[DATAQ DI-2008](https://www.dataq.com/products/di-2008/) from within any \nPython environment.\n\nThe intent of this project is not to provide an API that will be useful in 100% \nof use cases, but will target the 90%. In my experience, most of us need pretty \nbasic functionality and have only modest timing requirements when working with \nsuch instrumentation. As a result of this, the API will attempt to abstract \naway the lowest-level functionality which may result in a hiding or loss of \nfeature implementation available in the hardware. If this happens to you, feel \nfree to use the nuts and bolts exposed herein to inform your own development or, \nbetter yet, send us a pull request!\n\nCheck out the [documentation](https://slightlynybbled.github.io/di2008/)!\n\n## Installation\n\nThe hardware drivers must be installed before this package may be utilized. Hardware \ndrivers may be downloaded from the [manufacturer's product page](https://www.dataq.com/products/di-2008/).\n\nOnce drivers are installed:\n\n $> pip install di2008\n\n## Project Status and Future\n\nThe objects provided are tested and demonstrated to function well, however, there are still some features that have not been implemented.\n\nItems marked out have already been completed. The list is in approximate order of priority and marked out items have been completed.\n\n * ~~Implement Analog Scan List~~ complete\n * ~~Read Thermocouples~~ complete\n * ~~Read Analog Inputs~~ complete\n * ~~Read Rate Input~~ complete\n * Read Event Input\n * Read Counter Input\n * ~~Read Digital Input(s)~~ complete\n * ~~Write to Digital Outputs~~ complete\n * Better sample hardware timing control\n * Hardware Synchronization\n\n## Usage\n\nRegarding the specifics of usage, it may be very helpful for the user to read the device documentation so that some of the concepts enshrined herein are more precisely interpreted. Specifically, the concept of a \"scan list\" is somewhat unique to the product and difficult to abstract. As the project matures, more of the hardware idiosyncrasies are expected to be exposed to the user.\n\n## Deployment\n\nWhen deploying using `pyinstaller` in a windows environment, the `pyusb` library doesn't\nplay well with `libusb-1.0.dll`, so you will need to package `libusb0.dll` into your\npyinsteller `*.spec` file using the following line:\n\n datas=[('C:\\\\Windows\\\\System32\\\\libusb0.dll', '.'),],\n\n### Hardware Setup\n\nPlace device into 'USB' mode, not COM mode!!!\n\n 1. Disconnect from USB\n 2. Wait 5 seconds\n 3. Connect to USB and press button on side rapidly until LED changes\n \nThe device setting is persistent and will not need to be changed again. \nIf you see a COM port in your device manager with the label `DATAQ DI-2008` \nthen the device is NOT in the correct mode!\n\n### Software Setup\n\nTo read a few analog inputs, device setup is relatively simple.\n\n 1. Define the ports\n 2. Create the `Di2008` instance\n 3. Add the scan list\n 4. Start the scanning process\n 5. Read inputs at whatever timing is desired as the inputs will be updated \"live\"\n\nSome sample code might be more illuminating. A simple script to set up the scan list and to print the values every second:\n\n from time import sleep\n from di2008 import AnalogPort, RatePort, Di2008\n \n # create each of the inputs that need to be sampled\n an0 = AnalogPort(1, analog_range=10.0, filter='average')\n an1 = AnalogPort(2, thermocouple_type='j')\n an2 = AnalogPort(3, thermocouple_type='j')\n rate = RatePort(5000)\n \n daq = Di2008()\n daq.create_scan_list(\n [an0, an1, an2, rate]\n )\n daq.start()\n \n while True:\n print(f'{an0.value:.02f}')\n print(f'{an1.value:.02f}')\n print(f'{an2.value:.02f}')\n print(f'{rate.value:.02f}')\n print()\n \n sleep(1.0)\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Object-oriented API for DATAQ DI-2008",
"version": "0.4.9",
"project_urls": {
"Homepage": "https://github.com/slightlynybbled/di2008"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9aba513c5cdd29c41ab0e11f856764812eb738549c7863f0f0dae43ec67e962d",
"md5": "a1fdb172dc0aa3abd3da44967a582098",
"sha256": "ed39cb16ae4593d35522e2a6549c75243b681312db60820d004fc6f338721669"
},
"downloads": -1,
"filename": "di2008-0.4.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a1fdb172dc0aa3abd3da44967a582098",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6.0",
"size": 12145,
"upload_time": "2023-07-19T15:21:32",
"upload_time_iso_8601": "2023-07-19T15:21:32.208768Z",
"url": "https://files.pythonhosted.org/packages/9a/ba/513c5cdd29c41ab0e11f856764812eb738549c7863f0f0dae43ec67e962d/di2008-0.4.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-19 15:21:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "slightlynybbled",
"github_project": "di2008",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"test_requirements": [],
"lcname": "di2008"
}