adafruit / Adafruit_MCP3008

MCP3008 8-Channel 10-Bit ADC
MIT License
24 stars 14 forks source link

SPI CLOCK #9

Open simontpellier opened 3 years ago

simontpellier commented 3 years ago

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:

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 ??)

caternuson commented 3 years ago

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

simontpellier commented 3 years ago

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 .

caternuson commented 3 years ago

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.

ettoreleandrotognoli commented 1 month ago

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