Closed WizardTim closed 3 years ago
This pull request resolves #27, #35, #43.
New
Took 10.003 s to acquire 33000 samples.
Configured:
Requested = 3300 sps
Reported = 3300 sps
Actual:
Polling Rate = 3298.86 sps
99.97%
Skipped = 2
Repeats = 444
Conversion Rate = 3254.48 sps (estimated)
Plot of time.monotonic() error in comparison to time_next_sample at ADC read (3,300 sps jitter target is 303 μs)
Bugs: Will often skip first 1 or 2 samples, I suspect this is due to the following line however I don't think it's worth the trouble to change it. https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15/blob/c513e9ec6681e7f458a08d439f268b7c27585b6a/adafruit_ads1x15/ads1x15.py#L180
New Fix it skipping 1-2 samples on the first acquisition due to setup time, still skips 1 sample every so often with >1000 samples
Took 0.303 s to acquire 1000 samples.
Configured:
Requested = 3300 sps
Reported = 3300 sps
Actual:
Polling Rate = 3298.52 sps
99.96%
Skipped = 0
Repeats = 27
Conversion Rate = 3209.46 sps (estimated)
Sorry. Just now seeing this.
So this essentially looks like you've implemented something like suggested here? https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15/issues/35#issuecomment-501747400
Sorry. Just now seeing this.
So this essentially looks like you've implemented something like suggested here? #35 (comment)
Yes pretty much although this implementation is a bit more advanced to make sure the sample rate doesn't drift or over-sample to catch up. It also uses a blocking while
loop instead of time.sleep(SOME_DELAY)
in order to achieve better timing at the cost of power consumption.
Yep. Thanks. Looks like you also tested it, so I'm fine with merging. If this was useful for you, hopefully will be for others trying to use fast read.
Previously polling rate (apparent sample rate) was limited purely by I2C speed, script will now wait a full conversion cycle until it next reads the conversion result.
Requires #61 to be merged first.
With
RATE=250
andi2c_baudrate=1000000
(1 MHz)Old
New
Also constrains polling rate at any other valid sample rate, eg.
RATE=3300
andi2c_baudrate=1000000
(1 MHz) New