Digital tube hardware diagram
1. Connect the digital tube to the 74HC245 chip
The output of the IO port of the single-chip microcomputer is difficult to stabilize, and the connection between the digital tube and the single-chip microcomputer needs to increase the driving circuit, using 74HC245
abcdefgDP parallel export 74HC245 to drive the digital tube, P0 is the output current to drive the driver chip of each segment
The purpose of increasing the resistance is to prevent the digital tube from being burned out due to excessive current. Selected by P0 output section
2. The digital tube is two 4-in-one common cathode digital tubes
Common cathode means that all cathodes are connected together, connected to the common terminal, grounded, and the anode can be turned on and lit when it is given a high level.
The public end of the digital tube leads out
3. Use a 38 decoder to control the input, select the digital tube LED1~LED8 for the control bit
The 38 decoder is a chip with 3 inputs and 8 outputs, and the bit selection is controlled by the input of P2^2 P2^3 P2^4
4. What is a digital tube?
The digital tube is composed of 8 terminals or 7 terminals, and one more segment of the light-emitting diode is a point, which can form a decimal point
A digital tube package with 10 pins
Nixie tube classification:
anode
The anodes of all diodes are connected together, the cathode is independent, and the cathode lights up when it is low
cathode
The cathodes of all diodes are connected together, the anodes are independent, and the anode lights up when it is high.
The two positive and negative poles can be turned on when they are placed
How to display a word?
If a cathode digital tube is used to display:
If it shows 0, from the cathode binary is DP, g is 0 low level, others are high 0011 1111 conversion sixteen 3f
The digital tube is on
Common cathode digital tube abcdefg to be bright 1111 1100 decimal point is P0.7 is the high bit of data
Convert from high bit to bit P0.7~0.0 0011 1111 in hexadecimal to 0x3f
The common anode digital tube is the opposite value of the common negative digital tube
What is segment selection and what is bit selection?
Segment selection is the word composed of the segments displayed by each LED of the digital tube.
The bit selection is the pin drawn from the common end, which digital tube is selected to display
Segment selection display of common cathode and common anode 0~F
Common cathode digital tube bright
Common anode digital tube bright
How to choose which LED light to light up through the 38 decoder?
1. View the manual of the chip
2. Control bit selection output digital tube
A1A2A3 are low level, 000 Y0 is valid LED1
A1A2A3 is 100 Y1 is valid LED2
A1A2A3 is 010 Y2 is valid LED3
A1A2A3 is 110 Y3 is valid LED4
A1A2A3 is 001 Y4 is valid LED5
A1A2A3 is 101 Y5 is valid LED6
A1A2A3 is 011 Y6 is valid LED7
A1A2A3 is 111 Y7 is valid LED8
Flow chart:
disappear
Use the afterglow of human eyes and delay to make people feel the dynamic display of digital tubes
software programming:
#include "reg52.h"
typedef unsigned int u16;
typedef unsigned char u8;
#define SMG_A_DP_PORT P0
u8 gsmg_code[17] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; // 段选0-F
// 位选
sbit LSA = P2^2;
sbit LSB = P2^3;
sbit LSC = P2^4;
void delay_time(u16 times)
{
while(times--);
}
// 定义数码管显示的函数
void smg_display(void)
{
u8 i = 0; // 用一个循环,需要定义一个变量
for(i=0;i<8;i++)
{
//每次循环选择一个段选
switch(i)
{
case 0:LSC=1; LSB=1; LSA=1; break; // Y7 输出
case 1:LSC=1; LSB=1; LSA=0; break; // Y6 输出
case 2:LSC=1; LSB=0; LSA=1; break; // Y5 输出
case 3:LSC=1; LSB=0; LSA=0; break; // Y4 输出
case 4:LSC=0; LSB=1; LSA=1; break; // Y3 输出
case 5:LSC=0; LSB=1; LSA=0; break; // Y2 输出
case 6:LSC=0; LSB=0; LSA=1; break; // Y1 输出
case 7:LSC=0; LSB=0; LSA=0; break; // Y0 输出
}
SMG_A_DP_PORT = gsmg_code[i];
delay_time(100); // 1ms = 100 us
SMG_A_DP_PORT = 0x00;
}
}
void main()
{
while(1)
{
smg_display();
}
}