-
Notifications
You must be signed in to change notification settings - Fork 58
2 simultaneous differential channels #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks OK at a first glance. Do you really need continuous mode? It doesn't look like you are actually storing the values in your sampling loop. Just saving the max. Can you describe your use case. |
Yeah sure, I should have given more details. |
Is your hardware already embedded, or can you do some bread board testing of the ADS? |
Great idea. I might plug in a potentiometer on each channel and simulate a random signal by turning the knobs and trying to log on screen if the changes make sense. I'll let you know when I'm done. Thanks ! |
Also just to make sure the basics works. Try that with single shot. Then try continuous. Etc. Continuous is tricky and this library doesn't really support it well. Lot's of discussion here: |
Ok so a bit of testing and i came to some results: First change was I decided to actually store all the values instead of the max. Then, trying to read them in the same loop (simultaneously) didn't work at all: Loop:
Log: Here it's visible that the results are duplicated (I was turning a 500W load on and off which was connected to only one channel). But if i read them in separate loops with a timeout in between, it came out way closer than the expected:
CH1: 98 The 500W peaks appear in only one channel. And by the way i did a bread board testing using a potentiometer, splitting 4V across the channels and the readings were accurate, so the inputs are working fine (for DC). |
@caternuson apparently the time.sleep(5) between reading the channels solved the issue. Here is the new plot and I'm way happier with the results: |
Glad it's working a little better. It may not be the for i in range(SAMPLES):
data1[i] = chan1.value
data2[i] = chan2.value YES: for i in range(SAMPLES):
data1[i] = chan1.value
for i in range(SAMPLES):
data2[i] = chan2.value The way it works is it keeps track of the last channel read. If you read the same channel again, it bypasses a lot unnecessary setup and subsequent I2C traffic: But synchronizing the reads with ADC conversion completion is still an issue. The library currently has no mechanism for doing that. |
Thanks, I think it's clear now what the problem was. Closing this. |
Hello, i've been trying to setup 2 differential channels at the same time but i'm not sure if the code I wrote is quite right, couldn't find in the docs either.
I plotted the graph of the readings and somehow they appear to be related even if i'm reading completely different sources.
Here is the code i built so far:
The text was updated successfully, but these errors were encountered: