0

I want to read analog inputs from piezo sensors like these on Raspberry using python, which ADC do you advise me with 8 or more channels and how to wire and program it to get digital values?

tlfong01
  • 4,384
  • 3
  • 9
  • 23
Miky
  • 133
  • 4
  • 14
  • I have been playing with more than 10 ADCs this year, but never for piezo sensor. I read the follow article to know more: "The Ultimate Guide to Acoustic Guitar Pickups for Stage and Studio" https://ehomerecordingstudio.com/best-acoustic-guitar-pickups/. I always thought that you connect the sensor output to the input of a power amp. In other words, no ADC is needed. But if you can show me a weblink for your requirement, I can try to recommend an ADC for you. I tend ot think that ADC speed is perhaps at most of the order 1k samples per second, so that is not HiFi indeed. – tlfong01 Sep 23 '19 at 00:44
  • You might like to read my answer to this question for more details: https://raspberrypi.stackexchange.com/questions/102009/reading-analog-value-rasberry-pi – tlfong01 Sep 23 '19 at 00:47
  • You might also find this Q&A helpful: https://raspberrypi.stackexchange.com/questions/98201/adc-with-raspberry-pi-to-record-sound – tlfong01 Sep 23 '19 at 00:48
  • Thank you, in the meantime I bought a MCP3008. I didn't get the weblink to what did you ask me? I linked the piezo sensors I'll use. I read [here](https://my.eng.utah.edu/~cs5789/handouts/piezo.pdf#page=12) and elsewhere to use a 1M Ohm resistor and a 5.1V zener diode, but that's for Arduino, I don't know if on Raspberry it is the same – Miky Sep 23 '19 at 01:20
  • Well, you know Rpi does not have a ADC pin like Arduino, so you use MCP3008 ADC. Which ADC to use depends on your application. For example, for mole mallet hitting detection, MCP3008 is not a good choice, https://www.youtube.com/watch?v=VoP1E9J4jpg. If you let me know your project, perhaps I can recommend better ADCs! :) – tlfong01 Sep 23 '19 at 03:53
  • My goal is to build a musical instrument that reads piezo sensors inputs and plays samples at a volume proportional to the vibration in input. – Miky Sep 23 '19 at 06:36
  • Ah let me see. You might like to read my answers to the following questions. I have also answered about pressure/weight sensors but forgot which forum. Perhaps I can goggle later. (1) https://raspberrypi.stackexchange.com/questions/96259/connecting-32-magnetic-sensors (2) https://raspberrypi.stackexchange.com/questions/98440/multiple-gpio-buttons (3) https://raspberrypi.stackexchange.com/questions/99817/detect-multiple-button-presses-on-circuit – tlfong01 Sep 23 '19 at 06:59
  • I think I'll need a 1M Ohm resistor for each piezo, here's another Arduino example https://www.youtube.com/watch?v=vi-w_WqJjzQ he didn't use a zener diode, but I'd use it as protection from big voltages, not sure which voltage – Miky Sep 23 '19 at 08:42
  • Ah, the midi drum youtube is really good. For the resistor and zener diode, I guess you can do experiments. Since you have the Arduino code working, it should be not that difficult to port it to Rpi. By the way, why you want to use Rpi, as Arduino or Mega can already do the job well. – tlfong01 Sep 23 '19 at 09:00
  • Because I need more memory to store samples and I'll do some processing therefore a Pi is more powerful. I'm not so good in electronics so I need some help for the circuit to avoid damaging the Pi. – Miky Sep 23 '19 at 09:08
  • I agree Rpi is a good choice, if you want more memory and processing. And there is little risk of frying your Rpi, because you are using ADC as the middle guy to do the analogue to digital conversion. So you will fry the ADC first, and when you see white smoke coming out, or smelling burning plastic, you still have time to pull the plug. Furthermore, a cheapy ADC cost you only 2 US dollars, I suggest you to get a couple for frying. This ADC module is what I usually recommend to newbies to fry! :) https://www.electrodragon.com/product/pcf8591-adc-dac-adda-analog-digital-converter-module/ – tlfong01 Sep 23 '19 at 09:27
  • 1
    isn't there a more scientific way to build the right circuit without frying anything? :) – Miky Sep 23 '19 at 09:51
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/98987/discussion-between-tlfong01-and-miky). – tlfong01 Sep 23 '19 at 12:14
  • 1
    Shopping recommendations are off-topic here, but as your comment indicates you bought an MCP3008 (which is generally a reasonable choice), you could write a question about that if you show some work. Be advised, however, that, there are several questions about that here as well as tutorials online. – Brick Sep 23 '19 at 16:01

