Analog Multiplexer using AVR microcontroller
The test circuit (schematic below, photograph above), when running the associated firmware (click here to see the assembler code (file name “hfcm030602.asm”), compares two test voltages, appearing on the wires of the 10k pots, with a reference voltage, which appears on the wiper of the 50k pot. When a test voltage exceeds the reference voltage, the LED corresponding to that particular test voltage lights, demonstrating that the two sampled channels are independent.
The AT90S1200A used for the test has a single comparitor, but an analog multiplexer was formed using two of its digital bidirectional I/O ports. Notice that for each analog input, there is a 100k resistor, a .01 uf capacitor, and a diode. The resistor-capacitor combination form a low pass filter and switching of the charged capacitor is the means by which multiplexing is effected.
Here is how it works
The technique takes advantage of bidirectional I/O ports to switch from outputs to inputs. In the case of many AVR controllers, the input of the comparitor shares a pin with a bidirectional I/O bit. This allows the pin to be held at ground and then ungrounded when using it as an input for the comparitor.
Most of the time, the circuit is in the “filtering” sate (see the illustrations above). The inputs are sampled periodically at a low duty cycle as the sampling duty cycle affects cross talk among the inputs. This is discussed in more detail below. During filtering time, pin 12, which is the input to the comparitor is held at ground and pin 12 (the I/O pin is an output, written with a logic low), Pin 14, which is the multiplexing pin, is open. Under these conditions, the filter capacitor is kept charged to the input voltage (V1).
When it is time for the input voltage to be connected to the comparitor input, pin 12 is opened (the I/O pin is made into an input) and the multiplexing pin, pin 14, is connected to + 5V (made into an output pin and written with a logic high). This causes the positively charged plate of the capacitor to be connected to +5V through the diode. This results in a a Vdd minus one diode drop, minus the voltage on the capacitor being applied to pin 12.
Vpin12 = the voltage applied to the analog input of the comparitor, pin 12,
Vdd = the power supply voltage, 5 volts in this example,
Vdiode = the voltage drop across the diode, which is somewhat dependent on the current through the input resistor, and
Vin = the input voltage applied to the input of the RC filter.
One thing that should be apparent from looking at the expression above, is that input voltages are restricted to the range of 0 volts to Vdd-Vdiode, or 0 to about 4.4 volts. As voltages approach 4.4 volts, the current through the diode will become very low, and a noticeable linearity may develop.
To make a multiplexer, simply combine two or more of these switched capacitor stages along with their control I/O pins, as shown in the illustration below.
The diodes are necessary to provide isolation while the other channels are selected. In the third state illustrated below, the voltage V2 across a second channel is being sampled. If the V2 = 0 volts, and if V1 = 5V (so that the voltage across C1 = 5 volts), then when V2 is sampled, the cathode of the connected to pin 15 is one diode drop below the +5V supply, and that would put the positive plate of the C1 at about +9.4 volts. The diode in series with the multiplexing pins (14 and 15 in this example) is there to isolate the high positive voltages from the internal protection circuitry in the microcontroller.
As many channels as needed may be added by simply adding an additional resistor, capacitor, diode, and output pin for each channel.
For more detail: Analog Multiplexer using AVR microcontroller
Leave a Comment
You must be logged in to post a comment.