2

I would like to find out how many samples per second this ADC im using is capable of with a raspberry pi using i2c and python SMBUS2 library, but i dont know where to start.

As far as i know this depends on: CPU speed (how fast python runs), i2c speed, ADC sampling rate.

I would like my python program to return at least 10,000 values per second from the ADC.

Since the raspberry pi is running linux and the python program is a process with not all cpu power concentrated on it, it will be hard to determine how many times the pi can retrieve data from the ADC per second consistently. Example code of how many times python can increment a counter in 1 second:

import time
import smbus

cnt = 0
condition = True

ST = time.time()
ET = 0

while condition:
    if (time.time() > (ST + 1)):
        condition = False
        ET=time.time()
    cnt += 1

    #code for reading ADC potentially here: ADC_val = bus.read_byte_data(adr, Ain)


print(cnt)
print(ET-ST)

On my laptop with i5 @ 2.3 GHz it returned about 2.4 million times through the loop in 1 second.

The raspberry pi (actually im using a "vocore 2" a single board computer - similair to pi) returned 30k in 1 second.

The ADC (maxim MAX 11605 i2c version), supports i2c speed of 400kHz and 1.7MHz and is HS mode (1.7Mhz) it can do 188ksps and in FS mode (400kHz) it can do 44ksps.

So my question is, if CPU speed didnt matter, at an i2c speed of 400kHz of Pi and ADC and thus 44ksps from the datasheet, how many samples would the ADC deliver? 44ksps? Is the 400kHz relevant here?

Im grateful for any help or tips to find out more about i2c and ADC in general (and calculating sampling time), thank you

  • I guarantee you won't be cpu limited, the bus transaction speed will be your limit. – vicatcu Nov 25 '20 at 01:41
  • Assuming you want more-or-less periodic measurements, keep in mind that latency can be up to 0.5ms with the standard kernel, and that chip has 12 bytes of RAM- what does that suggest? – Spehro Pefhany Nov 25 '20 at 01:43
  • All the bits transferred on the bus are not sample data though, right? – vicatcu Nov 25 '20 at 01:57
  • @vicatcu but doesnt the python counter speed test prove that CPU speed is a limiting factor? if my SBC can only increment a counter 30k times a second then how is it meant to use smbus and i2c communication 10k per second? thats what confuses me, isnt that a lot more intensive than just incrementing a counter? – BetweenBeltSizes95 Nov 25 '20 at 08:34
  • @SpehroPefhany i dont understand what you're trying to say, the SBC is too slow / underpowered? i thought it would be powerful enough, it has 128Mb of RAM and a 0.58GHz CPU specs are here: (https://vocore.io/v2.html) – BetweenBeltSizes95 Nov 25 '20 at 08:37

0 Answers0