Maker Pro
Maker Pro

What cap, what resistor?

Johan_Ha

Apr 26, 2017
13
Joined
Apr 26, 2017
Messages
13
In another thread I showed this circuit:
Shocky.png
This is supposed to be a peak detector. The piezo creates one pulse (due to a hit on a board by a ball). The capacitor C1 gets charged and holds the voltage. Then Micro:bit reads the voltage at P0 and resets the voltage with a signal from P3. My problem is that a shock from the piezo raises the voltage only a bit. Next shock raises it again, and again and again. The cap is probably too big, the piezo obviously delivers only a very small charge, though the voltage is probably rather high, some 5 V.
So my first question is how to figure out the proper size of the cap. It should reach the max voltage with only one pulse from the piezo (or any lower voltage, if the shock on the piezo is smaller).
My second question is to figure out why there's a continuous raise of the voltage at C1, even if there's no piezo activity. Only sources are P0 and the piezo. The piezo might produce a voltage due to sound, or it just lying somewhere, where there's mechanical vibration. How could I stop leak into the cap from anywhere else, when I'm only interested in the piezo pulse?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
You should probably use a proper peak and hold circuit.

See here.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
If you have weak pull up on P0, or if it sources leakage current, you'll slowly charge the capacitor.

The circuit you have would need to use a very small value of capacitor because the piezo sensor cannot generate a significant current.
 

AnalogKid

Jun 10, 2015
2,896
Joined
Jun 10, 2015
Messages
2,896
I can state with perfect authority: Yes, the capacitor is too big.

ak
 

Johan_Ha

Apr 26, 2017
13
Joined
Apr 26, 2017
Messages
13
I put a .47 uF cap there and just using a multimeter it seemed to work. Though the cap seemed to discarge through itself and the piezo. Of course it discharged through the multimeter, too, but also while the multimeter was not attached. But that lasted several seconds and is not a problem. A bigger problem is the microcontroller charging the cap while waiting for the piezo pulse. Would a proper peak detector circuit be better isolated from the microcontroller?
 

Johan_Ha

Apr 26, 2017
13
Joined
Apr 26, 2017
Messages
13
Yes. Although I jumped from thing to thing. I just watched more thoroughly. I didn't pay attention to the precision thing, because I thought I wouldn't need it. After watching again, I'm still not sure whether the circuit with two opamps will be unaffected by my microcontroller.
 
Top