1. Basic part of eight-segment digital tube
1. Common cathode and common anode of eight-segment digital tube
An eight-segment digital tube is composed of eight segments of diodes, namely a, b, c, d, e, f, g, dop (dots), with a total of eight segments. There are two types of digital tubes, common cathode and common anode (common anode: the anodes of the digital tube are all connected together, and a low level lights it up. If it is a common anode, a low level lights it up.)
2. Bit code and segment code of eight-segment digital tube
Generally, a four-digit digital tube has four pins to control which digital tube is selected (bit selection), and the 8-bit segment selection is common, that is, when the bit selection is the first bit, the segment selection code is only related to the segments that light up the first bit. Similarly, when the second bit is selected, the segment code is only valid for the second bit, and so on. . . . Generally, after the hardware structure is determined, the term segment code and bit code will appear. For example, the four bit selection pins are connected to the microcontroller p2.2 2.3 2.4 (these three ports are the 74HC138 decoder ports), and the light-emitting tube is a common cathode, then the bit code of the first bit is xxxx1110; the second bit is xxxx1101; the third bit is xxxx1011; the fourth bit is xxxx0111; so when I display, if the first bit of data is displayed, xxxx1110 is sent to the p2 port, and then the segment code of the first bit is sent.
2. Eight-segment digital tube dynamic display
The so-called static display means that each segment code of the digital tube must occupy an output port with a latch function. The CPU sends the character code to be displayed to the output port, and the digital tube can display the corresponding character. The displayed content will not disappear until the next time another character code is sent. Dynamic display has the advantages of stable display, high brightness, and saving CPU time, but it occupies more I/O ports and has high hardware costs.
1. Eight eight-segment digital tubes dynamically scan 0 to 7 for a running display
#include #define uchar unsigned char #define uint unsigned int sbit LSA=P2^2; //74HC138 decoder port sbit LSB=P2^3; sbit LSC=P2^4; //Common anode digital tube coding table uchar code table1[] ={0xc0,0xf9,0xa4,0xb0, 0x99,0x92,0x82,0xf8, 0x80,0x90,0x88,0x83, 0xc6,0xa1,0x86,0x8e}; //Common cathode digital tube coding table uchar code table2[] ={0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71}; //Delay void DelayMS(uint x) { uchar t; while(x--) for(t=0;t<120;t++); } //Main program void main() { uchar i; while(1) { for(i=0;i<8;i++) { P0=0xff; LSA=0;LSB=0;LSC=0; P0=table2[0]; DelayMS(100); LSA=1;LSB=0;LSC=0; P0=table2[1]; DelayMS(100); LSA=0;LSB=1;LSC=0; P0=table2[2]; DelayMS(100); LSA=1;LSB=1;LSC=0; P0=table2[3]; DelayMS(100); LSA=0;LSB=0;LSC=1; P0=table2[4]; DelayMS(100); LSA=1;LSB=0;LSC=1; P0=table2[5]; DelayMS(100); LSA=0;LSB=1;LSC=1; P0=table2[6]; DelayMS(100); LSA=1;LSB=1;LSC=1; P0=table2[7]; DelayMS(100); } } } 2. Eight eight-segment digital tubes dynamically scan 0 to 7 and display them constantly #include typedef unsigned int uint; typedef unsigned char uchar; sbit LSA=P2^2; //74HC138 decoder port sbit LSB=P2^3; sbit LSC=P2^4; uchar out[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; void delay(uint num) { while(num--); } void display() { uint i; for(i=0;i<8;i++) { switch(i) //bit selection, select the digital tube to light up, { case(0): LSA=0;LSB=0;LSC=0; break;//display bit 0 case(1): LSA=1;LSB=0;LSC=0; break;//display the first bit case(2): LSA=0;LSB=1;LSC=0; break;//display the second digit case(3): LSA=1;LSB=1;LSC=0; break;//display the third bit case(4): LSA=0;LSB=0;LSC=1; break;//display the 4th bit case(5): LSA=1;LSB=0;LSC=1; break;//display the 5th bit case(6): LSA=0;LSB=1;LSC=1; break;//display the 6th bit case(7): LSA=1;LSB=1;LSC=1; break;//display the 7th bit } P0=out[i]; //Send segment code delay(100); //Scan after a certain period of time P0=0x00; //Blanking } } void main() { while(1) { display(); } } 3. Eight-segment digital tube static display Dynamic display is to connect the same segments of A-dp in the 8 segment codes of all displays together and connect them to a common output port, while the bit ends of the digital tubes are connected to other output ports respectively, and the display effect is produced through the interaction of the two groups of signals of these two output ports. That is, let each digital tube display in turn in a certain order. As long as the scanning frequency is high enough, due to the "visual persistence" phenomenon of the human eye, it can be displayed continuously and stably. Dynamic display can significantly reduce the cost of the display part and greatly reduce the wiring structure of the display interface. 1. A digital tube static display 0 to 9 #include #define uchar unsigned char #define uint unsigned int //Common anode digital tube coding table uchar code table1[] ={0xc0,0xf9,0xa4,0xb0, 0x99,0x92,0x82,0xf8, 0x80,0x90,0x88,0x83, 0xc6,0xa1,0x86,0x8e}; //Common cathode digital tube coding table uchar code table2[] ={0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71}; //Delay void DelayMS(uint x) { uchar t; while(x--) for(t=0;t<120;t++); } //Main program void main() { uchar i=0; P0=0x3f; for(; i < 10; ++i) { P0 = table2[i]; if(i == 9) i = 0; DelayMS(300); } while(1); }
Previous article:Study Notes: 51 MCU Keyboard
Next article:51 single chip microcomputer uses three methods to realize the water lamp
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
- How to Select a Digital Isolator
- Please advise on the problem of soldering pads not sticking to tin during soldering
- Sensitivity of the robot
- When defining and assigning a variable, a warning appears: Warning: extern variable has an initializer?
- [NUCLEO-WL55JC2 Review] +AT_Slave Routine Test
- My sharing of e-sports: A blessing in disguise
- MicroPython Update: 2021.1
- Best Illusions of 2019
- What challenges do you face in powering handling and harvesting robots? Let’s talk with Vicor engineers!
- MOS tube leakage current