Top Banner
8051 HOW-TO GUIDE Interfacing 7SEG with 8051
14

Seven Segment Display Interfacing With 8051 Primer

Sep 14, 2015

Download

Documents

project
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8051 HOW-TO GUIDE

    Interfacing 7SEG with

    8051

  • Join the Technical Community Today!

    http://www.pantechsolutions.net

    Contents at a Glance

    8051 Primer Board ........................................................... 3

    I2C (Inter Integrated Circuit) . Error! Bookmark not defined.

    Seven Segment Display .................................................... 3

    Interfacing Seven Segment Display .................................. 4

    Interfacing Seven Segment with 8051 .............................. 5

    Pin Assignment with 8051 ................................................ 6

    Circuit Diagram to Interface 7 seg with 8051 .................... 7

    Source Code .................................................................... 7

    C Program to 7 Segment Display using 8051 ..................... 8

  • Join the Technical Community Today!

    http://www.pantechsolutions.net

    8051 Primer Board

    The 8051 Primer board is specifically designed to help

    students to master the required skills in the area of

    embedded systems. The kit is designed in such way that all

    the possible features of the microcontroller will be easily

    used by the students. The kit supports in system

    programming (ISP) which is done through serial port.

    NXPs 8051 (AT89V51RD2), 8051 Primer Kit is proposed

    to smooth the progress of developing and debugging of

    various designs encompassing of speed 8-bit

    Microcontrollers.

    Seven Segment Display

    A seven segment display is the most basic electronic

    display device that can display digits from 0-9. The most

    common configuration has an array of eight LEDs arranged

    in a special pattern to display these digits. They are laid out

    as a squared-off figure 8. Every LED is assigned a name

  • Join the Technical Community Today!

    http://www.pantechsolutions.net

    from 'a' to 'h' and is identified by its name. Seven LEDs 'a' to

    'g' are used to display the numerals while eighth LED 'h' is

    used to display the dot/decimal.

    Interfacing I2C - Seven Segment Display

    Fig. 1 shows how to interface the seven segments with

    microcontroller. Seven segments are generally available in

    ten pin package. While eight pins correspond to the eight

    LEDs, the remaining two pins (at middle) are common and

    internally shorted. These segments come in two

    configurations, namely, Common cathode (CC) and

    Common anode (CA). In CC configuration, the negative

    terminals of all LEDs are connected to the common pins.

    The common is connected to ground and a particular LED

    glows when its corresponding pin is given high. In CA

    arrangement, the common pin is given a high logic and the

    LED pins are given low to display a number.

  • Join the Technical Community Today!

    http://www.pantechsolutions.net

    Fig. 1 Interfacing I2C - 7segment to Microcontroller

    Interfacing Seven Segment with 8051

    We now want to display a four digit number in 8051

    Primer Board by using seven segment displays. The seven

    segment display is connected with 801 controllers.

    In 8051 Primer Kit, 4 nos. of common anode seven

    segment displays are controlled I/O Lines(p1.0-p1.7).The 7-

    segmend display is powered from the 5V power supply

    enabled by switch SW30.

  • Join the Technical Community Today!

    http://www.pantechsolutions.net

    Pin Assignment with 8051

    7-SEG 8051 Pins 7-Segment Display

    Dig

    it s

    elec

    t lin

    es

    Digit - 1 P3.4

    Digit 2 P3.5

    Digit 3 P3.6

    Digit - 4 P3.7

    Segm

    en

    t Li

    ne

    s

    Seg - a P1.0

    Seg b P1.1

    Seg c P1.2

    Seg d P1.3

    Seg e P1.4

    Seg f P1.5

    Seg g P1.6

    Seg dp P1.7

    Make switch SW30 to

    7SEG label marking position

    +5V ON OFF

    SW30

    PWR ON/OFF

    1 2 3 4

    8 7 6 5

    LCD 7SEG

    GLCD SM/RL

    Make high to - digit selection

    Make low to - segment

    f

    a

    b

    c d e

    g

    VCC

    1

    2

    3

    1KDigit - 1

    seg-aSeg-bSeg-cseg-d

    seg-fseg-e

    seg-gseg--dp

    U1

    7 SEG DISP

    E1 D2

    CA

    3

    C4

    DP5

    B6 A7

    CA

    8

    F9

    G10

  • Join the Technical Community Today!

    http://www.pantechsolutions.net

    Circuit Diagram to Interface 7 seg with 8051

    Source Code

    The Interfacing seven segment displays with 8051

    program is very simple and straight forward that display a

    four digit number in seven segment displays by using I/O

    Lines. The C programs are developed in Keil software.

  • Join the Technical Community Today!

    http://www.pantechsolutions.net

    C Program to 7 Segment Display using 8051 ***************************************************************************************

    Title : Program to I2C - Seven Segment display ***************************************************************************************

    #include

    #include

    unsigned char SetDisplay(unsigned char);

    void delay();

    sbit eseg1000 = P3^7;

    sbit eseg100 = P3^6;

    sbit eseg10 = P3^5;

    sbit eseg1 = P3^4;

    unsigned char d0,d1,d2,d3;

    unsigned char SetDisplay(unsigned char value)

    {

    unsigned char segment[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x83,0xf8,0x80,0x98};

    if(value

  • Join the Technical Community Today!

    http://www.pantechsolutions.net

    }

    //--------------

    //Delay Function

    //--------------

    void delay()

    {

    int i;

    for(i=0; i

  • Join the Technical Community Today!

    http://www.pantechsolutions.net

    {

    eseg1000=0;

    eseg100=0;

    eseg10=0;

    eseg1=1;

    P1=SetDisplay(d0);

    turn = 2;

    delay();

    }

    else if(turn==2) //7-Seg Display 1

    {

    eseg1=0;

    eseg1000=0;

    eseg100=0;

    eseg10=1;

    P1=SetDisplay(d1);

    turn = 3;

    delay();

    }

    else if(turn==3) //7-Seg Display 2

    {

    eseg10=0;

    eseg1=0;

  • Join the Technical Community Today!

    http://www.pantechsolutions.net

    eseg1000=0;

    eseg100=1;

    P1=SetDisplay(d2);

    turn = 0;

    delay();

    }

    else //7-Seg Display 3

    {

    eseg100=0;

    eseg10=0;

    eseg1=0;

    eseg1000=1;

    P1=SetDisplay(d3);

    turn = 1;

    delay();

    }

    if(timer == 100){

    d0++;

    timer=0;

    if(d0>=10){

    d0=0;

    d1++;

  • Join the Technical Community Today!

    http://www.pantechsolutions.net

    if(d1>=10){

    d1=0;

    d2++;

    if(d2>=10){

    d2=0;

    d3++;

    if(d3>=10){

    d3=0;

    }

    }

    }

    }

    }

    timer++;

    }

    }

  • Join the Technical Community Today!

    http://www.pantechsolutions.net

    Pantech solutions creates information packed technical

    documents like this one every month. And our website is a rich

    and trusted resource used by a vibrant online community of

    more than 1,00,000 members from organization of all shapes

    and sizes.

    Did you enjoy the read?

  • Join the Technical Community Today!

    http://www.pantechsolutions.net

    What do we sell?

    Our products range from Various Microcontroller

    development boards, DSP Boards, FPGA/CPLD boards,

    Communication Kits, Power electronics, Basic electronics,

    Robotics, Sensors, Electronic components and much more . Our

    goal is to make finding the parts and information you need

    easier and affordable so you can create awesome projects and

    training from Basic to Cutting edge technology.