felixdrp / ads1x15

Ultra-Small, Low-Power, BitAnalog-to-Digital Converter with Internal Reference
GNU General Public License v2.0
3 stars 1 forks source link

Channel mismatch #3

Open alexander-thiesen opened 1 year ago

alexander-thiesen commented 1 year ago

Hello @felixdrp, we have a problem with the communication to our ads1115 chip. When we read out the chip using code similar to single-shot-example.js the channels get messed up. We used the implementation of (https://github.com/meeki007/node-red-contrib-ads1x15_i2c). That means that when we read out channel 2 and 3 the output of channel 2 has sometimes the value of channel 3, vice versa. For easy demonstration purposes we set the input voltages of the ADC to 1, 2, 3, 4 V respectively. We ask for the values every 200 ms. Input is single ended. Until now we used 128 Samples/sec. Do you have a idea where the source of this problem might be and how to solve it?

Thank you in advance

Alexander Thiesen

A similar Issue has been reported under: https://github.com/meeki007/node-red-contrib-ads1x15_i2c/issues/6#issue-1815835818

felixdrp commented 1 year ago

Hello @alexander-thiesen,

  1. Have you try with multiple ADC boards?
  2. Does It changes/replicates with different frequencies?
  3. Do you think it is the software/hardware issue?
  4. May be ambient conditions (cool, warm, etc)?
  5. Another alternative?
alexander-thiesen commented 1 year ago

Hello @felixdrp, Thank you for your suggestions. I analyzed the transferred signal using an oscilloscope seeing, that the data was transmitted correctly, but with the old value. My conclusion was that there is a timing issue. The time defined in line 351 of your code was not enough. https://github.com/felixdrp/ads1x15/blob/42644aaf043a9074e6ffa76cb1eea878a627bc0c/index.js#L351 The ADC chip was not finished with its measurements before your code read out the old value, which has not been changed yet. Adding another millisecond was sufficient in my case: const delay = (1000 / sps) + 2;

Alternatively, one could add a read request to read the config register. The first bit tells if a conversion is still running. I was thinking about adding a "safe" function that requests this value before read out.

Greetings

felixdrp commented 1 year ago

Hello @alexander-thiesen,

Thank for your detail explanation. We can add another parameter to the function so we can fine tune the delay time.

It sounds good 'to read the config register'. What about a mix where we have a smaller delay then 'read de register' and if it is not finish yet apply the delay again...? Can you have a look to it?

Many thanks

felixdrp commented 1 year ago

Updated version with delayFineTune option.