4
\$\begingroup\$

I'd like to take an audio line level signal and feed it into the ADC on a microcontroller (perhaps an rp2040, maybe a nodemcu, haven't decided yet), and feed that into an FFT for visualization purposes.

From skimming some docs and datasheets it seems like there are a couple of issues to consider:

  • The ADC input range is typically 0-VCC (so something like 0-3V or 0-5V)
  • Line level is nominally -1V to 1V, but may have larger spikes
  • Would like to avoid spikes travelling either direction along the line

I think what I need is a virtual analog ground to translate the line level into a range more tolerable for the ADC, a capacitor to prevent DC travelling back to the source, and some diodes to clip the signal if it somehow exceeds the nominal range.

I came up with the following schematic; LineIn represents the +ve input from the line source, with its ground going to the circuit ground. V+ is the VCC voltage from the microcontroller, and ADCIn represents the connection to the ADC in on the microcontroller.

R1 and R2 seem to do a good job at translating the signal to the appropriate range. D1 and D2 clip the signal if the input is excessive (eg: If I set the sine to 10V).

I tried C1 with 1uF, 10uF and 100uF. 100uF produces a wave that appears to be more closely in sync with the input sine wave in the simulation and produce more dynamic range in the translated signal.

I'd like to avoid damaging either the audio source or the microcontroller in case of transient spikes from eg: inserting an audio jack or during power-on.

My question(s) are:

  • Is this schematic sufficient? I haven't considered current and I'm not sure what I should do about it, if anything
  • Is 100uF a reasonable value? Would it be "safer" to select a smaller number? The phase difference in the simulation bothered me at smaller values, but I don't know if it is super critical for my application.
  • Are there other factors I should consider for this?

possible schematic

Edit:

Factoring in the comments, this version:

  • Uses larger R values for the divider
  • Uses a small series resistor to the ADC
  • Uses Schottkey diodes for the clamp
  • Adds a small cap to the ADC input

revised schematic

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Seems ok. Be aware that a 100 uF electrochemical capacitor has a "polarity" ... \$\endgroup\$
    – Antonio51
    Jun 26, 2022 at 7:10
  • 2
    \$\begingroup\$ The coupling cap should be something that is not sensitive to DC bias, or it will introduce distortions at low frequencies. Electrolytic is good (positive side towards ADC) or foil caps. Don't use X5R X7R ceramics. \$\endgroup\$
    – tobalt
    Jun 26, 2022 at 7:33

1 Answer 1

3
\$\begingroup\$

What you have is a good start. Now use low drop Schottky diodes for your clamp and place a low value resister of say 3K3 between your ADC input and the 10K divider. If this is audio then phase is less important than magnitude because of the way the human ear responds so 10 microfarad is safe for your analog coupling cap. Also consider aliasing, so look at your sampling rate and consider 1 nF from ADC in to ground.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Good advise, except that 3.3k series resistance could be a bit high: Depending on the ADC, input impedance can be rather low, even down to a few kOhm. Such a large series resistor would significantly attenuate. I would recommend something like 330R. For the same reason, I would use 100k in the divider. \$\endgroup\$
    – tobalt
    Jun 26, 2022 at 7:25
  • \$\begingroup\$ Thanks! I've updated the schematic with these suggestions in mind. Do you recommend any particular schottkey diode part for this application? \$\endgroup\$ Jun 26, 2022 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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