- Published: Tuesday, 21 May 2013
- Written by Jon Chandler
- Hits: 5446
This is a repost from EDN Magazine's Design Ideas.
This Design Idea shows how a single microcontroller port can drive a lot of output lines through shift register. In this case we use the shift register with strobe control to achieve perfect output line control.
Shift register outputs can drive LEDs, relays, etc. In other words, they can be used as (additional) general purpose outputs.
Today there are shift registers that have DATA and CLOCK inputs only, like 74HC164, and shift registers with same inputs plus STROBE control input, like 74HC4094 or 74HC595. The shift registers without STROBE control have short-term transient states at outputs during shifting. Transients occur because shift register is directly connected to output lines. This kind of shift register can be used for driving LEDs and similar devices where short-term transient is irrelevant. For example, the human eye can't notice LED flickers shorter than 10 msec. The shift registers with STROBE control have two registers.
The first one is shift register and the second one is storage register. The storage register keeps its data frozen while the new data are being loaded in shift register. After the new data is shifted in, STROBE pulse is used to transfer all data bits to storage register at once. In this way outputs are set without transients. This is a new quality which makes this shift register applicable for driving transient sensitive devices like TRIACs, super bright LEDs, etc.
There are several different solutions for driving shift register with few I/O lines. Some of the Design Ideas referenced below describe driving shift register without strobe control.1, 2
In order to explain how to drive shift register with STROBE control over only one I/O line we show circuits from figures 2 to 4. Figure 2 shows shift register controlled with three lines: DATA, CLOCK, and STROBE.3
If STROBE control input is connected to 5V, logical 1, we practically get shift register without STROBE control. For such a case we can apply the solution from Reference 1, where one I/O line drives DATA and CLOCK input (Figure 3).
Figure 3 One microcontroller port controls DATA and CLOCK inputs of shift registers. The STROBE input is inactive, connected to 5V (logical 1).
But when we want to use STROBE signal to get transient free output signals, it seems that we need two ports, CLOCK and STROBE. Further improvement is possible by adding a monostable multivibrator circuit, like in Reference 4.
Finally, we propose the simplest solution. In this solution STROBE input is controlled over RCD network (Figure 4).
Figure 4 The shift register (with STROBE input) is controlled over one I/O line, using RCD network.
The RCD network is formed from discrete resistor Rn=220KΩ, capacitor Cn=47p, and diode Dn. The RCD network enables that STROBE signal rapidly drops to zero, but slowly rise to one with time constant Rn×Cn=10.34 µsec.
Let us look at the first shift register. The microcontroller drives CLOCK input directly. The same signal passes through the RC filter and drives DATA input D (Figure 5). The RC filter is formed from discrete resistor R=470KΩ and D input pin capacitances, producing a time delay of approximately td=R×C×ln2=470KΩ×3 pF×0.7 ≈ 1 μsec.
To write “zero” in the shift register, the microcontroller holds low level longer then td i.e. 2.5 μsec and after that sets high level.
To write “one,” the microcontroller holds high level longer than td. After that microcontroller generates a short negative pulse (100 nsec).
The oscillogram in Figure 6 illustrates it. Channel 1 shows CLOCK signal, channel 2 shows DATA signal, and channel 3 shows STROBE signal. We used Tektronix oscilloscope DPO4034 with high-voltage probes TPP0850. These probes have 40MΩ input resistance and only 1.5 pF input capacitance. Using these probes we can be sure that DATA and STROBE signals are captured well, without significant capacitance load distortion.
Figure 6 This oscillogram was captured while writing bits sequence 1111100000000000 in a 16-LED dot-bar/bar-graph display. The upper (yellow) trace is CLOCK, the middle (blue) trace is DATA, and the lowest (pink) trace is STROBE.
The shift registers are clocked by rising edge of CLOCK signal. This corresponds to local minimum of the DATA signal. From the oscillograms, it can be seen that DATA minimum for logical zero is 1.2V and for logical one it is 4.2V. The shift register logical threshold is 2.5V, so we can conclude that these voltages 1.2 and 4.2V guarantee sufficient voltage margins. In the circuit realization, 16 bits are stored in shift registers in approximately 50 µsec.
Figure 6 also shows how the STROBE signal (pink) rises after all 16 bits are loaded. In contrast to shift register without STROBE,1 in this case (with STOBE control) port should not stay too long on high voltage level, to prevent unwanted STROBE activation. For this case high level time should not last more than 6 µsec.
In Figure 7 we used zoom function to show negative CLOCK pulse that writes logical one. In our realization the microcontroller ATTINY13 generates this pulse as short as 100 nsec.
Figure 7 The narrow CLOCK pulse that writes a logical 1 is seen here.
The oscillogram from Figure 8 shows the CLOCK pulse that writes logical 0.
Figure 8 This is the CLOCK pulse that writes logical 0.
Figure 9 shows the photo of 16-LED dot-bar/bar-graph display with 74HC4094 shift registers. There are two 8-Bit Serial-Input/Parallel-Output shift registers. We made it with one-side PCB, so all tracks are visible in this photo.
Figure 9 The 16-LED dot-bar/bar-graph display uses a two 8-Bit 74HC4094 shift registers.
The software is extremely simple (Listing 1). It turns the LEDs on one by one, every 500 sec until all LEDs are on. After that, it turns all LEDs off and starts the cycle again. Below are two short videos showing the LED function and oscilloscope screen with DATA, CLOCK, and STROBE signals.
- Mijanovic, Zoran and Nedjeljko Lekic, “Drive 16 LEDs with one I/O line,” EDN, June 9, 2011.
- Edited by Charles H Small and Fran Granville, “Microcontroller provides low-cost analog-to-digital conversion, drives seven-segment displays,” EDN, May 10, 2007.
- Raynus, Abel, “Squeeze extra outputs from a pin-limited microcontroller,” EDN, August 4, 2005.
- Rex Niven, “RC lowpass filter expands microcomputer’s output port,” EDN, June 21, 2007.