Author Topic: Tutorial: Protection resistors with microcontrollers  (Read 2514 times)

0 Members and 1 Guest are viewing this topic.

Offline Nominal AnimalTopic starter

  • Super Contributor
  • ***
  • Posts: 6522
  • Country: fi
    • My home page and email address
Tutorial: Protection resistors with microcontrollers
« on: April 27, 2018, 09:00:37 am »
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?
« Last Edit: April 27, 2018, 10:24:25 am by Nominal Animal »
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9914
  • Country: us
Re: Tutorial: Protection resistors with microcontrollers
« Reply #1 on: April 28, 2018, 03:05:11 pm »
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.
 
The following users thanked this post: Nominal Animal

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2497
  • Country: gb
 

Offline Bassman59

  • Super Contributor
  • ***
  • Posts: 2501
  • Country: us
  • Yes, I do this for a living
Re: Tutorial: Protection resistors with microcontrollers
« Reply #3 on: April 28, 2018, 08:10:39 pm »

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?

The 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.
 

Offline bson

  • Supporter
  • ****
  • Posts: 2317
  • Country: us
Re: Tutorial: Protection resistors with microcontrollers
« Reply #4 on: April 28, 2018, 11:33:56 pm »
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).
 
The following users thanked this post: rstofer, Nominal Animal

Offline Nominal AnimalTopic starter

  • Super Contributor
  • ***
  • Posts: 6522
  • Country: fi
    • My home page and email address
Re: Tutorial: Protection resistors with microcontrollers
« Reply #5 on: April 29, 2018, 09:11:25 am »
Check for the driving impedance requirement of any A/D inputs.
According 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.

The choice isn’t arbitrary. You have to mind the data sheet’s specs on the pins’ drive capability.
Of 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.)

Use a low-current LED and use it to monitor the I/O pin; this lets you keep your I/O functions.
Good 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.)
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9914
  • Country: us
Re: Tutorial: Protection resistors with microcontrollers
« Reply #6 on: April 29, 2018, 02:19:03 pm »
I do hope you keep us up to date with your tutorial.  The subject seems quite interesting!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf