PIC Input Protection using a Zener Diode - Page 1
Forum section: electronics / projects

author: abbtech
author_rank: Contributor
timestamp: October 29, 2010, 03:56:49 am
content: I want to protect a few PIC inputs from accidental connection to high voltage (12 volts). The PIC will be running 5 volts and the ADC inputs will be connected to some sensors and have a normal voltage of around 2 to 4.8 volts. There will be a 1K resistor between the PIC pin and the outside world. I wanted to toss a 5.1 volt zener from the PIC pin to ground but I was surprised when the zener affected the circuit when operating within the normal range and it restricted the input to around 4.6 volts.This is the device I am using for the testing 1N4733Ahttp://www.datasheetcatalog.com/datasheets_pdf/1/N/4/7/1N4733A.shtmlSince the only voltage I am concerned about would be 12 volts which would be connected to the PIC through a 1K resistor I am thinking that the built in I/O protection could probably handle it but I was wanting to add something a bit more bullet proof.Any suggestions?

author: cyberfish
author_rank: Regular Contributor
timestamp: October 29, 2010, 04:12:59 am
content: Schematics?

author: allanw
author_rank: Frequent Contributor
timestamp: October 29, 2010, 05:43:34 am
content: That makes sense.The zener starts to conduct at low currents, and will maintain close to 5.1V. I think there are circuits around online for doing this if you search for zener diode overvoltage production.

author: scrat
author_rank: Frequent Contributor
timestamp: October 29, 2010, 11:13:27 am
content: Zener diodes are not ideal devices.If you're using a quite high resistance in series (so you impose low current) the zener voltage will settle at a lower voltage.Look at the picture, I hope it is clear.EDIT:(In practice, I'm saying the same thing as allanw)

author: Feanor
author_rank: Regular Contributor
timestamp: October 29, 2010, 11:40:18 am
content: This is one possible circuit to protect your PIC. I have used a 5.6V zener diode, not a 5.1V. It all depends on your supply voltage stability and level. The data sheet maximum voltage for most 8bit PICs is VDD + 0.3. So if your supply is a rock solid 5V then this gives you 100mV clearance with the 5.1V zener. Three possible problems : -1.5.1V might be a bit close to your operating voltage, if this swells to over 5.1V or you have a switching transient that takes it up there the zener will conduct as much current as it needs to in order to get the voltage back down to 5.1V this current will be coming out of your PIC. If you are sure your supply is 5V or under always then you can go with the 5.1V zener. I would get my supply down to 4.9V to use the 5.1V zener. And be using a linear regulator and a fair bit of capacitance near the PIC.2.The next problem is not all zeners were made equal. Their voltages start off a bit off and then drift a bit with time and temperature. I am informed that the 5.6V zeners are the most accurate due to the physics of how a zener diode is created.How much truth there is to this I am not sure.3.Finally a zener diode only settles down to its final reverse bias voltage when a certain amount of current is flowing through it. So if you just bang 12V on the protected node then there is no problem. A small transient will occur that your PIC should survive. If you only apply 5.9V for instance however, then the current in the zener diode is very small and it may not clamp the voltage as expected.Any way because of a combination of these, I would if possible take VDD up to 5.3V and use the 5.6V zener. Provided that everything you are connecting to can survive 5.3V. Good luck!As a small aside, did you know you can connect 240V mains AC to your PIC pin configured as a digital input? All you need is a 10M ohm resistor between your PIC and the mains and it survives! I've seen it! This can be very handy indeed for applications where synchronizing to mains is necessary. When the mains is positive the pin is read as a 1 when the mains is negative the pin is a zero, all the usual as regards interrupts etc obviously apply.

author: scrat
author_rank: Frequent Contributor
timestamp: October 29, 2010, 11:55:44 am
content: Quote from: Feanor on October 29, 2010, 11:40:18 amI've seen also an example of AC solid-state switch application of ST that does this. I can't find it now, but it was similar to this:http://www.datasheetcatalog.org/datasheet/SGSThomsonMicroelectronics/mXxuyw.pdfHere they get supply from the mains, sense its voltage sign directly from a digital input and even interface to a touch sensor without any transformer.

author: Unknown
author_rank: Unknown
timestamp: October 29, 2010, 11:57:59 am
content: Isn't just clamping to Vdd/Vss easier? It will give you Vdd + 1 diode drop for free, use Schottky's if you're worried about internal diodes conducting before the discrete ones. Include series resistors to limit the current. If it's just 12V, I don't think you need to worry about speed and energy, as you would with ESD protection. With some series resistance, basic small-signal silicon or Schottky diodes should be fine.About the 240V AC with series resistance, the 10Mohm resistor limits the current to about +/-17uA. I would only use this if the datasheet explicitly mentions this as a safe amount of current for the clamping diodes, usually the documented safe maximum is no current at all. I would also be worried about transients. And you obviously have to treat your MCU circuit and everything connected to it as mains with regards to safety, creepage and isolation. Optical or magnetical isolation seems like the easier solution to me.

