I have this circuit and I am running code on the raspberry pi which checks the input pin continuously and converts the 10-bit digital signal to a readable voltage. So I can accurately see the voltage being generated.
I intend to stick the piezo disk onto an instrument to detect the note being played by the instrument this would require mimicking a sound wave so I can find the frequency and then the pitch of the note.
This is a graph showing the voltages when the E string of a guitar is played and the piezo is stuck to the body. To get a more accurate reading I would need the negative voltages. (x-axis is time and y-axis is volts)
The circuit only gives me values between 0-5v (0-1023), however, a sound wave would have negative voltage. Could anyone explain to me how I would alter my circuit to give readings between -5v -> +5v instead of 0-5v.
I have read this link and a few others : Read Positive and Negative Voltage in Arduino
but don't fully understand how they work.
Also, the datasheet recommends using an op-amp to buffer, filter and gain the original signal, but I am already getting 5V readings when I hit the piezo so could someone explain to me what an op-amp would do to my readings (other than amplify them)?
Also, can anyone tell me when I have a 0.02V reading all the time?
Thank you.
simulate this circuit – Schematic created using CircuitLab
Datasheet for the ADC: http://www.ee.ic.ac.uk/pcheung/teaching/ee2_digital/MCP3002.pdf
Piezo I am using: https://www.sparkfun.com/products/10293
Best Answer
This is likely the basic error in the ADC when connected to a source of very high impedance (1Mohm in parallel with the piezo). It is likely that ADC "doesn't like" high impedance signals and also any input bias currents will create a sizable DC error as you have seen. This is what the data sheet says: -
As for centralizing the signal, and assuming 1Mohm shunt resistor, split it into 2x 2Mohm resistors; one to ground and one to the reference voltage used by the ADC. You might also consider putting a 1 kohm resistor in series with the ADC input pin because, from what you said in your question, there could be significant voltages produced by the piezo and the 1 kohm would off some protection.