Categories: Firmware Guide-8051

Interfacing Seven Segment Display with 8051

A seven segment display module is an electronic device used to display digital numbers and it is made up of seven LED segments. Because of the small size of the LEDs, it is really easy for a number of them to be connected together to make a unit like seven segment display. In the seven segment display module, seven LED s are arranged in a rectangle. Sometimes, an additional LED is seen in a seven segment display unit which is meant for displaying a decimal point.

Each LED segment has one of its pins brought out of the rectangular package. Other pins are connected together to a common terminal. Seven segment displays can only display 0 to 9 numbers. These seven LEDs indicate seven segments of the numbers and a dot point.

Seven segment displays are seen associated with a great number of devices such as clocks, digital home appliances, signal boards on roads etc.

[fusion_imageframe image_id=”4336″ style_type=”none” stylecolor=”” hover_type=”none” bordersize=”” bordercolor=”” borderradius=”” align=”center” lightbox=”no” gallery_id=”” lightbox_image=”” alt=”” link=”” linktarget=”_self” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]http://learn.openlabpro.com/wp-content/uploads/2018/03/image.png[/fusion_imageframe]

Types of Seven segment displays

As mentioned in previous paragraphs, seven segment displays come up with two different configurations. They are the common anode and a common cathode. One pin each from each segment is connected to a common terminal. According to the pins which are connected to the common terminal, the seven segment display is categorized as a common anode and common cathode.

Common Cathode 7-segment display

As the name indicates, its cathode is connected to a common terminal. Below is the schematic diagram to indicate its common cathode structure. It should be connected to the ground while operating the display. If a high voltage is given to the anode, then it will turn on the corresponding segment.

[fusion_imageframe image_id=”4526″ style_type=”none” stylecolor=”” hover_type=”none” bordersize=”” bordercolor=”” borderradius=”” align=”center” lightbox=”no” gallery_id=”” lightbox_image=”” alt=”” link=”” linktarget=”_self” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]http://learn.openlabpro.com/wp-content/uploads/2018/03/7segca-1.png[/fusion_imageframe]

Common Anode 7-segment display

In this type, the anode is common. It should be connected to a high voltage (to the supply through a resistor to limit current). In order to turn on a particular segment, a ground level voltage is given to the corresponding pin. Since logic circuits can sink more current than they can source, common anode connection is used most widely.

[fusion_imageframe image_id=”4524″ style_type=”none” stylecolor=”” hover_type=”none” bordersize=”” bordercolor=”” borderradius=”” align=”center” lightbox=”no” gallery_id=”” lightbox_image=”” alt=”” link=”” linktarget=”_self” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]http://learn.openlabpro.com/wp-content/uploads/2018/03/7segan-1.png[/fusion_imageframe]

Display codes

Display codes are the voltages to be applied to the segments to display a number. It is in the order of segments ABCDEFG(DP), total 8 bits. For example, below is the common cathode display code of ‘0’ with decimal point OFF.

[fusion_imageframe image_id=”5669″ style_type=”none” stylecolor=”” hover_type=”none” bordersize=”” bordercolor=”” borderradius=”” align=”center” lightbox=”no” gallery_id=”” lightbox_image=”” alt=”” link=”” linktarget=”_self” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]http://learn.openlabpro.com/wp-content/uploads/2018/05/7seg-D0-1024×108.png[/fusion_imageframe]

Below is a table with display codes of all the digits with decimal point OFF.

[fusion_imageframe image_id=”5668″ style_type=”none” stylecolor=”” hover_type=”none” bordersize=”” bordercolor=”” borderradius=”” align=”center” lightbox=”no” gallery_id=”” lightbox_image=”” alt=”” link=”” linktarget=”_self” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]http://learn.openlabpro.com/wp-content/uploads/2018/05/7seg-DD-1024×628.png[/fusion_imageframe]

If number 0 has to be displayed, then the segments A through F are turned on. In order to turn on the segments, in common cathode mode, the anode terminals are subjected to a high voltage while in common anode mode, the cathode terminals are given a low voltage.

Interfacing with Microcontroller

[fusion_imageframe image_id=”5670″ style_type=”none” stylecolor=”” hover_type=”none” bordersize=”” bordercolor=”” borderradius=”” align=”center” lightbox=”no” gallery_id=”” lightbox_image=”” alt=”” link=”” linktarget=”_self” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]http://learn.openlabpro.com/wp-content/uploads/2018/05/7segan-connection-article-289×300.png[/fusion_imageframe]

In order to display 0, we first need send the display code for 0 in port 2. Here we use a common cathode display.

P2 = 0X3F;     // Display code for Zero with DP OFF

Advanced circuits

To avoid drawing high current from controller port, we can use a transistor driver in each of the segment lines. We can use either PNP or NPN transistors. In the case of PNP, the display codes should be inverted because PNP transistors turn ON by applying a LOW signal (i.e., for common cathode, use common anode’s display codes). The transistor acts as a high current switch when voltage and current levels are in the correct range with the switch being controlled by the lower current digital logic signal. In most cases, the transistor used is a BJT, especially in the case of low voltage circuits.
Here we can turn on the segment by giving a high in transistor base. In the case of PNP transistor, we need to give a low voltage for turning on.

[fusion_imageframe image_id=”5672″ style_type=”none” stylecolor=”” hover_type=”none” bordersize=”” bordercolor=”” borderradius=”” align=”center” lightbox=”no” gallery_id=”” lightbox_image=”” alt=”” link=”” linktarget=”_self” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]http://learn.openlabpro.com/wp-content/uploads/2018/05/7-semgent-transistor-driver1-224×300.png[/fusion_imageframe]

Multiplexed 7 segment display

Consider the case when two or more seven segment displays have to be used and the microcontroller unit does not have enough I/O ports to accommodate all the input pins of the seven segment display units. The best method to be adopted in such cases would be to use a multiplexer. By multiplexing, the number of seven segment units multiplexed would be using only the seven output ports and enable pins equal to the number of display units to display the output.
Now, how it is made possible to use only seven output ports to display output of the number of seven segment display units at a single time? The principle behind this is the persistence of vision. Only one unit is working at a single time and the switching between the seven segment display units are made faster so that the onlooker is not able to recognize the switching.

7 segment display driver IC

The driver circuit is included between the decoder circuit and the seven segment display units. It is necessary when high current is required to drive the display. In normal cases, decoder functions as a driver but when a number of seven segment units are multiplexed, then there is a requirement of high current. In such cases, a driver circuit is introduced between the decoder and seven segment display units. Besides, the driver circuit is helpful in simplifying the entire circuit as it reduces the number of components such as transistors.
One example of this type of IC is MAX7219, a serial I/O common-cathode display driver. It can interface up to eight 7-segment displays at a time. The communication with MAX7219 is achieved through a 4-wire serial interface. External components can be minimized using this type of drivers, in this case, we need only one external resistor.

Share