Adafruit_MCP3008 icon indicating copy to clipboard operation
Adafruit_MCP3008 copied to clipboard

SPI CLOCK

Open simontpellier opened this issue 4 years ago • 4 comments

Thank you for this library, works perfectly ; however, I would like to report an observation which seems to allow an improvement.

Indeed, I was initially very disappointed by the measurement speeds. I compare below 4x6 measurement cycles:

  • arduino NANO ADC pins : 600 microseconds
  • ESP32 ADC1 pins : 1100 us (!)
  • MCP3008 (on ESP32) : 800 us

What I wanted to point out is that by only changing the SPI clock => spiCLK=8000000 ; I get in combination with the ESP32 a much better time of 330us. Without noticing that measures are less accurate.

(BUT MAYBE IS THERE A DISADVANTAGE I DIDN'T (yet) DETECT ??)

simontpellier avatar Aug 15 '21 17:08 simontpellier

The datasheet has information about SPI clock timing. Max freq depends on VDD, but shouldn't be over 3.6MHz. Minimum freq is ~10kHz: image

caternuson avatar Aug 18 '21 17:08 caternuson

Hello, thank you for your response and time. I took some time to watch this ... and in the end I'm pretty lost!

first, no way to find the indicated datasheet secondly, I read this for myself:

[image: SPI.jpg] and thirdly, in use, reading SPI at 8Mhz is confirmed fully operational. so I don't understand the reference to a 3.6MHz clock frequency ??

regards

Le mer. 18 août 2021 à 19:53, Carter Nelson @.***> a écrit :

The datasheet has information about SPI clock timing. Max freq depends on VDD, but shouldn't be over 3.6MHz. Minimum freq is ~10kHz: [image: image] https://user-images.githubusercontent.com/8755041/129947517-1eb82cf7-4279-4528-a18a-08ec61bea704.png

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/adafruit/Adafruit_MCP3008/issues/9#issuecomment-901312545, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANE265O7G7GRBBF6VYPM4ATT5PXRJANCNFSM5CGL552A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

simontpellier avatar Aug 27 '21 10:08 simontpellier

There's a link to the datasheet on the product page: https://www.adafruit.com/product/856 Here's the Microchip (makers of the MCP3008) product page which also has a link: https://www.microchip.com/en-us/product/MCP3008

It sounds like you are seeing an increase in ADC read speed by increasing the SPI clock frequency. While that may decrease the amount of time it takes to get a reading back, the limitations in the datasheet should be considered to insure the readings are good.

caternuson avatar Aug 27 '21 14:08 caternuson

So the 200 ksps are never reached because of the SPI clock limitation? There is a way to increase the communication efficiency? Like reading more than one channel at once?

For example:

Increase the size of this buffer https://github.com/adafruit/Adafruit_MCP3008/blob/94e5003152294bf6877da976e079af476de3544f/Adafruit_MCP3008.h#L44-L48

And read more channels here? https://github.com/adafruit/Adafruit_MCP3008/blob/94e5003152294bf6877da976e079af476de3544f/Adafruit_MCP3008.cpp#L106-L116

ettoreleandrotognoli avatar Aug 20 '24 20:08 ettoreleandrotognoli