Page 1 of 2

Protecting PIC inputs?

Posted: Sun Sep 09, 2007 9:52 am
by MrAl
Hi there,

I was wondering how you might protect your PIC inputs.

In the drawing, the normal range of input voltage for each input
is 0 to +5 volts, but there may be excursions up to 10 volts in
either direction.
The top PIC is shown getting a minus 10 volt
input applied to its series 1k resistor, and the current flows
into the PIC1 through its protective diode D2 (conventional current
flow). This seems to be ok as long as the current rating of D2 is
not exceeded. The current flow is shown as red arrowheads.
The bottom PIC however is getting a plus 10 volt input applied
to its series 1k resistor. The current flow is shown as violet
arrowheads and can be seen supplying part of the load current
for both pics as well as flowing back into the 78L05 regulator.
If the current is higher than the load current of the PICs it could
raise the +5v line to as high as +10 volts !!

I am wondering how other people protect againts this second
problem where the input goes a little higher than expected.

I've considered zeners and more load on the +5v supply.
The zeners might interfere with the signal measurement
and the extra load adds to the supply demand on the regulator.

Keep in mind however that if we put a zener on the input then
that means we have to put a zener on EVERY input, of which there
could be 8 or more with one PIC chip so that would mean 8 zeners
for one chip!

Also note that the max current requirement of the internal protection
diodes isnt that hard to meet in this application, so i was thinking maybe
one zener across the +5v line in case it tried to go too high. Anyone
ever try this?


Posted: Mon Sep 10, 2007 5:41 am
by ecerfoglio
If the input pin can go to +10V then the current may be 10V/1k = 1 mA into a 0V supply or (10V-5V)/1k = 500 microA if the supply goes up to 5V.

If tte minmum current used is more than the number of inputs times 500 microA there is no problem.

If not, you can add a zenner (perhaps 5.5V or 6V) across the supply.

In a high power system, if the zenner's power (V x I) is more than say 400 mW to 1W, there are crowbar circuits in which a zenner triggers a SCR across the supply. They are (were?) used to protect the load in the event of the power supply failing to blow a fuse.

Posted: Mon Sep 10, 2007 6:16 pm
by MrAl
Hi ecerfoglio,

Well, 10v with 1k is actually 10ma, a little higher than 1ma, but
now that you mention it the actual max current into the pin will
be only (10-5)/1k which is 5ma, which is a little better anyway.

I'll try the zener idea i guess. I didnt really want to get
as complex as a crowbar circuit to try to keep it simple.

Posted: Thu Sep 13, 2007 5:34 am
by rshayes
Hello Al,

Zener diodes can be used for protection, but they can be tricky.

The breakdown voltage is usually measured at a fairly high current. There is also a fair tolerance on this measurement, usually 5 or 10 percent. The obvious choice for a 5 volt supply woould be a 5.1 volt zener (assume 10 percent). Except that this zener may conduct its test current at a voltage as low as 4.59 volts, which means that it will conduct with the supply voltage alone.

Working the other way, assume a 5.5 volt supply (5 volts plus 10 percent). The minimum zener rating would have to be at least 6.1 volts to guarentee that a low zener combined with a high supply will not conduct the test current of the zener current under normal conditions.

It gets worse. Low voltage zener diodes quite often have a soft knee, and may start conducting substantial current well below the voltage measured at the test current. The test current may be tens of milliamps, but with a soft knee, the current may be in the milliamp range as much as a volt below the rated voltage.

So you choose a 7.5 volt unit. Now, a 10 percent high unit with a sharp knee may not start conducting until the applied voltage is 8.25 volts.

In other words, you have a grey area between 5 volts and slightly over 8 volts where your clipper may or may not work.

You might consider the TL431 type of device instead of a zener diode. These are more stable, and the regulation voltage can be trimmed to close tolerances using trimming resistors.

Another alternative is to use two resistors and a zener on each input. The first resistor goes from the signal source to the zener cathode (anode grounded). The resistor value might be in the 1 K range. The second resistor would go from the cathode of the zener to the PIC input. This might also be in the 1 K range. The zener will limit the input voltage to something between 5 and 8 volts. At 8 volts, the maximum current to the PIC input woould be less that 2.5 milliamps, which may be less than the load current.

Posted: Thu Sep 13, 2007 11:30 am
by MrAl
Hi again,

