This chapter describes how a 7 segment display interfacing with pic microcontroller is being worked out. Seven segment display modules are not a recent invention as it’s first applications were dated back as earlier as in 1910.
Seven Segment Display Working
A seven segment display module is an electronic device used to display digital numbers and it is made up of seven LED segments. LEDs are PN-junction diodes which emit energy by a process called electroluminescence. 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. The light energy is emitted as ‘photons’ when it is forward biased by a voltage applied across its junctions. In a 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. Out of many types of segment displays available, this is the most common form.
It was mentioned earlier that the LEDs emit light only when it is forward biased and the amount of light emitted is proportional to the forward current. Since the light emission is directly proportional to the forward current, it is necessary to control the forward current according to the requirement of light emission. To limit forward current, a series resistance is connected to the voltage supply. To overcome the forward voltage drop, the voltage supplied should be greater than the actual forward voltage value.
Seven segment displays are seen associated with a great number of devices such as clocks, digital home appliances, signal boards on roads etc.
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 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.
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.
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.
Below is a table with display codes of all the digits with decimal point OFF.
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.
7-segment display Interfacing with PIC Microcontroller
This is the connection diagram, Port B is connected to different segments. Please see the above table to see each segment’s connection to the port pin.
In order to display 0, we first need to set the port B as output. Then, send the display code for 0 in port B. Here we use a common cathode display.
TRISB = 0X00; // Set port B as output
PORTB = 0b00111110; // Display code for Zero with DP OFF
The design we used has a drawback. It sources current from the microcontroller port directly. The maximum output current sourced by any I/O pin is 25mA and maximum current sourced by all ports is 200mA in the case of PIC18F4550 (These maximum values can be obtained from electrical characteristics of datasheets section). If we are using many devices to interface directly without driver circuits, chances are that you are exceeding this limit.
To avoid this condition, 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.
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.