1 Answers1

-1

Question

/ to continue, ...

Answer

Update 2019sep26hkt1626

I googled and found other circuits using a 5V PSU and connects 1M and piezo in series across the PSU. I found without the Zener, the piezo output spikes +-30V. This concludes that piezo output can burst many times up to 30V beyond 5V power. If the same PSU is used to power Rpi, than there is a risk of frying the Rpi.

piezo test


Now I am using a 5V Zener diode to clamp the 30V+ piezo signal to under 5V. The very high spike gets clamped down, and the following smaller wavelets look OK.

So next step is to try to use MCP3008 to sample the signal. The wave packet is less than 500mS long, amplitude smaller than 5V. So MCP3008 should be able to handle it.

Note - I have first connected the Zener diode to the Piezo, and then the Zener diode to the MCP3008 ADC. In other words, MCP3008 is directly connected to Zener (at points X, Y of picture below), NOT to piezo (points A, B). This way, even if the Zener is disconnected by a careless newbie mistake, any high pulse generated from piezo will not travel to the MCP3008, frying it and its master Rpi.

piezo

I tested the piezo disk torn down from another piezo buzzer and found the finger tapping output signal of a different shape from the first one. Anyway, I think the output amplitude under 5V and period of about 500mS good for MCP3008 to do conversion.

piezo test 2

I once played with electromagnetic buzzer and used a little audio amplifier to amplifier the buzzer audio output. Now the piezo also outputs audio range signals, so I am thinking of doing the same thing.

buzzer amp

/ to continue, ...

References

(1) Piezo Pickup Transducer 27mm Contact Microphone Trigger - Discs Elements for Acoustic Instrument: Guitar, Drum, CBG etc. with Leads $6.99/12Pcs

Resonant frequency: 4.6 +/- 0.5 KHz

Resonant impedance (ohms): 300 max

Plate material: Brass

Great for: Acoustic Instrument Pickups, Stomp Boxes, Contact Mics, etc...

(2) MCP3008 SPI 8 Channel 10 Bit ADC Datasheet - MicroChip

/ to continue, ...

Appendices

(A) Piezo with 1M, no Zener, One slight finger tap gives 30V peak

I was curious to know how high would be the piezo output voltage, without clamping it with a Zener diode. I surprisingly found it as high as 30V! This would fry both the MCP3008 and and it master Rpi!

piezo output

Conclusion: Zener diode is absolutely necessary!

(B) Piezo Buzzer Tearing Down

piezo buzzer

/ to continue, ...

(C) The Schematic

Now I am trying to use the RpiSO's built in CircuitLab schematic editor to draw my piezo toy. This editor is newbie friendly. I dragged and pasted the symbols, draw connecting wires, and finally saved and inserted. My masterpiece was automatically inserted here, with the HTML lines inserted along, no need to go outside to ask Imgur for help. Another good thing is that the RpiSO CircuitLab account tlfong01 is automatically created for me. So next time I came back and found my pictures ready for more "final" strokes! One thing not perfect though, is that I cannot "paint" the objects. I need to go outside and asked my PS for help.

...

schematic

simulate this circuit – Schematic created using CircuitLab

tlfong01
  • 4,384
  • 3
  • 9
  • 23
  • did you use the same piezo? I can't understand why I've seen many on Arduino not using the diode. So I'll need a 1M Ohm resistor and a 3.3V Zener diode for each piezo right? – Miky Sep 23 '19 at 20:42
  • Well, (1) Arduino is stronger than his weak sister Rpi, (2) My little finger tapping might only cause a baby lightning, while a heavy blow generated lighting might strike something fatal., (3) 99 other reasons, ... :) – tlfong01 Sep 24 '19 at 01:36
  • Last evening I searched my junk box and found a piezo buzzer. I tore it down and found the piezo disk, also 27mm in diameter. But my piezo is higher class than yours : it has a center tap for oscillator feedback. I checked that the oscillator is working, / to continue, ... – tlfong01 Sep 24 '19 at 01:53