Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microcontroller 8951S #interface-2.

Similar presentations


Presentation on theme: "Microcontroller 8951S #interface-2."— Presentation transcript:

1 microcontroller 8951S #interface-2

2 The 8051 Peripheral function interface circuit
LED and switch application seven(eight) segments LED circuit Keyboard interface circuit LCD interface circuit

3 LED digital tube "8" type, 7 segments (excluding decimal points) or 8 segments (including decimal points), each segment corresponds to a light emitting diode, common anode and common cathode two, as shown in below figure. The anode of the common anode digital tube is connected together and connected to the +5V; the common cathode is connected together to ground. 8-seg-anode 8-seg-cathode

4 LED digital tube To make the LED digital tube display different characters,It is necessary to provide one byte code for each section of the digital tube, that is, font code (also called segment code). Traditionally, the "a" section corresponds to the lowest bit of the font byte. Display character cathode font code anode font code Display character cathode font code anode font code

5 LED digital tube For example, the number in a memory cell is "02H", which means to display "2" on the common anode digital tube, and the "2" font code "A4H" is added to each segment of the digital tube. To keep the display character font code in a table (array), according to the character from the table to find the corresponding font code, and then each section of the font code output of the digital tube, digital tube public termination +5V at the same time, this time in the digital tube display character 2".

6 EXP Using the 51 mircocontroller to control a 8 segment LED digital tube, the first cycle shows a single even numbers: 0, 2, 4, 6, 8, and then show a single odd numbers: 1, 3, 5, 7, 9, so repeated cycle show.

7 #include "reg51. h" #include "intrins
#include "reg51.h" #include "intrins.h" #define uchar unsigned char #define uint unsigned int #define out P0 uchar code seg[]={0xc0,0xa4,0x99,0x82,0x80,0xf9,0xb0,0x92,0xf8,0x90,0x01}; void delayms(uint); void main(void) { uchar i; while(1) out=seg[i]; delayms(900); i++; if(seg[i]==0x01)i=0; // if the code is 0x01,Indicated that a loop display is over }

8 } void delayms(uint j) { uchar i; for(;j>0;j--) i=250; while(--i); i=249;

9 Display mode of LED digital tube
Static display dynamic display font code lines 8 bit I/O Bit selection

10 Static display

11 #include<reg51.h> void main(void) {
P1 and P0 respectively to control two digital tube DS0 and DS1 , and the common pin of anode digital tube DS0 and DS1 (common anode) is directly connected to the +5V, so the digital tube DS0 and DS1 is in the conducting state. because of P0 port and P1 port have latch function, so we should respectively write the display characters "2" and "7" font code to P0 port and P1 port . #include<reg51.h> void main(void) { P0=0xa4; //write font code :"2" to P0 P1=0xf8; //write font code :"7" to P1 while(1) ; }

12 Dynamic display At each point, only 1 bit lines are selected. One bit is displayed, and the other bits are not valid. Every time ,only the selected bit line ,which one have +5v or connect to the ground. This digital tube will display the font code of this time (scanning).Because of the digital tube afterglow and human "persistence of vision", as long as the control of each digital display of time interval, it may cause simultaneously display effect. The time interval (scanning interval) that each digital tube turns on should be determined according to the actual situation. Light emitting diode light from conduction to a certain degree of delay, if the light emitting time is too short, too weak, the human eye can not see; time is too long, flicker, and the time is longer, more time to take scm. Dynamic display essentially exchange the increased time of program execution for I/O port reduction.

13 Dynamic display

14 #include<reg51. h> #include<intrins
#include<reg51.h> #include<intrins.h> #define uchar unsigned char #define uint unsigned int uchar code dis_code[]={0xf9,0xa4,0xb0,0x99, 0x92,0x82,0xf8,0x80,0x90,0x88,0xc0}; void delay(uint t) { uchar i; while(t--) for(i=0;i<200;i++); } void main() uchar i,j=0x80; while(1) { for(i=0;i<8;i++) j=_crol_(j,1); P0=dis_code[i]; P2=j; delay(180); }


Download ppt "Microcontroller 8951S #interface-2."

Similar presentations


Ads by Google