slightlynybbled / di2008

Object-oriented API for DATAQ DI-2008
MIT License
5 stars 2 forks source link

Reading multiple analog sensors #10

Closed charlesxiao96 closed 2 years ago

charlesxiao96 commented 2 years ago

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?

slightlynybbled commented 2 years ago

Greetings -

I don't know exactly what the issue is. Could you post your setup code and I can try to replicate?

Thanks!

charlesxiao96 commented 2 years ago

Thanks for the reply This code is basically the same as the example, but modified to read multiple sensors. Could it possibly be an issue with the packet size?

testtest2_2.txt

slightlynybbled commented 2 years ago

Charles -

Thank you for the code snippet. Your setup code is as follows:

channels = [
    AnalogPort(2, analog_range='0.025', filter='average', loglevel=loglevel),
    AnalogPort(4, analog_range='0.025', filter='average', loglevel=loglevel),
    AnalogPort(8, analog_range='0.025', filter='average', loglevel=loglevel),
    AnalogPort(1, thermocouple_type= 't',filter='average'),
    AnalogPort(3, thermocouple_type= 't',filter='average'), 
    AnalogPort(7, thermocouple_type= 't',filter='average')
]

I have noticed in the past that I need to set up the channels in numeric order. I'm not sure why yet, and I haven't investigated. Try this:

channels = [
    AnalogPort(1, thermocouple_type= 't',filter='average'),
    AnalogPort(2, analog_range='0.025', filter='average', loglevel=loglevel),
    AnalogPort(3, thermocouple_type= 't',filter='average'), 
    AnalogPort(4, analog_range='0.025', filter='average', loglevel=loglevel),
    AnalogPort(7, thermocouple_type= 't',filter='average'),
    AnalogPort(8, analog_range='0.025', filter='average', loglevel=loglevel),
]

If that has issues, maybe try assigning the thermocouples on 7 and 8 to 5 and 6? I have deployed code into production that uses 4 channels, but not 6.

I look forward to hearing from you,

j

charlesxiao96 commented 2 years ago

Thank you. Setting the channels in numeric order appears to help. I'll keep you posted if other issues pop up