Skip to content
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

fix #87, update readme.md about ALERT pulse and polarity #88

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ADS1X15.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: ADS1X15.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.5.1
// VERSION: 0.5.2
// DATE: 2013-03-24
// PURPOSE: Arduino library for ADS1015 and ADS1115
// URL: https://github.com/RobTillaart/ADS1X15
Expand Down
4 changes: 2 additions & 2 deletions ADS1X15.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: ADS1X15.h
// AUTHOR: Rob Tillaart
// VERSION: 0.5.1
// VERSION: 0.5.2
// DATE: 2013-03-24
// PURPOSE: Arduino library for ADS1015 and ADS1115
// URL: https://github.com/RobTillaart/ADS1X15
Expand All @@ -12,7 +12,7 @@
#include "Arduino.h"
#include "Wire.h"

#define ADS1X15_LIB_VERSION (F("0.5.1"))
#define ADS1X15_LIB_VERSION (F("0.5.2"))

// allow compile time default address
// address in { 0x48, 0x49, 0x4A, 0x4B }, no test...
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.5.2] - 2025-01-27
- Add note about falling edge when using interrupts, see #87
- update comments in some examples
- minor edits

## [0.5.1] - 2024-10-17
- fix #82, minimal timeout 10 ms for RTOS, kudos to deKees687
- set error flag for TIMEOUT
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2013-2024 Rob Tillaart
Copyright (c) 2013-2025 Rob Tillaart

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
51 changes: 34 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ differential measurements.

### Interrupts

Besides polling the ADS1x14 and ADS1x15 support interrupts to maximize throughput
Besides polling the **ADS1x14** and **ADS1x15** support interrupts to maximize throughput
with minimal latency. For this these device has an ALERT/RDY pin.
This pin can be used both for interrupts or polling, see table of examples below.

Expand All @@ -55,6 +55,19 @@ This pin can be used both for interrupts or polling, see table of examples below
| ADS_read_RDY.ino | polling |


The examples of this library all use the **RISING** edge for the interrupt detection
of the ALERT / RDY pin.
In https://github.com/RobTillaart/ADS1X15/issues/87 it is observed that the **FALLING**
edge gave far more stable results for the application used (determine True RMS).
This effect can not be explained as the edges are only 8 us apart.
Thus changing the edge to **FALLING** might improve your measurements too.

Datasheet section 7.3.8 Conversion ready pin, figure 7-8 indicates using
the **FALLING** edge as the moment the conversion is ready.

If anybody can explain the observed effect, please let me know.


### 0.5.0 Breaking change

Fixed #80, setComparatorPolarity() and setComparatorLatch() as these inverted
Expand All @@ -72,12 +85,14 @@ before calling **begin()**.

### Related

- https://github.com/RobTillaart/AD7367 2 channel simultaneous 14 bit ADC.
- https://github.com/RobTillaart/ADC081S 10-12 bit, single channel ADC
- https://github.com/RobTillaart/ADC08XS 10-12 bit, 2 + 4 channel ADC
- https://gammon.com.au/adc tutorial about ADC's (UNO specific)
- https://github.com/RobTillaart/MCP_ADC 10-12 bit, 1,2,4,8 channel ADC
- https://github.com/RobTillaart/ADS1x15
- https://github.com/RobTillaart/PCF8591 8 bit single ADC (+ 1 bit DAC)
- https://github.com/RobTillaart/AD5593R 8 channel ADC / DAC / GPIO device.


