A single digit 7-segment display device, as shown, is to be interfaced to Port 1
ID: 2081993 • Letter: A
Question
A single digit 7-segment display device, as shown, is to be interfaced to Port 1 of an 8051 microcomputer. The 8051 will produce the correct 7-bit codes for the desired display outputs. a) With the aid of a simple hardware diagram, explain how this device can be connected to the 8051. Assume that the 7-segment display is a common-cathode device. Show connections to the power supply source and state the estimated current consumption for your circuit. b) Write an 8051 assembly language program which can output any number (0.9) to the display. As part of your program show a table which defines the bit patterns each number. a) Diagram is shown. Each segment will consume 10 ma current approx. The buffers are powered from a 5v supply. The 7-segment display device is not separately powered, each segment effectively sinks current to ground to light the relevant LED, 8051 will be shown to connect to 5v etc.Explanation / Answer
Looking at the sample answer in the sheet, it would have been pretty clear to you, that the ports of the 7 Segment Display are connected to the pins 2.0 to 2.6. The 2.7th pin of the microcontroller is connected, once there are decimal values involved in the segment display.
To have a seven segment display, the Led's is the display should get on and off alternatively depending upon the requirement of the number, we want to display.
For example,
If one has to display, number 0 in the Display, all Led's should light up other than the g bar.
For 1, the Led's b & c should light up and the rest should be in the off state.
For different numbers, there remain different numbers of combinations of the numbers of Led's in the on and off state, resulting in the required display.
The assembly level program that will display the digits from 0 to 9 using a seven segment display is:-
#include<reg51.h>
void msdelay(unsigned int time)
{
unsigned i,j ;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}
void main()
{
unsigned char number_code[]=[0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90];
int l;
while(1)
{
for(l=0;l<10;l++)
{
P2=number_code[l];
msdelay(100);
}
}
}
We have created ms_delay function to bring the delay in milliseconds, this is provided in any microcontroller program such that any microcontroller can complete its internal operation and go ahead of its next operation.
an array of the hex codes for 0 to 9 (Table, Below), has been created and finally the hex codes are sent to the port 2 connected to the common anode 7 segment. This way numbers from 0-9 can be displayed on a seven segment display bar.
One needs to keep in the mind the logic state-1 applies to get the display.
It can be positive one or a negative one. The program and the table given below has been used using negative logic, which means, that for off state of any LED bar, we will apply 1 to it and vice versa to keep it on, that is, 0 is applied to keep it on. This varies from people to people, on their matter of choice of taking the logics.
The table showing the bit pattern of the hex tables for the numbers are:-
Note: Here the 8th segment h is shown if there are any decimels involved. For cases, where decimel is not involved, the value of the seven segment can be found removing the first digit from the binary code.
Digit to display h g f e d c b a Hex code 0 1 1 0 0 0 0 0 0 C0 1 1 1 1 1 1 0 0 1 F9 2 1 0 1 0 0 1 0 0 A4 3 1 0 1 1 0 0 0 0 B0 4 1 0 0 1 1 0 0 1 99 5 1 0 0 1 0 0 1 0 92 6 1 0 0 0 0 0 1 0 82 7 1 1 1 1 1 0 0 0 F8 8 1 0 0 0 0 0 0 0 80 9 1 0 0 1 0 0 0 0 90Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.