panic mode
- Joined Oct 10, 2011
- 5,002
you can check schematic of your arduino and see if there is a bypass capacitor. and you can always add a bit more (it does not hurt). increased capacitance allows absorbing more energy if it reaches that rail...and example of this is if there is a surge at input...
for example instead of 12V input you see something unexpected and much higher such as 30V.
if you are using first circuit in post #6 (with D1/D2) then current would flow from 30V through R1, through D1 to 5V rail. if capacitance there is small, voltage would rise. instead of 5V, it could be something like 8V (just an example) and harm the MCU. so increased capacitance allows absorbing that and as a result voltage increase is smaller (instead of 8V, maybe it is only 6V). and that is why D3 is there to clamp it down to a safer value (5,1V or 5.6V).
think of capacitor as a something that holds water... like a drinking glass (small capacity or "capacitance"). if you insert an object (an egg or pebble or tablespoon of water) water level in that glass will rise. and it does not take much to create "disaster" (water spill). but if you the same experient with larger capacity container like a bathtub, water level rise would be negligible (for adding same quantity like to drinking glass).
you want to limit GPIO current - always. i never go for more than 5mA on MCU GPIO. this way high and low are still clearly high and low values and not something "close enough". when GPIO is configured as input, current is negligible. so this only applies to outputs. and if more output current is needed, i use additional components so that MCU is not stressed. don't want MCU suffer heart attack...
voltage divider is scaling down voltage. current through voltage divider does depend also on used resistor values but to work, voltage divider need TWO resistors. you are measuring voltage across lower resistor (R2). R1 is there to absorb excess. and - what you are measuring is VOLTAGE, not current. if R2 was missing (and the diodes used for protection), MCU input would see FULL voltage that is applied (12V). to prevent that, R2 is REQUIRED.
for example instead of 12V input you see something unexpected and much higher such as 30V.
if you are using first circuit in post #6 (with D1/D2) then current would flow from 30V through R1, through D1 to 5V rail. if capacitance there is small, voltage would rise. instead of 5V, it could be something like 8V (just an example) and harm the MCU. so increased capacitance allows absorbing that and as a result voltage increase is smaller (instead of 8V, maybe it is only 6V). and that is why D3 is there to clamp it down to a safer value (5,1V or 5.6V).
think of capacitor as a something that holds water... like a drinking glass (small capacity or "capacitance"). if you insert an object (an egg or pebble or tablespoon of water) water level in that glass will rise. and it does not take much to create "disaster" (water spill). but if you the same experient with larger capacity container like a bathtub, water level rise would be negligible (for adding same quantity like to drinking glass).
you want to limit GPIO current - always. i never go for more than 5mA on MCU GPIO. this way high and low are still clearly high and low values and not something "close enough". when GPIO is configured as input, current is negligible. so this only applies to outputs. and if more output current is needed, i use additional components so that MCU is not stressed. don't want MCU suffer heart attack...
voltage divider is scaling down voltage. current through voltage divider does depend also on used resistor values but to work, voltage divider need TWO resistors. you are measuring voltage across lower resistor (R2). R1 is there to absorb excess. and - what you are measuring is VOLTAGE, not current. if R2 was missing (and the diodes used for protection), MCU input would see FULL voltage that is applied (12V). to prevent that, R2 is REQUIRED.