1

I am using Raspberry pi 4 and I want to connect three MCP3008 ic. I am a little bit confused about how to SPI MISO and SPI MOSI and chip select of Raspberry pi to Dout Din and CS of each of the three MCP3008 ic's

Note: I need to read from the ics at the same time and DO NOT switch with them

Thanks in advance

MCP3008 schemetic diagram

Omar Alaa
  • 21
  • 3

3 Answers3

2

If you just need all 3 ADCs to sample at the same time, you can do this by connecting all the clock signals together on one Pi O/P pin, all the MOSI signals together to another O/P pin, and all the CS signals together onto a third Pi O/P pin. Connect the 3 MISO signals to individual Pi I/P pins.

Now write some 'bit-banging' code to set the CS line low, then toggle the clock while outputting the command to the ADCs on the MOSI line, then keep toggling the clock and read the result on all 3 MISO lines simultaneously. This will give you 3 values that are very accurately aligned together, as requested.

What this won't give you is an accurate time-spacing between each measurement cycle; you can try triggering the code from an periodic interrupt, but it will be subject to pauses and delays due to higher-priority processes interrupting the transfer; maybe around 100 microseconds of jitter in the time-interval, but this very much depends on what else the CPU is doing.

If you also want accurate time-intervals between measurements, the code gets much more complex; I suspect it may be possible using SMI (Secondary Memory Interface) but it won't be easy.

jayben
  • 597
  • 2
  • 4
0

You connect all of the MISO (Master In Slave Out), MOSI (Master Out Slave In), SCLK (SPI Clock) together and to the appropriate pins on the pi. The CS\ (Chip Select) is an active low pin that enables the A/D converter so it will communicate with the pi. Each CS\ will need to be assigned to a different GPIO pin on the Pi. Only one of the pins is allowed to be asserted low at any given time. This is done to select that individual chip so you can communicate with it. If two or more are selected you will get garbage.

Your question was not clear, the parts you chose to my knowledge are not designed to be sinked.It sounds like you need a simultaneous converting A/D. Do a google search for "simultaneous converting A/D" there are many good ones available. This will allow you to convert all channels at one time then read the values sequentially. This is a SWAG as you have not given more details of your project such as data rates etc.

Gil
  • 1,288
  • 6
  • 5
0

Your question keeps changing.

If you WANT independent, simultaneous conversion (depends on your definition of "simultaneous") you NEED to use different SPI devices. Although it is not clear WHY the small conversion time of MCP3008 would be a problem with sequential reading.

The BCM2711 has 6 (although not all are accessible on Pi4). I have only used SPI0, SPI1 but there is Device Tree support for all (in various combinations).

Milliways
  • 62,573
  • 32
  • 113
  • 225