piezo sensor/How it works/04. Four parts, one hump
How it works · 04 of 9

Four parts, one hump

A tapped disc rings, swinging both ways at a few kilohertz for a few milliseconds. The diode throws away every swing below 0 V, the 1 kΩ and 100 nF smooth what is left into one hump, and the 1 MΩ drains it in about a tenth of a second. Take any one away and the reading gets harder or worse.

A tap rings

A tap does not bend the disc once. It bends it, and the plate springs back past flat, and back again, ringing for a few milliseconds at a few kilohertz (the seller rates it as a buzzer at 5 kHz). So what the disc makes is a voltage swinging both ways, dying away fast. Four parts turn that into something a sketch can read.

Four parts, one hump
The board
Filter corner
about 1.6 kHz
Falls to a third in
about 120 ms
Readable hump
yes
A tap sets the disc ringing at a few kilohertz. The diode swallows every swing below 0 V, so what is left only pushes one way; the 1 kΩ and the 100 nF smooth it into a hump; the 1 MΩ drains the hump in a tenth of a second or so. One tap, one hump, easy to read.

Pick each version. The first window is the first 4 ms, where the ringing happens; the second is the first 400 ms, where the charge drains. Both are the shape each circuit gives, drawn with this book's model numbers, not measured.

What each part does

The diode (D2, an SS14) is cathode to the disc's node, anode to GND. When the ringing swings the node below 0 V, the diode conducts and empties that half into GND. The positive half it leaves alone. So every cycle adds a little charge one way and none the other, and the ringing becomes a one-way push. Without it the ringing reaches SIGNAL both ways and averages to nothing within a few milliseconds.

The 1 kΩ and the 100 nF (R8 and C4) smooth that push. Together they take 0.1 ms to charge by about two thirds, so anything much faster than about 1.6 kHz is cut down, and the ringing arrives at SIGNAL as a hump with a little ripple on it. The 100 nF also takes most of the disc's charge: it is larger than the disc's own capacitance (the disc's sheet gives no figure; this book's model uses 20 nF), so SIGNAL ends up at a fraction of what the bare disc would show. That fraction is what makes it safe to read most of the time.

The 1 MΩ (R9) drains the hump. With the 100 nF and the disc behind it, that takes about a tenth of a second to fall to a third, and the diode's own small leakage makes it a little quicker. The owner's bench log on an Uno shows it: a tap read as 1.8 V fell to 0.4 V two readings, about 0.2 s, later. Without R9 the charge has nowhere to go and the reading stays up.

Why this shape suits a sketch

A hump that rises in a millisecond and falls over a tenth of a second is easy to catch: a sketch reading every millisecond or two sees the top of it, and one reading every 20 ms still sees most of it. A tap is a hump works out how often is often enough.

When it does not work

Why not wire the bare disc straight to an analog pin?

Because then the pin sees all of the disc's voltage, ringing both ways, instead of a smoothed share of it: tall spikes that can pass the pin's limit, gone in a few milliseconds, below 0 V half the time. The board's four parts are the reason a slow loop can read a tap at all.

It reads near the top with nothing touching it.

Something is pulling SIGNAL up. INPUT_PULLUP on the pin puts tens of kilohms to the supply against the block's 1 MΩ to GND, and the pull-up wins: on an Uno SIGNAL then sits near 5 V. analogRead needs no pinMode at all; if the sketch sets one, make it INPUT.

Would a smaller resistor than 1 MΩ make it faster?

It would drain faster, and a note on the schematic says the designers tried 10 kΩ and saw little change in sensitivity. But the hump would then last about a millisecond instead of a tenth of a second, and a sketch would have to read far more often to catch it. The board ships with 1 MΩ.

Where this goes next

What stands between a hard blow and your pin.

How high it goes →

Edit this page — content/books/piezo-sensor/four-parts-one-hump.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Piezo-Ceramic Sensor

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum →