Let me first reply to the post written Sat Jan 18, 2025 6:51 pm by scruss ("the sample rate you get is never guaranteed").
I agree, but partially:
1. According to the guide by TI, the data rate variation is +-10 % (page 3). This is for a broad range of temperatures (-40 to 125 °C). I am operating the adapter under room temperature.
2. The difference I observed is much higher. For instance 50 SPS instead of 64 SPS is 21 % difference.
3. I tested two adapters with very similar results (approximately 1 % difference).
4. Even the internal oscillator would run on an incorrect frequency, the ratio between particular sampling rates should be exact. Compare the ratio 860/475 (catalogue), and 801.80/400.59 (measured)
Now, I would like to react to the comment posted Sat Jan 18, 2025 9:29 am by vffgaston.
Many thanks for the link to the guide. I found it very useful. However, the end of the chapter 4 covers a different problem. It deals with insufficiently high bit rate of I2C interface. This problem can be observed for high sampling rates. However, my problem occurs also for low frequencies which are not affected by limited I2C bit rate. Additionally, the guide deals with single shot mode where the sampling rate is affected by the RPI program. I am measuring the sampling rate during continuous mode when the rate is completely determined by the ADS1115 chip.
See the code below
The code sets the AD converter to the sampling rate of 32 SPS, takes 32 samples, and plots the data (time vs voltages). The input signal is triangle with the period of 1 sec (oscillogram below). .I would expect the 32 samples would fill exactly 1 period of the signal. However as seen on the plot, only 25 samples fit with single period (red dots) which leads to the real sampling rate of 25 SPSSo, my personal opinion is that either the adapter vendor started to use a different chip or TI changed technology without changing the guide. However, I cannot verify it, there is no usable identifier on the IO, just a label "A8 BOGI".
I agree, but partially:
1. According to the guide by TI, the data rate variation is +-10 % (page 3). This is for a broad range of temperatures (-40 to 125 °C). I am operating the adapter under room temperature.
2. The difference I observed is much higher. For instance 50 SPS instead of 64 SPS is 21 % difference.
3. I tested two adapters with very similar results (approximately 1 % difference).
4. Even the internal oscillator would run on an incorrect frequency, the ratio between particular sampling rates should be exact. Compare the ratio 860/475 (catalogue), and 801.80/400.59 (measured)
Now, I would like to react to the comment posted Sat Jan 18, 2025 9:29 am by vffgaston.
Many thanks for the link to the guide. I found it very useful. However, the end of the chapter 4 covers a different problem. It deals with insufficiently high bit rate of I2C interface. This problem can be observed for high sampling rates. However, my problem occurs also for low frequencies which are not affected by limited I2C bit rate. Additionally, the guide deals with single shot mode where the sampling rate is affected by the RPI program. I am measuring the sampling rate during continuous mode when the rate is completely determined by the ADS1115 chip.
See the code below
Code:
N = 32; Fs = 32 # number of samples, requested sampling rateimport timeimport boardimport busioimport adafruit_ads1x15.ads1115 as ADSfrom adafruit_ads1x15.analog_in import AnalogInimport RPi.GPIO as GPIOimport matplotlib.pyplot as pltimport numpy as npi2c = busio.I2C(board.SCL,board.SDA)ADC = ADS.ADS1115(i2c)ADC.data_rate = FsADC.gain = 2/3ADC.mode = 0# continuouschan = AnalogIn(ADC,ADS.P1)# channel #1 as analog inputa = chan.value# read one samople to force selecting the channel# enable alert/ready pin to indicate finished conversionADC.comparator_high_threshold = -1ADC.comparator_low_threshold = 0ADC.comparator_queue_length = 1# Callback function for conversion finished interruptdef ADC_callback(channel): global time0,t,n,busy current_time = time.time() if n == 0: time0 = time.time() if n >= N - 1: busy = False GPIO.remove_event_detect(ADC_ready_GPIO) print('End, samples = %i, time = %5.2f' % (n + 1,current_time - time0)) t[n] = current_time - time0 v[n] = ADC.get_last_result() n += 1 t = np.zeros(N); v = np.zeros(N)n = -1time0 = 0; current_time = 0busy = TrueADC_ready_GPIO = 4# ADS1115 alert/ready pinGPIO.setmode(GPIO.BCM)GPIO.setup(ADC_ready_GPIO,GPIO.IN,pull_up_down = GPIO.PUD_UP)# set as input, pull-up resistorGPIO.add_event_detect(ADC_ready_GPIO,GPIO.FALLING,callback = ADC_callback) #define callback functioon for IO4while busy: passADC.comparator_queue_length = 0# disable alert/ready signalADC.mode = 256;# stop ADCplt.plot(t[0:25],v[0:25],'.r')plt.plot(t[25:N-1],v[25:N-1],'.')plt.show() Statistics: Posted by zdenek.kohl — Sun Jan 19, 2025 7:15 pm