Hello wise gurus
I have a question: What would happen if i would connect eg. 12v to arduino digital input pin that is pulled up?
Is there a way to protect pin so that i would still work and would not burn on connecting high voltage to it?
Hello wise gurus
I have a question: What would happen if i would connect eg. 12v to arduino digital input pin that is pulled up?
Is there a way to protect pin so that i would still work and would not burn on connecting high voltage to it?
Are you talking about intentionally connecting 12 V or protecting against accidentally connecting excessive voltage levels to the pin?
You will destroy the pin, it doesn't matter if it is pulled up. The pin can be protected with zener diode and small resistor cca 1k.
EDIT: See this: https://www.rugged-circuits.com/. Look at the tech specs. They wrote that each pin is protected by 5.1V zener diode, 220ohm resistor and 30mA PTC fuse. There is also schematics.
pert:
Are you talking about intentionally connecting 12 V or protecting against accidentally connecting excessive voltage levels to the pin?
Yes i'm talking about doing such action by accident.
Budvar10:
You will destroy the pin, it doesn't matter if it is pulled up. The pin can be protected with zener diode and small resistor cca 1k.EDIT: See this: https://www.rugged-circuits.com/. Look at the tech specs. They wrote that each pin is protected by 5.1V zener diode, 220ohm resistor and 30mA PTC fuse. There is also schematics.
I suppose you have this circuit in mind? (see this link) Will it work to internally pulled up pin also?
I suppose you have this circuit in mind? (see this link) Will it work to internally pulled up pin also?
Exactly this circuit. It does not seem to be difference between external or internal pull-up. External one is usually used just because of different value need.
It should work.
That is not a pull-up resistor. It's a current limiting resistor, a very different function. In this circuit the 220Ω resistor limits the current for the 5.1V zener, which in turn limits the voltage on the pin. 12V gives a current of 32 mA in that circuit, which will be pretty much the limit with common 1/4-1/2W parts (SMD parts are often just 1/8W): 220 mW absorbed by the resistor and 160 mW by the zener.
In fact with 12V you should be safe when connecting a 10k resistor on the pin, as then you would rely on the internal clamping diodes to limit the voltage. The resistor limits the current through those clamping diodes to about 0.7 mA.
The internal pull-up resistor is of no use as it's between the pin and +5V. You need a resistor between the pin and your actual input,
That is not a pull-up resistor. It's a current limiting resistor, a very different function.
Of course, there is no pull-up in this schematics... This was proposed as solution for OP. 8)
wvmarle:
That is not a pull-up resistor. It's a current limiting resistor, a very different function. In this circuit the 220Ω resistor limits the current for the 5.1V zener, which in turn limits the voltage on the pin. 12V gives a current of 32 mA in that circuit, which will be pretty much the limit with common 1/4-1/2W parts (SMD parts are often just 1/8W): 220 mW absorbed by the resistor and 160 mW by the zener.In fact with 12V you should be safe when connecting a 10k resistor on the pin, as then you would rely on the internal clamping diodes to limit the voltage. The resistor limits the current through those clamping diodes to about 0.7 mA.
The internal pull-up resistor is of no use as it's between the pin and +5V. You need a resistor between the pin and your actual input,
So basically what you are saying, if i have a Pullup input pin, i can connect 10k resistor on it, and then connect it to device as usual, (Pin -> resistor -> device), and in case when 12v will be provided for the pin, pin will stay safe?
When your device outputs 12V your Arduino should be safe when the resistor is large enough. 10k should be OK even without the limiting Zener diode because Arduino has internal protection diodes that should handle small currents. But maybe you would get safer and better result with diode instead of the resistor:
Arduino pin -- |>| -- Device pin
This way Device is able to pull the pin low but not to pull it up (the Pull-up resistor does that).
tadasp:
So basically what you are saying, if i have a Pullup input pin, i can connect 10k resistor on it, and then connect it to device as usual, (Pin -> resistor -> device), and in case when 12v will be provided for the pin, pin will stay safe?
Yes - but mind that this is generally not recommended for permanent installations. The diode method is much safer, and that it works for any voltage >5V up to the breakdown voltage of the diode.
wvmarle:
Yes - but mind that this is generally not recommended for permanent installations. The diode method is much safer, and that it works for any voltage >5V up to the breakdown voltage of the diode.
Awesome, i'll just use the circuit from rugged-duino page and that will be that (i mean most safest way ). Thanks Guys, you are the best!
It is NOT the safest way! It is somewhat good only if you have good power source from your Arduino. For example if your power source is poor and provides only 4.5V (i.e. due to internal resistance) the Zener diode provides little to no protection. On the other side if your power is more than 5V it may be a problem if you configure the pin OUTPUT HIGH. Note USB is 5+/-0.25V so 5.25V is still within specs but "a lot" higher than breakdown voltage of the Zener.
Someone may argue the Zener is better than the resistor alone but external clamping Schottky diode to Vcc is (much) better IMHO.
Smajdalf:
It is NOT the safest way! It is somewhat good only if you have good power source from your Arduino. For example if your power source is poor and provides only 4.5V (i.e. due to internal resistance) the Zener diode provides little to no protection. On the other side if your power is more than 5V it may be a problem if you configure the pin OUTPUT HIGH. Note USB is 5+/-0.25V so 5.25V is still within specs but "a lot" higher than breakdown voltage of the Zener.
Someone may argue the Zener is better than the resistor alone but external clamping Schottky diode to Vcc is (much) better IMHO.
Can you explain a scheme a bit more? I did not quite got the way to connect Schottky diode?
I do have 7 volt voltage regulator feeding my Arduino in current scenario
Like this:
If the "high voltage DC signal" is high, the diode blocks it from reaching the Arduino, while the resistor pulls the pin high.
When that signal is low, it pulls down the pin.
It works for any signals >5V up to the breakdown voltage of the diode (50-1000V typically, depending on the type). Take a fast switching diode, such as the 1N4148 (4-8 ns reverse recovery), as otherwise you still get voltage spikes on your pin.
Note that of course you must connect the grounds together to make this work.
wvmarle:
Like this:If the "high voltage DC signal" is high, the diode blocks it from reaching the Arduino, while the resistor pulls the pin high.
When that signal is low, it pulls down the pin.
It works for any signals >5V up to the breakdown voltage of the diode (50-1000V typically, depending on the type). Take a fast switching diode, such as the 1N4148 (4-8 ns reverse recovery), as otherwise you still get voltage spikes on your pin.
Note that of course you must connect the grounds together to make this work.
Sounds very logic and understandable Thank You so much for all this
Hmm.., but how about analog pins?
What about them?
The digital pin protection will work just fine - when you treat them as digital inputs.
If you need accurate analog signals you can't add protection circuits just like that as it messes with the actual voltage you get. Best you can do is an external clamping diode and current limiting resistor.
This picture
from this page shows proper I/O overvoltage protection. I don't know what is C1 for and you may probably remove it. D3 protects from overvoltage while D4 from undervoltage (you may omit it too if you know the sensor don't produce voltage under GND).
C1 is probably there to stabilise the signal, and/or to smooth out sudden peaks (the cap should be faster to absorb the initial peak than even a Schottky diode can switch). C1 creates an RC circuit with R1, adding a reaction time to the pin voltage.
It also means it takes approx. R1xC1 seconds before the pin drops from high to low. For fast changing signals this may be an issue. For buttons, it's a great way to debounce them.
This should work quite well for analog inputs, as long as the overvoltage is not too great.
@wvmarle: you are right, I have read the linked article and C1 is meant as debounce and/or spike supression.
@OP: I think the article that is source of the image is worth reading. IMHO it is well written and easy to understand.
There is one issue with this circuit. It "removes" overvoltage by clamping it to power rails of Arduino. If the clamped current is less than current used by your system everything is OK. But if for some reason the current may be higher you need some overvoltage protection on power rails. A Zener diode (5V6 for 5V system is good choice).
It may seem the "proper" solution is a lot more complicated and needs the Zener anyway. But using Zener diode alone as protection works only if the "protected" Arduino is properly powered. If for any reason the Arduino loses power and the sensor does not the Zener provides no protection from overvoltage at all! In fact not so large drop in supply voltage (maybe battery powered system with nearly depleted batteries) makes the Zener protection fail. Ofc if you are sure this never happens the Zener is enough but...