Code Monkey home page Code Monkey logo

di2008's People

Contributors

mosindy avatar slightlynybbled avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

di2008's Issues

slist out of sync

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.

Reading multiple analog sensors

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?

8 analog channels?

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!

Feature request: indication when data is ready

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.

Add capability to scan the digital in to the scan list

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.

Unstable Sensor Readings

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

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.