# Zener diodes to protect microcontroller inputs

Discussion in 'General Electronics Chat' started by deweyusa, Apr 22, 2010.

1. ### deweyusaMember

Joined:
Feb 23, 2008
Messages:
42
Likes:
0
Hi

I have a question about protecting a microcontroller's analog inputs. I have a PIC that I'd like to use to measure an analog signal up to +5VDC. I was planning on using a standard voltage divider, consisting of two resistors in series, with the input going in the top of the upper resistor, a ground on the bottom of the lower resisotor, and a 3.3V zener in parallel with the lower resistor. The input to the controller would come from the node between the resistors:

Since the PIC can take a max of 3.6V on an analog input, and I've heard a lot of talk of the soft knee of most zeners, I was thinking of making the resistors equal in value, so the max the PIC would see in normal operation would be theoretically 2.5V (half the max input). It might serve to effectively lower the precision of the ADC's result a little, but would hopefully add a little protection to the circuit.

Now the question: I have seen a few app notes from Microchip that show a "typical" resistance to a PICs input in the range of 470K. However, I've seen many zener datasheets that show a "test current" in the neighborhood of 20mA. I'm assuming that is the amount of current it takes for the zener to kick in, and notice that many datasheets don't promise much unless you operate the zener at the test current.

If so, that would mean I'd need at least 20mA available from the input through the top resistor to divert through the zener to ground in a protection scenario, which, if I'm doing my math right, means half the input voltage drops over the top resistor, half the bottom one. This means at max input, 3.6V / 20mA = 180 Ω, which just seems dangerously small for a processor's input to me. Am I missing something? Would I want a further resistor to the right of the middle zener node, between the node and controller to limit current? If so, what would a safe range for it normally be?

Also, I've heard about these TVS devices as an alternative to a zener. But, I can't seem to ascertain whether they are made for sudden, ultra-high voltages (as in static spikes), or for continued slightly-higher than normal inputs (like someone hooking up +12V to an input designed for +5). Is a TVS made for sustained overvoltage conditions? Is that usually a concern in microcontroller input protection, or is static the main worry usually?

-Josh

2. ### ericgibbsWell-Known MemberMost Helpful Member

Joined:
Jan 4, 2007
Messages:
21,321
Likes:
649
Location:
Ex Yorks' Hants UK
ONLINE
hi,
Whats the value of R1 and R2.??
The PIC analog input expects a source impedance of less than 10K in order to run at its optimum rate.
If you examine the datasheet for the PIC it shows two clamp diodes on the input.
One connected to +V and the other to 0V, IIRC these diodes can sink 20mA, which means if you have a source resistance that limits the input current, to say 10mA, due an over voltage, these diodes will protect the PICs input.

3. ### Gary BNew Member

Joined:
Nov 4, 2009
Messages:
289
Likes:
7
Location:
Daytona Beach, Fl.
Most times, I have seen limiters built with two diodes clamping the input line to ± power and a series current limiting resister. In your case, I would use your zener to build a voltage source set to 2.6 v. That plus the diode’s forward drop will clamp at the maximum allowable voltage and still leave most of the operating range of the input in its linier range.

Joined:
Jan 12, 1997
Messages:
-
Likes:
0

5. ### Nigel GoodwinSuper ModeratorMost Helpful Member

Joined:
Nov 17, 2003
Messages:
39,380
Likes:
665
Location:
Derbyshire, UK
ONLINE

As Eric has pointed out, PIC's already have protection diodes on almost all pins (although there is the odd exception, covered in the datasheet).

6. ### Ubergeek63Well-Known Member

Joined:
Apr 16, 2008
Messages:
1,886
Likes:
37
zeners are notoriously inaccurate... clamp signals to the rails with diodes

7. ### deweyusaMember

Joined:
Feb 23, 2008
Messages:
42
Likes:
0
Hello all, and thank you very much for the help. Eric, you mentioned source impedance. Am I correct that you treat the positive and ground rails as the same node, then calculate impedance (in this case parallel resistance) between that node and the one between the two resistors and that is your source impedance?

-Josh

8. ### ericgibbsWell-Known MemberMost Helpful Member

Joined:
Jan 4, 2007
Messages:
21,321
Likes:
649
Location:
Ex Yorks' Hants UK
ONLINE
hi,
I would also consider the R1||R2 combination as the total resistance.
What range of source impedance are you expecting.?

EDIT: this image is based on the PIC's datasheet,

#### Attached Files:

• ###### AAesp01.gif
File size:
28.8 KB
Views:
776
Last edited: Apr 26, 2010
9. ### deweyusaMember

Joined:
Feb 23, 2008
Messages:
42
Likes:
0
I'm afraid that's an unknown for me. I'm hoping to offer a general analog input for sensors...but I'm afraid I don't know what the majority of their source impedances will be. I know one of them is a simple potentiometer-like water level sensor that is 10K across its fixed terminals.

Am I also correct that by matching source to load, you will see 1/2 of the power transfer to the load? (Does that apply to AC only, or DC too?)

Thanks again
-Josh

10. ### ericgibbsWell-Known MemberMost Helpful Member

Joined:
Jan 4, 2007
Messages:
21,321
Likes:
649
Location:
Ex Yorks' Hants UK
ONLINE
hi Josh,
The matching impedances is not an issue with the PIC's analog input as its impedance is very high so it will impose a minimal load on a source impedance of ~ 10K.

The point you have to consider is the sampling rate of the analog signal when the source resistance is high, if you want optimum accuracy you must give the PIC's internal adc capacitor time to charge/discharge to the 'new' signal level.

If the sampling rate and acquisition time is long when using a higher than recommended source resistance, adding a small value capacitor from the adc pin to 0V will allow the charge on the small cap to charge the the internal capacitor.

In cases where the source resistance is very high a common method is to use a non inverting amplifier between the signal source and the adc pin.
A OPA [amplifier] has a very high input impedance a low output impedance.