Static and dynamic digital tube display of 51 single chip microcomputer

Publisher:鑫森淼焱Latest update time:2022-04-23 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Digital tube display principle:


The digital tube is actually composed of 8 LEDs, divided into a, b, c, d, e, f, g, dp, and the digital tube is divided into common cathode (left, high level lights up) and common anode (right, low level lights up). Lighting up the corresponding LED can display the corresponding number. The common cathode coding table is as follows:


0x3f , 0x06 , 0x5b , 0x4f , 0x66 , 0x6d 、0x7d , 0x07 , 0x7f , 0x6f , 0x77 , 0x7c,0x39 , 0x5e , 0x79 , 0x71 , 0x00


They correspond to 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f respectively, while 0x00 is not displayed.


Note: For example, to display 0, abcdef must all be 1, that is, 0011 1111, which is 0x3f in hexadecimal, and so on.

In order to display numbers or characters, they must be encoded. The seven-segment digital tube plus a decimal point has a total of 8 segments. Therefore, the encoding provided for the LED display is exactly one byte. There are two working modes of LED displays: static display mode and dynamic display mode.


2. Static Display Principle


The characteristic of static display is that each segment of the digital tube must be connected to an 8-bit data line to maintain the displayed glyph code. After the glyph code is input once, the displayed glyph can be maintained until a new glyph code is input. The advantage of this method is that it takes up less CPU time and the display is easy to monitor and control. The disadvantage is that the hardware circuit is relatively complex and the cost is high.

Schematic diagram of eight-digit digital tube and 74HC573

D74HC138 decoder schematic diagram


3. Use of 74H573 latch (control segment selection)

OE is the enable terminal. When it is low, the latch starts working.

VCC and GND are power supply and ground

LE is the latch terminal. When LE is at a high level, Q0~Q7 are in the same state as D0~D7 and are in a direct connection state.

When LE is at a low level, Q0~Q7 latch data. No matter how D0~D7 changes, Q0~Q7 maintain the state before latching.


code show as below:


sbit LSA=P2^2;

sbit LSB=P2^3;

sbit LSC=P2^4;

 

u8 code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,

0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; //Display the value of 0~F

 

void main()

{

LSA=0;

LSB=0;

LSC=0; //Control the Y0 output of 38 decoder to low level

P0=smgduan[0];

while(1);

}


3. Dynamic digital tube


The characteristic of dynamic display is that the segment selection lines of all digital tubes are connected in parallel, and the bit selection line controls which digital tube is effective. The selected digital tube adopts dynamic scanning display. The so-called dynamic scanning display is to send the font code and the corresponding bit selection to each digital tube in turn, and use the afterglow of the light-emitting tube and the visual retention of the human eye to make people feel as if each digital tube is displaying at the same time. The brightness of dynamic display is worse than that of static display, so when selecting the current limiting resistor, it should be slightly smaller than that in the static display circuit.


3-8 decoder---D74HC138 (control bit selection)

74HC138D is a three-channel input, eight-channel output decoder, referred to as 3-8 decoder, mainly used in consumer electronics products

From the truth table we can see that:

image.png

The reverse rule is actually octal, 000 corresponds to Y0, 001 corresponds to Y1, 010 corresponds to Y2, and so on. In this way, the bit selection operation of the corresponding digital tube can be realized.


code show as below:


sbit LSA=P2^2;

sbit LSB=P2^3;

sbit LSC=P2^4;

 

u8 code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,

0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; //Display the value of 0~F

 

/***********************************************************************************

* Function name: delay

* Function    : Delay function, when i=1, the delay is about 10us

***********************************************************************************/

void delay(u16 i)

{

while(i--);

}

 

/***********************************************************************************

* Function name: DigDisplay

* Function    : Digital tube dynamic scanning function, cyclic scanning 8 digital tube displays

***********************************************************************************/

void DigDisplay()

{

u8 i;

for(i=0;i<8;i++)

{

switch(i) //bit selection, select the digital tube to light up,

{

case(0):

LSA=0;LSB=0;LSC=0; break;//display bit 0

case(1):

LSA=1;LSB=0;LSC=0; break;//display the first bit

case(2):

LSA=0;LSB=1;LSC=0; break;//display the second digit

case(3):

LSA=1;LSB=1;LSC=0; break;//display the third bit

case(4):

LSA=0;LSB=0;LSC=1; break;//display the 4th bit

case(5):

LSA=1;LSB=0;LSC=1; break;//display the 5th bit

case(6):

LSA=0;LSB=1;LSC=1; break;//display the 6th bit

case(7):

LSA=1;LSB=1;LSC=1; break;//display the 7th bit

}

P0=smgduan[i]; //Send segment code

delay(100); //Scan after a certain period of time

P0=0x00; //Blanking

}

}

 

void main()

{

while(1)

{

DigDisplay(); //Digital tube display function

}

}

Reference address:Static and dynamic digital tube display of 51 single chip microcomputer

Previous article:Serial port principle and reference code of C51/C52 microcontroller
Next article:Introduction and implementation of C51/C52 microcontroller interrupt (EXTI) (Part 2)

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号