(2) Nixie tube

LED digital tube: The digital tube is a simple and cheap display, which is composed of multiple light-emitting diodes packaged together to form an "8" character device

Please add a picture description

Please add a picture description

51 MCU is a common cathode connection

Please add a picture description

Please add a picture description

Please add a picture description

What is the function of the 74HC245 chip? Solution: This chip is called a bidirectional data buffer. It is used for data buffering (improving driving capability). So what does buffering mean?

Assuming that we give binary, we will go from A0 to B0. This is the connection relationship. If DIR is connected to a high level (1), then the data on the left can be connected to the data on our right. The role of the capacitor (100nf) here is: the power supply of the chip is more stable, which is called power filtering

Static digital tube display:

Determine the negative code (select the number): according to the CBA representation of the decoder

Determine the positive code (specifically which segment is bright): combine the 01 sequence through abcdefg (dp), and pass through the bidirectional data buffer high bit to high bit (reverse order)

选择第六个数字:
LED3 -> Y2 -> 010 -> P2_4=0;P2_3=1;P2_2=0;
显示"6":
abcdefg(dp) -> 10111110 -逆序-> 0111 1101 -> P0=0x7d;
#include <REGX52.H>

unsigned char NixieTable[]={
    
    0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};

void Nixie(unsigned char location, Number){
    
    
	switch(location){
    
    
		case 1: P2_4 = 1;P2_3 = 1;P2_2 = 1;break;
		case 2: P2_4 = 1;P2_3 = 1;P2_2 = 0;break;
		case 3: P2_4 = 1;P2_3 = 0;P2_2 = 1;break;
		case 4: P2_4 = 1;P2_3 = 0;P2_2 = 0;break;
		case 5: P2_4 = 0;P2_3 = 1;P2_2 = 1;break;
		case 6: P2_4 = 0;P2_3 = 1;P2_2 = 0;break;
		case 7: P2_4 = 0;P2_3 = 0;P2_2 = 1;break;
		case 8: P2_4 = 0;P2_3 = 0;P2_2 = 0;break;
	}
	P0 = NixieTable[Number];
}
void main(){
    
    
	Nixie(2, 2);
	while(1){
    
    }
}

Dynamic digital tube display:

Vanishing:

When we want to display the nixie tube, we first need to: bit selection, segment selection, and if we want to display, we need bit selection, segment selection, and cycle.

Then there will be problems in this way: first, select the "bit selection terminal" for the upper low level, then select the segment for the upper data, and then select the data for the upper and lower bits. But: Since the speed of our single-chip microcomputer is very fast, there will be problems between the segment selection and the next bit selection. In a very short time when we select the next bit, the previous data will be connected to the next data . Because they are next to each other, the data of the previous one will naturally come directly after I select the next one. This will show the problem of the string of data!

So how should we avoid this problem? Then we need to clear the last segment selection end, so that even if it reaches the next bit, it will not affect the previous bit ! Because and cleared. Therefore, the sub-function needs to be optimized. After the display is finished, we first need to delay it by 1ms. This is to make the program display more stably and clear it!

#include <REGX52.H>

unsigned char NixieTable[]={
    
    0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
void Delay(unsigned int xms)
{
    
    
	unsigned char i, j;
	i = 2;
	j = 239;
	while(xms--){
    
    
		do{
    
    
			while (--j);
		} while (--i);
	}
}

void Nixie(unsigned char location, Number, short dp){
    
    
	switch(location){
    
    
		case 1: P2_4 = 1;P2_3 = 1;P2_2 = 1;break;
		case 2: P2_4 = 1;P2_3 = 1;P2_2 = 0;break;
		case 3: P2_4 = 1;P2_3 = 0;P2_2 = 1;break;
		case 4: P2_4 = 1;P2_3 = 0;P2_2 = 0;break;
		case 5: P2_4 = 0;P2_3 = 1;P2_2 = 1;break;
		case 6: P2_4 = 0;P2_3 = 1;P2_2 = 0;break;
		case 7: P2_4 = 0;P2_3 = 0;P2_2 = 1;break;
		case 8: P2_4 = 0;P2_3 = 0;P2_2 = 0;break;
	}
	P0 = dp ? NixieTable[Number] | 0x80 : NixieTable[Number]; // 可以显示小数点
	Delay(1);
	P0 = 0;
}

void main(){
    
    
	while(1){
    
    
		Nixie(1, 1, 1);
		Nixie(2, 2, 0);
		Nixie(3, 3, 1);
		Nixie(4, 4, 0);
	}
}

Digital tube drive mode:

  • Single-chip computer direct scanning: the hardware device is simple, but it will consume a lot of single-chip CPU time
  • Dedicated driver chip: built-in video memory and scanning circuit, the MCU only needs to tell her what to display (TM1640)

Static drive is also called DC drive. Static driving means that each segment code of each digital tube is driven by a single-chip microcomputer I/O port, or is driven by decoding with a binary-decimal decoder such as BCD code.

  • The advantages of static drive are simple programming and high display brightness, but the disadvantage is that it occupies more I/O ports.

The digital tube dynamic display interface is one of the most widely used display methods in single-chip microcomputers. The dynamic drive is to use the same name of the 8 display strokes "a, b, c, d, e, f, g, dp" of all digital tubes. The terminals are connected together, and a bit strobe control circuit is added to the common pole COM of each digital tube. The bit strobe is controlled by an independent I/O line. When the single-chip microcomputer outputs the font code, all the digital tubes receive the same Font code, but which nixie tube will display the font depends on the control of the single-chip microcomputer to the COM terminal circuit.

So we only need to turn on the gate control of the digital tube that needs to be displayed, and the bit will display the font, and the digital tube without the gate will not be bright. By time-sharing and taking turns controlling the COM port of each digital tube, each digital tube is controlled and displayed in turn, which is dynamic drive . In the process of displaying in turn, the lighting time of each nixie tube is 1-2ms. Due to the persistence of vision and the afterglow effect of the light-emitting diodes, although in fact all the nixie tubes are not lit at the same time, as long as the scanning speed is sufficient Quick, the impression is that a set of stable display data will not flicker, and the effect of dynamic display is the same as that of static display.

During the stream display process, the lighting time of each nixie tube is 1~2ms. Due to the persistence of vision and the afterglow effect of the light-emitting diodes, although in fact all the nixie tubes are not lit at the same time, as long as the scanning speed is fast enough , giving the impression that a set of stable display data will not flicker, and the effect of dynamic display is the same as that of static display.

  • The advantage of dynamic driving is that it can save a lot of I/O ports and consume less power. The disadvantage is that it takes cpu time and programming is more complicated.

Guess you like

Origin blog.csdn.net/Falling_Asteroid/article/details/130736568