Arduino Digital Clock with Two 74HC595 Shift Registers

ArduinoArduino has become one of the easiest microcontroller platform to develop and therefore it is open source. In this post I’m trying to write down my experiment in using Arduino as 7-segment digital clock display controller driver.

In this project, I’m using digital multiplexing technique by using 2 74HC595 shift-register with latch ICs. The first shift register is used to transfer 8-bit 7-segment data serially for each digit from the Arduino and the other one is to multiplex the displayed digit one-by-one. We only able to display 1 digit at a time, so we have to display all the digits one by one. We do this really fast in <3ms so human eyes will see all the digits were lights up together. One 74HC595 shift register is able to multiplex 8 7-segments display at maximum.

Multiplexing the 7-Segment Display

74HC595 Shift Registers

Two 74HC595 Shift Registers used in Arduino Digital Clock to multiplex up to 8 7-segments and send the 7-segment data serially.

Assuming the two shift registers (SR) are named A (IC1) and B (IC2), SR A used to transfer the 7 segment data serially and SR B used to shift/move from each digit to another. QA to QH are the output of SR A and are connected to the 7-segments A to H pin respectively. QM1 to QM8 are connected to the common pin of each 7-segment respectively. Data, Clock, Data-M, Clock-M, Clear, and Latch pin are connected to the Arduino digital pins. The GND pin are connected to the circuitry ground and the Arduino ground pin.

Notice for a 1uF capacitor connected on the latch pin. Those capacitor are used to avoid flicker when the latch pin pulses (source: http://arduino.cc/en/Tutorial/ShiftOut).

The logic on how to multiplex the 7 segment are like the following steps:

  1. Turn the SR A and SR B latches OFF so the data transferred to the SR A are NOT displayed (visible) while transferring.
  2. Set the the first data-bit for SR B to HIGH, so that the first digit of 7-segment data will be displayed, but it is not displayed yet, because we set the latches OFF on previous step. This step requires 1 data-clock on Clock pin of SR B. Later, QM1 to QM8 will be set to HIGH one by one while “moving” to “SELECT” which 7-segment digit is displayed at a time.
  3. Send 1 byte data to be displayed to the first digit of the 7-segments serially. This step requires 8 data-clock of SR A. This 1 byte of data will be the output of QA to QH on SR A.
  4. Turn both SRs latch to ON, so that the data sent on SR A displayed on the first digit of 7-segments.
  5. Next, we have to display the value of the next digit. Turn the latch to OFF on both SRs.
  6. We have already set the data bit on SR B to HIGH to display the first digit, those bit will move to the next bit when we send another 1 clock to the data-clock of SR B. So, when displaying the 2nd to the 8th digit, we have to set the data bit to LOW and send 1 clock to the data Clock-M pin to shift the register data and “activate” the next digit.

    Multiplexing digit: When the previous output on SR B are nomary 10000000 then the next SR B output will be binary 01000000, and the next one will be binary 00100000, and so on… The one “1″ bit will be shifted 1 bit to the right for each clock to select which digit are ON at a time. After the one “1″ bit reaching the right most bit, it have to return to the left most bit on the next step.

    This is how we multiplex 8 digit of the 7-segments display. And we’re going to do this really fast!

  7. Send 1 byte data to be displayed to the next digit of the 7-segments serially. This step requires another 8 data-clock of SR A.
  8. Turn both SRs latch to ON, so that the data sent on SR A displayed on the first digit of 7-segments.
  9. Step 5 to 8 are repeated until the 8th digit and then repeat to step 1.

Driving 7 Segment Display from 74HC595 Output.

Each 74HC595 pin are able to draw a maximum current of around 35mA, those current are most likely enough to turn on 1 LED. For a 7 segment display, especially a large one (>0.5 inch in size) you will be most likely requires a large amount of current to turn on the 7-segment display especially when you multiplexed it. When you multiplex the displays to 8 digits, it will lights 1/8 of a time. So you probably need 8 times larger current flowing through the 7-segment display.

Current Amplifying General Purpose Transistor

How to amplify the current? What is the solutions? One of the most commonly used are by using an NPN transistor. In this experiment, I’m using a BC547 or 2N2222A general purpose transistor for each output of SR B which is connected to each common pin of the 7-segment display.

The transistor is used like a switch, when the QM1 output is HIGH at the base of the transistor, then it will allow a higher voltage and current to flow from transistor collector to emitter which is connected to the common pin of the 7-segment display. The amount of current can be drawn (Ice) are the current on it’s base (Ib) multiplied by it’s hfe. The amount of hfe can be seen on the datasheet. Thus this value are influence the calculated size of R1.

Calculating R at The Base of Transistor

Assuming a 7-segment had a nominal forward current of 20mA each segment. One 7-segment display may requires 8x20mA  = 160mA if all the 8 segments is ON. We’re going to multiplex it up to 8 digits, so we may requires up to 160x8mA = 1280mA, that is the value of Ice.

From the transistor datasheet, BC547 has a minimum value of hfe 110.

Ice = Ib x hfe
Ib = Ice/hfe
Ib = 1.280 A / 110 = 11.64 mA

We need to draw that much current at each of the output of the multiplexing shift register (SR B). The output voltage of SR B is 5V. From the calculation above, we know the amount of current needed at the base of the transistor (Ib). Based of the Ohm’s Law:

V = I x R, then R = V/I
Rb = Vbe / Ib = 5V / 0.01164A
Rb = 429.55 Ohm

In order to draw a minimum of that much current, we have to use a maximum resistor value of 430 Ohm. The power dissipated by the resistor is calculated as follow:

P = V x I
P = 5 x 0.01164
P = 0.0582 Watt

So, a 1/8 or 1/4 Watt resistor having a value of 430 Ohms is sufficient enough to dissipates those amount power.

Calculating R at Each Segment Pin of 7-segment Display

7-Segment Resistors

Based on the datasheet of the 7-segment, a 7-segment may have a forward voltage (Vf) of 3.2V for the A to G segments, and have a forward voltage 1.8V for the dot segment, but yours may vary. Lets calculate the R value on A segment.

The nominal voltage forwarded at the common pin is 5V. Forward voltage on A segment (Vf) is 3.2V, then the voltage at resistor connected to the A segment (RQ1) is:

VR = V – Vf
VR = 5V – 3.2V = 1.8V

From the calculation above, each segment may requires 20mA current multiplied by the number of multiplexed digits, so each segment may requires 8 x 20mA = 160mA of current (IR). Back to the Ohm’s Law, the value of resistor may be calculated as follow:

R = VR/IR = 1.8/0.160 = 11.25 Ohm.

With the same calculation method, we have the R value for the dot segment as follow:

R = (5 – 1.8) / 0.160 = 20 Ohm.

The power dissipated by the resistor (RQ1 to RQ7) are calculated as follow:

P = VR x IR
P = (5 – 3.2) x 0.160 =  0.288 Watt

And for RQ8 is calculated as follow:

P = VR x IR
P = (5 – 1.8) x 0.160 =  0.512 Watt

So we have to use a 1/2 Watt resistor (RQ1 to RQ7) valued at 11.25 Ohm and 20 Ohm for RQ8.

To be continued…

5 thoughts on “Arduino Digital Clock with Two 74HC595 Shift Registers

  1. what? to be continued..?
    this is a great post – please make more when you have time. much more informative and in depth than some of the other arduino stuff on the web. thanks very much! :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

CAPTCHA Image

*

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>