Michael Silverman documenting innovation at work

8Jan/130

Shift Registers: Serial In, Parallel Out

Schematic for 16 bit output

In this article I will examine Serial In Parallel Out (SIPO) shift registers. These are very useful for microcontroller projects. This type of register allows you to turn three output pins into as many as you would like. I will explain the theory behind the registers and give an actual implementation. As a working example we want to drive 16 pins for a clock application using as few pins on the microcontroller as possible.

Lets examine the logic diagram on the 74HC595. The pin descriptions in the datasheet can be confusing.

74595HC Logic Diagram

74HC595 Logic Diagram

One way to think of the register is this way: Each output bit utilizes two D latches (shown above as FFX and LATCH). The first latch is used for clocking in the data. The second latch acts as a buffer (or storage register) for the data.

Q0-Q7: These are our parallel outputs. Data shits in from Q0 to Q7.

DS: This is your serial data input, clocked by SHCP.

MR: This will reset the first latches FF*. We do not need to worry about a reset, so we will keep always keep this logic high.

SHCP: This is the clock for the serial data input. After setting each DS bit, you must clock SHCP.

STCP: This is the clock for the second D latch. By clocking this, the value on each latch set before through DS and SHCP will appear on the output of each bit's second D latch. This will act as our buffer from input to output.

OE: This enables the Q value on each second D latch (the one clocked by STCP) to appear on the output. Since we always want the data to appear on the output we will tie this to ground. By doing this, each clock shift of STCP will shift the storage registers value to the output. In other words, the output pins will always have a 0 or a 1, there is no high impedance off option. We want to switch from one digit to another so this is fine. The STCP will act as our "output enable".

Q7S: The shift register can only hold 8 bits. If you shift in 9 bits, the first bit shifted in will appear on the Q7S output. This feature allows you to daisy chain as many shift registers together as you would like. Just hook up Q7S to the DS input of the second register and you now have a 16 bit register. The clocking on SHCP and STCP are the same for each chip so you are not using any more pins on the microcontroller. To shift in N bits, put desired valued on DS, shift SHCP, repeat N times.

The schematic below shows is an example circuit for turning 3 pins into 18 using two shift registers.

Schematic for 16 bit output

Schematic for 16 bit output

The following is a logic analyzer example of the input and output. I made this diagram using a program called TimingAnalyzer. We will input 1110001110001110.

Timing Diagram 74HC595 Circuit

Timing Diagram 74HC595 Circuit

A few points should be made about the timing diagram. The DS bit is latched on the positive edge of the SHCP clock. Remember the last bit you shift in will appear on the least significant bit, or first output (Q0).

Between the schematic and the timing diagram it should now be easy to implement this solution in the microprocessor of your choosing.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.