Disclosure of Invention
The invention provides a high-efficiency single-wire communication method between single-chip microcomputers, aiming at improving the communication efficiency between the single-chip microcomputers.
In order to solve the technical problems, the technical scheme provided by the invention is as follows:
a high-efficiency single-wire communication method between single-chip microcomputers comprises a sending end, and the method for sending data by the sending end comprises the following steps:
s11, the sending end enables the bus voltage VCCA part of [ V ]A,VB]Is divided into at least n gradients, V is more than or equal to 0A<VB≤VCCConverting binary data to be transmitted into n-system, n is positive integer and n is equal to [3,4]]∪[9,16]∪(128,256]Any voltage value in the first n gradient voltage ranges represents a value in n-system, wherein the voltage value Vi of the ith gradient is in the range of [ (V)B-VA)/n]×i<Vi< [(VB-VA)/n]X (i +1), i is an integer, i belongs to [0, n-1 ]];
And S21, the sending end outputs voltage outwards.
Dividing a part of the bus voltage into n gradients, wherein any voltage value in each voltage gradient range corresponds to an n-system value; the data of one byte includes 8-bit binary data, data of one ternary number or four-decimal number can be converted into two-bit binary data, a nine-decimal number, a decimal number, … …, hexadecimal number can be converted into four-bit binary data, and a one hundred twenty eight-decimal number, a one hundred twenty nine-decimal number, … …, two hundred fifty-hexadecimal number can be converted into eight-bit binary data.
That is, when n belongs to [3,4], sending 4 times of data can transfer one byte of data; when n belongs to [9,16], sending 2 times of data can transfer one byte of data; n ∈ (128, 256), sending data once can deliver one byte of data.
The data sending efficiency can be greatly improved, and the efficiency of transmitting the data of one byte can be improved by 2, 4 and 8 times.
Preferably, after the sending end finishes sending data once or before sending data once, sending a separation code, wherein a voltage value V of the separation coden+1∈[0,VA]Or Vn+1∈[VB,VCC]. When data is transmitted, data is often transmitted for many times, different data need to be separated to avoid confusion, and voltage values which do not belong to the voltage gradient range can be sent outwards to separate the data.
Preferably, the voltage V output from the transmitting terminal isioutIs the interval ([ (V)B-VA)/n]×i,[(VB-VA)/n]X (i + 1)). Sending intermediate values may improve the fault tolerance rate.
Preferably, the transmitting end outputs the voltage to the AD module. Some single-chip microcomputers do not have a DAC module, and need to transmit data through an external AD module.
Preferably, the sending end outputs the voltage in a PWM output mode, and then converts the voltage into a dc voltage through an RC circuit and transmits the dc voltage to the AD module.
A high-efficiency single-wire communication method between single-chip microcomputers comprises a receiving end, wherein the method for receiving data by the receiving end is as follows:
s12, the receiving end reads a voltage value Vj;
S22, the receiving end reads the voltage value VjJudging the voltage range of the voltage value according to the voltage value VjThe voltage range determines the voltage value VjAnd converting the n-system data into a binary system according to the corresponding n-system data. The receiving end converts the voltage value into corresponding n-system data.
Preferably, the receiving endThe voltage value read in the process of reading the voltage value is large [0, V ]A]Or e [ V ]B,VCC]Then reception of the next data is started.
Preferably, the receiving end reads the content of the AD module.
A high-efficiency single-wire communication method between single-chip microcomputers comprises a sending end and a receiving end, and comprises the following steps:
s13, the sending end enables the bus voltage VCCA part of [ V ]A,VB]Is divided into at least n gradients, V is more than or equal to 0A<VB≤VCCConverting binary data to be transmitted into n-system, n is positive integer and n is equal to [3,4]]∪[9,16]∪(128,256]Any voltage value in the first n gradient voltage ranges represents a value in n-system, wherein the voltage value Vi of the ith gradient is in the range of [ (V)B-VA)/n]×i<Vi< [(VB-VA)/n]X (i +1), i is an integer, i belongs to [0, n-1 ]];
S23, the sending end outputs voltage outwards;
s33, the receiving end reads the voltage value Vj;
S43, the receiving end reads the voltage value VjJudging the voltage range of the voltage value according to the voltage value VjThe voltage range determines the voltage value VjAnd converting the n-system data into a binary system according to the corresponding n-system data.
Preferably, after the sending end finishes sending data once or before sending data once, sending a separation code, wherein a voltage value V of the separation coden+1∈[0,VA]Or Vn+1∈[VB,VCC];
The voltage value E [0, V ] read in the process of reading the voltage value by the receiving endA]Or e [ V ]B,VCC]Then reception of the next data is started.
Compared with the prior art, the invention has the beneficial effects that: the data sending efficiency can be greatly improved, and the efficiency of transmitting the data of one byte can be improved by 2, 4 and 8 times.
Detailed Description
The following examples are further illustrative of the present invention and are not intended to be limiting thereof.
Example 1
A high-efficiency single-wire communication method between single-chip microcomputers comprises a sending end, and the method for sending data by the sending end comprises the following steps:
s11, the sending end enables the bus voltage VCCA part of [ V ]A,VB]Is divided into at least n gradients, V is more than or equal to 0A<VB≤VCCConverting binary data to be transmitted into n-system, n is positive integer and n is equal to [3,4]]∪[9,16]∪(128,256]Any voltage value in the first n gradient voltage ranges represents a value in n-ary, wherein the voltage value V of the ith gradientiIn the range of [ (V)B-VA)/n]×i<Vi< [(VB-VA)/n]X (i +1), i is an integer, i belongs to [0, n-1 ]];
And S21, the sending end outputs voltage outwards.
After the sending end finishes sending data once or before sending data once, sending a separation code, wherein the voltage value V of the separation coden+1∈[0,VA]Or Vn+1∈[VB,VCC]。
The voltage V output by the sending terminalioutIs the interval ([ (V)B-VA)/n]×i,[(VB-VA)/n]X (i + 1)).
And the sending end outputs voltage to the AD module.
After the voltage is output by the sending end in a PWM output mode, the voltage is converted into direct current voltage through the RC circuit and then is transmitted to the AD module.
Example 2
A high-efficiency single-wire communication method between single-chip microcomputers comprises a sending end, and the method for sending data by the sending end comprises the following steps:
s11, the sending end enables the bus voltage VCCA part of [ V ]A,VB]Is divided into at least n gradients, V is more than or equal to 0A<VB≤VCCConverting binary data to be transmitted into n-system, n is positive integer and n is equal to [3,4]]∪[9,16]∪(128,256]Any voltage value in the first n gradient voltage ranges represents a value in n-ary, wherein the voltage value V of the ith gradientiIn the range of [ (V)B-VA)/n]×i<Vi< [(VB-VA)/n]X (i +1), i is an integer, i belongs to [0, n-1 ]];
And S21, the sending end outputs voltage outwards.
After the sending end finishes sending data once or before sending data once, sending a separation code, wherein the voltage value V of the separation coden+1∈[0,VA]Or Vn+1∈[VB,VCC]。
Example 3
An efficient single-wire communication method between single-chip microcomputers includes a sending end in this embodiment, and the method for sending data by the sending end includes:
s11, the sending end enables the bus voltage VCCA part of [ V ]A,VB]Is divided into not less than 16 gradients, 0= VA<VB<VCCConverting binary data to be transmitted into 16-system, wherein any voltage value in the first 16 gradient voltage ranges represents one value in n-system, and the voltage value V of the ith gradientiIn the range of [ V ]B/n]×i<Vi< [VB/n]X (i +1), i is an integer, i belongs to [0, n-1 ]];
And S21, the sending end outputs voltage outwards.
After the sending end finishes sending data once or before sending data once, sending a separation code, wherein the voltage value or V of the separation code17∈[VB,VCC]。
Table 116 system number and voltage value correspondence
In this embodiment, the sending-end single chip microcomputer sends out 4-bit information in one byte each time.
Example 4
An efficient single-wire communication method between single-chip microcomputers includes a sending end in this embodiment, and the method for sending data by the sending end includes:
s11, the sending end enables the bus voltage VCCSplit into 17 gradients, 0= VA<VB=VCCConverting binary data to be transmitted into 16-system, wherein any voltage value in the first 16 gradient voltage ranges represents a value in 16-system, and the voltage value V of the ith gradientiIn the range of [ V ]CC/n]×i<Vi< [VCC/n]X (i +1), i is an integer, i belongs to [0, n-1 ]];
And S21, the sending end outputs voltage outwards.
After the sending end finishes sending data once or before sending data once, sending a separation code, wherein the voltage value V of the separation code17∈[VB,VCC]。
In this embodiment, the sending-end single chip microcomputer sends out 4-bit information in one byte each time. In this embodiment, a part of the bus voltage is 0 to (V) in this embodimentCC17) × 16, the division code is actually a voltage value within the largest one of the 17 gradients, and the bus voltage in this embodiment is divided into n +1 gradients.
In fact, since the nona, decimal, … …, hexadecimal numbers can be converted into four-digit binary numbers, so that n ∈ [9,16], the implementation can be referred to in this embodiment.
Example 5
An efficient single-wire communication method between single-chip microcomputers includes a sending end in this embodiment, and the method for sending data by the sending end includes:
s11, the sending end enables the bus voltage VCCDivide into 3+1 gradients, 0= VA<VB=VCCConverting binary data to be transmitted into 3-system, wherein any voltage value in the first 3 gradient voltage ranges represents a value in 3-system, and the voltage value V of the ith gradientiIn the range of [ V ]CC/n]×i<Vi< [VCC/n]X (i +1), i is an integer, i belongs to [0, n-1 ]];
And S21, the sending end outputs voltage outwards.
After the sending end finishes sending data once or before sending data once, sending a separation code, wherein the voltage value V of the separation code17∈[(VCC/4)×3,VCC]。
Table 33 system number and voltage value corresponding relation
In this embodiment, the sending-end single chip microcomputer sends out 2-bit information in one byte each time. In this embodiment, a part of the bus voltage is 0 to (V) in this embodimentCC4) × 3, the division code is actually a voltage value within the largest one of the 4 gradients, and the bus voltage in this embodiment is divided into n +1 gradients.
In fact, since ternary and quaternary numbers can be converted into four-digit binary numbers, n ∈ 3,4 can be implemented with reference to the embodiment.
Example 6
An efficient single-wire communication method between single-chip microcomputers includes a sending end in this embodiment, and the method for sending data by the sending end includes:
s11, the sending end enables the bus voltage VCCDivide into 3+1 gradients, 0= VA<VB=VCCConverting binary data to be transmitted into 3-system, wherein any voltage value in the first 3 gradient voltage ranges represents a value in 3-system, and the voltage value V of the ith gradientiRange of (1)Is [ V ]CC/n]×i<Vi< [VCC/n]X (i +1), i is an integer, i belongs to [0, n-1 ]];
And S21, the sending end outputs voltage outwards.
After the sending end finishes sending data once or before sending data once, sending a separation code, wherein the voltage value V of the separation code17∈[(VCC/4)×3,VCC]。
TABLE 43 binary number to voltage value correspondence
In this embodiment, the sending-end single chip microcomputer sends out 2-bit information in one byte each time. In this embodiment, a part of the bus voltage is 0 to (V) in this embodimentCC4) × 3, the division code is actually a voltage value within the largest one of the 4 gradients, and the bus voltage in this embodiment is divided into n +1 gradients.
In this embodiment, the token code of the third gradient range is 5, and is not 2 in ternary in the conventional sense, which should be understood as that the so-called n-ary in this application is n symbols, each symbol corresponds to a voltage gradient range, as long as it can be understood that the transmitted data is the symbol in the voltage gradient range of a certain symbol, and similarly, the receiving end can also parse the symbol into binary numbers.
In fact, since ternary and quaternary numbers can be converted into four-digit binary numbers, n ∈ 3,4 can be implemented with reference to the embodiment.
Example 7
An efficient single-wire communication method between single-chip microcomputers includes a sending end in this embodiment, and the method for sending data by the sending end includes:
s11, the sending end enables the bus voltage VCCA part of [ V ]A,VB]Is divided into not less than 256 gradients, 0= VA<VB<VCCBinary data to be transferredConverted into 256-system, any voltage value in the first 256 gradient voltage ranges represents one value in 256-system, wherein the voltage value V of the ith gradientiIn the range of [ V ]B/n]×i<Vi< [VB/n]X (i +1), i is an integer, i ∈ [0,255 ]];
And S21, the sending end outputs voltage outwards.
After the sending end finishes sending data once or before sending data once, sending a separation code, wherein the voltage value or V of the separation code17∈[VB,VCC]。
Table 5256 binary number to voltage value correspondence
In this embodiment, the sending-end single chip microcomputer sends out 8-bit information in one byte each time.
Generally speaking, limited by common symbols, the method will not be applied to 256, but it cannot be denied that 129, 130, … …,256 numbers can be converted into 8-bit binary numbers, and one byte of data can be transmitted at a time. The transmission efficiency is further improved.
Example 8
A high-efficiency single-wire communication method between single-chip microcomputers comprises a receiving end, wherein the method for receiving data by the receiving end is as follows:
s12, the receiving end reads a voltage value Vj;
S22, the receiving end reads the voltage value VjJudging the voltage range of the voltage value according to the voltage value VjThe voltage range determines the voltage value VjAnd converting the n-system data into a binary system according to the corresponding n-system data.
The voltage value read by the receiving end in the process of reading the voltage value is large [0, V ]A]Or e [ V ]B,VCC]Then reception of the next data is started.
And the receiving end reads the content of the AD module.
Example 9
A high-efficiency single-wire communication method between single-chip microcomputers comprises a receiving end, wherein the method for receiving data by the receiving end is as follows:
s12, the receiving end reads a voltage value Vj;
S22, the receiving end reads the voltage value VjJudging the voltage range of the voltage value according to the voltage value VjThe voltage range determines the voltage value VjAnd converting the n-system data into a binary system according to the corresponding n-system data.
Example 10
A high-efficiency single-wire communication method between single-chip microcomputers comprises a receiving end, wherein the method for receiving data by the receiving end is as follows:
s12, the receiving end reads a voltage value Vj;
S22, the receiving end reads the voltage value VjJudging the voltage range of the voltage value according to the voltage value VjThe voltage range determines the voltage value VjAnd converting the n-system data into a binary system according to the corresponding n-system data. The correspondence relationship from the voltage value to the number is as shown in the following table, and in the present embodiment, n = 16.
Table 6 receiving terminal 16 system number and voltage value corresponding relation
In this embodiment, the receiving-end single chip microcomputer can receive 4-bit information in one byte at a time. The receiving end single chip microcomputer can convert the 16-system number into the 2-system number after receiving the information, thereby realizing the use of data and also directly outputting the 16-system number.
Example 11
A high-efficiency single-wire communication method between single-chip microcomputers comprises a sending end and a receiving end, and comprises the following steps:
s13, the sending end enables the bus voltage VCCA part of [ V ]A,VB]Is divided into at least n laddersDegree, 0 ≤ VA<VB≤VCCConverting binary data to be transmitted into n-system, n is positive integer and n is equal to [3,4]]∪[9,16]∪(128,256]Any voltage value in the first n gradient voltage ranges represents a value in n-system, wherein the voltage value Vi of the ith gradient is in the range of [ (V)B-VA)/n]×i<Vi< [(VB-VA)/n]X (i +1), i is an integer, i belongs to [0, n-1 ]];
S23, the sending end outputs voltage outwards;
s33, the receiving end reads the voltage value Vj;
S43, the receiving end reads the voltage value VjJudging the voltage range of the voltage value according to the voltage value VjThe voltage range determines the voltage value VjAnd converting the n-system data into a binary system according to the corresponding n-system data.
Dividing a part of the bus voltage into n gradients, wherein any voltage value in each voltage gradient range corresponds to an n-system value; the data of one byte includes 8-bit binary data, data of one ternary number or four-decimal number can be converted into two-bit binary data, a nine-decimal number, a decimal number, … …, hexadecimal number can be converted into four-bit binary data, and a one hundred twenty eight-decimal number, a one hundred twenty nine-decimal number, … …, two hundred fifty-hexadecimal number can be converted into eight-bit binary data.
That is, when n belongs to [3,4], sending 4 times of data can transfer one byte of data; when n belongs to [9,16], sending 2 times of data can transfer one byte of data; when n belongs to (128, 256), data of one byte can be transmitted by sending data once, the data transmission efficiency can be greatly improved, the efficiency of transmitting the data of one byte can be improved by 2, 4 and 8 times, the data of a plurality of bytes are often required to be transmitted during data transmission, the data of different bytes need to be separated to avoid confusion, voltage values which do not belong to a voltage gradient range can be sent outwards to separate the data, the fault tolerance rate can be improved by sending an intermediate value, some single-chip microcomputers do not comprise DAC modules and need to transmit the data through external AD modules, and a receiving end converts the voltage values into corresponding n-system data.
Example 12
A high-efficiency single-wire communication method between single-chip microcomputers comprises a sending end and a receiving end, and comprises the following steps:
s13, the transmitting terminal converts the bus voltage VCCSplit into 17 gradients, 0= VA<VB=VCCConverting binary data to be transmitted into 16-system, wherein any voltage value in the first 16 gradient voltage ranges represents a value in 16-system, and the voltage value V of the ith gradientiIn the range of [ V ]CC/n]×i<Vi< [VCC/n]X (i +1), i is an integer, i belongs to [0, n-1 ]];
S23, the sending end outputs voltage outwards;
table 716 binary number to voltage value correspondence
S33, the receiving end reads the voltage value Vj;
S43, the receiving end reads the voltage value VjJudging the voltage range of the voltage value according to the voltage value VjThe voltage range determines the voltage value VjAnd converting the n-system data into a binary system according to the corresponding n-system data, wherein the specific conversion relation is shown in a table.
After the sending end finishes sending data once or before sending data once, sending a separation code, wherein the voltage value V of the separation coden+1∈[0,VA]Or Vn+1∈[VB,VCC];
The voltage value E [0, V ] read in the process of reading the voltage value by the receiving endA]Or e [ V ]B,VCC]Then, the next data starts to be received
In this embodiment, the sending-end single chip microcomputer sends out 4-bit information in one byte each time. In this embodiment, a part of the bus voltage is 0 to (V) in this embodimentCC17) × 16, the separation code is actually within the largest one of the 17 gradientsThe bus voltage in this embodiment is divided into n +1 gradients.
The above detailed description is specific to possible embodiments of the present invention, and the above embodiments are not intended to limit the scope of the present invention, and all equivalent implementations or modifications that do not depart from the scope of the present invention should be included in the present claims.