Protecting ADC Inputs

I am nearing the finishing stages of a project to test the capacity of battery packs. If the proper selections are not made, it could result in 24V being connecting to one of the ADC inputs. What protection circuit can I add to protect the ADC. Would a Zener diode and resistor be enough?

Would a Zener diode and resistor be enough?

Yes - [u]Over-voltage protection circuits[/u]. But, I'd actually recommend a [u]voltage divider[/u] (2 resistors) and if the 24V is well-regulated you wouldn't need the diode. (Both wouldn't hurt)

There are actually "small" protection diodes built-into the ATmega chip but they are only good for a few milliamps so you still need a resistor, and again some external protection "wouldn't hurt".

If this is 24VAC, you need to also protect from the negative-voltage swing. The Zener will do that, or you can use the two diodes (as shown in the above link.)

P.S.
Of course, the ADC won't be of much use if your voltage is always clipped/clamped at 5V.... If you want to read/measure 0-24VDC you'll need the voltage divider.

I want to maximize the resolution when working 0-5V versus 5-24V. So I have the resistor divider for 5-24V, but there is a chance the 24V will be connected while set for measuring 5V. How to protect the input in this case?

P.S. It is 24VDC. It's from a battery pack that will be drained during the test, so the voltage will start in 24V range and fall to ~20V.

A 5:1 voltage divider will work. Unless you have charge voltage then use a 6:1. Also put your max input voltage or if 24 is max then put a 24vdc zener in parallel with the voltage divider.

How will that protect when the 24V battery is connected and it is set for a 5V test?

On another note... if 24 is your normal max, then I would build the colt divider to put it closer to 3vdc. That way you can see the drops still and spikes won't be as much of an issue... still use the zener as mentioned but use a slightly higher voltage.

I have a voltage divider for 5-24V tests. I don't need one for 0-5V and don't have one. So how to protect the 5V input from being connected to 24V (or more than 5V) by mistake?

Oh... gotcha. I don't know. Don't make a mistake. Could you post a schematic?

To big to post the whole thing. The input section to the ADC is a SPDT relay. COM to ADC, NC to center of resistor divider, NO to the battery directly.

If you use the internal voltage reference ( around 1.1volts) you can scale you voltage ( restore divider) input to suit .
The ADC pin is still safe to 5v , so you automatically get 5x your full scale voltage protection .

Eg if you scale you divider to 12v full scale , the input is protected upto 60v input .

I agree. If they do it correctly. If they connect the 24V battery and set it to the low voltage test (0-5V). then the smoke comes out. How do I make a protection circuit for this case?

The point of the question seems to be missed. Any voltage 0-24V can be applied at the from of the soon-to-be-machine. If 0-5V then select Low Voltage, if 5-24V then select high voltage. The High Voltage option utilizes a resistor divider to cut the voltage to 0-5V. But there isn't any way to prevent them from connecting 24V and selecting Low Voltage. What protections can be added for this case?

The standard protection scheme is to bolster the internal protection diodes with schottky diodes, and
add a series resistor large enough to limit the current to safe values.

In particular you have to consider fault currents raising the Vcc rail too high - so adding a voltage
clamp (or crowbar) to the Vcc rail is advisable.

adwsystems:
I agree. If they do it correctly. If they connect the 24V battery and set it to the low voltage test (0-5V). then the smoke comes out. How do I make a protection circuit for this case?

Use the same voltage divider for both 5 and 24V, when reading switch to internal analog reference for reading 5V and switch back to default for 24V readings. No more protection needed.

Ciao, Ale.

Use an adequately high resistance for the voltage divider. Calculate it so the worst-case fault voltage gives about 1mA into the Arduino's protection diode which conducts at 5.5V. Remember the bottom resistor is still conducting so don't forget to subtract its current.

Do NOT use a zener diode on an analog input. The zener curve means that it conducts a significant current (micro-amps) below its nominal voltage. A 5.5V zener will distort readings below 5V.

A TVS diode has a sharper response than a zener but the main purpose of a TVS is to clamp high-voltage low-energy events like a static electrical zap. It won't survive more than a few milliseconds with a direct connection to a 24V battery.

ilguargua:
Use the same voltage divider for both 5 and 24V, when reading switch to internal analog reference for reading 5V and switch back to default for 24V readings. No more protection needed.

Ciao, Ale.

That is a really cool solution. Probably got lucky with the the turn down of the voltages (24:5) being about the same as the turn down ratio of the references (5:1.1).

Can you not have a 5v rail and 24v rail? Then and measure both with separate analogInputs

LandonW:
Can you not have a 5v rail and 24v rail? Then and measure both with separate analogInputs

I'm not sure I understand. There is no rail, there is only one item with those voltages, the battery. The battery does not power the system. The battery is an input to the system, that can vary in two range, low =0-5V and high =5-24V.

How will this be powered? And if you are sensing 24v then you have potential for a 24v rail. Obviously you know that.... I f you use the switch method as described in other posts. I would maybe use a SPDT relay to close the 24v sensing circuit via button press and with the button press you can switch the ADC you are reading from in the software. (0-5v or 5-24v. As per your descriptions)

It is power from a 120VAC to 12V power supply via the DC jack. The 24V battery will never be connected to a power rail. The switch method does not, can not, guarantee the switch is in the correct position when the battery is connected; which may be connected before or after the unit is plugged into the wall.

Have you started building this yet?
Why are you using 120vac to 12vdc to 5vdc?
Does the 12vdc power anything else?
Why is there a 0 to 5 need along with a 5 to 24?
Since you haven't provided a schematic, I will draw one when I get home from work.