The SN74HC595 devices are 8-bit Serial-In, Parallel-Out Shift Registers , which basically means that, for example, a microcontroller can communicate with the device by a serial interface and then the SN74HC595 makes that data available in a parallel format (in this case, the 8 bits).
This functionality is very useful since we can extend the number of pins a microcontroller can control. Thus, in this case, as we will see next, we can control 8 output bits with only 3 digital pins from a microcontroller. A typical use case is controlling multiple LEDs.
Internal structure and operation
Internally, the device is composed of 2 registers, with 8 bits (which is the same as 8 memory positions) each. The first one, a shift register, will feed a second one, a storage register. Figure 1 illustrates the internal structure.
Naturally, we first need to load data to the shift register and then transfer it to the storage register. Figure 1 represents a possible state where some data as already been loaded to the shift register but none has been loaded to the storage register.
Notice that the serial input signal corresponds to the data that is transferred to the shift register of the SN74HC595 to latter be accessible in the parallel output. Since we have 8 output data bits, we typically want to pass 8 input data bits each time. This is an external signal and is accessible in a pin of the integrated circuit.
The clock signal, which is also an external signal available through a pin, controls the loading operation of data to the shift register.
Figure 2 illustrates the process of loading the serial data from the serial input.
As can be seen, when a positive edge occurs in the clock signal, the data in the serial input pin is transferred to the SN74HC595 as one bit. Internally, the first memory position of the shift register is set to the value of the serial input (HIGH = 1 or LOW = 0) and the other memory positions will get the values from the previous memory positions (thus shifting).
As represented in the figure, the bit that was in the last memory position of the shift register is “lost” when the shift occurs. Nevertheless, we can obtain that bit in a output pin of the IC. This allows, for example, to cascade multiple of these ICs, allowing to control even more output pins, with the exact same number of digital pins from a microcontroller.
So, since we already have data in the shift register, we can now signal the device to transfer those bits to the storage register. Then, each bit of the storage register will correspond to the 8-bit parallel output, available through pins of the integrated circuit.
The output bits are stored in the storage register and the transfer procedure is started by a rising edge in a specific signal, which is controlled externally to the device and exposed in one of its pins.
The serial input, the clock and the load signals are the main ones needed to control the state of the device and are, in typical applications, generated by a microcontroller.
Figure 3 shows the pin mapping of the SN74HC595.
Pins from QA to QH are the parallel outputs (8 bits). From a functional point of view, if we connect the device to a microcontroller, those will be 8 extended digital output pins. As we seen in the previous section, these pins correspond to the 8 bits stored in the memory positions of the storage register.
The SER pin corresponds to the serial input data, also mentioned in figures 1 and 2.
The SRCLK is the shift register clock and is, as mentioned, positive edge-triggered . So, when a positive edge occurs, the data in the SER pin is transferred to the SN74HC595 as one bit, to the first position of the shift register. Naturally, since we are operating with groups of 8 bits, we typically expect for 8 positive edges of SRCLK to pass all the data.
The RCLK pin corresponds to the signal to load data from the shift to the storage register, also mentioned before. Then, those bits will be available in pins QA to QH. Naturally, those pins will maintain the value until we send more bits with the previously mentioned method. This pin is also activated with a transition from LOW to HIGH.
The OE pin is the output-enable pin. The line on top of its name means that it is active-low. In order words, we need to connect it to LOW for the QA to QH pins to be in an HIGH or LOW state. Otherwise, if we connect that pin to HIGH, the QA to QH pins will be disabled (high-impedance state) . In typical applications, we connect it directly to GND.
The SRCLR pin allows to clear the shift register and is an active-low pin . For typical uses, we connect it to VCC, since we can clear the content of the shift register by sending LOW values by the serial interface.
Finally, the QH’ pin is the one where we can obtain the discarded bit of the shifting procedure. Explaining the procedure of cascading these ICs using this pin is outside the scope of this post and for applications that use just one SN75HC595 it can be left unconnected.
As stated in the datasheet of the device, the recommended supply voltage should be between 2 V and 6 V . This means that it can be used by both a regular Arduino operating at 5 V and also an ESP8266 operating at 3.3 V.
The absolute maximum output current per pin is 35 mA . Nevertheless, the maximum continuous current through VCC or GND is 70 mA . So, we should be careful to avoid that the sum of current of all pins becomes greater than this threshold.
The SN74HC595 is a very common device that has been used by makers for a long time. Thus, it’s a well known IC and there are lots of great tutorials around the web on how to use it with multiple microcontrollers, such as the Arduino.
Nevertheless, I decided to create this post as a starting point for future tutorials on how to control the SN74HC595 from an ESP8266.
I would also like to say that there are 74HC595 ICs from multiple manufacturers, but the working principle should be the same and thus, future tutorials should be compatible with them. This tutorial was based on the SN74HC595 from Texas Instruments.
- ESP8266: Connection to SN74HC595
- ESP8266: Connection to SN74HC595 via SPI
- ESP8266: Controlling chained SN74HC595 ICs