Using MCP3202 ADC with Raspberry Pi Zero.

6 years 10 months ago - 4 years 5 months ago #862 by ES_Team
Raspberry Pi does not include any analog-to-digital converter, so an external ADC is needed to process input audio. The MCP3202 from Microchip is easy to find, cheap, through-hole and the specifications are not bad at all.

The MCP3202 is connected to the raspberry Pi using SPI interface and requiring 4 lines: cs, clk, miso, mosi (check this if you want to learn more about the SPI interface)

ADC Power Supply:
The MCP3202 accepts power supply voltages from 2.7 to 5V. The sampling rate increases with the power supply voltage:
  • Vdd=5V, sampling rate 100Ksps[/li.
  • Vdd=2.7V, sampling rate 50Ksps
5V would be the ideal power supply for high sampling rate, BUT the Raspberry GPIOs work at 3V3 and they are not* compatible with 5V voltages. This issue could be overcome using level converters on the SPI lines but at the expense of complicating the circuit and adding 4 or 8 more parts.
* Not compatible in theory because some users reported that you can directly connect a 5V slave SPI device to a 3.3V Pi (against what Raspberry recommends).

Using a 3V3 power supply on the ADC results in a simpler and direct circuit, the sample rate is not the maximum but still good for audio processing.

Power Supply Filtering:
Raspberry Pi Zero 5 volts are directly taken from the USB connector, this source of power is noisy with a considerable ripple. To help with that pedal Pi uses two C-R-C filters (one on 3V3 and another on 5V) plus another 100nF caps placed very close to the ADC rails and the op-amp rails. These 6 caps and 2 resistors minimize the noise inducted on the audio signal.

Analogue input pins:
The guitar signal is amplified (to reach 3.3Vpp) and filtered (to avoid aliasing) before the ADC with one op-amp. The input pins are protected by clamping diodes so no extra protection is needed. Otherwise, external clamping diodes would be needed not to damage the input ADC pins when the input analog signal goes over 3.3V.
MCP3202 Software Configuration:.
The BCM2835 libraries are used to manage the ADC SPI bus communication, they are easy to use.
The block diagram is like this:

This is a sample code that will read the ADC0 and print the value on the screen:
www.electrosmash.com/forum/pedal-pi/244-...nd-adc-pedal-pi-code

note: To read the ADC1
note: Using the MCP3202
Attachments:

Please Log in to join the conversation.

4 years 5 months ago #1997 by sean5447

This is a sample code that will read the ADC0 and print the value on the screen:


I think you forgot to post the code. Is it still available somewhere?

Thanks

Please Log in to join the conversation.

4 years 5 months ago #1998 by Ray
sorry, yes. Have a look at this code, it prints the ADC on the screen (and other interesting values):
www.electrosmash.com/forum/pedal-pi/244-...nd-adc-pedal-pi-code

Please Log in to join the conversation.

4 years 4 months ago #2035 by santisk
Hello all,

Is there some way to know what is the exactly sampling frecuency? I'm trying to apply a reverb effect in a higher lever way (using the impulse response of the room as a filter) and I would need to know exactly the sampling frecuency of the guitar signal to match it with the impulse response one.

I'm trying to play the signal using 40ksps as you said it's supposed to be around, but it seems that it's not working. I would be gratefull if you provide with some information/approaches tosolve this problem.

Thank you in advance.

Santiago.

Please Log in to join the conversation.

Time to create page: 0.074 seconds
Powered by Kunena Forum
Joomla SEF URLs by Artio