I am trying to figure out a simple yet effective circuit to measure DC voltage using ADC whether it's negative or positive and indicate the value with the polarity (+ or -). The circuit should also be able to provide a protection against AC voltage in case an AC was connected by mistake.
The voltages I am working with are around -20V to 20V for DC, and the AC voltage that can be mistakenly connected is around 20VAC.
I learned that Arduino I/O pins have clamping protection diodes for overvoltage, with 1mA maximum limit. So a 22K (or higher) resistor to limit current would be enough protection.
Now for the DC part a voltage divider with 4:1 will keep the voltage down to 5V, but I don't think I can use the same ADC pin to measure -ve and +ve at the same time. So I need help with the circuit that can pass the +ve for example to pin A and -ve for pin B.
A simple passive resistor bipolar to unipolar circuit will convert a -20V to 20V signal to a 0 to 5V signal. If the output is 0 - 2.5V the inputs signal is -20 to 0V. If the output is 2.5 to 5V the input is 0 to 20V. For AC the Arduino cannot handle negative voltages but the output in this case will be a 0-5V sine wave. The gotcha is that if you say 20VAC and that means 20VAC RMS your peak voltage of ~28 volts would exceed the 5V and the pin input maximum and blow the arduino.
The 25K resistor is not a typical size, (although they can be obtained) is shown as one resistor in the circuit diagram but you would probably use more common resistors to obtain the 25K.
Other than that "around 20V" is not very descriptive. You need to pin down what around means to avoid exceeding the maximum pin voltage. Maybe a better description of what you are trying to do and how things like "accidentally connecting" AC happen?
I read somewhere that the built-in protection diodes are rated for 1nA (on an Uno or other board using an ATmega chip).
So with 20V and 20K more more of series resistance you should be safe.
Or you can add Schottky protection diodes which will kick-in at about 0.3V, protecting the internal silicon diodes. (You can leave-out the resistor if you already have one.)
Or, choose something close, and re-calculate. Or better yet, take a reading and compare to a multimeter and "calibrate" your Arduino code. That will correct for resistor tolerance and any other (constant) errors.
A standard straight-line calibration is an offset added/subtracted at (or near) zero (with a value of 0 for no correction) and then a slope multiplication factor at the maximum(s) or "most-expected" reading(s)". The slope is 1.0 when no correction is needed.
Problem is that 5volt might not be 5.00 volt all the time (or never). So your measurements could fluctuate. You should use a stable reference voltage, and calculate the divider for that.
For an Uno R3 that could be the 3.3volt supply.
Leo..
@jim-p is correct, however the ESD they are protecting for is not the ESD that comes from walking over the rug in December and touching the light switch. This ESD will fry the Arduino input pin.
The diodes are to protect from the small amount of ESD that occurs during handling on the bench.
Technically, electrically they should never be used.
Hello, I have a small comment regarding your circuit:
I would use a voltage reference as for the DC biasing voltage. I use LT1461 as a +5V reference. The arduino +5V is often to unstable.
Instead of the 100k R1 resistor (that wil likely fry the ADC..), I would use a voltate divider for the AC voltage too, with a 0.1uF ceramic cap towards the DC bias voltage divider. Then, you can safely get the AC voltage down to a level that do not harm the MCU. For example, if we bias with DC voltage, 2.5V, then the AC voltage could sving 0.6V RMS (0.6V x root2 x 2 => 1,7V (from top to bottom of the sine). Max voltage into the ADC is then 4.2V and min 0.8V, allowing for some safety leveles for protecting the ADC. So, we do not get negativ voltage that burn the ADC. Then, the ADC should be protected, if reading the mains voltage, as voltage spikes can occour. This can be clamping diodes, with TVS an schottky diodes and ferrites, that mitigate the dangerous voltage spikes.
This is another strange one that does not mention what the problem being solved is all about . Without more information the advice might not be the best solution
Whats the problem with 20VAC if your your DC input is +-20V dc? Is 20 VAC rms or 20 VAC pick-to-pick?
Usually the problem is the contrary, you may want to eliminate a DC component from a AC signal.
TS clearly state that the input may be 20VAC. That is 20Vrms x root2 = 28,3V height from "zero" to top on the sine, and 56,6V from top to bottom of the sine. If this ADC is not properly set with calculated resistors/divider circuit, you see the magic smoke.
I am overwhelmed by all these great inputs guys.. thank you all..
I have checked again to make sure I don't go way beyond required margins, and I can confirm the voltage is 15VRMS / 42Vp-p, this voltage source is a step down transformer.
However, perhaps I didn't make myself clear about the requirement of showing the polarity of the voltage being measured. The circuit should be able to pass the negative voltage to one pin and the negative voltage to another so I know whether this voltage is negative or positive.
If this is the case , there will be no DC component present , so still unsure what is going on here and what the OP actually wants to do and why .circuit diagram ????
β The voltages I am working with are around -20V to 20V for DC, and the AC voltage that can be mistakenly connected is around 20VAC.β
If the original high voltage has a DC component or transients on it , then he wonβt see it on the transformer output .
So I have a board that generates AC voltage with the mentioned value and a DC voltages that ranges from -20v to 20v.
I want to add a voltmeter to the board to measure the DC voltage using Arduino, but it could be that I connect the AC source to this voltmeter by mistake, and I don't want that to destroy my circuit or Arduino..
I have finally tested the circuit suggested by robertnc, and I am unable to measure negative voltage.. although the protection against AC seems to work just fine.
Here are the values to the ADC:
For 5V = 2.874
15V = 4.11
-5V = 2.06V
-15V = 2.06V
I think the current limit (set to 1A) perhaps dropping the voltage when testing -5V and -15V to around -1.7V. Or the signal is being clipped!.
For little overhead and good protection I'd use a dual op amp to provide separate +V and -V as you said here:
Look at the grounds in your circuit. Would I be right in thinking that in one of the switch positions one of the diodes in the bridge rectifier will be shorted out?