Join Date Feb 2009 Location some where left alone Posts 669 Helped 136 / 136 Points 5,796 Level 18. A relays is an electrical switch that opens and closes under control of another electrical circuit. It is therefore connected to ouput pins of the microcontroller and used to turn on/off high-power devices such as motors, transformers, heaters, bulbs, antenna systems etc.
A Note about 7 segment LED display.This article is about how to interface a seven segment LED display to an 8051 microcontroller. 7 segment LED display is very popular and it can display digits from 0 to 9 and quite a few characters like A, b, C,., H, E, e, F, n, o,t,u,y, etc. Knowledge about how to interface a seven segment display to a micro controller is very essential in designing embedded systems.
A seven segment display consists of seven LEDs arranged in the form of a squarish ‘8’ slightly inclined to the right and a single LED as the dot character. Different characters can be displayed by selectively glowing the required LED segments. Seven segment displays are of two types, common cathode and common anode.
In common cathode type, the cathode of all LEDs are tied together to a single terminal which is usually labeled as ‘ com‘ and the anode of all LEDs are left alone as individual pins labeled as a, b, c, d, e, f, g & h (or dot). In common anode type, the anode of all LEDs are tied together as a single terminal and cathodes are left alone as individual pins. The pin out scheme and picture of a typical 7 segment LED display is shown in the image below. 7 segment LED display Digit drive pattern.Digit drive pattern of a seven segment LED display is simply the different logic combinations of its terminals ‘a’ to ‘h‘ in order to display different digits and characters. The common digit drive patterns (0 to 9) of a seven segment display are shown in the table below. DigitabcdefgInterfacing seven segment display to 8051. Interfacing 7 segment display to 8051The circuit diagram shown above is of an AT89S51 microcontroller based 0 to 9 counter which has a 7 segment LED display interfaced to it in order to display the count.
This simple circuit illustrates two things. How to setup simple 0 to 9 up counter using 8051 and more importantly how to interface a seven segment LED display to 8051 in order to display a particular result. The common cathode seven segment display D1 is connected to the Port 1 of the microcontroller (AT89S51) as shown in the circuit diagram. R3 to R10 are current limiting resistors. S3 is the reset switch and R2,C3 forms a debouncing circuitry. C1, C2 and X1 are related to the clock circuit. The software part of the project has to do the following tasks.
Form a 0 to 9 counter with a predetermined delay (around 1/2 second here). Convert the current count into digit drive pattern. Put the current digit drive pattern into a port for displaying.All the above said tasks are accomplished by the program given below. Program.ORG 000H //initial starting addressSTART: MOV A,#00001001B // initial value of accumulatorMOV B,AMOV R0,#0AH //Register R0 initialized as counter which counts from 10 to 0LABEL: MOV A,BINC AMOV B,AMOVC A,@A+PC // adds the byte in A to the program counters addressMOV P1,AACALL DELAY // calls the delay of the timerDEC R0//Counter R0 decremented by 1MOV A,R0 // R0 moved to accumulator to check if it is zero in next instruction.JZ START //Checks accumulator for zero and jumps to START. Multiplexing 7 segement display to 8051When assembled and powered on, the circuit will display the number ’16’ and let us see how it is done.
Initially the first display is activated by making P3.0 high and then digit drive pattern for “1” is loaded to the Port 1. This will make the first display to show “1”. In the mean time P3.1 will be low and so do the second display will be OFF. This condition is maintained for around 1ms and then P3.0 is made low.
Now both displays will be OFF. Then the second display is activated by making P3.1 high and then the digit drive pattern for “6” is loaded to the port 1. This will make the second display to show “6”. In the mean time P3.0 will be low and so the second display will be OFF. This condition is maintained for another 1ms and then port 3.1 is made low. This cycle is repeated and due to the persistence of vision you will feel it as “16”.Transistor Q1 drives the first display (D1) and transistor Q2 drives the second display (D2). R11 and R12 are the base current limiting resistors of Q1 and Q2.
The purpose of other components are explained in the first circuit. Dear sir,I am a college student who is practicing 8051 with assembly language. I am new for both the component and program.My problem is as followsThe program I wrote counts up and down using button. But the button count down after it finishes up counting. I want it to count up when I press up button and down when I press down button.My program is as follows. Would you please help me by showing me how to write.I used the microcontroller pinsp2.0-p2.7 for counting and p3.0 for up button and p3.1 for down button.AND THE PROGRAMORG00HJMP MAINMAIN:MOVA,#00HUP: JB P3.0,$ADD A,#1DA AMOV P2,ACALL DELAYCJNE A,#30H,UPJMP DOWNDOWN: JB P3.1,$MOV P2,AADD A,#99HDA AMOV P2,ACALL DELAYCJNE A,#00H,DOWNJMP UPJMP MAIN;DELAY:MOV R0,#5DL2:MOV R1,#200DL1:MOV R2,#249DJNZ R2,$DJNZ R1,DL1DJNZ R0,DL2RETEND.
Random number generator using 8051 List of components. Microcontroller (AT89S51) – 1 nos. Push button switches – 2nos. 7-segment display – 2 nos. Transistor (2N2222) – 2 nos. Resistor (100 ohm) – 10 nos.
Resistor (8.2k ohm) – 1 nos. Resistor (10k ohm) – 1 nos. Capacitor (10uF/10V) – 2 nosWorkingThe two seven segment LED displays are multiplexed together and their data lines are connected to Port0 of the microcontroller. Transistors Q1 and Q2 drive the corresponding displays D1 and D2. The driving signals for there transistors are obtained from P1.1 and P1.2. Push button switch S1, capacitor C1 and resistor R10 forms a debouncing reset circuit. Resistor R9, capacitor C2 and pushbutton switch S2 will provide an active low hardware interrupt signal at INTO (pin12) whenever S2 is pressed.
Here also R9 and C2 are meant for debouncing.After power ON the display will show blank and when push button S2 is pressed the display will show a random number between 0 and 99. For another try, you have to press the reset switch and then switch S2. If you need a single digit setup only, then remove the display D2 and its associated components. Everything else is the same.