Author Topic: PIC Input Protection using a Zener Diode  (Read 29266 times)

0 Members and 1 Guest are viewing this topic.

Offline abbtechTopic starter

  • Contributor
  • Posts: 39
    • Alan's Electronic Projects
PIC Input Protection using a Zener Diode
« on: October 29, 2010, 03:56:49 am »
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 1N4733A http://www.datasheetcatalog.com/datasheets_pdf/1/N/4/7/1N4733A.shtml

Since 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?

Personal projects http://alan-parekh.com
Other cool project ideas http://hackedgadgets.com
 

Offline cyberfish

  • Regular Contributor
  • *
  • Posts: 240
  • Country: gb
Re: PIC Input Protection using a Zener Diode
« Reply #1 on: October 29, 2010, 04:12:59 am »
Schematics?
 

Offline allanw

  • Frequent Contributor
  • **
  • Posts: 343
    • Electronoblog
Re: PIC Input Protection using a Zener Diode
« Reply #2 on: October 29, 2010, 05:43:34 am »
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.
 

Offline scrat

  • Frequent Contributor
  • **
  • Posts: 608
  • Country: it
Re: PIC Input Protection using a Zener Diode
« Reply #3 on: October 29, 2010, 11:13:27 am »
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)
One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. - Elbert Hubbard
 

Offline Feanor

  • Regular Contributor
  • *
  • Posts: 56
Re: PIC Input Protection using a Zener Diode
« Reply #4 on: October 29, 2010, 11:40:18 am »
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.
« Last Edit: October 29, 2010, 11:43:33 am by Feanor »
 

Offline scrat

  • Frequent Contributor
  • **
  • Posts: 608
  • Country: it
Re: PIC Input Protection using a Zener Diode
« Reply #5 on: October 29, 2010, 11:55:44 am »
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.

I'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.pdf
Here 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.
One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. - Elbert Hubbard
 

alm

  • Guest
Re: PIC Input Protection using a Zener Diode
« Reply #6 on: October 29, 2010, 11:57:59 am »
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.
 

Offline TechGuy

  • Regular Contributor
  • *
  • Posts: 79
Re: PIC Input Protection using a Zener Diode
« Reply #7 on: October 29, 2010, 02:51:41 pm »
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.

Well 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

 

Offline abbtechTopic starter

  • Contributor
  • Posts: 39
    • Alan's Electronic Projects
Re: PIC Input Protection using a Zener Diode
« Reply #8 on: October 29, 2010, 02:55:49 pm »
Schematics?

Scrat 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.
Personal projects http://alan-parekh.com
Other cool project ideas http://hackedgadgets.com
 

Offline abbtechTopic starter

  • Contributor
  • Posts: 39
    • Alan's Electronic Projects
Re: PIC Input Protection using a Zener Diode
« Reply #9 on: October 29, 2010, 02:57:19 pm »
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)

Thanks, I can now see exactly why it isn't going to work as I expected in my case...
Personal projects http://alan-parekh.com
Other cool project ideas http://hackedgadgets.com
 

Offline abbtechTopic starter

  • Contributor
  • Posts: 39
    • Alan's Electronic Projects
Re: PIC Input Protection using a Zener Diode
« Reply #10 on: October 29, 2010, 02:59:23 pm »
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.

Wow I would never have thought about connecting 240 to the device!
Personal projects http://alan-parekh.com
Other cool project ideas http://hackedgadgets.com
 

Offline abbtechTopic starter

  • Contributor
  • Posts: 39
    • Alan's Electronic Projects
Re: PIC Input Protection using a Zener Diode
« Reply #11 on: October 29, 2010, 03:02:38 pm »
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.

I'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.pdf
Here 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.

I would feel a bit weary of touching the touch sensor the first time. :)
Personal projects http://alan-parekh.com
Other cool project ideas http://hackedgadgets.com
 

Offline abbtechTopic starter

  • Contributor
  • Posts: 39
    • Alan's Electronic Projects
Re: PIC Input Protection using a Zener Diode
« Reply #12 on: October 29, 2010, 03:06:38 pm »
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.

Wow, 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. :)
Personal projects http://alan-parekh.com
Other cool project ideas http://hackedgadgets.com
 

Offline migsantiago

  • Frequent Contributor
  • **
  • Posts: 381
  • Country: 00
    • MigSantiago's Web Site
Re: PIC Input Protection using a Zener Diode
« Reply #13 on: October 29, 2010, 03:28:45 pm »
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.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17838
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: PIC Input Protection using a Zener Diode
« Reply #14 on: October 29, 2010, 03:57:37 pm »
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.

I'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.pdf
Here 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.

I would feel a bit weary of touching the touch sensor the first time. :)

how 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
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19606
  • Country: gb
  • 0999
Re: PIC Input Protection using a Zener Diode
« Reply #15 on: October 29, 2010, 05:37:59 pm »
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.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 17838
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: PIC Input Protection using a Zener Diode
« Reply #16 on: October 29, 2010, 07:03:58 pm »
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,
 

Offline abbtechTopic starter

  • Contributor
  • Posts: 39
    • Alan's Electronic Projects
Re: PIC Input Protection using a Zener Diode
« Reply #17 on: October 29, 2010, 08:28:59 pm »
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.

Good point, a common diode would probably still leave the PIC to protect itself.
Personal projects http://alan-parekh.com
Other cool project ideas http://hackedgadgets.com
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf