Overview

Seven-segment displays are used to indicate digital information. The seven-segment display can display numbers from 0 to 9, and we can also display some letters such as A, b, C, H, E, e, F, etc. These are very popular and have many applications. So in this project, I will show you how a 7-segment display works by connecting the 7-segment display to the 8051 microcontrollers.

Required Hardware Components

Hardware

  • Launchxl-F28379D
  • 7 Segment Display

Software:

  • Code Composer Studio

Bill of Materials

S.NoCOMPONENTSDESCRIPTIONQUANTITYlink
1Launchxl-F28379d Launchxl-F28379d 1https://www.amazon.com/Arduino-A000066-ARDUINO-UNO-R3/dp/B008GRTSV6
2LEDLED1ader-em18-board-with-serial-ttl-interfacing-125-khz-through-a-rs232-converter-to-pc/?src=google&kwd=&adgroup={adgroup}&devicec&campaign={campaign}&adgroup={adgroup}&keyword=&matchtype=&gclid=CjwKCAjw49qKBhAoEiwAHQVTo-i85TwixHnJAFNHLfwUknLhBVYloMe3ECBLmMFtUFrk8qGBxO0vzhoCIAQQAvD_BwE
6Jumper WiresJumper Wires40https://www.flipkart.com/arduino-female-male-dupont-20cm-jumper-wire-40pcs-interconnect-electronic-hobby-kit/p/itmf8e5ezvkequ3h?pid=EHKF8DVBG9BXZHHH&lid=LSTEHKF8DVBG9BXZHHHUGSG9J&marketplace=FLIPKART&cmpid=content_electronic-hobby-kit_14498130132_u_8965229628_gmc_pla&tgi=sem,1,G,11214002,u,,,543116155366,,,,c,,,,,,,&ef_id=CjwKCAjwndCKBhAkEiwAgSDKQYwKr3euuMpKCLDJnf-

Introduction

Circuit Principle

The seven-segment displays internally consist of 8 LEDs. In these LEDs, 7 LEDs are used to indicate the numbers 0 to 9 and one LED is used to indicate the decimal point. In general, seven parts are two types, one is the common cathode and the other is the common anode.

On the common cathode, all the cathodes of the LEDs are connected together and are called com. The anode is left alone. In the common anode, the width of seven segments, all the anodes are joined together and the cathodes are left free. The following figure shows the internal connections of the seven-segment screen.

In the first circuit, I will connect a 7-segment common anode 1 display to the 8051 microcontrollers, while in the second circuit I will connect a 7-segment 4-digit anode display to the 8051 microcontrollers.

Circuit Diagram

Common Cathode 7-segment Display

2. The Common Anode (CA) – In the common anode display, all the anode connections of the LED segments are joined together to logic “1”. The individual segments are illuminated by applying a ground, logic “0” or “LOW” signal via a suitable current limiting resistor to the Cathode of the particular segment (a-g).

Common Anode 7-segment Display

DIGITAbcDefGHEX Value
000000010x40
110011110xF9
200100100x24
300001100x30
410011000x19
501001000x12
601000000x02
700011110xF8
800000000x00
900011000x10

In general, common anode displays are more popular as many logic circuits can sink more current than they can source. Also note that a common cathode display is not a direct replacement in a circuit for a common anode display and vice versa, as it is the same as connecting the LEDs in reverse, and hence light emission will not take place.

Depending upon the decimal digit to be displayed, the particular set of LEDs is forward biased. For instance, to display the numerical digit 0, we will need to light up six of the LED segments corresponding to a, b, c, d, e and f. Then the various digits from 0 through 9 can be displayed using a 7-segment display as shown.

Driving a 7-segment Display

Although a 7-segment display can be thought of as a single display, it is still seven individual LEDs within a single package and as such these LEDs need protection from over current. LEDs produce light only when it is forward biased with the amount of light emitted is proportional to the forward current.

This means then that a LEDs light intensity increases in an approximately linear manner with an increasing current. So this forward current must be controlled and limited to a safe value by an external resistor to prevent damage to the LED segments.

The forward voltage drop across a red LED segment is very low at about 2-to-2.2 volts, (blue and white LEDs can be as high as 3.6 volts) so to illuminate correctly, the LED segments should be connected to a voltage source in excess of this forward voltage value with a series resistance used to limit the forward current to a desirable value.

Typically for a standard red coloured 7-segment display, each LED segment can draw about 15 mA to illuminated correctly, so on a 5 volt digital logic circuit, the value of the current limiting resistor would be about 200Ω (5v – 2v)/15mA, or 220Ω to the nearest higher preferred value.

So to understand how the segments of the display are connected to a 220Ω current limiting resistor consider the circuit below.

 Driving a 7-segment Display

In this example, the segments of a common anode display are illuminated using the switches. If switch a is closed, the current will flow through the “a” segment of the LED to the current limiting resistor connected to pin a and to 0 volts, making the circuit. Then only segment a will be illuminated. So a LOW condition (switch to ground) is required to activate the LED segments on this common anode display.

But suppose we want the decimal number “4” to illuminate on the display. Then switches b, c, f and g would be closed to light the corresponding LED segments. Likewise for a decimal number “7”, switches a, b, c would be closed. But illuminating 7-segment displays using individual switches is not very practical.

7-segment Displays are usually driven by a special type of integrated circuit (IC) commonly known as a 7-segment decoder/driver, such as the CMOS 4511. This 7-segment display driver which is known as a Binary Coded Decimal or BCD to 7-segment display decoder and driver is able to illuminate both common anode or common cathode displays. But there are many other single and dual display drivers available such as the very popular TTL 7447.

This BCD-to-7 segment decoder/driver takes a four-bit BCD input labelled A, B, C and D for the digits of the binary weighting of 1, 2, 4and 8 respectively, has seven outputs that will pass current through the appropriate segments to display the decimal digit of the numeric LED display.

The digital outputs of the CD4511 are different from the usual CMOS outputs because they can provide up to 25mA of current each to drive the LED segments directly allowing different coloured led displays to be used and driven.

Final Code Method_1

#include "F28x_Project.h"
#include "driverlib.h"
#include "device.h"

void gpioinit();

unsigned char Val[10]={0XC0,0XF9,0XA4,0XB0,0X99,0X92,0X82,0XF8,0X80,0X90};

int i;

void main(void)
{

    Device_init();
    Device_initGPIO();

    gpioinit();

    while(1)
    {
      

        for(i=0;i<10;i++)
        {

            GpioDataRegs.GPASET.all=Val[i];     // 0 HIG
             DEVICE_DELAY_US(500000);
             GpioDataRegs.GPACLEAR.all=0XFF;   // 1 LOW   0 HIGH
             DEVICE_DELAY_US(100);

        }


    }


}

void gpioinit()
{
    EALLOW;
 // declare all gpion pins using mux
    GpioCtrlRegs.GPAGMUX1.all=0x00;
    GpioCtrlRegs.GPADIR.all=0xFF;
    GpioCtrlRegs.GPAPUD.all=0x00;
    EDIS;
}

Final Code Method_2

#include "F28x_Project.h"
#include "driverlib.h"
#include "device.h"

#define gpio_1 0
#define gpio_2 1
#define gpio_3 2
#define gpio_4 3

#define gpio_5 4
#define gpio_6 5
#define gpio_7 6
#define gpio_8 7

#define     low 1
#define     high 0

void gpioinit();
int i;

void main(void)
{
    Device_init();
    Device_initGPIO();

    gpioinit();

    while(1)
    {
        //Generating 0

                GPIO_writePin(gpio_1, high);  // 0 high 1 low
                GPIO_writePin(gpio_2, high);
                GPIO_writePin(gpio_3, high);
                GPIO_writePin(gpio_4, high);
                //
                GPIO_writePin(gpio_5, high);
                GPIO_writePin(gpio_6, high);
                GPIO_writePin(gpio_7, low);

                DEVICE_DELAY_US(500000);

                //Generating 1
                GPIO_writePin(gpio_1, low);  // 0 high 1 low
                GPIO_writePin(gpio_2, high);
                GPIO_writePin(gpio_3, high);
                GPIO_writePin(gpio_4, low);
                //
                GPIO_writePin(gpio_5, low);
                GPIO_writePin(gpio_6, low);
                GPIO_writePin(gpio_7, low);

                //Generating 2
                DEVICE_DELAY_US(500000);
                GPIO_writePin(gpio_1, high);  // 0 high 1 low
                GPIO_writePin(gpio_2, high);
                GPIO_writePin(gpio_3, low);
                GPIO_writePin(gpio_4, high);
                //
                GPIO_writePin(gpio_5, high);
                GPIO_writePin(gpio_6, low);
                GPIO_writePin(gpio_7, high);

                //Generating 3
                DEVICE_DELAY_US(500000);
                GPIO_writePin(gpio_1, high);  // 0 high 1 low
                GPIO_writePin(gpio_2, high);
                GPIO_writePin(gpio_3, high);
                GPIO_writePin(gpio_4, high);
                //
                GPIO_writePin(gpio_5, low);
                GPIO_writePin(gpio_6, low);
                GPIO_writePin(gpio_7, high);

                //Generating 4
                DEVICE_DELAY_US(500000);
                GPIO_writePin(gpio_1, low);  // 0 high 1 low
                GPIO_writePin(gpio_2, high);
                GPIO_writePin(gpio_3, high);
                GPIO_writePin(gpio_4, low);
                //
                GPIO_writePin(gpio_5, low);
                GPIO_writePin(gpio_6, high);
                GPIO_writePin(gpio_7, high);

                //Generating 5
                DEVICE_DELAY_US(500000);
                GPIO_writePin(gpio_1, high);  // 0 high 1 low
                GPIO_writePin(gpio_2, low);
                GPIO_writePin(gpio_3, high);
                GPIO_writePin(gpio_4, high);
                //
                GPIO_writePin(gpio_5, low);
                GPIO_writePin(gpio_6, high);
                GPIO_writePin(gpio_7, high);


                //Generating 6
                DEVICE_DELAY_US(500000);
                GPIO_writePin(gpio_1, high);  // 0 high 1 low
                GPIO_writePin(gpio_2, low);
                GPIO_writePin(gpio_3, high);
                GPIO_writePin(gpio_4, high);
                //
                GPIO_writePin(gpio_5, high);
                GPIO_writePin(gpio_6, high);
                GPIO_writePin(gpio_7, high);


                //Generating 7

                DEVICE_DELAY_US(500000);
                GPIO_writePin(gpio_1, high);  // 0 high 1 low
                GPIO_writePin(gpio_2, high);
                GPIO_writePin(gpio_3, high);
                GPIO_writePin(gpio_4, low);
                //
                GPIO_writePin(gpio_5, low);
                GPIO_writePin(gpio_6, low);
                GPIO_writePin(gpio_7, low);

                //Generating 8
                DEVICE_DELAY_US(500000);
                GPIO_writePin(gpio_1, high);  // 0 high 1 low
                GPIO_writePin(gpio_2, high);
                GPIO_writePin(gpio_3, high);
                GPIO_writePin(gpio_4, high);
                //
                GPIO_writePin(gpio_5, high);
                GPIO_writePin(gpio_6, high);
                GPIO_writePin(gpio_7, high);

                //Generating 9
                DEVICE_DELAY_US(500000);
                GPIO_writePin(gpio_1, high);  // 0 high 1 low
                GPIO_writePin(gpio_2, high);
                GPIO_writePin(gpio_3, high);
                GPIO_writePin(gpio_4, high);
                //
                GPIO_writePin(gpio_5, low);
                GPIO_writePin(gpio_6, high);
                GPIO_writePin(gpio_7, high);

                DEVICE_DELAY_US(1000000);
    }


}

