5

I'm hoping to interface a Raspberry Pi 4 with an 8 channel, 48 kHz ADC. Ideally a 24 bit ADC, which if my math is right means 9.216 megabits per second. But a 16 bit ADC would be acceptable: that would bring the requirement down to 6.144 Mbit/s.

I haven't selected the specific ADC yet, so I have some freedom to choose one that supports an interface most amenable to the Pi.

I imagine the Ethernet and USB interfaces are capable of this speed, but for reasons of cost and simplicity I have to rule those out. I've yet to find an ADC that interfaces with Ethernet. There are a few with a USB interface, but they are aimed at low-cost consumer electronics and have insufficient performance for my application. Of course there are professional USB audio interfaces with excellent performace, but they cost an order of magnitude more than the Pi which would rather defeat the purpose.

Bit-banging in Python or even C over the GPIO pins, if it can work at these speeds at all, probably won't leave enough CPU to do anything useful with the data.

So I'm looking at the hardware peripherals like I2C, SPI, I2S, etc. Documentation on these is pretty scant, and it's not always clear if the limits of what actually works differ from the limits of what's configurable. So I thought I'd ask: has anyone been down this road that can confirm an interface that would meet my required speeds?

Phil Frost
  • 161
  • 7

3 Answers3

4

When sampling parallel ADC's the synchronization becomes more problematic than the raw bandwidth. You have not really made it clear what your application is but I assume audio.

Your quickest turn around would be to use a COTS sampling device over USB at the best performance point you can afford.


Simultaneous sampling ADC's are an option but generally have specalized application and complex interfacing, for example ADS7850 Uses the SPI clock to sample at up to 750KHz on two channels simulataneously, but streams the data to two SPI inputs at once, known as "Dual SPI", there is also Quad SPI (QSPI), neither is supported on the Pi.

enter image description here]1 From ADS7850 Datasheet

Multiplexed ADC's are out of the question for audio applications, as they typically do round robin sampling which is fine for process control (e.g. temperature) but not for audio sampling. An example of a high perfomance multiplexed ADC is the ADS1256

enter image description here Image from ADS1256 Datasheet showing the round robin channel cycling of the ADC

So you are left with the option of sampling 8 ADC's in parallel

That mandates a low level interface, that is, 8 USB devices will not suffice. Too much jitter and overhead and very difficult to synchronize for audio sampling purposes.

Typically one sees SPI in the domain. (High Precision, moderate sampling rate)

Unfortunately SPI is a serial Bus so that means we are looking for devices that have onboard data buffers and support SPI Clocks of >10MHz* . Because we still need to clock the data out of the SPI bus before the next sample comes around

We also want devices that can be mutually synchronized so that they complete a conversion at the same time and sample the same portion of time as one another.

An example of this is the ADS1255 device which is a single channel variant of the ADS1256 above, however this device does not support 48KHz sampling, but it does have synchronization pin that can be used to synchronize multiples in parallel.

enter image description here

You would issue syncs to all the devices at once and then read the sample when ready.

So to support your application I would look for:

  • Single Channel ADC
  • SPI Interface
  • 48Ksps
  • 24Bit
  • External Sync
  • Internal Buffer
  • Support SPI clock 10 MHz

And get 8 of them. Unfortunately the ADS1255 is only up to 30KSPS

* You can split sampling across the 3 SPI buses on the RPI and reduce the clock rate requirement

crasic
  • 3,033
  • 1
  • 11
  • 20
4

There is a big difference between 6..9 MHz clock speed (which according to the BCM2835 datasheet is derived from 150MHz core_clk with a power-of-two 16-bit integer divider CDIV, I assume the Pi 4 is similar) and 6..9 Mbit/s data rate which you won't achieve if you can only read 2-3 bytes at a time. The overhead of IO library and drivers will limit you to tens of thousands SPI transfers per second.

If you find an ADC that can be configured to buffer samples and them stream them over SPI in large chunks, it may just work with a direct SPI connection. However, ADCs which require you to read out the last sample before they can produce a new one will require external buffering.

Look at FT42XX products: those are USB to SPI/Quad SPI bridges supporting up to 30 Mbit/s clock rates. FTDI offers drivers for ARMv7 and ARMv8 as a part of their libft4222 package, so there's a good chance those bridges will work with a Pi.

Digikey sells FT4222H modules for $18 a piece.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147
3

To answer your topic question.

The SPI peripheral can work at those speeds. I2C can not. I do not know about I2S.

However I have not heard of any software which allows continuous SPI readings at those (or any other) rates. I doubt it is possible without periodic interruptions.

As you suggest bit banging via software is out of the question. I doubt it would work in assembler in bare metal let alone under Linux.

joan
  • 71,852
  • 5
  • 76
  • 108