I build a circuit for measurement of round about 50V with a simple voltage divider. As it is a high voltage I like to avoid a melting PSU or something else if I put on the battery with wrong polarity.
The arduino should check if a battery is connected, it is for supervision only. I use a voltage divider to bring down the voltage to 4V. So the voltage should be -4V at the analog input if I put it on in reverse.
How can I protect the circuit at best from a wrong connected battery. The Charger has a reverse polarity protection so the Arduino is missing only.
What is the value of the resistors ? Because the Arduino gets a negative current through its internal ESD protection diodes. So this is about negative current, not negative voltage.
Which Arduino board do you use ?
You can use a voltage divider with three resistors to measure -50V to +50V.
Looks good.
It's anyway easy to calculate. Take the extreme voltage you get with respect to the pin; deduct 0.5V for the diode, and make sure the resulting current is less than 0.5 mA. Those diodes can handle about 1 mA so that's a safe value.
So in case of +50V on the pin: effective voltage is 50V - 5V (supply voltage) - 0.5V (diode) = 44.5V. That requires at least 89k of resistance to limit the current to 0.5 mA.
And in case of -50V on the pin: effective voltage is 50V - 0V (ground) - 0.5V (diode) = 49.5V. That requires at least 99k of resistance to limit the current to 0.5 mA.
That circuit shows 147k between the "akkus" points and the Arduino pin.
Another thing: for more stable and accurate measurements bring down the voltage to <1V and use the internal 1.1V reference (remember to calibrate this, as the 1.1V has a 10% tolerance so the absolute value varies board to board). That way you're independent of the inevitable fluctuations in your 5V supply.
NILSRO:
Is this enough resistance for a simple protection?
Yes, as wvmarle explained, only those resistors is okay.
Fun fact: no one knows how much current the internal ESD diodes can have. There is a Application Note that says that for AVR microcontrollers 1mA is no problem. Some have a bad circuit and push 10mA trough those diodes and that does not seem to harm them.
When you use the USB to power the Arduino Nano Every, the reference voltage will be the 5V from the USB bus. That is unreliable.
When you use the 1.1V internal reference, then you might use a higher value for the resistor to the battery, making it even more safe.
Is the Arduino Nano Every a MegaAVR board ? Then you have a number of internal voltages to choose from.
Do you use two batteries ? Or do you connect both terminals to one battery ? I assume that you have two batteries.
About the protection circuit in the link by DVDdoug: I'm very unhappy with that. They are not okay for an Arduino. With a low resistor current, the resistor and zener diode might get hot. With a high resistor value, the zener diode leakage current might leak away a big part of the current. The second one with two diodes is also bad, because those two diodes will be parallel to the internal ESD diodes. That gives no extra protection.
The second circuit with the two diodes can be used, but then with an extra resistor between the diodes and the Arduino input. For example 1k. That circuit with high values for a voltage divider (1M or more), possibly using two resistors in series for the high voltage, makes it possible to measure hundreds of volts and withstand voltage peaks from an inductive load. The diodes can be the 1N4148. I use such a circuit to measure the voltage of a Geiger counter.
However, for a DC voltage below 100V or 200V, then only resistors if often enough.
Yes, using two batteries but it’s the same for one. Want to keep the question simple.
The internal reference of the every with 4.3V is as reliable as the 1.1V according to the datasheet. I like to get the resistor at low as possible as I read it is better for the measurement.
So as the resistance is enough I am really happy and surprised. Learned something new. Thanks a lot.