Zibb

Design Idea

Analog multiplexer uses flying capacitors

Edited by Bill Travis

Dick Cappels, Mesa, AZ -- EDN, 1/22/2004

This Design Idea describes a way to increase the number of analog inputs to your microcontroller for cases in which adding an analog-multiplexer chip or upgrading to a microcontroller with more inputs might be impractical. If the microcontroller you're using has some spare I/O pins and at least one of them is bidirectional or is amenable to tristating, you can configure a simple analog multiplexer using switched capacitors. Figure 1 shows a two-input multiplexer. A typical switched-capacitor multiplexer completely disconnects the capacitor from the sensed voltage before sampling the voltage across the capacitor.

To use a typical microcontroller's I/O ports, one terminal of the capacitor remains connected to the input source through a resistor. During most of the operating time, pins 12, 14, and 15 are configured as output pins and are held at logic 0. Diodes D1 and D2 do not conduct, so capacitors C1 and C2 charge to the values of the input voltages V1 and V2, respectively. To sample the voltage stored in the capacitors, pin 12 becomes an input, and the pin associated with each channel switches high while the microcontroller's comparator compares the voltage on Pin 12 with the reference voltage. Listing 1 gives the code fragment that samples the inputs.

The voltage on Pin 12 is VPIN12=VDD–VDIODE–VIN, where VPIN12 is the voltage applied to the analog input of the comparator; VDD is the power-supply voltage (5V in this example); VDIODE is the voltage across the diode, and VIN is the voltage applied to input of the RC filter. During the sampling of one input, the voltage on the positive terminals of the capacitors exceeds VDD; thus, D1 and D2 are in series with microcontroller pins 14 and 15 to block voltages above VDD and prevent C1 and C2 from discharging into the power supply. Also during sampling, C1 and C2 are in series with the filter resistor of the input undergoing sampling, causing the capacitors to discharge through the resistor. For this reason, it is important to keep the RC time constant with respect to the sampling period. The worst-case voltage error occurs in the second channel to be sampled, when both V1 and V2 are at 0V:

where TSAMPLE is the time one of the diodes' anodes switches to VDD (3 µsec in this example). This sampling time uses the assumptions R1=R2, C1=C2, and the fact that the sampling periods for each channel are the same.

With the 1-MHz controller in Figure 1, sampling time is a total of 6 µsec for the two channels; using a 16-MHz controller, the total sampling time would be only 375 nsec. When you expand the circuit for more inputs (for example, using the four-input multiplexer in Figure 2a), you must take the extra sampling time into account. To maintain a low duty cycle and thus allow the RC filters to charge to the full input voltage, the software should infrequently call the sampling routine. An interrupt every 2048 clock cycles calls the sampling routine in this example. The voltage at Pin 12 in Figure 2a is inverted, and, because of the isolation diodes, the maximum input voltage is a diode drop below VDD (approximately 4.4V). If you multiplex both inputs, the circuit compensates for both the polarity and the diode drop (Figure 2b). Listing 2 gives the microcontroller assembly code for the multiplexer scheme.

Check out our Best of Design Ideas section!



Reed Business Information Resource Center

Featured Company


Related Resources

ADVERTISEMENT

ADVERTISEMENT

Related Content

 

By This Author

There are no additional articles written by this author.


ADVERTISEMENT

Knowledge Center



Technology Quick Links

EDN Marketplace


©1997-2009 Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy

Please visit these other Reed Business sites