Multiplexer Restores Analog Inputs To Flash Microcontroller

March 6, 2000
Several years ago, I designed a remote energy-control system that split a building into sections and wired the overhead space heaters into "zones." As space was an issue and OAC5s (optically isolated output modules) were way too big, each...

The Microchip PIC16F877 microcontroller provides data acquisition, digital I/O, and parallel port communication in an easy-to-use package. However, by design, if the parallel slave port is used, the analog input channels 5 through 7 aren't available.

The circuit shown in Figure 1 restores these analog inputs by adding a 74HC4053 multiplexer IC and one resistor. Notice that resistor R1 is required because port RA4 of the flash microcontroller is an open-drain output

Regaining the use of these analog inputs does require some additional hardware and software overhead. The user must disable the parallel slave port when reading the analog inputs. This should not present a problem. In a typical data-acquisition application, all eight channels are read. Then the results are passed on via the parallel slave port.

Adding the multiplexer does add between 40 and 100 Ù of series resistance to these inputs. Using an appropriate op amp to condition these inputs will eliminate this as a design issue.

The code listing provides the two subroutines necessary for enabling and disabling readings from analog input channels 5 through 7. Note that these subroutines are sufficient for analog-to-digital conversions based on polling the GO/DONE bit of ADCON0. If interrupt-based A/D conversions are used, however, it would be necessary to disable the A/D interrupt to use the parallel slave port, and enable it to use the analog-to-digital converter.

The circuit and code listing provided have been tested using an IBM PC and one of its printer ports for parallel communication. To do this, additional circuitry is required to complete the interface. Also, the microcontroller must be stepped through desired functions. A Windows-based demonstration program, using parallel port 0378H and displaying all eight analog inputs, is available from the author.

Sponsored Recommendations


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