A simple lowpass RC filter enables a single output pin of a microcontroller to expand the number of output bits.
It is almost a corollary to Moore's Law: Next year, microcomputers will have more features, and the software team will have better ideas. Unfortunately, though, the number of output pins will stay the same. Finding even one spare output for diagnostics, test, or even standard I/O can be a tussle. The single-pin "bus" in figure 1 can provide an unlimited number of parallel outputs with simple additional hardware. A microcomputer output with an RC lowpass filter controls serial-to-parallel converter HC164. To enter data into the serial-to-parallel converter, each bit consists of a one-to-zero-to-one transition, which alters the length of the low state. If the low state is longer than the lowpass filter's time constant, a zero shifts into the register. If the low state is short, then a one shifts into the register. The clock and data signals thus combine into one signal. A lowpass filter separates the clock and data signals (figure 2).
Figure 1: This single-pin "bus" can provide an unlimited number of parallel outputs with simple additional hardware.
Figure 2: The clock and data signals combine into one signal.
Listing 1, a simple "Whip" routine, performs the output function for eight bits. Assume that the RC time constant is 3µsec, and the instruction time should be 1µsec or less at a crystal frequency of 4MHz or greater. The routine uses bitwise manipulation of output My_Bit of port My_Port.
Figure 3: This circuit uses another serial-in/parallel-out register, the 4094, which has a strobe input to allow simultaneous updates of all outputs without temporary levels.
Listing 1: Whip-routine output function.
Although the circuit in figure 1 can control slow-reacting devices, such as relays or LCDs, using it with LEDs can give an annoying flicker when the HC164 is writing. To address that problem, the circuit in figure 3 uses another serial-in/parallel-out register, the 4094, which has a strobe input to allow simultaneous updates of all outputs without temporary levels. A twin monostable circuit supplies the data and strobe signals. This circuit should be able to control parallel devices, such as display modules based on HD44780 devices.
This article is a Design Idea selected for re-publication by the editors. It was first published on June 21, 2007 in EDN.com.