C language course design project-51 single-chip microcomputer-digital tube

  (Creating is not easy, thank you, your support is the biggest motivation for me to move forward, if it is helpful to you after reading it, please leave your footprints)

Table of contents

static nixie tube

1. How does the digital tube display characters

Display and its interface

Common cathode digital tube code table 

Development board digital tube circuit diagram  

2. Digital tube static display principle

3. The use of 74HC573 chip

4. Write the program 

Dynamic digital tube

1. The principle of digital tube dynamic display

2. The use of chips

74HC245 chip

74HC138 chip 

3. Write dynamic digital tube program


static nixie tube

1. How does the digital tube display characters

Display and its interface

Commonly used displays in single-chip microcomputer systems include: Light Emitting Diode (Light Emitting Diode) displays, Liquid Crystal LCD (Liquid Crystal Display) displays, TFT liquid crystal displays, etc.

LED displays have two display structures: segment display (7-segment, rice font, etc.) and dot matrix display (5×8, 8×8 dot matrix, etc.).    

LED digital tubes can be divided into two types according to the different connection methods of LEDs: common cathode and common anode.

The above picture (a) is the digital tube, (b) is two connection methods: the left is the common cathode connection, the right is the common anode connection, and the development board uses the common cathode connection

Common cathode digital tube code table 

When using LED displays, pay attention to distinguish between these two different connection methods. In order to display a number or character, the number or character must be encoded. Seven-segment digital tube plus a decimal point, a total of 8 segments. So the encoding provided for the LED display is exactly one byte. Our experiment board uses a common-cathode LED display. According to the circuit connection diagram, the encoding of the hexadecimal number is listed in the table below.

We can use 0 as an example. When the digital tube displays 0, as shown in the figure below: except for g and dp, the rest must be lit. The binary representation of the common cathode connection is 11111100, and it is converted into hexadecimal . 0x3f _

                                            

Development board digital tube circuit diagram  

2. Digital tube static display principle

There are two working modes of LED display: static display mode and dynamic display mode.

The characteristic of static display is that the segment selection of each nixie tube must be connected with an 8-bit data line to keep the displayed font code. After sending in the font code once, the displayed font can be kept until a new font code is sent in. The advantage of this method is that it takes less CPU time, and the display is easy to monitor and control. The disadvantage is that the hardware circuit is more complicated and the cost is higher.

  

3. The use of 74HC573 chip

1. OE is the enable terminal, when it is low level, the latch starts to work

2. VCC and GND are power and ground

3. LE is the latch terminal. When LE is high level, Q0~Q7 are in the same state as D0~D7. When LE is low level, Q0~Q7 are all latching data, no matter how D0~D7 Change, Q0~Q7 all maintain the state before the latch.

4. Write the program 

Let the last display of the 8-bit digital tube be 0

//让8位一体的数码管最后一个显示为0
#include"reg51.h"
typedef unsigned char u8;
typedef unsigned int u16;

sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;

u8 code smgduan[]={0x3f,0x05,0x5b,0x4f,0x66,0x6d,
					0x7d,0x07,0x7f,0x6f,0x77,
					0x7c,0x39 , 0x5e , 0x79 , 0x71};
void main()
{	
	//选择最后一个数码管显示  
	LSA=0;
	LSB=0;
	LSC=0;
	P0=smgduan[0]; //  输入字码,使其显示为0
 	while(1);  //通过循环实现按键控制LED
}

Dynamic digital tube

1. The principle of digital tube dynamic display

The characteristic of the dynamic display is that the segment selection lines of all the digital tubes are connected in parallel, and which bit of the digital tube is effective is controlled by the bit selection line. The selected digital tube adopts dynamic scanning display. The so-called dynamic scanning display promptly sends font codes and corresponding position selections to each nixie tube in turn, and utilizes the afterglow of the luminescent tube and the persistence of vision of the human eye to make people feel as if each nixie tube is displaying at the same time. The brightness of the dynamic display is worse than that of the static display, so when choosing a current limiting resistor, it should be slightly smaller than that of the static display circuit.

2. The use of chips

74HC245 chip

It is a three-state output, eight-channel signal transceiver, mainly used in large-screen display, and other consumer electronic products to increase the drive

Using CMOS technology

Wide voltage working range: 3.0V-5.0V

Bi-directional three-state output

Eight-wire bidirectional transceiver

Package form: SOP20, SOP20-2, TSSOP20, DIP20

Drivers for displays and other digital circuits

74HC138 chip 

It is a three-channel input, eight-channel output decoder, mainly used in consumer electronics products

Using CMOS technology

low power consumption

Working voltage: 3.0V-5.0V

Package form: SOP16

Suitable for 3-8 decoding function in digital circuit

3. Write dynamic digital tube program

//实现数码管的动态显示
#include"reg51.h"
typedef unsigned char u8;
typedef unsigned int u16;

sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;

u8 code smgduan[]={0x3f,0x05,0x5b,0x4f,0x66,0x6d,
					0x7d,0x07,0x7f,0x6f,0x77,
					0x7c,0x39 , 0x5e , 0x79 , 0x71};

void delay(u16 i)
{
 	while(i--);
}


void DigDisplay()
{
 	u8 i;
	for(i=0;i<8;i++)
	{
	 	switch(i)
		{
		 	case 0:	 //点亮第一个
				LSA=0;
				LSB=0;
				LSC=0;
				break;
			case 1:	 //点亮第二个
				LSA=1;
				LSB=0;
				LSC=0;
				break;
			case 2:
				LSA=0;
				LSB=1;
				LSC=0;
				break;
			case 3:
				LSA=1;
				LSB=1;
				LSC=0;
				break;
			case 4:
				LSA=0;
				LSB=0;
				LSC=1;
				break;
			case 5:
				LSA=1;
				LSB=0;
				LSC=1;
				break;
			case 6:
				LSA=0;
				LSB=1;
				LSC=1;
				break;
			case 7:
				LSA=1;
				LSB=1;
				LSC=1;
				break;
		}
		P0=	smgduan[i];//点亮后显示相应的字码
		delay(100);//短暂延迟,实现动态效果
		P0=0x00;  //对P0口清零,防止重影
	}
}

void main()
{	

	P0=~smgduan[0]; //  输入字码,使其显示为0
 	while(1)  //通过循环实现按键控制LED
	{
	 	DigDisplay();
	}
}

Guess you like

Origin blog.csdn.net/weixin_73295475/article/details/130024902