author: TechGuy
author_rank: Regular Contributor
timestamp: October 29, 2010, 02:51:41 pm
content: Quote from: Feanor on October 29, 2010, 11:40:18 amWell that still puts the device at risk for surge spikes. The 10M resistor is limiting the current to about 34 uA. but a voltage spike could exceed the 10M resistor voltage rating causing the resistor to pass a destructive amount of current. If the voltage is high enough it can cause the resistor to drop its resistance, perhaps less than 1 ohm.I would recommend using TVS Silicon avalanche diodes instead of Zener since the are designed for voltage spikes and over voltage conditions. You can also buy TVS ICs that are designed to protect multiple inputs (ie Buses). The problem with Zeners and Avalanche diodes is that the have a small amount of capacitance which can degrade digital signals by round off the square wave which can impact high speed serial and digital buses.For PIC ADCs I use a 7V TVS (SMA7.5CA) for over voltage protection

author: abbtech
author_rank: Contributor
timestamp: October 29, 2010, 02:55:49 pm
content: Quote from: cyberfish on October 29, 2010, 04:12:59 amScrat has a schematic that is exactly what I am doing except the vdd on the left is my analog input and V is the PIC pin.

author: abbtech
author_rank: Contributor
timestamp: October 29, 2010, 02:57:19 pm
content: Quote from: scrat on October 29, 2010, 11:13:27 amThanks, I can now see exactly why it isn't going to work as I expected in my case...

author: abbtech
author_rank: Contributor
timestamp: October 29, 2010, 02:59:23 pm
content: Quote from: Feanor on October 29, 2010, 11:40:18 amWow I would never have thought about connecting 240 to the device!

author: abbtech
author_rank: Contributor
timestamp: October 29, 2010, 03:02:38 pm
content: Quote from: scrat on October 29, 2010, 11:55:44 amI would feel a bit weary of touching the touch sensor the first time.

author: abbtech
author_rank: Contributor
timestamp: October 29, 2010, 03:06:38 pm
content: Quote from: alm on October 29, 2010, 11:57:59 amWow, I had never thought of that. The PIC is good for 5.5 volts and I am using a stable regulator so I will have very close to 5 volts on my vdd rail. I will just clamp it to the vdd rail using a common diode. Thanks for offering something other than the zener solution that I seem to have got stuck in my brain as the best solution.

author: migsantiago
author_rank: Frequent Contributor
timestamp: October 29, 2010, 03:28:45 pm
content: Hi there, I'd rather use a schottky diode.The schottky diode could be a 1N5819 (as far as I remember) with a drop voltage of 0.3V.If a negative voltage enters at Vin, the voltage at the PIC pin will be -0.3V, and the PIC can take it since it tolerates negative voltages from -0.6V to Vss.If a high positive voltage enters at Vin, the voltaje at the PIC pin will be Vdd + 0.3V. The PIC tolerates Vdd + 0.6V at its inputs.In the images I attach, I entered +12V and -12V at the input and the voltages present at the PIC are +5.25V and -0.25V respectively.

author: Simon
author_rank: Unknown
timestamp: October 29, 2010, 03:57:37 pm
content: Quote from: abbtech on October 29, 2010, 03:02:38 pmhow do you suppose many "mains detector" screw drivers work ? particularly those with the little neon bulb in them, you touch a live point with the screw driver tip that is connected to a 100 Kish resistor that is connected to a neon light in the screw drivers handle, you put your finger on the end of the driver handle that has a contact connected to the other side of the light and you complete the circuit to earth with your body (potentially across the heart), the current flowing through the bulb flows through you and is enough to make light, if it's less than a few mA you would never know the difference

author: Zero999
author_rank: Super Contributor
timestamp: October 29, 2010, 05:37:59 pm
content: Those mains testers are dangerous. The resistor needs to be able to withstand 8kV pulses to be safe (I doubt cheap screwdrivers use HV resistors) and what's more dangerous is it might give a false power off if you're not properly earthed.

author: Simon
author_rank: Unknown
timestamp: October 29, 2010, 07:03:58 pm
content: I'd not want to rely on one either, I was just trying to explain how small currents through the body are more common place than people think. I think the only time I used one was to check for voltage when the board was on and then use it to double check power was off when the alleged power switch was turned off as I had no multimeter,

author: abbtech
author_rank: Contributor
timestamp: October 29, 2010, 08:28:59 pm
content: Quote from: migsantiago on October 29, 2010, 03:28:45 pmGood point, a common diode would probably still leave the PIC to protect itself.