So, I am using the SPI interface on the Pi 2 model B to communicate with a MCP 3008 ADC chip, following the tutorial on http://www.raspberrypi-spy.co.uk/2013/10/analogue-sensors-on-the-raspberry-pi-using-an-mcp3008/ to read the ADC, and http://www.raspberrypi-spy.co.uk/2014/08/enabling-the-spi-interface-on-the-raspberry-pi/ to enable the raspberry pi. I am using 5V supplied by a 1A regulator, with nothing on that line except the ADC and the potentiometers I am reading. The Pi is a 2B, running the default Raspbian. The code is a direct copy/paste of the tutorial. I am currently getting about 8.3 ksps, but the datasheet says I should be able to get up to 200 ksps.

I want to get my code to run faster, as the ADC read time is the slowest part of it. Googling around, I found https://www.raspberrypi.org/forums/viewtopic.php?t=19489 on decreasing the latency of SPI, however, as this thread is from 2012, the patch may already be included in Raspbian.

My questions:

Given the SPI setup I used, is the patch mentioned in the 2012 forum thread included, and if not, how do I install it?

More generally, how do I increase the read rate of the ADC? Should I increase the SPI clock speed?

EDIT: Following the instructions in How do I set CLK speed on SPI for Raspberry Pi, I managed to increase the read rate to 20Ksps at 8Mhz clock speed, but I don't know if I am getting good data or just gibberish.

  • It would seem sensible to increase the clock speed to the fastest supported by your device. Have you identified where all the time is being spent? – joan Jan 2 '16 at 19:55
  • raspberrypi.stackexchange.com/questions/4884/… is a good tutorial on how to set the clock speed that I just found, I will do tests and determine if increasing clock speed will help. Results to come. – dpdt Jan 2 '16 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.