1. Introduction of TX1C digital tube
Common cathode and common anode digital tubes. The experimental board has a common cathode digital tube, a 6-bit digital tube.
The connection principle diagram is as follows: the segment lines (segment selection lines, i.e. abcdefgh) connected together control which digital tube lights up, and the independent common end (bit selection line, i.e. common cathode or common anode) controls which digital tube lights up. Because the segment lines are connected together, the displayed numbers are the same, and the common cathode end is an independent common end, so the lower six bits control which digital tube lights up. Using two latches, any digital tube can be controlled to display any number.
1. Static display of digital tube
Static display means that the numbers displayed on the digital tubes with the bit selection turned on are the same because the segment selections are connected together.
1. The first three digits of the digital tube display 666
#include sbit temperature=P2^7; sbit dula=P2^6; void main() { wela=1; //The bit selection is turned on, that is, the latch end is set high, and the output of the latch changes with the input P0=0xf8; //1111 1000, the first three digits are lit wela=0; //bit selection is off, that is, the latch end is set low, the latch maintains the previous state, that is, the first three digital tubes are lit game=1; P0=0x7d; //Display 6 digits on the digital tube, 0111 1101 game=0; while(1) { } } 2. The 6-digit digital tube displays 996ICU at 500 millisecond intervals #include sbit dula=P2^6; sbit temperature=P2^7; unsigned char code table[]={0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71,0x3e}; //0 to F encoding, the last one is U, 0011 1110 void delayms(unsigned int xms) { unsigned int i,j; for(i=xms;i>0;i--) for(j=110;j>0;j--); } void main() { temperature=1; P0=0xc0; //1100 0000, six digital tubes light up temperature=0; while(1) { game=1; P0=table[9]; //The array starts from 0 and displays 9 game=0; delayms(500); game=1; P0=0; game=0; delayms(300); //Due to two consecutive 9s, the middle is off for 300 milliseconds game=1; P0=table[9]; game=0; delayms(500); game=1; P0=table[6]; //display 6 game=0; delayms(500); game=1; P0=table[1]; //Since I cannot be displayed, use 1 instead game=0; delayms(500); game=1; P0=table[12]; //Display C game=0; delayms(500); game=1; P0=table[16]; //Display U game=0; delayms(300); } } Because of the two 9s in the middle, the display effect is not very good. 2. Dynamic display of digital tube The so-called dynamic display is to display numbers from the first digital tube to the last digital tube in sequence, and delay the display of numbers so that each digital tube displays them in sequence, and then shorten the time very short. The digital tubes display them in turn at high speed, which cannot be seen by the human eye, giving the feeling that they are displayed simultaneously. The following code shows the words 996ICU #include #define uint unsigned int //macro definition, rename unsigned int to uint for easy use sbit dula=P2^6; sbit temperature=P2^7; unsigned char code table[]={0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71,0x3e}; //0 to F encoding, the last one is U, 0011 1110 void delayms(uint xms); void main() { game=0; wela=0;/*Turn off the bit selection. Otherwise, when the segment selection is just turned on, the digital tubes lit by ox6f will display 9, but it will be too fast to be seen by the eyes. If you add a delay statement, you can see it. You can add while(1) after the first dula=0 statement below to test it*/ while(1) { game=1; P0=table[9]; //The first digital tube displays 9 game=0; P0=0xff; //Eliminate. If not added, before turning on the first digital tube, first turn on the bit select P0 with 9, which is 0x6f. wela=1; //If the sequence runs too fast, it cannot be seen. If it runs slowly, the digital tubes will be confused. P0=0xfe; //Turn on the first digital tube temperature=0; delayms(1); wela=1; //If you do not add these three statements, you will see that the unlit part of the digital tube will have a weak brightness P0=0xff; //The reason is that when executing downward, the bit selected fe is first selected for the following segment, and the first digital tube quickly displays fe wela=0;/*Then the following table[9] is displayed on the first digital tube, because both numbers are 9, change the number It is obvious, so there will be a weak brightness under high-speed display without delay. If it is slower, confusion may occur. All the displayed numbers The reason why it is brighter is because of the delay, so just turning off the first digital tube will solve the problem. Because of the high-speed display, you won't see the first digital tube go out*/ game=1; P0=table[9]; game=0; P0=0xff; temperature=1; P0=0xfd; //Turn on the second digital tube temperature=0; delayms(1); temperature=1; P0=0xff; temperature=0; game=1; P0=table[6]; //display 6 game=0; P0=0xff; temperature=1; P0=0xfb; //Turn on the third digital tube temperature=0; delayms(1); temperature=1; P0=0xff; temperature=0; game=1; P0=table[1]; //Display I, replace with 1 game=0; P0=0xff; temperature=1; P0=0xf7; //Turn on the fourth digital tube temperature=0; delayms(1); temperature=1; P0=0xff; temperature=0; game=1; P0=table[12]; //Display C game=0; P0=0xff; temperature=1; P0=0xef; //Turn on the fifth digital tube temperature=0; delayms(1); temperature=1; P0=0xff; temperature=0; game=1; P0=table[16]; //Display U game=0; P0=0xff; temperature=1; P0=0xdf; //Turn on the sixth digital tube temperature=0; delayms(1); temperature=1; P0=0xff; temperature=0; } } void delayms(uint xms) { uint i,j; for(i=xms;i>0;i--) for(j=110;j>0;j--); } At the beginning, set the delayms function to a longer time, delayms(500), so that it displays the content one by one at a speed of 0.5 seconds. Then slowly reduce the time to delayms(1) 1 millisecond to gain a deeper understanding. Conclusion 1. Encoding method The common cathode digital tube encoding on this experimental board is as follows: unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71}; This code is 0 to F, that is, 0 is 0011 1111, 1 is 0000 0110. Different circuits may have different codes. You can code by knowing the principle of digital tube display. There is an additional code keyword after the array type. Note: Defining an array in a microcontroller occupies memory space, while defining a code is directly allocated to the program space. After compilation, the code occupies the program storage space, not the memory space. 2. It is very important to eliminate the shadow, otherwise the digital tube will be confused or there will be afterglow in the parts other than the numbers. In the second code, the closed bit selection is invisible to the human eye. The reason for the simultaneous display is the high-speed display and the afterglow effect after the diode is lit.
Previous article:Keyboard detection principle of 51 single chip microcomputer
Next article:51 single chip microcomputer realizes the operation of running water lamp
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [Raspberry Pi 3B+ Review] Install libjpeg library & drive USB camera
- C language BCD code to decimal (hexadecimal HEX) program
- From ERM to X-axis LRA, TI provides you with a comprehensive Haptics Solution
- Single-cell Li-ion battery fuel gauge and low cutoff current charging IC
- I'm a newbie and need help. How to declare lcd_wdat? Please help me.
- 【TI mmWave Radar Evaluation】+Configuration File Test (Part 2)
- [AT-START-F425 Review] + Get MCU 96-bit unique ID, FLASH size
- Looking for a car charger IC with dual port output power of 40W or more C+A port
- Why does the ripple of a switching power supply increase as the output voltage decreases?
- TI Live: Overview and application introduction of 60G millimeter wave sensors, "packaged antenna" makes building and factory detection solutions simpler