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