Subscribe to EDN
RSS
Reprints/License
Print
Email

Microcontroller multiplexes DIP switches to I/O port

Gregory Willson, ACS Defense Inc, Warrenton, VA -- EDN, February 17, 2000

At times, a µC must read a large number of DIP switches, such as for system identification, bus-address setup, manual configuration, or other purposes. However, the available number of I/O lines is sometimes not enough to assign a switch to each one. You can use multiplexer ICs to share one I/O port with multiple switches, but they complicate the circuit, dissipate additional power, and consume precious board real estate. Figure 1 shows a method of multiplexing 32 DIP switches using only 12 I/O pins and eight pullup resistors. Four 8-bit DIP switches connect in parallel to a single 8-bit I/O port. A pullup resistor on each port pin defaults the input to a high state; a switch closure pulls the input to a low state. The key to multiplexing the DIP switches is to ground each set of eight switches in turn using output pins from a second I/O port.

o deselect a set of switches, the controlling-port pin acts as an input, rendering it a high-impedance port. In this way, 12 I/O pins can read 32 switches, and 16 I/O pins can read 64 switches. Select the values of the pullup resistors to limit the total current into the controlling-port pin to less than the maximum sink current. Some µCs, such as the Microchip PIC16C6x family, provide the ability to enable weak internal pullups on I/O port pins. By using this feature, you can eliminate the eight external pullp resistors. The code fragment in Listing 1 illustrates reading the four 8-bit DIP switches and storing the results, using a Microchip PIC16C63 µC. (DI #2483)


RSS
Reprints/License
Print
Email
Canon Resource Center

Featured Company


Most Recent Resources

Advertisement
Related Content

No related content found.

  • 0 rated items found.
Advertisement

KNOWLEDGE CENTER

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)
Engineering Careers
Jobs sponsored by
Advertisement
About EDN   |   Site Map   |   Contact Us   |   Subscription   |   RSS
© 2012 UBM Electronics. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy

Please visit these other UBM Canon sites

UBM Canon | Design News | Test & Measurement World | Packaging Digest | EDN | Qmed | Pharmalive | Appliance Magazine | Plastics Today | Powder Bulk Solids | Canon Trade Shows