Making a serial seven segments display using 74HC595 shift register

Multi digits display

Multiplexed seven segment display is capable of driving fewer digit around 6 digits. Things become worse when we try to multiplex many digits for example 10 digits.

In convenience we use serial transmission method for sending data to each digits. Each digits are independence and are driven by individual shift register. Each shift register connects to each other via two line: serial data line and serial clock line.

Introduction To SN74HC595 IC

74HC595 is a popular IC widely use with microcontroller to receive serial data from microcontroller. It’s a serial in / parallel out shift register. It’s CMOS type. The output data is 8-bit wide. And it has a serial data out pin to shift data to next external register.

The block diagram below show the function diagram of 74HC595.

74HC595_function_diagram

Data is shifted in to the shift register via serial data line (DS) synchronizes with serial clock line (SHCP). /MR is the reset signal it must connected to Vcc in normal operation. Q7S is a serial data pin that shift data out to next IC.

Data is latched into storage register via internal parallel data lines when  storage register clock (STCP) pin is active ( Low to High).

Output register shift data out in parallel to outside world. It usually connect to LEDs, seven segment display or relay ,etc. The /OE pin controls the output of output register. It must connect to ground to enable the outputs.

The output data is 8-bit wide ranging from Q0 to Q7.

Serial display board design

In this project I create seven segment board that consist of 7 digits. Each digit is red in color, 1 inch diagonal and common cathode type. Data is shift into this module serially via three wires: serial data (DS), serial clock (SHCP) and storage clock (STCP). First IC connect to next IC via two wire: serial data output (Q7S) and serial clock (SHCP). STCP is common to all ICs. It’s commonly use with +5V logic level.

Let see the schematic below:

serial_display2

The PCB is single sided board with some jumpers.

serial_display2-1

I create the design file with Proteus 8.5 SP0. You can download it here.

The galleries below shows the complete work of this project.

74HC959_Serial-Displays_board-774HC959_Serial-Displays_board-674HC959_Serial-Displays_board-574HC959_Serial-Displays_board-474HC959_Serial-Displays_board-374HC959_Serial-Displays_board-2

For a larger display with DIY PCB you can see this PCB design.

Making A DIY SN74HC595 Serial 10-Digit 7-Segment Display Board

Making A DIY SN74HC595 Serial 10-Digit 7-Segment Display Board

Making A DIY SN74HC595 Serial 10-Digit 7-Segment Display Board

Making L298N DC Motor Driver PCB

L298D is an integrated high voltage, high current dual full bridge driver designed to drive inductive loads such as DC motor, solenoids and stepper motors. It works with TTL level logic.

There are four output drivers. That’s two pairs and each pair is control by its individual enable signal.

The current output come from the load of each pair flow through pin 15 and 1 respectively. when can connect those pin directly to ground. Otherwise we can put an external resistor to sense the output driving current.

In this example I use Multiwatt15 package. The graphic below show the pin diagram of L298D.

L298N_pin_diagram

The picture below is the block diagram of L298.L298N_block_diagram

I draw the L298 driver board using Proteus 8. There are input logic, output drivers, power supply for logic and driver, enable pins and current sensing elements. I also put the spike protection diodes. At this time I don’t have high speed diode. So I decide to use standard recovery diode instead.

L298N

Below is the artwork of the circuit.

L298N_artwork

I have assembled the module and I have already test it.

L298_Assembled-2L298_Assembled-1

Here is download link for designed file ( Proteus 8.5 SP0 ).

Making multiplexed seven segments display from individual digit

Multiplexed display is very popular in microcontroller projects because it use much little output pins. In the market multi digit seven segments display are build into one module. They are internally connected and the output pins are control pins. That’s easy to use.

In the case we don’t have the multiplexed display module we have to use individual digit and connect each segments of the digit together. This require to design our own circuit board and take time to complete the design and making the PCB. And it also require assembling and soldering the components.

I decided to use Proteus a UK based software vendor that specializes in developing the SPICE model for digital and microprocessor/microcontroller simulation. They also provide a tool for designing the professional PCB.

