Efficient single-wire communication method between single-chip microcomputers
Technical Field
The invention relates to the field of single-chip microcomputer communication, in particular to a high-efficiency single-wire communication method between single-chip microcomputers.
Background
In the single-wire communication mechanism between the current single-chip microcomputers, a bit transmission mechanism is mostly adopted, a pulse width method is commonly used, two different pulse widths are used for representing 0 and 1, then 8 times of transmission are carried out, and finally one byte is combined.
If the information of one BYTE is transmitted between the single-chip microcomputers 1 to 2 times, the whole communication efficiency is improved by at least 4 times or 8 times.
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 VCCToMoiety [ V ]A,VB]Is divided into at least n gradients, V is more than or equal to 0A<VB≤VCCConverting binary data to be transferred into n-system, n being positive integer, n ∈ [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]× (i +1), i is an integer, i ∈ [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, n ∈ [3,4], n ∈ [9,16], 2, and n ∈ (128, 256), where one byte of data can be transferred by transmitting data once.
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]× (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 voltage value read by the receiving end in the process of reading the voltage value is large [0, V ]A]Or ∈ [ 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 transferred into n-system, n being positive integer, n ∈ [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]× (i +1), i is an integer, i ∈ [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 ∈ [0, V ] read by the receiving terminal in the process of reading the voltage valueA]Or ∈ [ 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.
Drawings
Fig. 1 is a schematic diagram of a transmitting end of a high-efficiency single-wire communication method between single-chip microcomputers.
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 transferred into n-system, n being positive integer, n ∈ [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]× (i +1), i is an integer, i ∈ [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]× (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 transferred into n-system, n being positive integer, n ∈ [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]× (i +1), i is an integer, i ∈ [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]× (i +1), i is an integer, i ∈ [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]× (i +1), i is an integer, i ∈ [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 embodimentCC/17) × 16, the separation code is actually the voltage value in the largest one of the 17 gradients, and the bus voltage in this embodiment is divided into n +1 gradients.
In fact, since the nine, decimal, … …, hexadecimal numbers can be converted into four-digit binary numbers, so that n ∈ [9,16] can be implemented with reference to the 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]× (i +1), i is an integer, i ∈ [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 the present example, the present inventors found thatIn the examples, a part of the bus voltage is 0 to (V) in the examplesCC/4) × 3, the separation code is actually the voltage value in 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 gradientiIn the range of [ V ]CC/n]×i<Vi<[VCC/n]× (i +1), i is an integer, i ∈ [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 embodimentCC/4) × 3, the separation code is actually the voltage value in 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<VCCConverting binary data to be transmitted into 256-system, wherein any voltage value in the first 256 gradient voltage ranges represents one value in the 256-system, and the voltage value V of the ith gradientiIn the range of [ V ]B/n]×i<Vi<[VB/n]× (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 ∈ [ 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 corresponding relationship of the voltage value to the system number is shown in the following tableIn the examples, 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 gradients, V is more than or equal to 0A<VB≤VCCConverting binary data to be transferred into n-system, n being positive integer, n ∈ [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]× (i +1), i is an integer, i ∈ [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 ∈ [3,4], 4 times of data can be transmitted to transmit one byte of data, when n ∈ [9,16], 2 times of data can be transmitted to transmit one byte of data, when n ∈ (128, 256), one time of data can be transmitted to transmit one byte of data, the data transmission efficiency can be greatly improved, the efficiency of transmitting one byte of data can be improved by 2, 4, 8 times, when data is transmitted, data of a plurality of bytes often need to be transmitted, data of different bytes need to be separated to avoid confusion, voltage values which do not belong to a voltage gradient range can be transmitted outwards to separate data, the fault tolerance rate can be improved by transmitting intermediate values, some single-chip microcomputers do not have DAC modules, data need to be transmitted through external AD modules, and receiving ends convert 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]× (i +1), i is an integer, i ∈ [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 VjIs located in a voltage range determining electricityPressure 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 ∈ [0, V ] read by the receiving terminal in the process of reading the voltage valueA]Or ∈ [ 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 embodimentCC/17) × 16, the separation code is actually the voltage value in the largest one of the 17 gradients, and the 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.