0
\$\begingroup\$

I am very new to hardware design and am making an optical detection circuit using a photodiode. I simply need to interface with the photodiode and save the output voltage values on Arduino IDE

Hardware setup:

  • Photodiode (BPW21R) connected in transimpedance arrangement with 100K feedback resistor and OPA350 op amp
  • Output signal from the transimpedance amplifier is connected to CH0 on the ADC (MCP3302)
  • Op amp and ADC to be powered to +5V using Arduino Micro power pin

ADC <-> Arduino Micro Connections:

  • VDD and VRef <-> +5V Power Pin
  • CS/SHDN <-> RX_LED / SS
  • DIN <-> MOSI
  • DOUT <-> MISO
  • CLK <-> SCK

MCP3302 ADC Arduino Micro MCU

My two questions are:

  • Are my connections between ADC and Arduino Micro correct to communicate by SPI protocol?

  • In Arduino IDE, how can I edit the code so that the Arduino Micro receives data from the ADC by SPI protocol and displays it in the serial monitor?

    #include <SPI.h>

    void setup() {

    pinMode(SS, OUTPUT);
    pinMode(MISO, OUTPUT);  
    
    digitalWrite(SS,HIGH);
    Serial.begin(115200);
    

    }

    void loop() { byte c;
    digitalWrite(SS,LOW);

    Serial.println(analogRead(MISO));
    
    digitalWrite(SS, HIGH);
    delay(100);
    

    }

\$\endgroup\$
2
  • \$\begingroup\$ Why are you using an external ADC with the Arduino? Have you read the header file for SPI.h to see what functions are available and to see which pins should be used? Is your Arduino operating at 5V or 3.3V? \$\endgroup\$ Sep 18 at 21:13
  • \$\begingroup\$ The external ADC provides higher resolution for my needs, and the Arduino is operating at +5V. I can use the ICSP headers on the Micro for SPI as outlined in SPI.h, however, how can I adjust the current code that I have to receive data? \$\endgroup\$
    – Kevin
    Sep 18 at 21:54
0
\$\begingroup\$

This is NOT how an SPI ADC works.

Your approach is mixing the digital and the analog worlds in the weirdest way possible.

The external ADC stores the data bytes in a register after data is sampled. Values must be queried using the appropriate commands through a library or custom set of instructions using the SPI communication protocol

The way you are trying to read the value from the ADC by expecting an analog value in the MISO pin is simply wrong and makes no sense.

Read the device's manual and figure out what commands you need to send to it to request the digitised values.

Also, get a good understanding on how the SPI protocol works. That's going to be extremely helpful.

This library might be of help: https://github.com/bakercp/MCP3XXX

I reiterate, as many wise men use to say: RTFM!

\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.