I found a zener that conducts at 4.7 volts in my old parts bin, but i like
your two resistor + zener solution better because that sounds more
practical for building more than one circuit. I was hoping to get
away from having to use parts on EVERY input, but now that we've discussed
it a little bit i see that it might be something that can not be gotten
around. So i guess you are suggesting to use two resistors plus a 6.2v zener?

The only thing i dont understand is where did you get your notes on
the voltage tolerance of the zeners? You are basically saying that
a 5.1v zener (dont need anything lower with the weak knee) voltage
can vary from 4.6v up to 5.6 volts at 25 deg C right? Wouldnt the
manufacturer bin the parts based on their zenering voltage?
It's been a while since i looked at the finer points of zeners.

More about the voltage tolerance of zeners...
Also, the part that i found in my old bin was 4.7 volts and sure enough
it draws low current when connected through a 1N4001 diode to +4.98 volt
regulated supply (1 or 2ma) but when connected directly to +4.98 volts
it draws the full regulator current of 100ma and pulls the supply
down to 4.7 volts or a tiny bit higher (4.75 volts max). Could
i have gotten that lucky to find a part that works exactly as it's
voltage rating indicated? BTW this is working at 25 deg C but i could
look up the temp co at some point too.

I also like the shunt regulator idea as that would be very accurate.
I was hoping to get away from adding another ic, but that is a smaller
device anyway so maybe it wouldnt be that bad.

Posted: Thu Sep 13, 2007 7:56 pm
by rshayes
Hello Al,

Most of this shows up on the data sheet for the zener diode. The Motorola databooks had these data sheets. They may be on the ON Semi web site.

The early zener diode types, such as the 1N746 series, started with a 10 percent tolerance, with an A suffix for 5 percent tolerance. Later suffixes were added for 2 and 1 percent tolerance. Later diodes started with 5 percent tolerance, with 1 and 2 percent available with different suffixes. The most common tolerance is probably 5 percent, you could check Digi Key to see if tighter tolerances are available and at what price. The 5 percent tolerance is probably the easiest to get.

A 4.7 volt diode with 5 percent tolerance can have a breakdown voltage betweeen 4.465 and 4.935 volts when tested at its rated test current, temperature, and heat sink.

The zener voltage is that measured at a specifiied test current (Izt). There is no standard test current. In some series a different test current is specified for each type. The test current is usually fairly high. For example, it is 20 milliamps for the 1N751A (about 100 milliwatts dissipation). Higher power diodes are ususally are tested at higher currents.

The parts are binned based on their voltage at the test current. I don't know how tight the distribution is for the parts on a wafer. If a wafer produces parts that are sorted into several bins, the distribution within a bin will be uniform. Alternately, if all of the devices on a wafer match, the entire wafer will fall in one bin, clustered around a single value.

The test current is high enough that there is usually some self heating of the device being tested. Fortunately, diodes in the 5 volt range tend to have low temperature coefficients. Higher voltage diodes have a significant positive temperature coefficient, so the breakdown voltage will also depend on ambient temperature and heatsinking.

If you are only using a few devices, they can be tested and selected for the voltage you want. This doesn't work on a production line. In one case, where zeners were used to protect TTL inputs, things went along fine for several years. Then one day, a batch of zeners came through that was at the low voltage end of the range and had soft knees. These drew significant current at the 3 volt TTL logic level even though they were nominally 5 volt devices.

If possible, you want to design equipment such that any part allowed by the data sheet specification will work properly in the circuit. This can be quite a challange with zener diodes.

The complexity of the protection networks depends on what you are trying to protect against. Resistors and zeners before the PIN on the PIC will give the best protection, but will require a lot of parts. Aseries resistor combined with the protection diodes in the PIC will give less protection, but this might be adequate for some purposes.

Posted: Thu Sep 13, 2007 9:42 pm
by Robert Reed
I agree with RSHayes reply, but I thought I would toss out a few ideas also. As to your "luck" on the 4.7 VZ being right on- no luck involved there. The Manu's specs only guarantee that the device will not fall out side stated limits, so you are just as likely to be "right on the money" as to being the full limit of tolerance off the mark.The optimum Zener voltage for temperature stability is usually 6.2 volts at which point they have a 0 TC. If memory serves me right - negative TC below this voltage and positive TC above. For whatever reasons, the 750 series of zeners has always performed horribly for me. I have since stayed with the 4700A series (1 watt) and they seem to be much more predictable. If you decide on the zener route, buy them by the handful as they are now dirt cheap, but hopefully they will not have been made in the same batch!
One other thing you might want to experiment with is the reverse emitter- base junction break down voltage of the common 2N3906/04 transistors (also dirt cheap). I have never had occasion to use these in that fashion but they may have a sharper knee.

