This versatile chip simplifies display driving for LEDs and 7-segment displays, for just about any application.
So what’s a 74HC595? A car number plate? The name of a far-off star? A Google search shows that 74595 is an area called Langenburg in Germany. Well, we could be referring to any of them, but for we makers it’s a very useful integrated circuit that forms the heart of our 7-segment display modules.
The 74HC595 is an 8-bit serial in, parallel out shift register with an 8-bit D-type storage register and high output current capability. Phew, but what is it? More simply, it is a device that accepts 1 bit of data (0 or 1... sounds like something useful for a computer doesn’t it?) at a time, and internally moves (shifts) it along its internal storage to form an 8-bit output.
The 8-bit D-type storage register keeps the values of the bits until either the power is removed or the SRCLR (shift register clear) pin is pulled low. The outputs can provide enough current to drive an LED (or one node of a multi-segment display) via, say, a 220ohm current limiting resistor. That really helps to reduce the number of components needed, and because the data is transmitted over one Arduino pin plus a couple of control pins (more on this shortly), the number of resources used on the Arduino is reduced. Compare that to using eight Arduino digital pins, each driving a transistor which then switches one LED on/off; that’s a lot more components and a lot of valuable Arduino pins used.
UNDERSTANDING CONTROL PINS
The good news is that there are only two of them; so including the data pin, that’s three pins in total from the Arduino. We control these pins by using the digitalWrite() to set their level high (logic 1) or low (logic 0) as required.
The pins we use to control the 74HC595 are:
- Pin 11 of the 74HC595 known as SRCLK (Serial Register Clock)
- Pin 12 of the 74HC595 known as RCLK (Register Latch).
Along with pin 14 of the 74HC595, which is the data input pin known as SER (or serial data), that’s all we need.
The 74HC595 will accept a bit (0 or 1, it doesn’t matter) on SER, and shifts existing bits (if any) along when SRCLK goes high; but only on the rising edge of the SRCLK pin going high (i.e., during that VERY short time when the level goes from low to high). To ensure the 74HC595 only accepts data when we’re ready, the RCLK must be pulled low too.
The '595 is a "load and shoot" device. The procedure is to load the serial registers with 8 bits, e.g. '10110110', by issuing a clock pulse (ser) for each bit as presented. When 8 bits (or more) have been loaded, issuing a register clock pulse transfers the last 8 bits of the serial data into the parallel register, all at once. Extra bits will pass out via QH' allowing multiple '595s to be cascaded into 16, 24, etc. outputs.
THE LAST FEW PINS
OE (Output Enable - pin 13) will enable the parallel outputs when pulled low. If OE is left high, the outputs go tri-state; effectively ‘not there’. The last pin is SRCLR (Shift Register Clear - pin 10).
This clears the contents if pulled low. In our display modules for our MEGA DIGITS project in this issue, we keep OE low and SRCLR high.
Bigger is better, right? If some is good, more is better...? With one 74HC595 we can display 8 bits of data, be that on individual LEDs or a 7-segment LED display. But what if we want more? The design of the 74HC595 allows for this. If more than 8 bits are shifted into it, then generally the first bit shifted in will be shifted out and lost. However, pin 9 - let’s call it overflow - has the value of that bit, and we can transfer that bit to another 74HC595. With two 74HC595 we can display 16 bits of data on LEDs, or 2 x 7-segment displays. Neat! With six 74HC595 we could display decimal values up to 999999, or we could display 23 59 59, being one second before midnight, or any time in between. With 847,341 74HC595's we could display... well nothing probably, as it would need too much power. So what if we wanted to drive super bright LEDs from 12V? Well...
A NOTE OF CAUTION
The 74HC595 will operate with Vcc of 2-6VDC. For most makers this means using it with 5V from the Arduino. With extra circuitry it can drive higher voltage displays, but remember it IS a 5V part and connecting it to 12V or more may let the smoke out (and rest assured, it will never go back in).
SO WHAT DOES THIS ALL MEAN FOR MAKERS?
Essentially the main benefit here is offsetting the duties of handling display to another integrated circuit. It is indeed possible to drive 7-segment displays and such, directly from an Arduino board but you quickly run out of I/O ports, and your code could become unmanageable. If you’re only outputting to one single 7-segment display, you can probably drive it directly. What about two displays, four, or ten? It quickly becomes unmanageable. Even to display the time you would need 28 x IO just to have hours and minutes, or 42 x IO to include seconds. That’s starting to push the limits of even a MEGA board, and it’s horrible to code.
By implementing discrete, purpose-built ICs into our projects, then driving them with suitable data from an Arduino, we open up a world of potential. You can keep your code leaner, use smaller Arduino boards, and generally use each piece of hardware to the best of its abilities.
See our super-sized time display project, as one example of a great practical application.