Tutorial: Protection resistors with microcontrollers - Page 1
Forum section: electronics / beginners

author: Nominal Animal
author_rank: Super Contributor
timestamp: April 27, 2018, 09:00:37 am
content: I will be introducing some people to microcontrollers, using Arduino Leonardo clones (Pro Micro clones with Leonardo bootloader; ATmega32u4), some LEDs, and tactile buttons, on breadboards.Because I expect mishaps, I intend to ensure they put an "extra" protection resistor between each pin and a tactile button, similar to the attached image:The reason for this is obvious: if it is omitted, and the pin is accidentally set as an output with output high, it'll create a short to ground, and probably burn the pin internals. I do intend to explain the purpose of this resistor, of course, and also why you do not commonly see such in circuits.The choice of the resistors is a bit arbitrary. 470 Ω limits the current at 5V to about 11 mA, at 3.3V to about 7 mA, so I can use the same resistors for both LEDs and pin protection. I expect to have just a few (maybe four switches and four LEDs) total, but perhaps a short explanation about power budget is also in order in the tutorial.Comments? Better suggestions? Other suggestions?

author: rstofer
author_rank: Super Contributor
timestamp: April 28, 2018, 03:05:11 pm
content: Many FPGA boards do a similar thing. Sometimes it is to dampen down reflections, more often I suspect it is to protect the pin.On FPGA boards without the resistors, I put a 330 Ohm resistor on my attached gadget. Mostly for reflections but, again, it helps protect the pin.As long as the voltage divider guarantees meeting the logic 0 threshold, no problem!Check for the driving impedance requirement of any A/D inputs. I think 10k will work but some uCs want to see a lot less.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: April 28, 2018, 03:35:08 pm
content: https://www.rugged-circuits.com/10-ways-to-destroy-an-arduino/is quite fun.

author: Bassman59
author_rank: Super Contributor
timestamp: April 28, 2018, 08:10:39 pm
content: Quote from: Nominal Animal on April 27, 2018, 09:00:37 amThe choice isn’t arbitrary. You have to mind the data sheet’s specs on the pins’ drive capability. If the pin can only source 8 mA, you will want to ensure that the load doesn’t draw more.And this is all design dependent, too. Driving an LED? Of course you need to limit the current, not only for the pin but also for the LED. But if you’re driving a logic gate (with a high input impedance), the series resistor is less about limiting current and more about signal integrity. Running a 2” trace from your micro to an SPI device? You don’t need the series resistor.

author: bson
author_rank: Unknown
timestamp: April 28, 2018, 11:33:56 pm
content: Use a low-current LED and use it to monitor the I/O pin; this lets you keep your I/O functions. For example, for 3.3V logic:For 5V I/O use R2=47k. This particular LED reaches a solid indicator brightness at about 50µA, so will have no effect whatsoever on the I/O function (other than prevent it from floating above ~2.5V).

author: Nominal Animal
author_rank: Super Contributor
timestamp: April 29, 2018, 09:11:25 am
content: Quote from: rstofer on April 28, 2018, 03:05:11 pmAccording to the datasheet, ATmega32u4's analog inputs can handle 10kOhm, yes.However, I personally am not going to include analog input in the tutorial. For correctly sampling any input signal, one would need to low-pass filter it, and that would require much more explanation. I intend to focus on the gadget-computer interface, and how to create utilities and tools, in Linux, that interface with such gadgets. I chose ATmega32u4, because I'm familiar with it, and I like its native USB interface. In the tutorial, the gadget itself will be basically as simple as I can get away with.Quote from: Bassman59 on April 28, 2018, 08:10:39 pmOf course. The resistor choices are a bit arbitrary in the sense that there is a wide range of values that work well and safely. I have not fixed my choice to those particular resistors yet, but I wanted the illustration to have something sensible to start with. (ATmega32u4's pins can sink and source 20 mA at 5V, 10 mA at 3V, but there is also a 100 mA sum limit on certain sets of pins.)Quote from: bson on April 28, 2018, 11:33:56 pmGood idea! It had not even occurred to me to try something like that.I'm tempted to create a carrier board, with a socket for a Pro Micro/Leonardo clone, that simply incorporates a bunch of those LEDs and their resistors, for safe experimentation on a breadboard. Not necessarily for all I/O pins, but maybe a dozen or so. If it spanned the gap between two breadboards (instead of straddling the center of one), it might be even more useful.I am also thinking about using a small OLED display (I2C) instead of, or in addition to, the LEDs. They're cheap, easily available, and it makes more sense wrt. my actual objective (how to create Linux programs to interface to USB gadgets) - definitely much more exiting than just blinking LEDs, although there is more programming effort involved.I do intend to explain all of this in the tutorial, probably in two levels. (That is, with an optional in-depth explanation, while the main text simply explains the ranges and choices made.)

author: rstofer
author_rank: Super Contributor
timestamp: April 29, 2018, 02:19:03 pm
content: I do hope you keep us up to date with your tutorial. The subject seems quite interesting!