void gpioinit()
{
    EALLOW;
    // 1st 4
    GPIO_setPinConfig(GPIO_32_GPIO32);
    GPIO_setDirectionMode(gpio_1, GPIO_DIR_MODE_OUT);
    GPIO_writePin(gpio_1, 1);
    GPIO_setPadConfig(gpio_1, GPIO_PIN_TYPE_STD);
    GPIO_setMasterCore(gpio_1, GPIO_CORE_CPU1);

    GPIO_setPinConfig(GPIO_19_GPIO19);
    GPIO_setDirectionMode(gpio_2, GPIO_DIR_MODE_OUT);
    GPIO_writePin(gpio_2, 1);
    GPIO_setPadConfig(gpio_2, GPIO_PIN_TYPE_STD);
    GPIO_setMasterCore(gpio_2, GPIO_CORE_CPU1);

    GPIO_setPinConfig(GPIO_18_GPIO18);
    GPIO_setDirectionMode(gpio_3, GPIO_DIR_MODE_OUT);
    GPIO_writePin(gpio_3, 1);
    GPIO_setPadConfig(gpio_3, GPIO_PIN_TYPE_STD);
    GPIO_setMasterCore(gpio_3, GPIO_CORE_CPU1);

    GPIO_setPinConfig(GPIO_67_GPIO67);
    GPIO_setDirectionMode(gpio_4, GPIO_DIR_MODE_OUT);
    GPIO_writePin(gpio_4, 1);
    GPIO_setPadConfig(gpio_4, GPIO_PIN_TYPE_STD);
    GPIO_setMasterCore(gpio_4, GPIO_CORE_CPU1);

    ////////////// 2nd 4
    GPIO_setPinConfig(GPIO_111_GPIO111);
    GPIO_setDirectionMode(gpio_5, GPIO_DIR_MODE_OUT);
    GPIO_writePin(gpio_5, 1);
    GPIO_setPadConfig(gpio_5, GPIO_PIN_TYPE_STD);
    GPIO_setMasterCore(gpio_5, GPIO_CORE_CPU1);

    GPIO_setPinConfig(GPIO_60_GPIO60);
    GPIO_setDirectionMode(gpio_6, GPIO_DIR_MODE_OUT);
    GPIO_writePin(gpio_6, 1);
    GPIO_setPadConfig(gpio_6, GPIO_PIN_TYPE_STD);
    GPIO_setMasterCore(gpio_6, GPIO_CORE_CPU1);

    GPIO_setPinConfig(GPIO_22_GPIO22);
    GPIO_setDirectionMode(gpio_7, GPIO_DIR_MODE_OUT);
    GPIO_writePin(gpio_7, 1);
    GPIO_setPadConfig(gpio_7, GPIO_PIN_TYPE_STD);
    GPIO_setMasterCore(gpio_7, GPIO_CORE_CPU1);

    GPIO_setPinConfig(GPIO_105_GPIO105);
    GPIO_setDirectionMode(gpio_8, GPIO_DIR_MODE_OUT);
    GPIO_writePin(gpio_8, 1);
    GPIO_setPadConfig(gpio_8, GPIO_PIN_TYPE_STD);
    GPIO_setMasterCore(gpio_8, GPIO_CORE_CPU1);

    EDIS;
}

output

By Admin

Leave a Reply

Your email address will not be published.

%d bloggers like this: