@@ -474,26 +474,33 @@ Flag is only explicitly set after a **readADC()** or a **requestADC()**
474
474
- **uint8_t getComparatorPolarity()** returns value set.
475
475
476
476
477
- From tests (#76) it became clear that the behaviour of the **ALERT/RDY** pin is a bit ambiguous.
478
- The meaning of HIGH LOW is different for **continuous** and **single** mode, see
479
- the table below. Also different is the timing of the pulse at the **ALERT/RDY** pin.
480
- See **ADS_COMP_POL.ino**.
477
+ From tests (see #76) it became clear that the behaviour of the **ALERT/RDY** pin
478
+ looks ambiguous. Further investigation eventually showed that the behaviour is
479
+ logical but one should not think in "pulses", more in levels and edges.
481
480
482
- Timing of pulse from a synchronous ```ADS.readADC(0)``` call.
481
+ In the continuous mode it looks like an 8us pulse, however this "pulse" is
482
+ actual a short time (8 us) of IDLE followed by a long time pulse of converting.
483
+
484
+ In the single shot mode it looks like the converting time is the pulse
485
+ as that is the only single change visible. This is IMHO the correct view.
486
+
487
+
488
+ #### ALERT RDY table
489
+
490
+ | MODE | COMP_POL | IDLE | START | CONVERT | READY |
491
+ |:---------------|:-----------|:-------|:----------|:----------|:----------|
492
+ | 0 = continuous | 0 = LOW | HIGH | FALLING | LOW | RISING |
493
+ | 0 = continuous | 1 = HIGH | LOW | RISING | HIGH | FALLING |
494
+ | 1 = single | 0 = LOW | HIGH | FALLING | LOW | RISING |
495
+ | 1 = single | 1 = HIGH | LOW | RISING | HIGH | FALLING |
483
496
484
- | TEST | MODE | COMP_POL | ALERT/RDY PIN | Notes |
485
- |:----:|:-----------------|:-----------|:------------------------------|:--------|
486
- | 1 | 0 = continuous | 0 = LOW | LOW with 8 us HIGH pulse | as specified in datasheet
487
- | 2 | 0 = continuous | 1 = HIGH | HIGH with 8 us LOW pulse | as specified in datasheet
488
- | 3 | 1 = single | 0 = LOW | HIGH with an 8 ms LOW pulse | depends on data rate
489
- | 4 | 1 = single | 1 = HIGH | LOW with an 8 ms HIGH pulse | depends on data rate
490
497
491
498
See issue #76 for some screenshots.
492
499
493
500
494
- #### Effect Data Rate
501
+ #### Converting time by Data Rate
495
502
496
- | data rate | pulse length | Notes |
503
+ | data rate | convert time | Notes |
497
504
|:-----------:|:--------------:|:-------:|
498
505
| 0 | 125 ms |
499
506
| 1 | 62 ms |
@@ -509,14 +516,25 @@ Times are estimates from scope.
509
516
510
517
#### Conclusions
511
518
512
- - Conversion always generates a pulse.
513
- - The length of the pulse in continuous mode and in single mode differs.
514
- - In single shot mode the length of the pulse indicates the conversion time.
515
- - In continuous mode the pulse indicates the end of conversion.
516
- - The polarity in single mode seems to have an inverted pulse, however it is
517
- not about the pulse, it is about the edge.
518
- - If COMP_POL = 0, a FALLING edge indicates conversion ready.
519
- - If COMP_POL = 1, a RISING edge indicates conversion ready.
519
+ - Conversion generates a conversion pulse with length depending on the data rate.
520
+ - In continuous mode it looks like there is a short pulse, but actual the long
521
+ period is the conversion pulse.
522
+
523
+ In short:
524
+
525
+ - if COMP_POL = 0,
526
+ - a FALLING edge indicates conversion start.
527
+ - a LOW level indicates converting.
528
+ - a RISING edge indicates conversion ready.
529
+ - a HIGH level indicates idle.
530
+
531
+ - if COMP_POL = 1,
532
+ - a RISING edge indicates conversion start.
533
+ - a HIGH level indicates converting.
534
+ - a FALLING edge indicates conversion ready.
535
+ - a LOW level indicates idle.
536
+
537
+ This interpretation is in line with all tests done in #76.
520
538
521
539
522
540
### Latch
@@ -568,6 +586,23 @@ mean something different see - Comparator Mode above or datasheet.
568
586
- **int16_t getComparatorThresholdHigh()** reads value from device.
569
587
570
588
589
+ ## Error codes
590
+
591
+ This section has to be elaborated.
592
+
593
+ Some functions return or set an error value.
594
+ This is read and reset by **getError()**
595
+
596
+ | Value | Define | Description |
597
+ |:-------:|:-------------------------:|:-------------:|
598
+ | 0 | ADS1X15_OK | idem.
599
+ | -100 | ADS1X15_INVALID_VOLTAGE | getMaxVoltage()
600
+ | -101 | ADS1X15_ERROR_TIMEOUT | readADC() device did not respond in time.
601
+ | -102 | ADS1X15_ERROR_I2C | I2C communication failure.
602
+ | 0xFF | ADS1X15_INVALID_GAIN | getGain()
603
+ | 0xFE | ADS1X15_INVALID_MODE | getMode()
604
+
605
+
571
606
## Future ideas & improvements
572
607
573
608
#### Must
@@ -580,10 +615,11 @@ mean something different see - Comparator Mode above or datasheet.
580
615
- Remove the experimental **getWireClock()** as this is not really a library function
581
616
but a responsibility of the I2C library.
582
617
- Investigate ADS1118 library which should be a similar SPI based ADC.
618
+ - improve error handling
619
+ - refactor values to be more logic.
583
620
584
621
#### Could
585
622
586
- - More examples
587
623
- SMB alert command (00011001) on I2C bus?
588
624
- Sync code order .h / .cpp
589
625
0 commit comments