ricardo.santos
Posts: 43
Joined: Thu Jan 18, 2018 12:18 pm

Buffer of ADC overflows?

Thu Nov 15, 2018 6:19 pm

Hi all

I'm doing a acquisition system for analog sensors (water pressures and water turbidity) using a raspberry pi 3B and a ADC (ADS1115).

The problem that i am facing is that from time to time the buffer (or whatever) gets full and the ads1115 gives a zero reading.

The lower the data rate (or whatever), the more frequente are the nulls.

Here I show the plots that i have:

DATA RATE = 8 sps

Image

DATA RATE = 16 sps

Image

The drops were turbidity goes to zero and pressure to negative values are a consequence of the zero readings in the adc.


Is there a way to clear the buffer (or whatever) of the adc? Or do you think the problem is other?

The connections that i have are all in the github repository: https://github.com/Ricardosgeral/relier ... /README.md

The code for the reading of the ADS1115 is in this file https://github.com/Ricardosgeral/relier ... _thread.py


I would appreciate some directions here.

Thanks

User avatar
OutoftheBOTS
Posts: 711
Joined: Tue Aug 01, 2017 10:06 am

Re: Buffer of ADC overflows?

Thu Nov 15, 2018 11:24 pm

It is the software your using.

The AD1115 doesn't have a buffer it just has constally reads and stores the lastest conversion in its register.

The software your using has a thread that is started when you call the function run() that reads the ADS1115 then stores the data in a buffer then when you call the function read_analog() it returns the average of all the data stored in the buffer and then resets the buffer to start filling again.

Your problem will be when this buffer gets full as it isn't a ring buffer so it overflows. The better way to use a buffer to store a constant flow of data so that you can average is to use a ring buffer. A ring buffer when full then starts to write back at the beginning again instead of overflowing.

ricardo.santos
Posts: 43
Joined: Thu Jan 18, 2018 12:18 pm

Re: Buffer of ADC overflows?

Fri Nov 16, 2018 10:28 am

ohh thanks. That makes sense.
I will investigate that ring buffer. I don't know how to implement it.

ricardo.santos
Posts: 43
Joined: Thu Jan 18, 2018 12:18 pm

Re: Buffer of ADC overflows?

Fri Nov 16, 2018 3:12 pm

OutoftheBOTS wrote:
Thu Nov 15, 2018 11:24 pm
I have another question!

Is there a way to know if a pin of the ADS1115 has no sensor attached?

thank you

User avatar
OutoftheBOTS
Posts: 711
Joined: Tue Aug 01, 2017 10:06 am

Re: Buffer of ADC overflows?

Sat Nov 17, 2018 6:15 am

If there isn't anything attached to the ADC pins then it should read zero or very very close to it :)

User avatar
OutoftheBOTS
Posts: 711
Joined: Tue Aug 01, 2017 10:06 am

Re: Buffer of ADC overflows?

Sun Nov 18, 2018 4:39 am

Instead of using the mean(average) of the ADC readings it is usually better to use the median see this video for better explanation https://youtu.be/H51OzQl3BC8

Brandon92
Posts: 775
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Buffer of ADC overflows?

Tue Nov 20, 2018 10:04 pm

OutoftheBOTS wrote:
Sat Nov 17, 2018 6:15 am
If there isn't anything attached to the ADC pins then it should read zero or very very close to it :)
Well I think that is not correct. You will measure anything and everything between the 0 and the maximal value, if the input of the ADC is floating. This is because the input impedance of the ADC is high, in this case between the 3M -100M Ohm. And it will pick up any noise, signals, ect. that are in the air. So, basely the values are random that you will get.

Return to “Automation, sensing and robotics”