Projects > Hardware Projects >

Driving Seven Segment Display using Shift Register 74HCT595


Few days ago I got a bunch of seven segment displays from a scrap shop (for me, scrap shops are like heaven). I had some projects that needed some of them. I first thought of using ordinary seven segment display drivers such as 7448, 74248, 4511 etc. But I found limitations using them as drivers. So I needed an alternative and found the shift registers good for my applications. It only needs 3 pins to transmit the data which saves pins when used with microcontrollers. We can display anything on the seven segments as we like and the serial input of the shift register also reduces the coding complexity if used with Arduino. The 74HCT595 is a 'Serial In Parallel Out' (SIPO) shift register from 74XX family with storage register and 3-state output (High, Low and high Z). Shift registers are very useful when you want to expand the no. of outputs of your microcontrollers.

The shift register has 8+1 outputs which is enough to drive the eight segments of the seven segment display including the decimal point. Following is the pin configuration of the 595.

Pin Configuration

https://docs.google.com/uc?id=0B_FuMGaqECLuWHBYUlRnQW4tWXM&export=view
The Q0-Q7 are the parallel output pins and the Q7' is the serial output pin. The data bits are serially fed through DS (data serial) pin. ST_CP is the storage register clock and SH_CP is the shift register clock. OE is grounded to enable the outputs. The memory is cleared when the MR is tied to Low. The following is the circuit I used with Arduino Uno R3.

Circuit Diagram


https://docs.google.com/uc?id=0B_FuMGaqECLuT2tHMDNiQlpTV1U&export=view



To use the shift register with Arduino, we first need to map the outputs of the shift register to the seven segment pins. Following is the mapping I used with my common cathode displays. For common anode displays, the bits are to be complemented. It uses the LSBFIRST scheme, that means the lowest significant bits (the right most bits) are transmitted first. The mapping let's you to enable the decimal point segment just by adding 1 to the value to display.

Segment Mapping


https://docs.google.com/uc?id=0B_FuMGaqECLuZFBDU0tJNHBtcWM&export=view

Program


The sample Arduino code to display all possible recognizable characters is as follows.



//**************************************************************//
//  Name    : SevenSegment using 595                            //
//  Author  : Vishnu M Aiea (www.vishnumaiea.in)                //
//  Date    : 15-06-2014                                        //
//  Version : 1.0                                               //
//  Notes   : Code for using a 74HC595 Shift Register           //
//            to dispaly all possible characters on a           //
//            seven segment display (coommon cathode)           //
//****************************************************************

int latchPin = 8; //Pin connected to ST_CP of 74HC595
int clockPin = 12; //Pin connected to SH_CP of 74HC595
int dataPin = 11; //Pin connected to DS of 74HC595

int segMap[19] = {252,96,218,242,102,182,190,224,254,
                  246,238,156,158,142,110,28,206,124,2};

void setup() {
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {
  //count up routine
  for (int j = 0; j<19; j++) {
    //ground latchPin and hold low for as long as you are transmitting
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, LSBFIRST, segMap[j]);   
    //return the latch pin high to signal chip that it 
    //no longer needs to listen for information
    digitalWrite(latchPin, HIGH);
    delay(300);
  }
} 

Images


     https://docs.google.com/uc?id=0B_FuMGaqECLuamdrejhnWWVuSjg&export=view
 https://docs.google.com/uc?id=0B_FuMGaqECLuUGRwblc4YUxJM1E&export=view















Time-stamp

Date published : 1:17 AM 13-12-2014-Saturday
Last updated : 8:58 PM 31-03-2016, Thursday
SelectionFile type iconFile nameDescriptionSizeRevisionTimeUser
Ċ
View
PDF file  Dec 12, 2014, 11:57 AM Vishnu M Aiea