Posted: Fri Sep 14, 2007 11:46 am
by MrAl
Hi again,

I agree that a zener probably isnt the way to go for long term use.
I'll probably go with the 431 idea because that should be accurate
enough and not consume any power when it's not needed.

Robert, what i meant by 'luck' is this:
If you throw 5 zener diodes obtained from various places on the floor and
their voltages at say 40ma are graduated from 4.5 to 5.9 volts like this:
4.5, 4.6, 4.7, 4.8, 4.9v, what is the chance that you will pick up the one
that is exactly 4.7 volts?
The chance is only 20 percent, and if you do in fact pick that one up
and that is the one that you wanted, you are indeed said to be 'in luck'
because there are 4 chances to loose and only one chance to win.

Posted: Fri Sep 14, 2007 4:35 pm
by Robert Reed
Just a little humor-
When you finally do get that perfect match and are hanging on to it for dear life, invariably that will be the only component dropped on the floor all night and it will dissapear forever :grin:

Posted: Fri Sep 14, 2007 5:49 pm
by MrAl
Hi again,

Ha ha, yeah dont i know what that's like he he.......

Posted: Fri Sep 14, 2007 8:58 pm
by dyarker
How about a newer part number zener? See:
2% Vz tolerance, only 2uA at 2V for 5.1V model TA. Only problem might be hand soldering the tiny buggers. 500mW and 1W SMD devices would be easier to solder but the tolerances aren't as good.

Is some knee softness a good thing? Seems that it would really damp any ringing on digital lines, without trashing the rise/fall times like a cap would.

It seems to me that you wouldn't need protect inputs coming from other ICs on the same PCB, so we're taking about signals from "outside" or off board.

Instead of 1K resistors and 4.7V zeners; consider 1K resistor to 5.6V zener to 100 Ohm resistor to uP pin. Internal diode to Vcc and 1.1K total resistance protects uP guts upto 5.6V. The zener protects the internal diode up to 10V or more, including any spikes the wires might pick up.

How far away is the signal source that may go to 10V? If it's not floating reletive to ground, then maybe opto-isolators are called for.


Posted: Sat Sep 15, 2007 2:50 pm
by MrAl
Hi Dale,

Well, i dont want to have to add 3 components to every single
input unless it becomes absolutely necessary because there is
just no other way to do it.
I originally put 1k resistors in series with each input and that limits
current to 5ma with the circuit turned on and 10ma with the
circuit turned off, and i thought that would be enough and didnt
really want to add anything else.

On the other hand, it might be called for to add a set of two resistors
and zener to every input because i am assuming 10v max input,
but what if somebody happens to connect 20v by accident? Blow out
the circuit? I dont like that idea either, so perhaps i should rethink this
or else keep enough parts on hand to cover any accidental blow outs.

The circuit constraints are such that 1k is really the max input resistance
that can be added to the input (ok 1.2k is ok too) or the accuracy
starts to fall.
Maximum lead distance about 18 inches.

Maybe i should just add differential op amps to each input? Really
starts to get 'partie' then though, as 4 resistors per op amp
has to be added, and then those inputs have to be protected anyway.

I'll have to think about the (input) two resistor and zener approach again.

Posted: Sat Sep 15, 2007 5:51 pm
by dyarker
Okay, 20V. Just use a 200mW, or larger, zener.

Change 1K resistor to 840 and you're under 1K again. 1/8W resistor would be a really slow-blow fuse. Put 8 resistors on a 16 pin DIP header, and 16 pin DIP socket on the PCB, makes a burned resistor easier to replace.

Posted: Fri Jan 11, 2008 8:14 pm
by Droidwerkz
are optoisolators an option?

Posted: Fri Jan 11, 2008 11:28 pm
by MrAl
Hi there Droid,

Optos would work for digital inputs that dont have to be too fast, but
for fast digital inputs and for analog inputs this would be a problem.

I happen to need to use mostly analog inputs as the digital ones
dont need protecting for my design. I wouldnt want to use optos
as this would be very expensive for analog or else inaccurate.
Still an interesting idea however.