Comments (15)
Thanks for these tests,
Need to confirm these so it might take (serious) time before I have a HW setup.
from ads1x15.
@lynx985
Updated the readme.md with all the detailed insights from above.
Took more time than expected and imho it was worth the effort to understand these details
New version 0.4.4 will be (expect) this weekend.
from ads1x15.
thanks for all your work =)
from ads1x15.
First results of 4 test runs.
// test polarity
// MODE COMP_POL ALERT/RDY PIN
// 0 = continuous 0 = LOW LOW with 8 us HIGH pulse
// 0 = continuous 1 = HIGH HIGH with 8 us LOW pulse
// 1 = single 0 = LOW continuous HIGH
// 1 = single 1 = HIGH continuous LOW
In single mode I get no pulses (yet).
Test sketch
//
// FILE: ADS_COMP_POL.ino
// AUTHOR: Rob.Tillaart
// PURPOSE: read analog input
// URL: https://github.com/RobTillaart/ADS1X15/issues/76
#include "ADS1X15.h"
// choose your sensor
// ADS1013 ADS(0x48);
// ADS1014 ADS(0x48);
// ADS1015 ADS(0x48);
// ADS1113 ADS(0x48);
// ADS1114 ADS(0x48);
ADS1115 ADS(0x48);
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("ADS1X15_LIB_VERSION: ");
Serial.println(ADS1X15_LIB_VERSION);
Wire.begin();
ADS.begin();
ADS.setGain(0); // 6.144 volt
// test polarity
// MODE COMP_POL ALERT/RDY PIN
// 0 = continuous 0 = LOW 8 us HIGH PULSE
// 0 = continuous 1 = HIGH 8 us LOW pulse
// 1 = single 0 = LOW continuous HIGH
// 1 = single 1 = HIGH continuous LOW
ADS.setMode(1);
ADS.setComparatorPolarity(1);
// enable ALERT/RDY pin
ADS.setComparatorThresholdHigh(0x8000);
ADS.setComparatorThresholdLow(0x1000);
ADS.setComparatorQueConvert(0);
Serial.println("Voltage");
}
void loop()
{
int16_t raw = ADS.readADC(0);
delay(1000);
Serial.println(ADS.toVoltage(raw), 3);
delay(1000);
}
// -- END OF FILE --
from ads1x15.
Fetched a better scope to check for pulses - see 3 screenshots below - resulted in the following observations.
TEST | MODE | COMP_POL | ALERT/RDY PIN | Notes |
---|---|---|---|---|
1 | 0 = continuous | 0 = LOW | LOW with 8 us HIGH pulse | micro second pulse as specified in datasheet |
2 | 0 = continuous | 1 = HIGH | HIGH with 8 us LOW pulse | micro second pulse as specified in datasheet |
3 | 1 = single | 0 = LOW | HIGH with an 8 ms LOW pulse | 1000 x longer pulse |
4 | 1 = single | 1 = HIGH | LOW with an 8 ms HIGH pulse | 1000 x longer pulse |
Observations:
- polarity in single mode seems indeed inverted
- length of the pulse in continuous mode and in single mode differs a factor 1000.
Screenshots
MODE = 0, COMP_POL = 1, DATARATE = 4
MODE = 1, COMP_POL = 0, DATARATE = 4
MODE = 1, COMP_POL = 1, DATARATE = 4
from ads1x15.
TODO: add note in the readme.md
from ads1x15.
Created a new develop branch with updated readme.md (and some minor edits).
from ads1x15.
so did a short test
measured the RDY-pin on an oscilloscope
in single shot mode RDY remains high/low until the next request is made (not just a pulse)
but COMP_POL seems to be switched COMP_POL (0) goes LOW while convertig (around 1.2 ms) and HIGH when ready for as long as one wishes COMP_POL(1) goes HIGH while convertig (around 1.2 ms) and LOW when ready
Can you post your test sketch, so I can confirm (understand) your observations as these are slightly different than mine.
What board do you ise?
from ads1x15.
Note that my above observations are made with a fixed data rate and synchronous calls.
Todo: investigate effect data rate
Todo:: investigate async calls.
Hypothesis
Maybe the single shot mode is not inverted, but only looks that way due to sync call.
Todo: what is state of the ALERT/RDY pin before any request, after request, and after read.
Might be e.g. LOW before, HIGH after request, and Low after read again. (Mode 0).
from ads1x15.
Investigate effect data rate
Same sketch as above + ADS.setDataRate()
- MODE = 1 (Single shot modus)
- COMP_POL = 1
- DATA_RATE = 0..7
datarate | pulse length |
---|---|
0 | 125 ms |
1 | 62 ms |
2 | 32 ms |
3 | 16 ms |
4 | 8 ms |
5 | 4.4 ms |
6 | 2.4 ms |
7 | 1.2 ms |
Quick estimates from scope.
from ads1x15.
Investigate level before any call
Same sketch as above minus code in loop()
- MODE = 1 (Single shot modus)
- COMP_POL = 1
- DATA_RATE = 4
After power off and no request the polarity is indeed HIGH.
- MODE = 1 (Single shot modus)
- COMP_POL = 0
- DATA_RATE = 4
After power off and no request the polarity is still HIGH.
mmmm, lets think....
aha, settings are not activated as the library does that in the requestADC() call
Added call to ADS.requestADC() at end of setup()
COMP_POL = 0 => gave HIGH with a 8 ms LOW pulse (as before).
COMP_POL = 1 => gave LOW with a 8 ms HIGH pulse
Conclusions
- COMP_POL is indeed behaving inverted in single shot mode.
- conversion ready always gives a pulse
- the length of the pulse depends on the data rate in single shot mode.
from ads1x15.
See my tests above,
And yes, when switching from POL 0 to 1 or vice versa, the ADS only activates this setting when a requestADC() call is made.
I will (try to) document this all in the readme.
from ads1x15.
Found the right phrasing for the semantics of COMP_POL:
- if COMP_POL = 0, a FALLING edge indicates conversion ready.
- if COMP_POL = 1, a RISING edge indicates conversion ready.
This is true for both continuous and single mode.
from ads1x15.
I am not convinced yet the (my) story about the COMP_POL is 100% complete.
However the part described seems correct, logical and useful, and I expect some small updates to fill some gaps.
from ads1x15.
@lynx985
My latest insights are as follows:
MODE | COMP_POL | IDLE | START | CONVERT | READY |
---|---|---|---|---|---|
0 = continuous | 0 = LOW | HIGH | FALLING | LOW | RISING |
0 = continuous | 1 = HIGH | LOW | RISING | HIGH | FALLING |
1 = single | 0 = LOW | HIGH | FALLING | LOW | RISING |
1 = single | 1 = HIGH | LOW | RISING | HIGH | FALLING |
This view matches with all the scope images above and observations including those in your first post.
It shows that the 8us pulse in continuous mode shows the IDLE time,
while one should look at the CONVERT time as the actual pulse.
Yes, it need time to get good insights.
Will update the readme any time soon.
from ads1x15.
Related Issues (20)
- How to check if the data rate is correct? HOT 8
- ADS1115 on RP2040 Wire, 0x4B is busy HOT 14
- Arduino Micro and ADS1115 - 860SPS (Only on 1 channel ?) HOT 62
- Error during compiling HOT 5
- ESP32 work on Espressif 1.04 but No on Espressif 2,07 HOT 4
- Synchronous mode very slow HOT 13
- [Query] Example for continuously reading all four channels at max sps? HOT 2
- Differential continuous mode HOT 12
- Cannot change address HOT 11
- ADS1115 value from one channel is being copied to the other HOT 6
- The use of Wire1 is not allowed for ESP32 or ESP8266 HOT 3
- Alternate I2C/TWI library or library abstraction layer HOT 8
- [question] About using ALERT RDY in ADS_continuous_differential.ino example. HOT 8
- getMaxVoltage() does not handle ADS1113 HOT 6
- interrupt driven reads HOT 6
- Differential input and gain for maximum precision. HOT 4
- wire speed HOT 22
- 10-12 Channel Continuous with interrupts. HOT 11
- possible error in the readme HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ads1x15.