[Single-chip microcomputer/Puzhong A2] study notes 3-digital tube

The main concept of digital tube

References: Click to go


Nixie tube classification

字形重叠数码管: Overlap different numbers, letters and symbols, and display the one that needs to be used

分段式数码管: The most common digital tube, displayed according to the strokes, there are mainly seven-segment and eight-segment digital tubes

点矩阵式数码显示: as the name suggests


Eight-segment digital tube

There are two display methods of digital tubes, common cathode and common anode

  • Common cathode: the output terminal is grounded and always low; if the input terminal is high level, it is turned on at the moment, and the LED is on; if the input terminal is low level, the LED is off
  • Common anode: the output terminal is connected to the power supply and is always at a high level; the LED lighting method is opposite to that of the common cathode

The digital tubes in Puzhong A2 development board are common cathode digital tubes

The COM port of the digital tube shown in the figure below is the output terminal, and the remaining pins are input terminals

insert image description here


As the name suggests, the eight-segment digital tube has eight pins to control eight strokes, one of which is the decimal point DP

Then corresponding to the figure below, according to the nature of the common cathode, the input terminal is defined as 0x3F, at this time, it is converted into binary as 1111 1100
the corresponding ABCDEF pins of the six strokes are all high, and they are directly turned on. 0

The display of other numbers & letters follow the above rules, very simple!

insert image description here


Seven-segment digital tube

Slightly different from the eight-segment digital tube, the seven-segment type has no decimal point

He has one output, three input

Convert the input results (binary) of the three input terminals into decimal to display the corresponding strokes.
For example, input 101 at the input terminal, then convert it into binary to 5, and the corresponding number 5 stroke e will light up!

As for how to display a complete number, you need to use a cyclic method to cycle through different strokes in a very short time. Since the human eye cannot distinguish it, it looks like a normal display.


Strip digital tube

That is, a four-digit digital tube formed by combining four unit digital tubes

First get to know the decoder;

The principle of the decoder P22 P23 P24is There are three
input terminals and eight output terminals.

The figure below is the principle diagram of Puzhong. The eight LEDs that can be lit are marked on the output of the decoder, which respectively indicate the number of the lit. The following is a detailed introduction

insert image description here


As shown in the figure below, each digit on the digital tube corresponds to an input terminal, where the signal from our decoder is connected to light up the corresponding digit of the digital tube in a directional way

Below is the input terminal of the eight-segment digital tube, which is used to light up the corresponding strokes, which is very simple

insert image description here


the case

Static lighting digital tube

The decoder output is called "bit code output" (that is, which bit is lit) and the
STC output is called "segment code output" (that is, which stroke is lit)

The figure below shows the effect of lighting up the corresponding digital digital tube and displaying the specified number

#include <REGX52.H>

// 段码表,可以对照前面提到的表格,输出对应的数字/字母
unsigned char NixieTable[]={
    
    0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};

//数码管显示子函数
void Nixie(unsigned char Location,Number)
{
    
    
	switch(Location)		//位码输出
	{
    
    
        // 按照二进制转10进制,直接组合出8种情况,使用switch判断
		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口输出二进制信号,点亮对应笔画
	P0=NixieTable[Number];	//段码输出
}

void main()
{
    
    
	Nixie(2,3);	//在数码管的第2位置显示3
	while(1)
	{
    
    

	}
}

Dynamic lighting digital tube

The so-called dynamic refers to the digital tube displaying multiple digits at the same time.

The display method is very simple. In the while loop, the digital tubes on each bit are displayed alternately. Pay special attention to the need to reset to zero (that is, set 0x00) after each display, to avoid the residual image affecting the visual effect when the LED is switched.

#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;
	while(xms--)
	{
    
    
		i = 2;
		j = 239;
		do
		{
    
    
			while (--j);
		} while (--i);
	}
}

//数码管显示子函数
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];	//段码输出
	Delay(1);				//显示一段时间
	P0=0x00;				//段码清0,消影
}

void main()
{
    
    
	while(1)
	{
    
    
		Nixie(1,1);		//在数码管的第1位置显示1
//		Delay(20);
		Nixie(2,2);		//在数码管的第2位置显示2
//		Delay(20);
		Nixie(3,3);		//在数码管的第3位置显示3
//		Delay(20);
	}
}

Guess you like

Origin blog.csdn.net/delete_you/article/details/130011329