WillPowellUk / MCP3464-ADC

Driver for the ADC MCP3464
2 stars 1 forks source link

Small errors #1

Open nhatminh2h opened 2 years ago

nhatminh2h commented 2 years ago

Hi,

I have tried compiling the code for an Arduino Nano and have a few compiler errors:

  1. This seems to work only with the mbed OS compiler.
  2. Serial.printf does not exist as a function in the Serial library. I have worked around this with sprintf and print.
  3. The SPI function is deprecated as the Arduino SPI library has now changed. Also a trivial fix.

I can submit a pull request for these issues.

I would like to ask what is the function of of the "Interrupt Wrapper for Static to Non Static Conversion" at the beginning of the .cpp file.

WillPowellUk commented 2 years ago

Hi,

Thank you for your notes and I appreciate your PR offer.

This library was designed for ESP32 hence why the printfs won't work.

Please go ahead and send a PR to make it compilable with Arduino and ESP32. I was unaware of the SPI depreciation, but will test after the PR.

About the Interrupt Wrapper, this is a work around for passing a non-static method, in this case the dataReadyInterrupt fn. Please see this explanation for more detail.

Will

tawat25 commented 1 year ago

Hi , I am developing project with MCP3464. I need to read sampling data at 10ksps i have test at 1 sps is ok , but at 10 sps it not ok . i got same value . Can you advise me to solve this problem. in data sheet specify to 153 K. but only 10 sps not work.

WillPowellUk commented 1 year ago

Hi @tawat25,

I do not have enough context to help you, but I will try to give you some things to check:

  1. Check the hardware, most importantly, are you using an interrupt? This interrupt pin should be connected to an interrupt compatible pin.
  2. Are you using an internal or external clock? You can use an external oscillator up to 20MHz I belive or use the internal one at 4.9MHz.
  3. Is the SPI behaving as expected, is it set to the correct speed (max 20MHz on arduinos)?
  4. Change the OSR (oversampling ratio) which can increase/decrease sampling rate

It is a very complicated chip, and the datasheet is not an easy read. Only use this chip if you need to!

Hope this helps, Will