## I2C Address
Expand Down Expand Up @@ -284,7 +299,7 @@ Therefore the user should check with **getError()** if an error has occurred aft
// handle error
```

The errorhandling within the library need to be improved, see also issue #84.
The error handling within the library need to be improved, see also issue #84.


### Read the ADC in asynchronous way
Expand Down Expand Up @@ -511,15 +526,17 @@ as that is the only single change visible. This is IMHO the correct view.

#### ALERT RDY table

| 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 |
| MODE | COMP_POL | CONVERT | COMPLETING | READY |
|:---------------|:-----------|:----------|:-------------|:----------|
| 0 = continuous | 0 = LOW | LOW | RISING | FALLING |
| 0 = continuous | 1 = HIGH | HIGH | FALLING | RISING |
| 1 = single | 0 = LOW | LOW | RISING | FALLING |
| 1 = single | 1 = HIGH | HIGH | FALLING | RISING |


See issue #76 and #87 for some screenshots.

See issue #76 for some screenshots.
See also [Rev. D data sheet, Page 17 Figure 7-8 Conversion Ready Pulse in Continuous-Conversion Mode](https://www.ti.com/lit/ds/symlink/ads1115.pdf)


#### Converting time by Data Rate
Expand Down Expand Up @@ -547,18 +564,18 @@ Times are estimates from scope.
In short:

- if COMP_POL = 0,
- a FALLING edge indicates conversion start.
- a LOW level indicates converting.
- a RISING edge indicates conversion ready.
- a HIGH level indicates idle.
- a RISING edge indicates conversion completing.
- a FALLING edge indicates conversion ready.

- if COMP_POL = 1,
- a RISING edge indicates conversion start.
- a HIGH level indicates converting.
- a FALLING edge indicates conversion ready.
- a LOW level indicates idle.
- a FALLING edge indicates conversion completing.
- a RISING edge indicates conversion ready.

This interpretation is in line with all tests done in #76 and #87.

This interpretation is in line with all tests done in #76.
See also [Rev. D data sheet, Page 17 Figure 7-8 Conversion Ready Pulse in Continuous-Conversion Mode](https://www.ti.com/lit/ds/symlink/ads1115.pdf)


### Latch
Expand Down
23 changes: 21 additions & 2 deletions examples/ADS_1114_two_continuous/ADS_1114_two_continuous.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,27 @@
// FILE: ADS_1114_two_continuous.ino
// AUTHOR: Rob.Tillaart
// PURPOSE: demo reading four ADS1114 modules in parallel
// interrupt driven to catch all conversions.
// URL: https://github.com/RobTillaart/ADS1X15

// test
// connect multiple potmeters to 2 ADS1114
//
//
// RDY1 ----------------- pin 2 (for IRQ, adjust if needed)
//
// RDY2 ----------------- pin 3 (for IRQ, adjust if needed)
//
//
// GND ---[ x ]------ 5V
// |
//
// measure at x - connect to AIN0..1.
//
// for the test it is good to have AIN2 connected to 5V and AIN3 to GND
// so one can see these as references in the output.
//


#include "ADS1X15.h"

Expand Down Expand Up @@ -61,8 +80,8 @@ void setup()
pinMode(3, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(3), adsReady_2, RISING);

ADS_2.setMode(0); // 0 == continuous mode
ADS_2.readADC(); // 0 == default channel, trigger first read
ADS_2.setMode(0); // 0 == continuous mode
ADS_2.readADC(); // 0 == default channel, trigger first read
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
// test
// connect multiple potmeters
//
// RDY ----------------- pin 2 (for IRQ)
// RDY ----------------- pin 2 (for IRQ, adjust if needed)
//
// GND ---[ x ]------ 5V
// |
// |
// ADS(n)
//
// measure at x - connect to AIN0..3.
// measure at x - connect to AIN0..1.
//
// for the test it is an option to have AIN3 connected to 5V and AIN4 to GND
// for the test it is an option to have AIN2 connected to 5V and AIN3 to GND
// so one can see these as references in the output.
//
// has an issue with the index of the channels. not not investigated yet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
// test
// connect multiple potmeters
//
// RDY ----------------- pin 2 (for IRQ, adjust if needed)
//
// GND ---[ x ]------ 5V
// |
//
// measure at x - connect to AIN0..4.
// measure at x - connect to AIN0..1.
//
// for the test it is good to have AIN3 connected to 5V and AIN4 to GND
// for the test it is good to have AIN2 connected to 5V and AIN3 to GND
// so one can see these as references in the output.
//

Expand Down
26 changes: 16 additions & 10 deletions examples/ADS_continuous_8_channel/ADS_continuous_8_channel.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@
// test
// connect multiple potmeters to 2 ADS1115
//
//
// RDY1 ----------------- pin 2 (for IRQ, adjust if needed)
//
// RDY2 ----------------- pin 3 (for IRQ, adjust if needed)
//
//
// GND ---[ x ]------ 5V
// |
//
// measure at x - connect to AIN0..4.
// measure at x - connect to AIN0..1.
//
// for the test it is good to have AIN3 connected to 5V and AIN4 to GND
// for the test it is good to have AIN2 connected to 5V and AIN3 to GND
// so one can see these as references in the output.
//

Expand Down Expand Up @@ -47,8 +53,8 @@ void setup()

// SETUP FIRST ADS1115
ADS_1.begin();
ADS_1.setGain(0); // 6.144 volt
ADS_1.setDataRate(7); // 0 = slow 4 = medium 7 = fast
ADS_1.setGain(0); // 0 == 6.144 volt, default
ADS_1.setDataRate(7); // 0 = slow 4 = medium 7 = fast

// SET ALERT RDY PIN
ADS_1.setComparatorThresholdHigh(0x8000);
Expand All @@ -59,14 +65,14 @@ void setup()
pinMode(2, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(2), adsReady_1, RISING);

ADS_1.setMode(0); // continuous mode
ADS_1.readADC(channel_1); // trigger first read
ADS_1.setMode(0); // 0 == continuous mode
ADS_1.readADC(channel_1); // 0 == default channel, trigger first read


// SETUP SECOND ADS1115
ADS_2.begin();
ADS_2.setGain(0); // 6.144 volt
ADS_2.setDataRate(7);
ADS_2.setGain(0); // 0 == 6.144 volt, default
ADS_2.setDataRate(7); // 7 == highest

// SET ALERT RDY PIN
ADS_2.setComparatorThresholdHigh(0x8000);
Expand All @@ -77,8 +83,8 @@ void setup()
pinMode(3, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(3), adsReady_2, RISING);

ADS_2.setMode(0); // continuous mode
ADS_2.readADC(channel_2); // trigger first read
ADS_2.setMode(0); // 0 == continuous mode
ADS_2.readADC(channel_2); // 0 == default channel, trigger first read
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
// test
// connect 4 potmeters
//
// RDY ----------------- pin 2 (for IRQ, adjust if needed)
//
// GND ---[ x ]------ 5V
// |
//
// measure at x - connect to AIN0..4.
// measure at x - connect to AIN0..3.
//
// adjust IRQ pin if needed


#include "ADS1X15.h"
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/ADS1X15"
},
"version": "0.5.1",
"version": "0.5.2",
"license": "MIT",
"frameworks": "*",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ADS1X15
version=0.5.1
version=0.5.2
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for ADS1015 - I2C 12 bit ADC and ADS1115 I2C 16 bit ADC
Expand Down