CN111431631A - Bidirectional communication method, receiving equipment, sending equipment and communication system - Google Patents

Bidirectional communication method, receiving equipment, sending equipment and communication system Download PDF

Info

Publication number
CN111431631A
CN111431631A CN202010208586.6A CN202010208586A CN111431631A CN 111431631 A CN111431631 A CN 111431631A CN 202010208586 A CN202010208586 A CN 202010208586A CN 111431631 A CN111431631 A CN 111431631A
Authority
CN
China
Prior art keywords
decoding
minimum
pulse
receiving
pulses
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010208586.6A
Other languages
Chinese (zh)
Other versions
CN111431631B (en
Inventor
韦依宁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Hetai Intelligent Home Appliance Controller Co ltd
Original Assignee
Shenzhen Het Data Resources and Cloud Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Het Data Resources and Cloud Technology Co Ltd filed Critical Shenzhen Het Data Resources and Cloud Technology Co Ltd
Priority to CN202010208586.6A priority Critical patent/CN111431631B/en
Publication of CN111431631A publication Critical patent/CN111431631A/en
Application granted granted Critical
Publication of CN111431631B publication Critical patent/CN111431631B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04BTRANSMISSION
    • H04B14/00Transmission systems not characterised by the medium used for transmission
    • H04B14/02Transmission systems not characterised by the medium used for transmission characterised by the use of pulse modulation
    • H04B14/04Transmission systems not characterised by the medium used for transmission characterised by the use of pulse modulation using pulse code modulation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/0001Systems modifying transmission characteristics according to link quality, e.g. power backoff
    • H04L1/0006Systems modifying transmission characteristics according to link quality, e.g. power backoff by adapting the transmission format

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Quality & Reliability (AREA)
  • Communication Control (AREA)

Abstract

The invention relates to the field of communication, and discloses a bidirectional communication method, receiving equipment, sending equipment and a communication system, wherein the method comprises the following steps: receiving a head code sent by sending equipment to enter an awakening state according to the head code; receiving a learning code sent by a sending device to extract a minimum decoding pulse according to the learning code; receiving a data frame obtained by encoding a target content byte by a sending device according to a preset encoding mode and a minimum encoding pulse; and decoding the data frame according to a preset decoding mode and the minimum decoding pulse to obtain the target content byte. Therefore, the receiving equipment enters an awakening state according to the head code, and the receiving equipment is prevented from being awakened in sleep and abnormal when communicating with the sending equipment; the receiving equipment decodes the target content bytes according to the minimum decoding pulse, so that decoding failure caused by inconsistency of the encoding pulses of the receiving equipment and the sending equipment is avoided, the stability of communication between the equipment is improved, and the decoding accuracy is improved.

Description

Bidirectional communication method, receiving equipment, sending equipment and communication system
Technical Field
The present invention relates to the field of communications, and in particular, to a bidirectional communication method, a receiving device, a transmitting device, and a communication system.
Background
At present, in various chip designs, with the continuous expansion of chip functions, the communication between devices is increasing, which inevitably increases the communication modes of various signal instructions on each chip.
Generally, the conventional devices communicate with each other through standard communication interfaces UART, SPI, and the like, such communication modes can be realized only by providing hardware resources corresponding to the standard interfaces in a chip, and the communication modes occupy two or more interface resources.
Disclosure of Invention
An object of the embodiments of the present invention is to provide a bidirectional communication method, a receiving device, a transmitting device, and a communication system, which can improve the accuracy of decoding.
In order to solve the technical problems, the invention provides the following technical scheme:
in a first aspect, an embodiment of the present invention provides a bidirectional communication method, which is applied to a receiving device in a communication system, where the communication system further includes a sending device, and the receiving device communicates with the sending device based on a single data line, and the method includes:
receiving a head code sent by the sending equipment so as to enter an awakening state according to the head code;
receiving a learning code sent by the sending equipment so as to extract a minimum decoding pulse according to the learning code, wherein the minimum decoding pulse is a corresponding value of a minimum coding pulse of the sending equipment at the receiving equipment;
receiving a data frame obtained by encoding a target content byte by the sending equipment according to a preset encoding mode and the minimum encoding pulse;
and decoding the data frame according to a preset decoding mode and the minimum decoding pulse to obtain the target content byte.
Optionally, the receiving the header code sent by the sending device to enter the awake state according to the header code includes:
and under the condition of being in a sleep state, when a falling edge is detected for the first time, determining to receive the head code sent by the sending equipment, and awakening the receiving equipment.
Optionally, the learning code is composed of a fixed number of high and low levels, and the receiving the learning code sent by the sending device to extract the minimum decoding pulse according to the learning code includes:
and when the rising edge is detected for the first time, determining that the learning code sent by the sending equipment is received, recording the pulse width of the learning code, and taking the quotient of the pulse width and the fixed number as the minimum decoding pulse.
Optionally, the minimum decoding burst comprises a minimum positive decoding burst or a minimum negative decoding burst, and the predetermined decoding mode comprises a variable length decoding mode or a fixed length decoding mode;
in the variable length decoding mode, both of the same two minimum positive decoding pulses or both of the same two minimum negative decoding pulses may represent a binary 1, and one of the minimum positive decoding pulses or one of the minimum negative decoding pulses may represent a binary 0; alternatively, the first and second electrodes may be,
in the fixed-length decoding mode, in order, a set of decoding pulses consisting of the same two minimum positive decoding pulses and one minimum negative decoding pulse may represent a binary 1, and a set of decoding pulses consisting of the same two minimum positive decoding pulses and the same two minimum negative decoding pulses may represent a binary 0.
Optionally, the method further comprises:
when a send task is detected, processing the send task after decoding the content bytes.
In a second aspect, an embodiment of the present invention provides a bidirectional communication method, which is applied to a sending device in a communication system, where the communication system further includes a receiving device, and the sending device communicates with the receiving device based on a single line, where the method includes:
sending a header code to the receiving device, so that the receiving device enters an awakening state;
sending a learning code to the receiving device, so that the receiving device extracts a minimum decoding pulse according to the learning code, wherein the minimum decoding pulse is a corresponding value of a minimum coding pulse of the sending device at the receiving device;
according to a preset coding mode, coding the target content byte into a data frame consisting of a plurality of minimum coding pulses;
and sending the data frame to the receiving equipment, so that the receiving equipment decodes the data frame according to a preset decoding mode and the minimum decoding pulse to obtain the target content byte.
Optionally, the minimum coded pulse comprises a minimum positive coded pulse or a minimum negative coded pulse, and the predetermined coding mode comprises a variable length coding mode or a fixed length coding mode;
in the variable length coding mode, both of the same two minimum positive coded pulses or both of the same two minimum negative coded pulses may represent a binary number 1, and one of the minimum positive coded pulses or one of the minimum negative coded pulses may represent a binary number 0; alternatively, the first and second electrodes may be,
in the fixed-length coding mode, in order, a coding pulse set composed of the same two minimum positive coding pulses and the same two minimum negative coding pulses may represent a binary number 1, and a coding pulse set composed of the same two minimum positive coding pulses and the same two minimum negative coding pulses may represent a binary number 0.
In a third aspect, an embodiment of the present invention provides a receiving apparatus, including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a two-way communication method as claimed in any one of the preceding claims.
In a fourth aspect, an embodiment of the present invention provides a sending apparatus, including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a two-way communication method as claimed in any one of the preceding claims.
In a fifth aspect, an embodiment of the present invention provides a communication system, including:
the above-mentioned receiving device; and
the above-mentioned transmitting device, the transmitting device communicates with the receiving device based on a single wire.
Compared with the prior art, the bidirectional communication method, the receiving device, the sending device and the communication system provided by the embodiments of the invention receive the head code sent by the sending device so as to enter the awakening state according to the head code; receiving a learning code sent by sending equipment so as to extract a minimum decoding pulse according to the learning code, wherein the minimum decoding pulse is a corresponding value of a minimum coding pulse of the sending equipment at the receiving equipment; receiving a data frame obtained by encoding a target content byte by a sending device according to a preset encoding mode and a minimum encoding pulse; and decoding the data frame according to a preset decoding mode and the minimum decoding pulse to obtain the target content byte. Therefore, the receiving equipment enters an awakening state according to the head code, and the receiving equipment is prevented from being awakened in sleep and abnormal when communicating with the sending equipment; the receiving equipment extracts the minimum decoding pulse according to the learning code, decodes the target content byte according to the minimum decoding pulse, avoids decoding failure caused by inconsistency of the encoding pulse of the receiving equipment and the encoding pulse of the sending equipment, improves the stability of communication between the equipment, improves the accuracy of decoding, and effectively achieves the aim of single-wire two-way communication.
Drawings
One or more embodiments are illustrated by way of example in the accompanying drawings, which correspond to the figures in which like reference numerals refer to similar elements and which are not to scale unless otherwise specified.
Fig. 1 is a block diagram of a communication system according to an embodiment of the present invention;
fig. 2 is a block diagram of a communication system according to another embodiment of the present invention;
fig. 3 is a schematic flowchart of a single-wire communication method according to an embodiment of the present invention;
fig. 4 is a schematic flowchart of a data receiving method according to an embodiment of the present invention;
FIG. 5 is a diagram illustrating a data format according to an embodiment of the present invention;
fig. 6 is a flowchart illustrating a data transmission method according to an embodiment of the present invention;
fig. 7 is a diagram illustrating a data encoding format according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a block diagram of a communication system according to an embodiment of the present invention, where the communication system 100 includes a first device 10 and a second device 20, where the first device 10 communicates with the second device 20 based on a single line. In the communication process, the first device 10 and the second device 20 are receiving and/or transmitting devices with each other, for example, if the first device 10 is configured as a transmitting device, the second device 20 is configured as a receiving device; if the first device 10 is configured as a receiving device, the second device 20 is configured as a transmitting device.
The first device 10 comprises at least one processor and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a method of receiving and/or transmitting data as described in method embodiments below.
The second device 20 comprises at least one processor and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a method of receiving and/or transmitting data as described in method embodiments below.
The processor and the memory may be connected by a bus or other means. The memory, which is a non-volatile computer-readable storage medium, may be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions corresponding to data receiving and/or transmitting methods in embodiments of the present invention. The processor executes the non-volatile software programs, instructions, and modules stored in the memory to perform the data receiving and/or transmitting methods described in the method embodiments below.
The memory may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data and the like created at the time of data transmission and/or reception according to the device embodiments described below. Further, the memory may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device.
The first device 10 and the second device 20 communicate with each other via a single line, where the single line communication refers to bidirectional data transmission between the first device 10 and the second device 20 via a single signal line, for example, when the first device 10 is used as a transmitting device and the second device 20 is used as a receiving device, data is transmitted from the first device 10 to the second device 20. Or, the first device 10 acts as a receiving device and the second device 20 acts as a sending device, and then the data is transmitted from the second device 20 to the first device 10. Because only one signal line is used for data interaction between communication devices, it can be understood that only one party can receive or send data at the same time, that is, at a certain time, data is only allowed to be transmitted in one direction. In this embodiment, two ends of the signal line are respectively connected to any I/O port of the first device 10 and the second device 20 for data transmission or reception.
In some embodiments, the first device 10 and the second device 20 may further perform remote communication, please refer to fig. 2, fig. 2 is a block diagram of a communication system according to an embodiment of the present invention, where the communication system 100 further includes a first repeater 30 and a second repeater 40, the first device 10 is connected to the first repeater 30 by a single line, the second device 20 is connected to the second repeater 40 by a single line, and the first repeater 30 and the second repeater 40 are connected to perform remote communication through a network, so that physical signal transmission between two network nodes is achieved, and a distance of network transmission is extended.
It can be understood that, when the communication device is initially powered on, the device is initialized according to the function, and specifically, the attribute of the I/O port performing communication connection is configured to be in a receiving state, that is, the level of the I/O port is set to be a high level, and the external interrupt function of the I/O port is enabled. The external interrupt is a processing mechanism for processing an external event in real time by a CPU, and the method for triggering the external interrupt comprises level triggering and/or edge-jumping triggering. Level-triggered is that the initialization level of the I/O port is high, when an external interrupt is input at low level, the external interrupt function of the I/O port is triggered, and the external interrupt program can clear the external interrupt request source, i.e. after the external event is executed, the I/O port level will be set to high level again. The jump edge trigger means that the negative jump of the input line of the I/O port sampled by the CPU triggers the external interrupt, namely, the external interrupt is input in a negative pulse form to trigger the interrupt so that the CPU processes the external event. In this embodiment, the communication I/O ports of the first device 10 and the second device 20 can both support a level triggering method and/or a jump edge triggering method to trigger the external interrupt.
Furthermore, it can be understood that after the device completes the initialization operation, the device may directly enter the sleep state, or a sleep time threshold is preset in the system, and if no event processing instruction is received within the sleep time threshold, the device enters the sleep state to reduce the power consumption of the system, or whether the device enters the sleep state may be determined according to the system function.
The event processing instruction comprises a data sending instruction and a data receiving instruction, and it can be understood that when the event processing instruction is received, the device enters a corresponding communication processing flow according to the event processing instruction. Specifically, referring to fig. 3, fig. 3 is a schematic flow chart of a single-wire bidirectional communication method according to an embodiment of the present invention, including:
s31, the first device 10 and the second device 20 are all powered on and initialized, the attribute of the I/O port for communication connection is configured to be in a receiving state, and the external interrupt function of the I/O port is enabled;
it is understood that the first device 10 and the second device 20 may set the system to sleep after the initialization setting is completed, and circularly detect whether there is a receiving event and/or a sending requirement for triggering.
S32, when the first device 10 detects a sending request, setting the attribute of the I/O port to be a sending state, and turning off its external interrupt function;
it can be understood that the external interrupt function is used for triggering the I/O port to enter an interrupt handler according to an external event, and when the device detects a transmission request, since the two devices for communication are based on single-wire communication, at the same time, data can be transmitted only in one direction, and the external interrupt function of the I/O port is turned off, so as to ensure that the data can be successfully communicated in one direction.
S33, the first device 10 starts a timer according to the communication protocol, and sends a header pulse signal to the second device 20 during the timer interrupt;
the communication protocol refers to a rule which is agreed by both parties for communication and must be followed, and the communication equipment performs cooperative work through the communication protocol to realize data interaction and resource sharing. Specifically, in this embodiment, by starting the function of the timer, the timer is set according to the pulse width of the header code pulse signal, and when the timing interrupt is triggered, the sending of the header code pulse signal is completed.
S34, the second device 20 detects the trigger of the receiving event, enters a receiving state, and starts receiving the header pulse signal sent by the first device 10;
it can be understood that if the current system of the second device 20 is in the sleep state, the wake-up state is entered according to the header pulse signal; if the current system of the second device 20 is in the wake-up state, it is ready to receive other pulse signals immediately after the header code according to the header code pulse signal. In this embodiment, the header pulse signal is a low level signal with a fixed duration, where the fixed duration can be set according to a clock of an actual receiving device, and the low level signal with the fixed duration is used to ensure that the receiving device enters a wake-up state from a sleep state through the low level signal when the receiving device is in the sleep state, so as to ensure that the first device and the second device can communicate normally.
S35, the first device 10 starts a timer according to the communication protocol, and sends a learning code pulse signal to the second device 20 during the timing interruption;
specifically, the method for transmitting the learning code by the first device 10 is the same as the method for transmitting the header code, and the learning code is generated and transmitted by a pulse signal generated by a timer interrupt.
S36, the second device 20 receives the learning code sent by the first device 10, and extracts the minimum decoding pulse according to the learning code;
here, the learning code is used to make the second device 20 learn to confirm the reception value of the minimum coded pulse transmitted by the first device 10 at the second device 20, that is, the learning code is used to extract the minimum decoded pulse in the following embodiments. For example, the minimum encoding pulse width of the learning code sent by the first device 10 is 100us, the clock of the second device 20 is affected by other factors, the minimum pulse unit of the received learning code is 60us, and if the second device 20 decodes with 100us as the minimum decoding pulse, the decoding of the data frame is unsuccessful or an error occurs in the decoding; if the second device 20 decodes with 60us as the minimum decoding pulse, the received data frame can be accurately decoded, that is, 60us is the minimum decoding pulse that the second device 20 learns and confirms according to the learning code. Therefore, the minimum decoding pulse is confirmed through learning code learning, and the decoding accuracy of the equipment is improved.
S37, the first device 10 sends a data frame obtained by encoding the content byte according to a predetermined encoding mode;
the encoding means that a content byte is represented by a pulse unit formed by combining one or more high and low pulses according to a certain mode, for example, a binary number "1" is represented by a pulse unit formed by sequentially combining two high levels + one low level, and for example, a binary number "0" is represented by a pulse unit formed by sequentially combining one high level + two low levels. In this embodiment, two encoding methods are provided for encoding content bytes, where the encoding methods include variable length encoding and/or fixed length encoding, and please refer to the following embodiments of data encoding formats, which are not repeated herein.
S38, the second device 20 receives the data frame sent by the first device 10, and decodes the data frame according to the predetermined decoding mode and the minimum decoding pulse to obtain the target content byte;
the decoding means that one or more high and low pulses are combined according to a certain mode to obtain a new pulse unit, for example, a pulse unit formed by sequentially combining two high levels and one low level is identified as a binary number "1", and for example, a pulse unit formed by sequentially combining one high level and two low levels is identified as a binary number "0". It is understood that the predetermined encoding mode in the first device 10 corresponds to the predetermined decoding mode in the second device 20, specifically, if the predetermined encoding mode is fixed-length encoding, the predetermined decoding mode is fixed-length decoding; if the predetermined coding mode is variable length coding, the predetermined decoding mode is variable length decoding.
In some embodiments, the end of the data frame is provided with an end-pointer for indicating that the data frame has been completely received, and when the end-pointer is detected by the second device 20, the received data frame is decoded. In some embodiments, the second device 20 starts a timer interrupt when receiving the skip edge, and if no change of the skip edge is received in the timer interrupt, the second device 20 finishes receiving the data frame when the timer interrupt triggers, so that the second device 20 finishes receiving the data frame, and enters a loop to detect whether there is a receiving event and/or a sending requirement for triggering.
It can be understood that, if the second device 20 detects a transmission requirement during the frame data receiving process, the transmission requirement is pushed to the stack for waiting until the receiving event is completed, and the related processing flow of the transmission requirement is executed.
S39, after the first device 10 finishes sending the data frame, reconfigure the attribute of the I/O port performing the communication connection to the receiving state, and enter a loop to detect whether there is a receiving event and/or a sending requirement to trigger.
In the embodiment of the invention, the first device and the second device which are in communication realize bidirectional half-duplex data communication through single-wire connection, thereby reducing the occupation of chip pins.
Specifically, when a first device or a second device detects a reception event, an external interrupt of an I/O port of the first device or the second device is triggered, and the device is awakened and enters a data reception processing program according to the reception event. Referring to fig. 4, an embodiment of the present invention provides a bidirectional communication method, applied to a receiving device in a communication system, where the communication system further includes a sending device, and the receiving device communicates with the sending device based on a single data line, and the method includes:
s41, receiving the head code sent by the sending equipment, and entering an awakening state according to the head code;
and S42, receiving the learning code sent by the sending equipment, and extracting a minimum decoding pulse according to the learning code, wherein the minimum decoding pulse is a corresponding value of the minimum coding pulse of the sending equipment in the receiving equipment.
Specifically, please refer to fig. 5, fig. 5 is a schematic diagram of a communication data format according to an embodiment of the present invention, and as shown in fig. 5, the communication data includes a preamble and a content byte, and the preamble is located in a group of bytes at the start of the communication data packet to remind the receiving device to prepare to receive a data frame.
Specifically, the preamble includes a header code and a learning code, the header code is a low level with a fixed duration and is used to wake up the receiving device, and the fixed duration can be three times or four times the minimum decoding pulse as the fixed duration of the header code according to the functional requirements. In actual operation, when the receiving device detects a falling edge of the header code, triggering external interrupt of the I/O port, and if the receiving device is in a sleep state, entering an awake state according to the header code pulse signal, specifically, converting a clock of the receiving device from a low clock to a stable state of a high clock; and if the receiving equipment is in an awakening state, preparing to receive other pulse signals immediately after the head code according to the head code pulse signal. Wherein, the sleep state means that the device does not perform any substantial work and the clock frequency is reduced to reduce the power consumption; the wake-up state refers to the state where the device is operating at a normal clock frequency and can handle the triggering of various events or commands in time. In this embodiment, the device may wake up from an external interrupt on the I/O port and switch from the sleep state to the wake state.
The learning code is used for the receiving device to learn a reception value of a minimum coded pulse of the transmitting device in the receiving device, that is, a minimum decoded pulse, which includes a minimum positive decoded pulse or a minimum negative decoded pulse. In this embodiment, the learning code is composed of a fixed number of high and low levels, where the fixed number is any integer value from two to four. When the receiving device detects the rising edge of the learning code, recording the pulse width of the learning code, and taking the quotient of the pulse width and the fixed number as the minimum decoding pulse.
In some embodiments, the receiving device records the pulse width of the learning code by starting a timer. Specifically, when the receiving device detects a rising edge of the learning code, the timer is started, and a time value of the timer is recorded until the learning code is completely received, wherein the time value corresponds to a pulse width of the learning code.
S43, receiving a data frame obtained by encoding the target content byte by the sending equipment according to a preset encoding mode and the minimum encoding pulse;
s44, decoding the data frame according to the preset decoding mode and the minimum decoding pulse to obtain the target content byte.
The data frame is obtained by the sending device according to a predetermined coding mode and the minimum coding pulse coding and sent to the receiving device, wherein the data frame includes a start bit, a data length, data content and data verification, and as can be understood, the start bit is used for marking the start position of the data frame, the data length is used for indicating the length of the data content to be received, and the data verification is used for verifying the integrity of the data. It is understood that the above composition of the data frame is only used as an exemplary illustration, and in the specific operation, the data frame may be increased or decreased according to the functional requirements.
The target content byte is obtained after decoding according to a preset decoding mode and the minimum decoding pulse. Wherein the predetermined decoding mode includes a variable length decoding mode or a fixed length decoding mode, in the variable length decoding mode, both of the same two minimum positive decoding pulses or both of the same two minimum negative decoding pulses may represent a binary 1, one of the minimum positive decoding pulses or one of the minimum negative decoding pulses may represent a binary 0, and adjacent two bit levels are opposite in a level direction within one byte. In the fixed-length decoding mode, in order, a set of decoding pulses consisting of the same two minimum positive decoding pulses and one minimum negative decoding pulse may represent a binary 1, and a set of decoding pulses consisting of the same two minimum positive decoding pulses and the same two minimum negative decoding pulses may represent a binary 0.
It is understood that the predetermined decoding mode corresponds to a predetermined encoding mode adopted by the transmitting device when encoding, for example, if the predetermined encoding mode of the transmitting device is variable length encoding, the predetermined decoding mode of the receiving device is variable length decoding mode; similarly, if the predetermined encoding mode of the sending device is fixed-length encoding, the predetermined decoding mode of the receiving device is fixed-length decoding mode. Specifically, please refer to the following description of the embodiment of the encoding mode in the transmitting device.
In the embodiment of the invention, a head code sent by sending equipment is received so as to enter an awakening state according to the head code; receiving a learning code sent by sending equipment so as to extract a minimum decoding pulse according to the learning code, wherein the minimum decoding pulse is a corresponding value of a minimum coding pulse of the sending equipment at the receiving equipment; receiving a data frame obtained by encoding a target content byte by a sending device according to a preset encoding mode and a minimum encoding pulse; and decoding the data frame according to a preset decoding mode and the minimum decoding pulse to obtain the target content byte. Therefore, the receiving equipment enters an awakening state according to the head code, and the receiving equipment is prevented from being awakened in sleep and abnormal when communicating with the sending equipment; the receiving equipment extracts the minimum decoding pulse according to the learning code, decodes the target content byte according to the minimum decoding pulse, avoids decoding failure caused by inconsistency of the encoding pulse of the receiving equipment and the encoding pulse of the sending equipment, improves the stability of communication between the equipment, improves the accuracy of decoding, and effectively achieves the aim of single-wire two-way communication.
When a first device or a second device detects a sending requirement, setting the attribute of an I/O port of the first device or the second device to be in a sending state, and closing external interruption of the I/O port, wherein the first device or the second device enters a data sending processing program according to the sending requirement. Referring to fig. 6, an embodiment of the present invention provides a bidirectional communication method, applied to a sending device in a communication system, where the communication system further includes a receiving device, and the sending device communicates with the receiving device based on a single data line, and the method includes:
s61, sending a header code to the receiving equipment, so that the receiving equipment enters an awakening state;
s62, sending a learning code to the receiving device, so that the receiving device extracts a minimum decoding pulse according to the learning code, wherein the minimum decoding pulse is a corresponding value of a minimum coding pulse of the sending device at the receiving device;
s63, according to a preset coding mode, coding the target content byte into a data frame consisting of a plurality of minimum coding pulses;
s64, sending the data frame to the receiving device, so that the receiving device decodes the data frame according to a predetermined decoding mode and the minimum decoding pulse to obtain the target content byte.
The format and the related description of the communication data refer to the description in the above data receiving method embodiment, and are not described in detail here.
It should be noted that, in this embodiment, the sending device sends the communication data through an interrupt function of a timer, specifically, a target content byte to be sent is encoded according to a preset encoding mode and a minimum encoding pulse to obtain a data frame, and level pulse widths adjacent to and in the same direction in the data frame are sequentially written into the timer, so as to generate a level pulse with the width according to the timer. And the directions of the level pulses generated by two adjacent started timers are opposite.
In the embodiment of the present invention, the sending device sends a header code to the receiving device, so that the receiving device enters an awake state, and the receiving device and the sending device can perform stable communication; the sending equipment sends a learning code to the receiving equipment, so that the receiving equipment extracts a minimum decoding pulse according to the learning code, wherein the minimum decoding pulse is a corresponding value of a minimum coding pulse of the sending equipment at the receiving equipment; according to a preset coding mode, coding the target content byte into a data frame consisting of a plurality of minimum coding pulses; and sending the data frame to the receiving equipment, so that the receiving equipment decodes the data frame to obtain the target content byte according to a preset decoding mode and the minimum decoding pulse, thereby avoiding decoding failure caused by inconsistency of coding pulses of the receiving equipment and the sending equipment, improving the stability of communication between the equipment and improving the accuracy of decoding.
In some embodiments, the minimum coded pulse comprises a minimum positive coded pulse or a minimum negative coded pulse, and the predetermined coding mode comprises a variable length coding mode or a fixed length coding mode; in the variable length coding mode, both of the same two minimum positive coded pulses or both of the same two minimum negative coded pulses may represent a binary number 1, and one of the minimum positive coded pulses or one of the minimum negative coded pulses may represent a binary number 0. In the fixed-length coding mode, in order, a coding pulse set composed of the same two minimum positive coding pulses and the same two minimum negative coding pulses may represent a binary number 1, and a coding pulse set composed of the same two minimum positive coding pulses and the same two minimum negative coding pulses may represent a binary number 0.
Specifically, referring to fig. 7, fig. 7 is a schematic diagram of a data encoding format according to an embodiment of the present invention, as shown in fig. 7, taking a target content byte as 0X90 and a corresponding binary code as 10010000 as an example, to illustrate that when the predetermined encoding mode is a variable length encoding mode or a fixed length encoding mode, the content byte is encoded according to the predetermined encoding mode at the sending device.
When the predetermined coding mode is variable length coding, the same two minimum positive coded pulses or the same two minimum negative coded pulses can both represent a binary number 1, and one of the minimum positive coded pulses or one of the minimum negative coded pulses can represent a binary number 0, so that the target content byte 0X90(10010000) is a pulse signal as shown in fig. 7 after being coded according to the variable length coding mode. It can be understood that, in the variable length coding mode, the pulse widths used for representing binary numbers "0" and "1" are not consistent, the binary number "0" is represented by a high level or a low level of one pulse width, and the binary number "1" is represented by two continuous high levels or low levels of pulse widths, so that when the sending device sends different target content bytes, the pulse lengths of the data frames obtained by coding the different target content bytes according to the variable length coding mode are also not consistent, that is, the time efficiency of data communication can be improved by coding the communication data by using the variable length coding mode relative to the fixed length coding mode described below.
When the predetermined coding mode is fixed-length coding, a coding pulse set composed of the same two minimum positive coding pulses and the same two minimum negative coding pulses may represent a binary number 1, and a coding pulse set composed of the same two minimum positive coding pulses and the same two minimum negative coding pulses may represent a binary number 0, so that the target content byte 0X90(10010000) is a pulse signal as shown in fig. 7 after being coded according to the fixed-length coding mode. . It can be understood that, in the word fixed length type coding mode, "two high pulses + one low pulse" represents a binary number "1", and "one high pulse + two low pulses" represents a binary number "0", and the pulse length of the data frame obtained by coding is fixed, that is, in the fixed length type coding mode, the length of the data frame corresponding to the data frame obtained by coding different target content bytes is fixed, so that developers can conveniently debug and perform functional analysis according to the data frame with fixed length.
In the embodiment of the present invention, two different coding modes are provided, the sending device obtains the data frame according to a predetermined coding mode, when the predetermined coding mode is variable length coding, the pulse lengths of the data frames obtained according to the variable length coding of different target content bytes are also inconsistent, that is, the data is coded by using the variable length coding mode, so that the timeliness of data communication can be improved; when the preset coding mode is fixed-length coding, the length of the data frame obtained by coding is fixed, and the pulse length of the data frame obtained by coding is fixed, so that debugging and functional analysis are facilitated for developers. Thus, the transmitting device can select a suitable coding mode for coding according to its functional requirements.
The above-described embodiments of the apparatus or device are merely illustrative, wherein the unit modules described as separate parts may or may not be physically separate, and the parts displayed as module units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network module units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
Through the above description of the embodiments, it is clear to those skilled in the art that each embodiment can be implemented by software plus a general hardware platform, and can also be implemented by hardware. Moreover, since the concept of the random encoding apparatus is the same as that of the random encoding method described in the above embodiments, the contents of the above embodiments may be referred to in the embodiments of the random encoding apparatus without conflicting with each other, and are not described herein again.
Embodiments of the present invention provide a non-transitory computer-readable storage medium having stored thereon computer-executable instructions for execution by one or more processors, e.g., to perform the method steps of fig. 3, 4, and 6 described above.
Embodiments of the present invention provide a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, cause the computer to perform the random encoding method in any of the above-described method embodiments, e.g. to perform the method steps of fig. 3, 4 and 6 described above.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; within the idea of the invention, also technical features in the above embodiments or in different embodiments may be combined, steps may be implemented in any order, and there are many other variations of the different aspects of the invention as described above, which are not provided in detail for the sake of brevity; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A bidirectional communication method applied to a receiving device in a communication system, the communication system further including a transmitting device, the receiving device communicating with the transmitting device based on a single data line, the method comprising:
receiving a head code sent by the sending equipment so as to enter an awakening state according to the head code;
receiving a learning code sent by the sending equipment so as to extract a minimum decoding pulse according to the learning code, wherein the minimum decoding pulse is a corresponding value of a minimum coding pulse of the sending equipment at the receiving equipment;
receiving a data frame obtained by encoding a target content byte by the sending equipment according to a preset encoding mode and the minimum encoding pulse;
and decoding the data frame according to a preset decoding mode and the minimum decoding pulse to obtain the target content byte.
2. The method of claim 1, wherein the header is a low level with a fixed duration, and wherein the receiving the header sent by the sending device to enter the awake state according to the header comprises:
and under the condition of being in a sleep state, when a falling edge is detected for the first time, determining to receive the head code sent by the sending equipment, and awakening the receiving equipment.
3. The method of claim 2, wherein the learning code consists of a fixed number of high and low levels, and wherein receiving the learning code transmitted by the transmitting device to extract the minimum decoded pulse according to the learning code comprises:
and when the rising edge is detected for the first time, determining that the learning code sent by the sending equipment is received, recording the pulse width of the learning code, and taking the quotient of the pulse width and the fixed number as the minimum decoding pulse.
4. The method of claim 1, wherein the minimum decoding burst comprises a minimum positive decoding burst or a minimum negative decoding burst, and wherein the predetermined decoding mode comprises a variable length decoding mode or a fixed length decoding mode;
in the variable length decoding mode, both of the same two minimum positive decoding pulses or both of the same two minimum negative decoding pulses may represent a binary 1, and one of the minimum positive decoding pulses or one of the minimum negative decoding pulses may represent a binary 0; alternatively, the first and second electrodes may be,
in the fixed-length decoding mode, in order, a set of decoding pulses consisting of the same two minimum positive decoding pulses and one minimum negative decoding pulse may represent a binary 1, and a set of decoding pulses consisting of the same two minimum positive decoding pulses and the same two minimum negative decoding pulses may represent a binary 0.
5. The method of any of claims 1 to 4, further comprising:
when a send task is detected, processing the send task after decoding the target content bytes.
6. A two-way communication method applied to a transmitting device in a communication system, the communication system further including a receiving device, the transmitting device communicating with the receiving device based on a single wire, the method comprising:
sending a header code to the receiving device, so that the receiving device enters an awakening state;
sending a learning code to the receiving device, so that the receiving device extracts a minimum decoding pulse according to the learning code, wherein the minimum decoding pulse is a corresponding value of a minimum coding pulse of the sending device at the receiving device;
according to a preset coding mode, coding the target content byte into a data frame consisting of a plurality of minimum coding pulses;
and sending the data frame to the receiving equipment, so that the receiving equipment decodes the data frame according to a preset decoding mode and the minimum decoding pulse to obtain the target content byte.
7. The method of claim 6, wherein the minimum coded pulse comprises a minimum positive coded pulse or a minimum negative coded pulse, and wherein the predetermined coding mode comprises a variable length coding mode or a fixed length coding mode;
in the variable length coding mode, both of the same two minimum positive coded pulses or both of the same two minimum negative coded pulses may represent a binary number 1, and one of the minimum positive coded pulses or one of the minimum negative coded pulses may represent a binary number 0; alternatively, the first and second electrodes may be,
in the fixed-length coding mode, in order, a coding pulse set composed of the same two minimum positive coding pulses and the same two minimum negative coding pulses may represent a binary number 1, and a coding pulse set composed of the same two minimum positive coding pulses and the same two minimum negative coding pulses may represent a binary number 0.
8. A receiving device, comprising:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the two-way communication method of any one of claims 1 to 5.
9. A transmitting device, comprising:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the two-way communication method of any one of claims 6 or 7.
10. A communication system, comprising:
the receiving device of claim 8; and
the transmitting device of claim 9, the transmitting device communicating with the receiving device based on a single data line.
CN202010208586.6A 2020-03-23 2020-03-23 Bidirectional communication method, receiving equipment, sending equipment and communication system Active CN111431631B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010208586.6A CN111431631B (en) 2020-03-23 2020-03-23 Bidirectional communication method, receiving equipment, sending equipment and communication system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010208586.6A CN111431631B (en) 2020-03-23 2020-03-23 Bidirectional communication method, receiving equipment, sending equipment and communication system

Publications (2)

Publication Number Publication Date
CN111431631A true CN111431631A (en) 2020-07-17
CN111431631B CN111431631B (en) 2022-02-18

Family

ID=71549284

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010208586.6A Active CN111431631B (en) 2020-03-23 2020-03-23 Bidirectional communication method, receiving equipment, sending equipment and communication system

Country Status (1)

Country Link
CN (1) CN111431631B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112180828A (en) * 2020-10-10 2021-01-05 湖南天桥嘉成智能科技有限公司 Method for detecting communication state of PLC and third-party equipment

Citations (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6151149A (en) * 1998-04-04 2000-11-21 Sigmatel, Inc Method and apparatus for pulse pattern modulation
US20050286643A1 (en) * 2004-04-16 2005-12-29 Thine Electronics, Inc. Transmitter circuit, receiver circuit, clock data recovery phase locked loop circuit, data transfer method and data transfer system
EP1936801A1 (en) * 2004-05-28 2008-06-25 The TC Group A/S Pulse width modulator system
CN101340307A (en) * 2007-07-05 2009-01-07 厦门大学 Control mechanism for energy saving of short distance wireless sensor network node
US20090103437A1 (en) * 2007-10-22 2009-04-23 Electronics And Telecommunications Research Institute Method of transmitting/receiving data in sensor network for reducing overhearing of sensor nodes
CN101599214A (en) * 2009-07-13 2009-12-09 利尔达科技有限公司 Networking low power consumption wireless meter reading method
CN101032113B (en) * 2005-09-26 2011-01-19 松下电器产业株式会社 Single-line two-way communication device and system
US20110176465A1 (en) * 2010-01-21 2011-07-21 Robert Bosch Gmbh Asynchronous low-power multi-channel media access control
CN102685860A (en) * 2012-05-04 2012-09-19 华为终端有限公司 Method and device for transmitting and receiving data
CN104780596A (en) * 2015-04-09 2015-07-15 深圳市科陆电子科技股份有限公司 Communication method, communication device and communication system capable of realizing ultra-low power consumption
CN105869238A (en) * 2016-03-24 2016-08-17 深圳市前海铂智科技有限公司 Access control system based on WeChat platform and WeChat control method
US20160366644A1 (en) * 2015-06-11 2016-12-15 Chittabrata Ghosh Waking up internet of things devices in a high efficiency wireless local-area network
CN106327828A (en) * 2016-08-27 2017-01-11 宁波三星医疗电气股份有限公司 Method to awaken several wireless water & gas meters synchronously for meter reading
CN107102101A (en) * 2017-04-17 2017-08-29 广州市弘宇科技有限公司 A kind of synchronic gas acquisition method and device
CN107135067A (en) * 2016-02-26 2017-09-05 英飞凌科技股份有限公司 Method from sensor device to electronic control unit, sensor device and electronic control unit for transmitting data from
CN107390090A (en) * 2017-07-28 2017-11-24 思源电气股份有限公司 A kind of circuitry fault detection method and system
CN108829002A (en) * 2018-06-26 2018-11-16 南京航空航天大学 A kind of MMC control system state machine and its control method based on CAN bus agreement
EP3447187A1 (en) * 2017-08-25 2019-02-27 Koninklijke Philips N.V. Garment care device with movement sensor

Patent Citations (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6151149A (en) * 1998-04-04 2000-11-21 Sigmatel, Inc Method and apparatus for pulse pattern modulation
US20050286643A1 (en) * 2004-04-16 2005-12-29 Thine Electronics, Inc. Transmitter circuit, receiver circuit, clock data recovery phase locked loop circuit, data transfer method and data transfer system
EP1936801A1 (en) * 2004-05-28 2008-06-25 The TC Group A/S Pulse width modulator system
CN101032113B (en) * 2005-09-26 2011-01-19 松下电器产业株式会社 Single-line two-way communication device and system
CN101340307A (en) * 2007-07-05 2009-01-07 厦门大学 Control mechanism for energy saving of short distance wireless sensor network node
US20090103437A1 (en) * 2007-10-22 2009-04-23 Electronics And Telecommunications Research Institute Method of transmitting/receiving data in sensor network for reducing overhearing of sensor nodes
CN101599214A (en) * 2009-07-13 2009-12-09 利尔达科技有限公司 Networking low power consumption wireless meter reading method
US20110176465A1 (en) * 2010-01-21 2011-07-21 Robert Bosch Gmbh Asynchronous low-power multi-channel media access control
CN102685860A (en) * 2012-05-04 2012-09-19 华为终端有限公司 Method and device for transmitting and receiving data
CN104780596A (en) * 2015-04-09 2015-07-15 深圳市科陆电子科技股份有限公司 Communication method, communication device and communication system capable of realizing ultra-low power consumption
US20160366644A1 (en) * 2015-06-11 2016-12-15 Chittabrata Ghosh Waking up internet of things devices in a high efficiency wireless local-area network
CN107135067A (en) * 2016-02-26 2017-09-05 英飞凌科技股份有限公司 Method from sensor device to electronic control unit, sensor device and electronic control unit for transmitting data from
CN105869238A (en) * 2016-03-24 2016-08-17 深圳市前海铂智科技有限公司 Access control system based on WeChat platform and WeChat control method
CN106327828A (en) * 2016-08-27 2017-01-11 宁波三星医疗电气股份有限公司 Method to awaken several wireless water & gas meters synchronously for meter reading
CN107102101A (en) * 2017-04-17 2017-08-29 广州市弘宇科技有限公司 A kind of synchronic gas acquisition method and device
CN107390090A (en) * 2017-07-28 2017-11-24 思源电气股份有限公司 A kind of circuitry fault detection method and system
EP3447187A1 (en) * 2017-08-25 2019-02-27 Koninklijke Philips N.V. Garment care device with movement sensor
CN108829002A (en) * 2018-06-26 2018-11-16 南京航空航天大学 A kind of MMC control system state machine and its control method based on CAN bus agreement

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张超,等: "直流输电阀基电子单元编解码研究", 《第三十二届中国控制会议论文集(D卷)》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112180828A (en) * 2020-10-10 2021-01-05 湖南天桥嘉成智能科技有限公司 Method for detecting communication state of PLC and third-party equipment
CN112180828B (en) * 2020-10-10 2023-03-24 湖南天桥嘉成智能科技有限公司 Method for detecting communication state of PLC and third-party equipment

Also Published As

Publication number Publication date
CN111431631B (en) 2022-02-18

Similar Documents

Publication Publication Date Title
US7729427B2 (en) Pseudo-synchronous one wire bidirectional bus interface
US9578612B2 (en) Node device and method for communication
EP3675398A1 (en) Check code processing method, electronic device, and storage medium
CN108701112B (en) Method and device for simulating serial port communication based on query mode
CN111431631B (en) Bidirectional communication method, receiving equipment, sending equipment and communication system
CN110213020A (en) Data transmission method, terminal, system and device based on bluetooth peripheral hardware
US5077552A (en) Interface for coupling audio and video equipment to computer
CN108197062B (en) Method, system, equipment and medium for realizing communication between single chip microcomputer and terminal equipment
US5812878A (en) System for DMA transfer wherein controller waits before execution of next instruction until a counter counts down from a value loaded by said controller
CN113760808A (en) Power supply primary and secondary serial port communication method, system and storage medium
JPS62141875A (en) Preventing system for propagation of decoding error
JPH03174643A (en) Integrated circuit peculiar to application for serial data bus
CN115599722B (en) Method and device for realizing accurate transmission of serial port data based on kernel of operating system
US11876629B1 (en) Data transmission method, device, electronic equipment, and storage medium
CN110336641B (en) Relay protection test method, relay test equipment, storage medium and device
SU379923A1 (en) in ^ -? About;> & YuZND ?? ] YATYATSH-GEKHSh ^ IE ^ LJ BIG ^ PIOT ^ ON;
JPS6029252Y2 (en) decoder
SU1307462A1 (en) Interface for linking electronic computer with using equipment
CN114283549A (en) Communication method for fire alarm system
JPS6225798Y2 (en)
JPH0828707B2 (en) Polling control method
CN114670705A (en) Battery management system daughter board configuration method and device and electronic equipment
CN103106162B (en) Logical device and MDIO interface communication method thereof
CN111224801A (en) Vehicle-mounted HDLC recording method and device
JPS6010842A (en) Pulse counter control system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP01 Change in the name or title of a patent holder

Address after: 518000 Guangdong science and technology innovation and Research Institute, Shenzhen, Shenzhen, Nanshan District No. 6, science and technology innovation and Research Institute, Shenzhen, D 10, 1004, 10

Patentee after: Shenzhen Hetai intelligent home appliance controller Co.,Ltd.

Address before: 518000 Guangdong science and technology innovation and Research Institute, Shenzhen, Shenzhen, Nanshan District No. 6, science and technology innovation and Research Institute, Shenzhen, D 10, 1004, 10

Patentee before: SHENZHEN H&T DATA RESOURCES AND CLOUD TECHNOLOGY Ltd.

CP01 Change in the name or title of a patent holder