Welcome, Guest
Username: Password: Remember me

TOPIC: Using MCP3202 ADC with Raspberry Pi Zero.

Using MCP3202 ADC with Raspberry Pi Zero. 1 year 6 months ago #862

  • ES_Team
  • ES_Team's Avatar
  • OFFLINE
  • Administrator
  • Posts: 23
  • Thank you received: 2
  • Karma: 0
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-pizero.png

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 samplig rate, BUT the Rapsberry 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.
power-supply-filter.png

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-input-pin.png

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:

note: To read the ADC1
note: Using the MCP3202
Last Edit: 1 year 6 months ago by ES_Team.
The administrator has disabled public write access.
Time to create page: 0.097 seconds
Powered by Kunena Forum
Joomla SEF URLs by Artio

Our Instagram

Follow us

You can also follow us on:

facebook   google   instagram

pinterest   youtube   twitter