I've put in a zener diode to help regulate over excess current frying the Arduino, but is it in the right place and will that actually do what I hope it will do?
I made these plans as I'm using two sensors, and I'm not sure I completely followed the drawings and descriptions that were laid out in the above posts (and in several of them the images are no more).
OK both will not work I am afraid.
A zener diode breaks down at a specific voltage, therefore to protect an input you have to have it between the input and ground.
But basically the whole idea is flawed for an analogue input because the diode starts to conduct before the specified value and that will distort the signal you are truing to measure.
This might give you some ideas.
I've put in a zener diode to help regulate over excess current frying the Arduino,
No it does not protect against excess current but excess voltage. But it is not the current that kills an input because the impedance is so high hardly any current flows at all. It is the excess voltage that kills things.
OK, so now I think I get it (better). Thanks for the gentle dope slap. Thoughts below, with followup questions in bold.
Did some homework over the weekend, and think I've got this just about solved. Had looked at the digikey diagrams, and not sure I understood them. Looked at them again, and I'm still not there 100%. I do know that I had the zener diodes backwards and in the wrong spot (thanks!). Also, having them at 5.1V for the zener voltage would cause the scale to be off as you allude to, but only as we approach the maximum (I think; see below). I'll be using these sensors between zero and half maximum, so the current draw should be minimal.
So, what I propose to do is go with the 5.1V zener diode in a more appropriate location. I could also put in a switch to take it off line when calibrating at maximum pressure. With that, I bring you plan C (minus the switch):
Does that look more reasonable?
--Extraneous content removed by user--
I'm thinking I could also install a resetable fuse like this one from SparkFun:
Even a 5V1 zener will start conducting in a non linear fashion at about 3V, as I said you should not use them like this in an analogue circuit.
However you could use that switch not for calibrating but to see how much it effects the reading, or is that what you are going to. The diodes however are in a much better place.
Fuses are very slow in electronic terms and will not protect anything. In fact the Arduino will blow first and protect the fuse. The resettable ones are even slower some can take up to 60 seconds to blow, so they offer no protection against surges.
A zener diode is useless in most cases.
It only protects when the Arduino is on, but not when you (accidently) turn it off.
Inputs can't handle more than 0.5volt above and below VCC (VCC = 0volt when off).
They also introduce non-linearity errors.
A (very slow) polyfuse is also useless to protect an input.
I think you're overthinking things.
Drop everyting.
Use a 51ohm resistor (E24 1%) for the current sensing. Or two 100ohm in parallel if you can't get it.
That will only cut 1volt from your 12volt sensor supply.
Now measure the voltage across the 51ohm resistor with 1.1volt Aref enabled in your code.
Same resolution, and higher stability than default Aref.
For protection, use a 10k resistor between the 51ohm resistor and the analogue pin, and a 100n capacitor from analogue pin to ground.
The pin now stays in range (0-5volt) upto ~100mA sensor current.
The 10k resistor protects the pin to at least +15volt and -10volt by limiting internal pin clamping diode current to <1mA.
The 10k/100n make a low-pass filter that kills (line) spikes.
Leo..
Thanks GM and Wawa. Ok, I'm convinced now. Less overthinking. Gone are the fuses, gone are the zener diodes, and here comes an addition of some capacitors. In short, I bring you Plan D:
Plan E will have the 100n caps from the analogue inputs to ground, as explained in post#4.
This simple test program should work. You should see ~200 without pressure.
Leo..
int value_1;
int value_2;
void setup()
{
analogReference(INTERNAL); // use the internal ~1.1volt reference | change (INTERNAL) to (INTERNAL1V1) for a Mega
Serial.begin(9600);
}
void loop()
{
value_1 = analogRead(A1);
value_2 = analogRead(A2);
// print to serial monitor
Serial.print("A/D value 1 is: ");
Serial.println(value_1);
Serial.print("A/D value 2 is: ");
Serial.println(value_2);
Serial.println("");
delay(1000); // one second between measurements
}
OK, now I think I have it. Thanks Outsider for catching my sloppy labeling, and wawa for steering me in ever closer directions and correcting my mistakes.
So, the capacitor needs to move relative to the resistors, but it can still go to the board gnd, right?See if this version looks better:
I also went ahead and made a new and improved simulated version (for fun) of the circuit along with "static shock" and "12V" momentary switches to see how well the circuit works for filtering out little and large zaps with and without a capacitor (switch on capacitor). Can also play with the capacitor size. See what you think:
The spike simulator does not include a diode (inside the Atmega chip) between A0 and Arduino's 5volt rail.
That clamps the spike to about 5.7volt (and negative spikes to about -0.7volt).
Leo..
Alright, good deal, thanks Leo! Something more like this (diode shown as external to the arduino box for clarity): New simulated circuit? I hadn't realized that there was a protection diode there in the first place. That's a nice feature.
Thanks so much to everybody for your input on this project. I'm sure this won't be the last question I have, but I feel like I have a good path forward with this part of the project.