protection for digital input pin

I have a switched mode power supply outputting 12v into my sensor. When my sensor is HIGH the output will be 12v, and so I will use a voltage divider to reduce this to 4.5v. Do the following values look ok?

Vin = 12v
r1 = 10K
r2 = 6K
Vout = 4.5v

Is there any thing else I should add to this protection circuit?

Provided your sensor is connected across R2, those values seem fine.

You could give yourself a bigger margin of safety against over-voltage. Something like 27k and 10k will give 3.24V for 12V and be safe upto 18.5V.

Using higher value resistors provides even more protection against damage (but the values I chosen stay below the 10k impedance limit recommended for the analog inputs to guarantee full accuracy).

MarkT:
You could give yourself a bigger margin of safety against over-voltage. Something like 27k and 10k will give 3.24V for 12V and be safe upto 18.5V.

That makes sense. What voltage does an Arduino consider HIGH?

I was thinking of connecting like in the attached diagram, is this correct?

davivid: I was thinking of connecting like in the attached diagram, is this correct?

Yes, that would measure across R2 or in other words just measuring R2's voltage drop.

Edit: Typo, extraneous "be"

Better still put a 5V1 zener across your input pin as well. http://www.thebox.myzen.co.uk/Tutorial/Protection.html

Better still put a 5V1 zener across your input pin as well.

Thanks for link.

Is the following diode suitable? 0.5W Zener Diodes BZX79C 5V1

Consider buying a Ruggeduino. They have Zeners and more across all input pins. Beautiful design.

Is the following diode suitable?

Yes. :)

Hey, let's dig up this :P

So I'm doing a project where I'll hook up the arduino power to 12v, from the car lighter. In my project I'll have a 7805 voltage regulator, so it will break down the 12v to 5v.

I'll use 12v to power the arduino. And the 5v from the voltage regulator to a sliding switch that I'll read as input on a digital pin.

I'm afraid that over-voltage can occur on the digital input, so I was thinking about protecting the digital pin with the following circuit: http://www.thebox.myzen.co.uk/Tutorial/Protection_files/shapeimage_9.png

that I've read from this link: http://www.thebox.myzen.co.uk/Tutorial/Protection.html

Is this a good way to protect it?

Thanks, Tiago

It's my page so yes I think it is good especially if you are only protecting against transients. If the voltage is going to be constantly over 5V then make that resistor something like 100R.

Grumpy_Mike:
Better still put a 5V1 zener across your input pin as well.
Protection

The datasheet section “I/O pins” says:

All I/O pins have protection diodes to both VCC and Ground

So you don’t need any more.

(Assuming you’ve limited the number of amps that can reach the pin, eg. though a 10k resistor).

So you don't need any more.

Yes you do. 1mA is the maximum current that should flow through the internal protection diodes.

Grumpy_Mike: It's my page so yes I think it is good especially if you are only protecting against transients. If the voltage is going to be constantly over 5V then make that resistor something like 100R.

Got it :)

I don't have a 100pF can I use other values?

Grumpy_Mike:

So you don't need any more.

Yes you do. 1mA is the maximum current that should flow through the internal protection diodes.

Not if you use a 10K series resistor as he suggested, that will limit the current to (12 - 5)/10 = 0.7mA. But personally, I would use a higher value, e.g. 47K or 100K.

Grumpy_Mike:

So you don't need any more.

Yes you do. 1mA is the maximum current that should flow through the internal protection diodes.

I actually said:

So you don't need any more.

(Assuming you've limited the number of amps that can reach the pin, eg. though a 10k resistor)

(Assuming you've limited the number of amps that can reach the pin, eg. though a 10k resistor)

The thing is that once you start putting 10K series resistors on inputs your noise immunity is shot and it limits the rise time of the signals. That is why I have a 22R series resistor so the protection circuit does not end up crippling the signal.

Grumpy_Mike: It's my page so yes I think it is good especially if you are only protecting against transients. If the voltage is going to be constantly over 5V then make that resistor something like 100R.

Got it :)

I don't have a 100pF can I use other values?

What impact the capacitor values have?

I don't have a 100pF can I use other values?

Yes, using other values will control the balance between protection against spikes and disrupting the input signal. The capacitor absorbs voltage spikes ( good ) and also slows down the input rise time ( bad ) .