slightlynybbled / di2008 Goto Github PK
View Code? Open in Web Editor NEWObject-oriented API for DATAQ DI-2008
License: MIT License
Object-oriented API for DATAQ DI-2008
License: MIT License
I am getting voltage values from 6 channels from the dataq. Randomly, the readings from the Analog ports will get out of sync and its always by a factor of two. For example I am reading channels 1-6. Randomly, the program will output channel 3's value as channel 1's value or channel 3's value as channel 5's value.
Can you just add the passthrough? I can throw up a PR if you give access :)
Hi,
I'm trying to read 3 thermocouples, 3 heat flux sensors, and 1 solar flux sensor while also doing digital io. When I try to read the 7 sensors with the winDaq program, it gives no issues, but when I try to read them with my program the readings are unstable and erroneous. What's strange is that reading from ports 1 and 2 seem to be fine, but the other ports seem to be causing issues. Any insights on what the potential causes of this issue is?
I have 4 DI-2008 units I want to read from, so my approach is to create 4 instrument
class instances with serial numbers, and then 8 each analog channels for the scan list.
I found that this works unless I try and read the 8th channel. If I add this to the scan list, I never get anything but 'None' as a value.
Here's my code example:
chan_list = []
for i in range(4,9):
print("adding", i)
chan_list.append(AnalogPort(i, thermocouple_type='k', filter='average', filter_decimation=100))
print("added", chan_list)
daq = Di2008(port_name="COM4", loglevel=logging.DEBUG)
daq.create_scan_list(chan_list)
daq.start()
while chan_list[0].value is None:
# wait for readings to appear
pass
logging.info("started, checking values")
while True:
print('time', strftime("%H:%M:%S"), end="\t")
for d in chan_list:
print(round(d.value,2), end=" - ")
print()
sleep(1)
This works with channels 1-7, or 3-7 or just 7, but as soon as I add channel 8 I get:
$ python.exe monitor.py
adding 4
adding 5
adding 6
adding 7
adding 8
added [<di2008.instrument.AnalogPort object at 0x0000023704DD94C0>, <di2008.instrument.AnalogPort object at 0x0000023704DD9490>, <di2008.instrument.AnalogPort object at 0x0000023704DF8400>, <di2008.instrument.AnalogPort object at 0x0000023704DF8460>, <di2008.instrument.AnalogPort object at 0x0000023704DF84C0>]
INFO:Di2008:device found on COM4
DEBUG:Di2008:sending "stop"
DEBUG:Di2008:received from unit: "b'stop\r'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "stop"
INFO:Di2008:message could not be parsed: "stop"
DEBUG:Di2008:sending "info 0"
DEBUG:Di2008:received from unit: "b'info 0 DATAQ\r'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "info 0 DATAQ"
DEBUG:Di2008:sending "info 1"
DEBUG:Di2008:received from unit: "b'info 1 2008\r\x00'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "info 1 2008"
DEBUG:Di2008:sending "info 2"
DEBUG:Di2008:received from unit: "b'info 2 71\r\x00'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "info 2 71"
DEBUG:Di2008:sending "info 6"
DEBUG:Di2008:received from unit: "b'info 6 5DBC38D3\r\x00'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "info 6 5DBC38D3"
DEBUG:Di2008:sending "srate 4"
DEBUG:Di2008:received from unit: "b'srate 4\r\x00'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "srate 4"
INFO:Di2008:message could not be parsed: "srate 4"
DEBUG:Di2008:sending "ps 0"
DEBUG:Di2008:received from unit: "b'ps 0\r'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "ps 0"
INFO:Di2008:message could not be parsed: "ps 0"
DEBUG:Di2008:sending "slist 0 4867"
DEBUG:Di2008:received from unit: "b'slist 0 4867\r'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "slist 0 4867"
INFO:Di2008:message could not be parsed: "slist 0 4867"
DEBUG:Di2008:sending "slist 1 4868"
DEBUG:Di2008:received from unit: "b'slist 1 4868\r'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "slist 1 4868"
INFO:Di2008:message could not be parsed: "slist 1 4868"
DEBUG:Di2008:sending "slist 2 4869"
DEBUG:Di2008:received from unit: "b'slist 2 4869\r'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "slist 2 4869"
INFO:Di2008:message could not be parsed: "slist 2 4869"
DEBUG:Di2008:sending "slist 3 4870"
DEBUG:Di2008:received from unit: "b'slist 3 4870\r'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "slist 3 4870"
INFO:Di2008:message could not be parsed: "slist 3 4870"
DEBUG:Di2008:sending "slist 4 4871"
DEBUG:Di2008:received from unit: "b'slist 4 4871\r'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "slist 4 4871"
INFO:Di2008:message could not be parsed: "slist 4 4871"
DEBUG:Di2008:sending "filter 4 1"
DEBUG:Di2008:received from unit: "b'filter 4 1\r'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "filter 4 1"
INFO:Di2008:message could not be parsed: "filter 4 1"
DEBUG:Di2008:sending "dec 100"
DEBUG:Di2008:received from unit: "b'dec 100\r\x00'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "dec 100"
INFO:Di2008:message could not be parsed: "dec 100"
DEBUG:Di2008:sending "filter 5 1"
DEBUG:Di2008:received from unit: "b'filter 5 1\r'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "filter 5 1"
INFO:Di2008:message could not be parsed: "filter 5 1"
DEBUG:Di2008:sending "dec 100"
DEBUG:Di2008:received from unit: "b'dec 100\r\x00'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "dec 100"
INFO:Di2008:message could not be parsed: "dec 100"
DEBUG:Di2008:sending "filter 6 1"
DEBUG:Di2008:received from unit: "b'filter 6 1\r'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "filter 6 1"
INFO:Di2008:message could not be parsed: "filter 6 1"
DEBUG:Di2008:sending "dec 100"
DEBUG:Di2008:received from unit: "b'dec 100\r\x00'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "dec 100"
INFO:Di2008:message could not be parsed: "dec 100"
DEBUG:Di2008:sending "filter 7 1"
DEBUG:Di2008:received from unit: "b'filter 7 1\r'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "filter 7 1"
INFO:Di2008:message could not be parsed: "filter 7 1"
DEBUG:Di2008:sending "dec 100"
DEBUG:Di2008:received from unit: "b'dec 100\r\x00'"
DEBUG:Di2008:"\r" detected, decoding message...
DEBUG:Di2008:message received: "dec 100"
INFO:Di2008:message could not be parsed: "dec 100"
DEBUG:Di2008:sending "filter 8 1"
DEBUG:Di2008:sending "dec 100"
DEBUG:Di2008:sending "info 9"
DEBUG:Di2008:sending "start"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
DEBUG:Di2008:sending "din"
... forever
I went through the instrument class, and I don't see anything obvious that may cause this? Do you have any ideas?
Environment: Python 3.9, Windows 10
Thanks for any insight!
I've been using this library to write data to CSV and other logging purposes, and I can't seem to find a way to determine if a "fresh set" of readings from the device are available. It looks to me like it's just editing the .value attribute of the scan list objects whenever it parses the received data from the device. Is there a way to either set a variable or trigger a callback function so that I don't have to rely on sleep() statements for synchronization?
If not, could this be a feature that is added? I might be able to hack it in by editing the library directly but I'd rather have it done by someone who has a better understanding of how this library works.
I am aware that the device sends its data in small packets, the event should fire when the scanlist completes.
Thank you for any help you can provide.
Currently, the digital inputs are only polled when not scanning using the din
command. As this is a write/read operation, it does not function when scanning. One of the scan list words is a digital in and I would like for the software to default to this mode when in scan mode.
Hi,
Sometimes when I'm running my program, the sensors would suddenly read obviously incorrect values. Often my program will run fine for several minutes, but then all of a sudden the readings will spike. Sometimes the readings will return to normal on its own and other times it won't.
I have yet to see this problem when reading the sensors on WinDAQ program.
temp-control4_2.txt
I don't think this is a wiring connection issue. I have jiggled the wires around when the sensors are reading normal and nothing changes. I'm wondering if this might be a software issue? Perhaps, it might be the way I'm exiting the program. I often stop the program by either pressing ctrl+c or exiting Anacoda, the IDE I'm using. I've attached my program for reference.
Charles
temp-control4_2.txt
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.