Resistor Allows Multiplexing Of Microcontroller I/O Lines

Jan. 25, 1999
Because of their small size, low cost, and advanced functionality, the PIC12CXXX family of microcontrollers developed by Microchip are an attractive design element for embeddedcontrol...

Because of their small size, low cost, and advanced functionality, the PIC12CXXX family of microcontrollers developed by Microchip are an attractive design element for embeddedcontrol applications. Unfortunately, their restricted number of I/O lines (five bidirectional and one input-only) are sometimes not enough. A method of multiplexing the bidirectional lines using just a resistor is presented here.

There are two keys to this circuit: the isolation resistor (R1) and the software-programmable I/O functionality of the PIC microcontroller. The I/O pin can be programmed as either an input or as an output driving the pin high or low. To read the value of the switch S1, the I/O pin is confirmed as an input. Thus, the value of the switch is read easily. Ignoring the leakage current of the I/O pin and whatever the output is attached to, the voltage is given simply as a voltage divider:

The not-so-obvious part of this circuit occurs when the I/O pin is used as an output and the switch input is closed. Without R1, the value at the I/O pin (VA) would be ground. However, R1 provides isolation, allowing VA to be set by the I/O pin. To output a high voltage, the I/O pin must be able to source at least the output voltage/R1. At +5 V VCC, this is −5 mA, which is well under the 25 mA maximum per I/O for the 12CXXX device. To output a low, the I/O pin must be able to sink at least VCC/R2, in this case about 50 µA. This is well under the 25 mA maximum for the 12CXXX microcontroller family.

Switching an I/O pin from an input to an output, reading the I/O, and writing a value is extremely simple using Microchip’s reduced-instruction set. The code listing provides software snippets needed to accomplish these tasks.

With this multiplexing method, the output always overrides the input, allowing the output to be absolutely defined during critical times. This enables the I/O pin to perform as a data line in a synchronous communication scheme, or as a driver for an LED to provide a rudimentary user interface. And, at the same time, it implements non-timecritical input, such as a configuration switch or a request for service button.

For clarification, the figure shows R2 as an external pull-up resistor. However, the 12CXXX microcontrollers have internal pull-up resistors. This eliminates RZ as a discrete element in the circuit, further reducing system cost and complexity.

With a single resistor, the functionality of an I/O pin on a microcontroller can be vastly increased to allow for an input from one device and an output to another device. With the built-in capabilities of the microcontroller, this method is an easy and effective way to increase the functionality of a product while reducing system cost.

Sponsored Recommendations

Board-Mount DC/DC Converters in Medical Applications

March 27, 2024
AC/DC or board-mount DC/DC converters provide power for medical devices. This article explains why isolation might be needed and which safety standards apply.

Use Rugged Multiband Antennas to Solve the Mobile Connectivity Challenge

March 27, 2024
Selecting and using antennas for mobile applications requires attention to electrical, mechanical, and environmental characteristics: TE modules can help.

Out-of-the-box Cellular and Wi-Fi connectivity with AWS IoT ExpressLink

March 27, 2024
This demo shows how to enroll LTE-M and Wi-Fi evaluation boards with AWS IoT Core, set up a Connected Health Solution as well as AWS AT commands and AWS IoT ExpressLink security...

How to Quickly Leverage Bluetooth AoA and AoD for Indoor Logistics Tracking

March 27, 2024
Real-time asset tracking is an important aspect of Industry 4.0. Various technologies are available for deploying Real-Time Location.

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!