当前位置:网站首页>Actual combat 8051 drives 8-bit nixie tube
Actual combat 8051 drives 8-bit nixie tube
2022-07-03 04:54:00 【Huawei MCU programming】
8051 Drive common cathode
There is a little time for Chinese New Year , Clean up the computer , Turn to a previous small work , At the request of a new friend , control 8 Digital tube , Show... In turn 0~9. Send it out for everyone to see , Master, please skip .
Because there was no development board in hand , Just use Proteus Let's do circuit simulation .
The work environment :
Keil uVision5
Proteus 8 Professional
Nixie tube
First of all, understand the relevant knowledge of digital tubes
The basic unit of digital tube is led , According to the number of segments, it can be divided into seven segment nixie tubes and eight segment nixie tubes , Eight segment nixie tube has one more LED unit than seven segment nixie tube , One more decimal point (DP), This decimal point can more accurately represent what the nixie tube wants to display ; Press to display how many (8) Can be divided into 1 position 、2 position 、3 position 、4 position 、5 position 、6 position 、7 position 、8 Digital tube .
> Internal principle of digital tube
The above figure is an internal schematic diagram of a nixie tube , The display part of a nixie tube consists of 8 Diodes , Just one byte ,51 SCM is also 8 Bit MCU .
According to the common connection end of the internal led , It can be divided into common anode connection and common cathode connection , The common anode connection method is that the positive poles of light-emitting diodes are connected to the power supply together VCC, The number is displayed by controlling whether the negative pole of each LED is grounded . Common cathode connection means that the negative pole of each LED is grounded together GND, The number is displayed by controlling whether the positive pole of each LED is connected to the power supply .
In the figure a~g The pin controls the on and off of each LED respectively , therefore , If you want to show 1 Words , Just light up b,c Two paragraphs ( Output the corresponding port of MCU 0x06 that will do ); If you want to display numbers 5, Then just light up a,f,g,c,d Segments can form numbers 5 Display of (0x6d).
> Internal schematic diagram of multi digit nixie tube
Above, 4 Internal wiring of bit nixie tube , Anode of each nixie tube ( Or cathode ) Connected to a , Other pins of the same pin are connected , Altogether 12 Two control pins , It can also be concluded that 8 Digit digital tubes have 16 Two control pins ,8 Ge Gongyang ( Or common Yin ) End ,8 A control a~g According to the content .
74LS138 Decoder
From the display principle of digital tube , A nixie tube should display different characters , It is necessary to control each diode in the nixie tube differently , Each diode needs to use a control pin of the MCU , For example, in practical applications, eight digit common cathode or common anode digital tubes , share 16 One pin , If you use MCU pins to control , This is too wasteful , Originally, the resources of SCM are very tight .
The solution is to use a decoder as the bit selector of the nixie tube , Which display is needed to control the common Yang of which nixie tube ( Or common Yin ) End .
74LS138 Decoder 1~3 Is the input , From high to low CBA; 7~15 Is the output , From high to low Y7-Y0.
working process : Input three binary numbers at the input end , To decimal , After passing through the decoder , The output end corresponds to the pin of decimal number ( Corresponding Y) Low level , The rest are high level , such as :
Input 000, Decimal system 0, The output of 0 Bit pin is low , Others are high , That is to say 1111 1110;
Input 101, Decimal system 5, The output of 5 Bit pin is low , Others are high , That is to say 1101 1111.
Three binary numbers can just represent 0~7,8 A digital , That is, you can control 8 Digital tube .
P=============roteus Circuit diagram
Programming
#include <REGX51.H>
// The time delay function
void delay(unsigned int ms){
int k,l;
for(k=0;k<ms;k++)
for(l=0;l<120;l++);
}
// A nixie tube display 0~f Hexadecimal array
char numHex[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
/**
Choose the digital tube , And display the corresponding decimal number
index : Nixie tube position subscript
num :char numHex[] The array corresponds to the subscript of the decimal number
*/
void setIndexNum(unsigned char index,unsigned char num){
switch(index){// Digital tube position selection ,74LS138 The input of the decoder
case 0:
P1_2=0;
P1_3=0;
P1_4=0;
break;
case 1:
P1_2=1;
P1_3=0;
P1_4=0;
break;
case 2:
P1_2=0;
P1_3=1;
P1_4=0;
break;
case 3:
P1_2=1;
P1_3=1;
P1_4=0;
break;
case 4:
P1_2=0;
P1_3=0;
P1_4=1;
break;
case 5:
P1_2=1;
P1_3=0;
P1_4=1;
break;
case 6:
P1_2=0;
P1_3=1;
P1_4=1;
break;
case 7:
P1_2=1;
P1_3=1;
P1_4=1;
break;
}
P3=numHex[num];// The nixie tube displays characters
}
void main(){
//proteus no need while Can be recycled , Don't understand
unsigned char i,j;
for(i = 0;i < 8;i++){
for(j = 0;j < 16;j++){
setIndexNum(i,j);
delay(300);
if(j >= 15) break;
}
if(i >= 7) break;
}
}
Friends who want to learn SCM together , Comment on ” I want to get started “, Have a pleasant surprise , Join us , You can interact with your mentor one-on-one , The rapid growth
边栏推荐
- Handling record of electric skateboard detained by traffic police
- JS multidimensional array to one-dimensional array
- Current market situation and development prospect prediction of global direct energy deposition 3D printer industry in 2022
- The 19th Zhejiang I. barbecue
- Network security textual research recommendation
- MPM model and ab pressure test
- Crazy scientist
- STM32 reverse entry
- 《牛客刷verilog》Part II Verilog进阶挑战
- Thesis reading_ Tsinghua Ernie
猜你喜欢
Oracle SQL table data loss
Cross platform plug-in flutter for displaying local notifications_ local_ notifications
2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills
Leetcode simple problem delete an element to strictly increment the array
MediaTek 2023 IC written examination approved in advance (topic)
[tools run SQL blind note]
Leetcode simple question: check whether the array is sorted and rotated
Retirement plan fails, 64 year old programmer starts work again
关于开学的准备与专业认知
The consumption of Internet of things users is only 76 cents, and the price has become the biggest obstacle to the promotion of 5g industrial interconnection
随机推荐
Oracle SQL table data loss
Thesis reading_ Tsinghua Ernie
Market status and development prospect prediction of the global forward fluorescent microscope industry in 2022
The programmer resigned and was sentenced to 10 months for deleting the code. JD came home and said that it took 30000 to restore the database. Netizen: This is really a revenge
Shuttle + Alluxio 加速内存Shuffle起飞
普通本科大学生活避坑指南
论文阅读_中文NLP_ELECTRA
Hire cashier (differential constraint)
Leetcode simple question: check whether the array is sorted and rotated
Wechat applet waterfall flow and pull up to the bottom
雇佣收银员(差分约束)
Retirement plan fails, 64 year old programmer starts work again
《牛客刷verilog》Part II Verilog进阶挑战
[tools run SQL blind note]
[clock 223] [binary tree] [leetcode high frequency]: 102 Sequence traversal of binary tree
Learning practice: comprehensive application of cycle and branch structure (I)
Market status and development prospect prediction of global SoC Test Platform Industry in 2022
Mount NFS in kubesphere
Market status and development prospect prediction of global fermentation acid industry in 2022
sql语句模糊查询遇到的问题