Closed HineSite closed 2 months ago
Thanks for the issue, As I am quite busy on some other tasks, it might take several days (weeks) before I can dive into it. Definitely looks like a bug given your code snippet, so I labeled it as such to give it priority it needs.
@HineSite Can you run this example as I have to test setup near me. Please post the output.
It checks all the "configuration flags".
//
// FILE: ADS_test_config.ino
// AUTHOR: Rob.Tillaart
// PURPOSE: test config flags
// URL: https://github.com/RobTillaart/ADS1X15
// triggered by issue 80
#include "ADS1X15.h"
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();
Serial.println("\nTEST GAIN");
int gain = 16;
for (int i = 0; i < 6; i++)
{
Serial.print(gain);
ADS.setGain(gain);
if (ADS.getGain() == gain) Serial.println("\tOK");
else Serial.println("\tFAIL");
}
Serial.println("\nTEST DATARATE");
for (int i = 0; i < 7; i++)
{
Serial.print(i);
ADS.setDataRate(i);
if (ADS.getDataRate() == i) Serial.println("\tOK");
else Serial.println("\tFAIL");
}
Serial.println("\nTEST MODE");
for (int i = 0; i < 2; i++)
{
Serial.print(i);
ADS.setMode(i);
if (ADS.getMode() == i) Serial.println("\tOK");
else Serial.println("\tFAIL");
}
Serial.println("\nTEST COMP MODE");
for (int i = 0; i < 2; i++)
{
Serial.print(i);
ADS.setComparatorMode(i);
if (ADS.getComparatorMode() == i) Serial.println("\tOK");
else Serial.println("\tFAIL");
}
Serial.println("\nTEST COMP POLARITY");
for (int i = 0; i < 2; i++)
{
Serial.print(i);
ADS.setComparatorPolarity(i);
if (ADS.getComparatorPolarity() == i) Serial.println("\tOK");
else Serial.println("\tFAIL");
}
Serial.println("\nTEST COMP LATCH");
for (int i = 0; i < 2; i++)
{
Serial.print(i);
ADS.setComparatorLatch(i);
if (ADS.getComparatorLatch() == i) Serial.println("\tOK");
else Serial.println("\tFAIL");
}
Serial.println("\nTEST COMP QUECONVERT");
for (int i = 0; i < 2; i++)
{
Serial.print(i);
ADS.setComparatorQueConvert(i);
if (ADS.getComparatorQueConvert() == i) Serial.println("\tOK");
else Serial.println("\tFAIL");
}
Serial.println("\ndone...");
}
void loop()
{
}
// -- END OF FILE --
Note to myself: check if unit tests can be added
@HineSite Created a develop branch with a preliminary fix, If you have time, please verify if it works as expected.
If the readme.md needs additional information on latch/polarity topic feel free to provide such. (now back to my other tasks)
@HineSite Build of develop branch is stable, created a PR for release 0.5.0
This is the results when ran against 0.4.5
TEST GAIN
16 OK
16 OK
16 OK
16 OK
16 OK
16 OK
TEST DATARATE
0 OK
1 OK
2 OK
3 OK
4 OK
5 OK
6 OK
TEST MODE
0 OK
1 OK
TEST COMP MODE
0 OK
1 OK
TEST COMP POLARITY
0 FAIL
1 FAIL
TEST COMP LATCH
0 FAIL
1 FAIL
TEST COMP QUECONVERT
0 OK
1 OK
done...
Thanks for running the testcode That confirms the bug and shows there are no other inverted flags (as far as test goes).
Here are the results against the development branch.
ADS1X15_LIB_VERSION: 0.5.0
TEST GAIN
16 OK
16 OK
16 OK
16 OK
16 OK
16 OK
TEST DATARATE
0 OK
1 OK
2 OK
3 OK
4 OK
5 OK
6 OK
TEST MODE
0 OK
1 OK
TEST COMP MODE
0 OK
1 OK
TEST COMP POLARITY
0 OK
1 OK
TEST COMP LATCH
0 OK
1 OK
TEST COMP QUECONVERT
0 OK
1 OK
@HineSite Merged PR into master, Again, thanks for reporting this issue, appreciated!
I could be wrong, but I don't think these are correct?
Based on how the registers are being set later:
Example:
Results:
Polarity: 0 | Latch: 0