robert-hh / ads1x15

Micropython driver for ADS1115 and ADS1015
89 stars 26 forks source link

Sampling rate problem #8

Open rboot071 opened 2 years ago

rboot071 commented 2 years ago

Hi here is the function I used for sampling at 860s/s.
i2c = I2C(1,scl=Pin(15), sda=Pin(14), freq=400000) ads = ads1x15.ADS1115(i2c, addr, gain) def sample(adc = ads.read_rev, data=data, timestamp = timestamp, voltage=ads.raw_to_v): global index_put, irq_busy for i in range(860): if irq_busy: return irq_busy = True if index_put < _BUFFERSIZE: ads.set_conv(7, 0) data[index_put] = ads.read_rev() index_put += 1 i +=1 irq_busy = False irq_busy = False index_put = 0 Here is what I get with a 40Hz Sine: Screenshot 2022-03-17 011346

I don't know if it is my ADC or a problem in my code! Any response is greatly appriciated :)

robert-hh commented 3 months ago

Sorry for responding late. I just noticed it. If I count right, I see 19 sample point at the 40Hz sine. That is equivalent to a data rate of about 760 samples. That seems OK, given that the data transfer takes time as well.