In this project I use four single seven segments display with the diameter of 0.56 inch. They are common cathode red segment. I also put the transistor driver on that single board for the ease of use.

Below is the schematic:

four_mux_ssd_Ccc

Below is the copper layer of the PCB that’s ready to print.

four_mux_ssd_Cc_PCB

Below is the top silk layer of the PCB that’s ready to print.

four_mux_ssd_Ccc_silk

I also take the 3D model but it lack of 3D components.

four_mux_ssd_Ccc-Proteus-8-Professional-3D-Visualizer

Here is the attached design file designed using Proteus 8.5 SP0.

The gallery below is the completed project.

mux_disp1-6.jpgmux_disp1-5.jpgmux_disp1-2.jpgmUX_DISP1-1

I have already test this module with Arduino.

tested_arduino.jpg

Using PIC16F887 External Interrupt in MikroC

Introduction to external interrupt

In PIC16 family external interrupt is an interrupt triggers by the changing of logic state input to pin RB0 of PORTB. Change of logic state has two case:

  • transition from high to low (negative edge) and
  • transition from low to high (positive edge)

Both of two case are programmable in software. We will show you next step.

Setting up external interrupt

To write the code properly we must follow the following step :

  • Setup the direction of RB0 pin as a digital input by setting the corresponding TRISB to 1 . Furthermore disable any associated analog input function.
  • Select the edge of the interrupt from INTEDG of OPTION_REG. If INTEDG=0 interrupt will occur in negative edge otherwise positive edge.
  • INTCON is an interrupt control register. We must setup the interrupt manner as following: enable global interrupt by giving GIE = 1 , enable external interrupt by giving RBIE=1 and clear interrupt flag RBIF=0.
  • Write the interrupt service routine (ISR).
  • In the main task of the program keep your programming running without polling the interrupt. When Interrupt occurs it will jump to ISR.

External interrupt programming in MikroC

In this example we demonstrate the use of external interrupt by toggling LED on and off each time the interrupt occurs.

Pin RB0 functions as an interrupt pin. It will generate interrupt signal whenever the digital signal input change from high to low. Fortunately each pin of PORTB come with individual weak pull up resistor so we don’t need to add any external resistor. We can enable it in software.

In the interrupt service routine we check for external interrupt flag (RBIF). If it occurs we toggle LED0.

The main task of the program is to blink LED1 on and off regularly without polling any external event.

Let see the schematic below:

External_Interrupt

Here’s the code written in MikroC:

 

#define LED0 PORTB.RB6 
// LED0 IS CONNECTED TO RB6 
#define LED1 PORTB.RB7 
// LED1 IS CONNECTED TO RB7 
// INTERRUPT SERVICE ROUTINE 
void interrupt() {
 if(INTCON.INTF) // CHECK IF THERE'S EXTERNAL INTERRUPT OCCURED
 {
   LED0^=1; // TOGGLE OUTPUT ON RB6
 }
   INTCON.INTF=0;
 }
 void main() {
   PORTB=0x00;// CLEAR PORTB BEFORE USE
   TRISB=0x01; // RB0 IS AN INPUT
   ANSELH=0x00; // DISABLE ANALOG FUNCTION RELATED TO PORTB
   OSCCON|=0x70; // SELECT INTERNAL 8MHz OSCILLATOR
   OPTION_REG.NOT_RBPU=0; // ENABLE WPUB
   WPUB=0x01; // TURN ON WEAK PULLUP ON RB0
   OPTION_REG.INTEDG=0; // SET INTERRUPT FROM H TO L
   INTCON.GIE=1; // ENABLE GLOBAL INTERRUPT
   INTCON.INTE=1; // ENABLE EXTERNAL INTERRUPT
   INTCON.INTF=0; // CLEAR INTERRUPT FLAG
 // MAIN TASK
 while(1){
   LED1^=1; // TOGGLE LED ON RB7 REGULARLY
   delay_ms(500);
   }
 }