2

TL;DR: I have virtually no knowledge of electrical engineering and I want to know if I can connect this ADC to a Raspberry Pi 3 and be able to read 15+ piezoelectric sensors at a very low latency (≤ 3ms)?

My electric drum module is starting to fart out and I'm trying to avoid spending hundreds of dollars on a new module. At the very least, I'm trying to make something that can detect the drum pads being struck and send the appropriate MIDI note to a computer. Eventually I might look into trying to use the Raspberry Pi (or comparable, more powerful system like the Orange Pi or one of the Pine64 boards) to generate sound too, but if that's impossible I'm okay with that.

The drum pads are just piezoelectric sensors (not sure on the voltage, though I can plug headphones straight into the pads and "hear" it being struck, if that helps.) Each pad plugs into a 1/4" cable (TS for single-zone pads, TRS for dual zone) which all snake together into a DB25, very much like this cable. Right now the kit has 15 channels (3x single-zone pads and 6x dual-zone pads), though I went for this 28-channel PIC16F1519 ADC since it's only a couple bucks anyway and that leaves a LOT of room for expansion. IIRC MIDI notes represent "velocity" (in this case, how hard the pad is struck) with only 7 bits (0-127), so a 10-bit ADC seems A-OK, unless again there's more to this than I know.

I'm just curious if it is possible for me to connect the ADC to the Raspberry Pi's GPIO and use it to "listen" to the piezo's at a reasonably low latency (no more than a couple of milliseconds, since I also need to consider sending MIDI notes and synthesizing sound on a computer), and if so, how hard would it be? Just soldering/plugging into a breadboard? Posts like this have me hopeful, but I just want to make sure. I'm familiar enough with C/C++ and Python that I could Google my way through writing the software side, but I'm simply too ignorant of how the hardware works.

  • 1
    The PIC chip you've chosen is a programmable chip. It's a microcontroller which can communicate with the Raspberry Pi through SPI. From the datasheet, it seems it's possible to program the device "in circuit" if the circuit has supporting interface circuitry... This chip is not a beginner's chip. I typically use Atmel AVRs for this sort of application. However, I also have a general purpose chip programmer... I would recommend using a single purpose ADC, like the MCP3008 ... two of them... – RubberStamp Dec 11 '17 at 0:45
  • Here is an article I found informative on using the MCP3008 with Raspberry Pi with an experiment. hertaville.com/… Here is my github with the test application I used with a link to the lesson from the kit vendor I used, Osoyoo. github.com/RichardChambers/raspberrypi/tree/master/project07 The author of the article mentions an estimated max sampling rate of 20K samples per second. – Richard Chambers Dec 11 '17 at 3:08
  • Thanks for the tip, RubberStamp. I'd heard of the MCP3008's but was unsure if I would be able to squeeze 3 (or more!) of these MCP3008's on the Raspberry Pi 3? I'd assume that the GP in GPIO would imply I could use any pins (excluding ground and power pins) on the GPIO header and connect them to the MCP, but the Adafruit tutorial refers to specific pins and I'm too ignorant of the subject to know whether my assumption is correct. – Cowbell Dec 14 '17 at 18:27
  • Richard Chambers, thanks as well for referring me to the MCP3008. If you also know the answer to my above comment I'd love to hear it. I'd also like to ask if this understanding of the sampling rate is too naive or if it is correct: 20K samples per second = 1/20k seconds per sample = 0.00005 seconds per sample, meaning I'd theoretically have a latency of 0.00005 seconds? – Cowbell Dec 14 '17 at 18:33
1

To answer your question, yes, you can connect PIC16F1519 to your Raspberry pi. You can use SPI (low latency) to interface with the microcontroller.

The project won't be easy if you don't know anything about EE. Some EE and programming knowledge is required.

You need to program your PIC in C or Assembly to scan the ADC channels and output channel data to SPI. Your PIC microcontroller will act as SPI master and Raspberry Pi will act as slave. You would need to install programming tool chain (MPLABX - free from Microchip) on a PC/Laptop and buy programming hardware to physically program the flash memory of PIC.

In addition, you would need to design input filters for your ADC inputs as a single piezoelectric sensor could output more voltage that the ADC input can accept. Here is an article on piezoelectric sensors and design. A sample input stage schematic is below. The resistor values would have to be chosen as per your sensor spec (from datasheet).

sample input stage

On the other hand, you need to write software for Raspberry Pi to accept the data from SPI port and process the data as you wish.

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.