Thanks for that schematic, Paul. I think I understand 'clamping diodes' better now.
That may be beyond me for this project. I'm already in over my head, and if I can reach a good way to do the wiring, and to understand why, that's great for this step.
On that note...
How can it be done well without the 100K:100K divider? I don't have one, and I need to start building this. I'm sure to need a lot of time for problem solving the code. Once I get through this project, I'll be curious to learn about the role of dividers.
If I need to do the approach that Paul posted, but when I picture doing the wiring, I'm a bit intimidated. I can do it, but if there's a workable method without the two four-junction links between the resistors and diodes, that'd sure help.
Will this work? Meaning, will it protect the Arduino while still registering impact on the piezo?
That's great - thank you! If that's enough to read the piezo signal while protecting the Arudino, I'll get working on it.
To help improve my understanding,
What's the purpose of the VCC link (to 5v)? The vibration the piezo provides energy, so is the 5v link to power the signal to the Arduino? Does the A0 pin not provide any power?
Is the 1M resistor in parallel there to make the piezo less sensitive to vibrations across the room?
What's the problem with the plans that included zener diodes? I see that they provide no protection when the Arduino is off, but it looked like the 5.1V was also not a good choice? Post #12 gives some info, but the article linked in post #15 sure makes it sound like a 5.1V zener is a good way to limit directional voltage to that amount. What more should I know?
Without the 100K to ground, what would this circuit fail to do? I get how the 100K to the VCC helps protect it, and I'd like to see why to include the one to ground.
Nothing to do with power.
It moves the piezo mid-voltage, about 2.5volt. So the A/D can catch positive peaks as well as negative peaks. This makes the circuit fast and sensitive. You might not need that sensitivity for what you're doing.
The resistors limit current, so the two clamping diodes that are already inside the Arduino can't be overloaded. Like the 10k that is used in the diagram in post#21.
That diagram should be good enough for what you're doing.
Don't overthink it.
Leo..
No, the piezo is actually a capacitor, so there is no other DC path to actually determine the voltage on the analog input. However with a 1M plus 50k in series, you may have some difficulties with repeatedly reading the analog input.
The article linked in post #15 may be rather misleading. If you actually examine the curves given, you will seen that the Zener conduction is anything but sharp; it has very significant internal resistance. To use Zeners as a voltage reference you must arrange to operate them at a constant current (not to mention temperature compensation).
This is why diodes - even not Schottky - to ground and the supply rail are the proper approach. For a digital input where you only need to reasonably exceed a Vcc/2 threshold, a 3.7 V Zener would be appropriate but this would interfere with analog measurements.
As explained by Wawa, nothing to do with protection as such, but setting a resting value from which the ADC can detect changes of either polarity.
I read every post here, but some statements become clear with explanation. I saw the whole piezo as a 'brass disk,' but now I see the earlier statement meant to connect the brass side - not the white ceramic - to the 100K pair. I'll do that and get it running today.
There's a scene in Mr Holland's Opus where Mr. Holland complains about a student who isn't learning his lessons, despite putting in effort. A fellow teacher notes that if Mr. Holland can't teach a willing student, he needs to turn his critical eye on his teaching, not his student.
That's the piezo I'm using and the schematic that seems closest to getting consensus among the the competing arguments. See above about the skepticism of applying zeners here.
Would you suggest one of the previously posted plans, or something different?
I've been appreciative about suggestions here and diligent in trying to understand them. I read every post in the thread and think about each before responding.
But as a newcomer, I'll naturally misunderstand some directions when they're given with sparse explanation. And like anyone learning, I may need some concepts explained a different way before fully grasping them.
Enough on that and back to the project. Your code looks a lot like what I've come up with, along with values that seem to work. If there's anything I should do to refine the code for this, I'd be glad to.
// these constants won't change:
const int knockSensor = A0; // the piezo is connected to analog pin 0
const int threshold = 550; // threshold value to decide when the detected sound is a knock or not
const int threshold2 = 470;
// these variables will change:
int sensorReading = 0; // variable to store the value read from the sensor pin
void setup() {
Serial.begin(9600); // use the serial port
}
void loop() {
// read the sensor and store it in the variable sensorReading:
sensorReading = analogRead(knockSensor);
Serial.print("Sensor Reading = ");
Serial.println(sensorReading);
// if the sensor reading is greater than the threshold:
if (sensorReading >= threshold || sensorReading <= threshold2) {
// send the string "Target hit!" back to the computer, followed by newline
Serial.println("Target hit!");
}
delay(100); // delay to avoid overloading the serial port buffer
}
The sensor readings are more fiddly than I expected, with 'hits' (for now, I'm tapping the piezo) returning values just outside the threshold limits. I've kept those limits as narrow as the range of values returned when I'm not tapping the piezo.
I'm building the target now, and if I can get that to work, I'll mark this as 'Solved' with Leo's post from #22, unless another post makes more sense. I'll also add notes that may help any other newcomer hoping to do a similar project.
Tom, I appreciate the help, but I'm really new, and I'm not sure how to read your suggestions. Can you please help with these questions?
'Strange' that the voltage will go up to 9v, or 'strange' to read that someone claims it would do so?
Is the first schematic showing you should expect up to 9V in with that arrangement?
And can you help me understand the second, suggested schematic? I get the R2 to ground and the R1 to VCC, but the horizontal leg is less clear to me.
There's a capacitor, even though the piezo is also a capacitor?
the AC inputs on both sides correspond to the two wires of the piezo? One gets wired to the capacitor, and the other to A0 and VCC - with no resistor - and both join the line with resistors R1 and R2?