BIVBlog #50: Floating Microcontroller Inputs, Single Throw Switches and Pull-Up/Pull-Down Resistors

Feeding analog voltages to digital microcontroller inputs already got us some interesting effects, but what about leaving an input pin entirely disconnected? All of a sudden microcontrollers become sensitive to the weather outside, and the clothes we wear—or any other source of electrostatic.

The easy way to deal with this is to always ensure that an input is always fed a proper input voltage. But if we want to use a “single throw” (or “connect—disconnect”) type of switch or pushbutton, then we have to use a simple, high value resistor as a “pull-up” or “pull-down” resistor.

The good news is that many microcontrollers already have at least pull-up resistors built in; all we have to do is enable them as needed. The bad news is that some (i.e. Microchip PIC) only have some of their GPIO pins equipped with them, which may require some datasheet reading and some extra care when assigning pins to particular tasks. And of course there is always a chance that specific requirements require specific values for the pull-up/pull-down resistors, making an external resistor necessary.

Table of Contents

00:00:50 The demonstration setup
00:01:25 Tickling the PIC
00:02:00 Plastic rulers and an old fleece sweater (or glass rods and cat furs)
00:02:40 Reading input from disconnected wires
00:03:45 A different program: Counting input changes
00:04:20 50 Hz flicker from nearby mains carrying cables
00:05:40 Why microcontrollers still leave input pins floating by default
00:06:25 Going from double throw to single throw switches, like mouse pianos (DIP switches)
00:08:00 Why single throw switches and similar inputs are actually desirable
00:08:30 Drawing a simple circuit schematic
00:09:40 Removing one throw
00:10:20 Adding a pull-up (or pull-down) resistor
00:10:50 The impedance (resistance) of microcontroller inputs
00:11:20 How does it work?
00:13:10 Trying it out on the breadboard
00:14:35 Why pull-up/pull-down resistors are better than double throw switches
00:16:10 Built-in pull-up and pull-down resistors
00:18:25 Enabling and disabling the resistors in the various microcontrollers
00:18:50 A look at the updated microcontroller cheat sheets
00:19:20 Pull-ups with the Microchip PIC 16F887
00:20:50 … and with the Atmel ATmega 328p
00:21:50 … and both pull-ups and pull-downs with the TI MSP430 G2553
00:22:50 Putting it all in a portable header file

Ressources

bivblog50-floating-inputs-20161230-235758-tar.gz: The programs used in this episode.

About

Long term IPv6 evangelist/book author/trainer/consultant and generic Unix guy (*BSD, Linux, Solaris, and about a dozen more).

Leave a Reply

Your email address will not be published.