When multiple digital tubes display numbers, we actually turn on the digital tube in turn (only one digital tube is bright at a time), and it can be done by using the visual persistence phenomenon (also called the afterglow effect) of the human eye. It seems that all the digital tubes are on at the same time. This is the dynamic display, also called dynamic scanning.
For example, if there are 2 digital tubes, we want to display the number "12". First, let the high-order bit select the transistor to conduct, then control the segment to display "1". After a certain time delay, let the lower bit select the triode. Turn on, then control the segment selection to display "2". By circulating this process at a certain speed, the digital tube can display "12". Since the alternating speed is very fast, the two digits recognized by the human eye are "12".
So how long does a digital tube need to be lit? In other words, how long does it take to complete the scanning of all the digital tubes (obviously: the overall scanning time = single digital tube lighting time * number of digital tubes)? The answer is: within 10ms. When TVs and monitors are still in the era of CRT (electronic picture tube), there is a very popular slogan - "100Hz no flicker", yes, as long as the refresh rate is greater than 100Hz, that is, the refresh time is less than 10ms, you can do To no flicker, this is the hard indicator of our dynamic scanning. Then you may ask, is there a limit on the minimum? In theory, there is no such thing, but in fact, it does not have any progress in refreshing, because there is no flicker, and there is still no flickering. It just increases the load of the CPU in vain (because it needs to execute more in 1 second). Secondary scanning procedure). So usually we design
When the program is in use, it takes a value of nearly 10ms and a more regular value. We have 6 digital tubes on the development board, so we will now write a digital tube dynamic scanning program to verify and verify the dynamic display principle mentioned above.
Our goal is to implement the stopwatch function, but this time there are 6 digits, the maximum can be counted as 999999 seconds. So the program to be implemented now is much more complicated than the routines in the previous chapters, both to handle the stopwatch count and to handle dynamic scanning. When writing such a slightly complicated program, it is recommended that beginners use the program flow chart to clarify the entire process of the program. Before the handwriting program, the structure of the entire program is set up, and each link is implemented. The function is refined first, and then implemented step by step with the program code. This will avoid the confusion of nowhere to write. Figure 6-1 is the flow chart of this example. Let's go through the process in the brain according to the flow chart, then look at the next program code, and appreciate the role of the flowchart to see if it helps. You smooth out the process flow more smoothly.
Figure 6-1 Digital tube dynamic display stopwatch program flow chart
#include
Sbit ADDR0 = P1^0;
Sbit ADDR1 = P1^1;
Sbit ADDR2 = P1^2;
Sbit ADDR3 = P1^3;
Sbit ENLED = P1^4;
Unsigned char code LedChar[] = { // digital tube display character conversion table
0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8,
0x80, 0x90, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E
};
Unsigned char LedBuff[6] = { //The digital tube displays the buffer, the initial value is 0xFF.
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
Void main(){
Unsigned char i = 0; //dynamically scanned index
Unsigned int cnt = 0; //record the number of T0 interrupts
Unsigned long sec = 0; //Number of seconds passed
ENLED = 0; //Enable U3, select control digital tube
ADDR3 = 1; //Because you need to dynamically change the value of ADDR0-2, you don't need to initialize it again.
TMOD = 0x01; //Set T0 to mode 1
TH0 = 0xFC; // initial value 0xFC67 for T0, timing 1ms
TL0 = 0x67;
TR0 = 1; //Start T0
While (1){
If (TF0 == 1){ //Judge whether T0 overflows
TF0 = 0; //T0 clears the interrupt flag after overflow
TH0 = 0xFC; // and re-assign initial value
TL0 = 0x67;
Cnt++; //count value from 1
If (cnt >= 1000){ //Judge if T0 overflows 1000 times
Cnt = 0; //The count value is cleared after 1000 times
Sec++; //second count since adding 1
/ / The following code will sec in decimal digits from low to high and then into the digital display characters
LedBuff[0] = LedChar[sec%10];
LedBuff[1] = LedChar[sec/10%10];
LedBuff[2] = LedChar[sec/100%10];
LedBuff[3] = LedChar[sec/1000%10];
LedBuff[4] = LedChar[sec/10000%10];
LedBuff[5] = LedChar[sec/100000%10];
}
/ / The following code to complete the digital tube dynamic scan refresh
If (i == 0)
{ ADDR2=0; ADDR1=0; ADDR0=0; i++; P0=LedBuff[0];
Else if (i == 1)
{ ADDR2=0; ADDR1=0; ADDR0=1; i++; P0=LedBuff[1];
Else if (i == 2)
{ ADDR2=0; ADDR1=1; ADDR0=0; i++; P0=LedBuff[2];
Else if (i == 3)
{ ADDR2=0; ADDR1=1; ADDR0=1; i++; P0=LedBuff[3];
Else if (i == 4)
{ ADDR2=1; ADDR1=0; ADDR0=0; i++; P0=LedBuff[4];
Else if (i == 5)
{ ADDR2=1; ADDR1=0; ADDR0=1; i=0; P0=LedBuff[5];
}
}
}
This program, everyone copied to Keil, and then copy and combine the program flow chart to understand, and finally download to the experimental board to see the results. The if...else statement below is to quickly refresh a digital tube every 1ms, so that the time for the six digital tubes to be refreshed is 6ms. The visual sense is that six digital tubes are lit at the same time.
In C language, /" is equivalent to the division operation in mathematics, and "%" is equivalent to the remainder calculation of our primary school. This has been introduced before. If it is the number 123456, we have to display it on the digital tube. The single digit display is to directly take the remainder of 10, and the "6" comes out. The ten digits are divided by 10 first, then the remainder of 10, and so on, and all 6 digits are displayed.
For the way of dynamically refreshing the digital tube, we will have a better effect if we use switch. Let's take a look at the situation we completed with the switch statement.
#include
Sbit ADDR0 = P1^0;
Sbit ADDR1 = P1^1;
Sbit ADDR2 = P1^2;
Sbit ADDR3 = P1^3;
Sbit ENLED = P1^4;
Unsigned char code LedChar[] = { // digital tube display character conversion table
0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8,
0x80, 0x90, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E
};
Unsigned char LedBuff[6] = { //The digital tube displays the buffer, the initial value is 0xFF.
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
Void main(){
Unsigned char i = 0; //dynamically scanned index
Unsigned int cnt = 0; //record the number of T0 interrupts
Unsigned long sec = 0; //Number of seconds passed
ENLED = 0; //Enable U3, select control digital tube
ADDR3 = 1; //Because you need to dynamically change the value of ADDR0-2, you don't need to initialize it again.
TMOD = 0x01; //Set T0 to mode 1
TH0 = 0xFC; // initial value 0xFC67 for T0, timing 1ms
TL0 = 0x67;
TR0 = 1; //Start T0
While (1){
If (TF0 == 1){ //Judge whether T0 overflows
TF0 = 0; //T0 clears the interrupt flag after overflow
TH0 = 0xFC; // and re-assign initial value
TL0 = 0x67;
Cnt++; //count value from 1
If (cnt >= 1000){ //Judge if T0 overflows 1000 times
Cnt = 0; //The count value is cleared after 1000 times
Sec++; //second count since adding 1
/ / The following code will sec in decimal digits from low to high and then into the digital display characters
LedBuff[0] = LedChar[sec%10];
LedBuff[1] = LedChar[sec/10%10];
LedBuff[2] = LedChar[sec/100%10];
LedBuff[3] = LedChar[sec/1000%10];
LedBuff[4] = LedChar[sec/10000%10];
LedBuff[5] = LedChar[sec/100000%10];
}
/ / The following code to complete the digital tube dynamic scan refresh
Switch (i){
Case 0: ADDR2=0; ADDR1=0; ADDR0=0; i++; P0=LedBuff[0]; break;
Case 1: ADDR2=0; ADDR1=0; ADDR0=1; i++; P0=LedBuff[1]; break;
Case 2: ADDR2=0; ADDR1=1; ADDR0=0; i++; P0=LedBuff[2]; break;
Case 3: ADDR2=0; ADDR1=1; ADDR0=1; i++; P0=LedBuff[3]; break;
Case 4: ADDR2=1; ADDR1=0; ADDR0=0; i++; P0=LedBuff[4]; break;
Case 5: ADDR2=1; ADDR1=0; ADDR0=1; i=0; P0=LedBuff[5]; break;
Default: break;
}
}
}
}
The function of the program is exactly the same, but let's see if the switch statement is neat and tidy than the if...else statement.
Ethernet cables connect devices such as PCs, routers, and switches within a local area network.Most technicians refer to these standards as CAT5 and CAT6, respectively. Also CAT3 available. Because of this, many online stores that sell network cables use this abbreviated language as well.
The connector can by shield or non-shield type, raw cable can be UTP, STP, FTP type. Also the molded shape can be custom mould by straight, right-angle, 105 degree, etc.
These physical cables are limited by length and durability. If a network cable is too long or of poor quality, it won't carry a good network signal. These limits are one reason there are different types of Ethernet cables that are optimized to perform certain tasks in specific situations.
Ethernet Cable Wiring,RJ45 cable,networking cable,8P8C cable
ETOP WIREHARNESS LIMITED , https://www.wireharness-assembling.com