CN108170630B - Serial port communication baud rate self-adaption method, system and equipment - Google Patents

Serial port communication baud rate self-adaption method, system and equipment Download PDF

Info

Publication number
CN108170630B
CN108170630B CN201711463331.9A CN201711463331A CN108170630B CN 108170630 B CN108170630 B CN 108170630B CN 201711463331 A CN201711463331 A CN 201711463331A CN 108170630 B CN108170630 B CN 108170630B
Authority
CN
China
Prior art keywords
communication
baud rate
serial port
module
judging whether
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.)
Active
Application number
CN201711463331.9A
Other languages
Chinese (zh)
Other versions
CN108170630A (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.)
Hangzhou Vango Technologies Inc
Original Assignee
Hangzhou Vango Technologies Inc
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 Hangzhou Vango Technologies Inc filed Critical Hangzhou Vango Technologies Inc
Priority to CN201711463331.9A priority Critical patent/CN108170630B/en
Publication of CN108170630A publication Critical patent/CN108170630A/en
Application granted granted Critical
Publication of CN108170630B publication Critical patent/CN108170630B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • G06F13/4291Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus using a clocked protocol

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Communication Control (AREA)
  • Information Transfer Systems (AREA)
  • Synchronisation In Digital Transmission Systems (AREA)

Abstract

The invention discloses a serial port communication baud rate self-adaption method which comprises the following steps: s1: judging whether a communication module of the serial port is in a self-adaptive state or not; if yes, go to S2; if not, go to S3; s2: calculating the baud rate of the communication module through a preset byte; s3: judging whether the communication module communicates correctly at the baud rate; if yes, go to S4; if not, go to S2; s4: measuring a current HRC value inside the serial port through a preset byte; s5: judging whether the difference value between the current HRC value and the HRC value at the last moment is smaller than a preset value; if yes, the current HRC value is used as the HRC value of the last time. The serial port communication baud rate self-adaption method disclosed by the invention can ensure the real-time performance and the anti-interference performance of serial port communication under the condition that an internal clock source is unstable. The invention also discloses a serial port communication baud rate self-adaption system and equipment and a computer readable storage medium, and the technical effects can be realized.

Description

Serial port communication baud rate self-adaption method, system and equipment
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a serial port communication baud rate adaptive method, system and device, and a computer readable storage medium.
Background
The serial communication is a common communication mode in the current embedded system because of low cost and easy realization. In serial communication, "baud rate" is a unit used to describe the communication speed. In communication, normal communication can be ensured only if the baud rates of two communication parties are the same, which brings inconvenience to the use of serial communication equipment, especially when the baud rate of one party is unknown to the other party. If the self-adaption of the serial communication baud rate can be realized, the flexibility and the universality of the serial communication equipment can be undoubtedly improved.
Two common ways of baud rate adaptation are currently: standard baud rate exhaustion method and symbol width real-time detection method. The baud rate exhaustion method requires that the baud rate of the communication equipment can only change between limited fixed values, and after the serial equipment is started, characteristic characters sent by the data terminal are tried to be received one by one according to different baud rates until the characteristic characters can be received correctly. The method has low efficiency, and cannot ensure the timeliness of communication for places with high requirements on real-time communication.
The code element width real-time detection method requires a data terminal to send characteristic characters according to convention, serial equipment measures the code element width of input data, and then calculates the baud rate to be detected. The method is widely applied at present. However, if the waveform is distorted by an external circuit, the calculated baud rate has a large error, which affects the success rate of communication.
Meanwhile, the two self-adaptive methods work on a stable clock source based on a system, but in order to save cost, a plurality of MCU (Micro Control Unit, Chinese) adopt a crystal-oscillator-free design in sequence, an internal HRC (clock source) is used as the clock source of the system, the internal HRC has about +/-5% frequency change along with temperature, and the change affects the accuracy of baud rate.
Therefore, how to ensure real-time performance and interference immunity of serial communication under the condition that an internal clock source is unstable is a problem to be solved by those skilled in the art.
Disclosure of Invention
The invention aims to provide a serial port communication baud rate self-adaption method, a serial port communication baud rate self-adaption system, serial port communication baud rate self-adaption equipment and a computer readable storage medium, and under the condition that an internal clock source is unstable, the real-time performance and the anti-interference performance of serial port communication are ensured.
In order to achieve the above object, an embodiment of the present invention provides a serial port communication baud rate adaptive method, including:
s101: judging whether a communication module of the serial port is in a self-adaptive state or not; if yes, entering S102; if not, the step S103 is entered;
s102: calculating the baud rate of the communication module through preset bytes;
s103: judging whether the communication module is in correct communication at the baud rate; if yes, entering S104; if not, entering S102;
s104: measuring the current HRC value inside the serial port through the preset byte;
s105: judging whether the difference value between the current HRC value and the HRC value at the last moment is smaller than a preset value; if yes, the current HRC value is used as the HRC value of the last time.
Wherein, judging whether the communication module of the serial port is in a self-adaptive state comprises:
judging whether the serial port carries out reset operation or not, and judging whether the communication module has errors in communication at the current baud rate or not;
and if the serial port number is equal to the preset value, the communication module of the serial port is in a self-adaptive state.
Wherein the S102 includes:
and calculating the first collection point number between two falling edges of the communication waveform of the communication module through the 0x7D bytes.
Wherein, before S105, the method further includes:
and judging whether the HRC value at the previous moment exists, if so, executing the step S105.
Wherein the S104 includes:
and calculating the second collection point number of the communication waveform 8bit falling edge of the communication waveform through 0x7D bytes.
Wherein, if the HRC value at the previous time exists, the step S105 includes:
judging whether the difference value of the second collection point at the current moment and the second collection point at the previous moment is less than 5% of the second collection point at the current moment; and if so, taking the second collection point number at the current moment as the second collection point number at the previous moment.
If there is no HRC value at the previous time, after calculating the second collection point number of the communication waveform 8bit falling edge of the communication waveform by using 0x7D bytes, the method further includes:
calculating the proportional relation between the first collection points and the second collection points;
judging whether the proportional relation is 4: 1;
and if so, taking the second collection point number as the second collection point number at the last moment.
In order to achieve the above object, an embodiment of the present invention provides a serial port communication baud rate adaptive system, including:
the first judgment module is used for judging whether the communication module of the serial port is in a self-adaptive state or not; if yes, starting the working process of the calculation module; if not, starting the working process of the second judgment module;
the computing module is used for computing the baud rate of the communication module through preset bytes;
the second judging module is used for judging whether the communication module is correct in the baud rate; if yes, starting the working process of the measurement module; if not, starting the working process of the calculation module;
the measurement module is used for measuring the current HRC value inside the serial port through the preset byte;
the adjusting module is used for judging whether the difference value between the current HRC value and the HRC value at the last moment is smaller than a preset value; if yes, the current HRC value is used as the HRC value of the last time.
In order to achieve the above object, an embodiment of the present invention provides a serial port communication baud rate adaptive device, including:
a memory for storing a computer program;
and the processor is used for realizing the steps of the serial port communication baud rate self-adaption method when the computer program is executed.
To achieve the above object, an embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the serial port communication baud rate adaptive method as described above.
According to the scheme, the serial port communication baud rate self-adaption method provided by the embodiment of the invention comprises the following steps: s101: judging whether a communication module of the serial port is in a self-adaptive state or not; if yes, entering S102; if not, the step S103 is entered; s102: calculating the baud rate of the communication module through preset bytes; s103: judging whether the communication module is in correct communication at the baud rate; if yes, entering S104; if not, entering S102; s104: measuring the current HRC value inside the serial port through the preset byte; s105: judging whether the difference value between the current HRC value and the HRC value at the last moment is smaller than a preset value; if yes, the current HRC value is used as the HRC value of the last time.
The baud rate self-adaption method for serial port communication provided by the embodiment of the invention adopts a baud rate fine adjustment technology, is suitable for occasions which do not adopt a stable clock source as a system clock, and carries out fine adjustment on the baud rate by accurately measuring the change of the HRC. Therefore, the serial port communication baud rate self-adaption method provided by the embodiment of the invention ensures the real-time performance and anti-interference performance of serial port communication under the condition that an internal clock source is unstable. The invention also discloses a serial port communication baud rate self-adaption system and equipment and a computer readable storage medium, and the technical effects can be realized.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a serial port communication baud rate adaptive method disclosed in an embodiment of the present invention;
fig. 2 is a flowchart of another serial port communication baud rate adaptive method disclosed in the embodiment of the present invention;
FIG. 3 is a schematic diagram illustrating calculation of baud rate and HRC value according to an embodiment of the present invention;
fig. 4 is a structural diagram of a serial port communication baud rate adaptive system disclosed in the embodiment of the present invention;
fig. 5 is a structural diagram of a serial port communication baud rate adaptive device disclosed in the embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention discloses a serial port communication baud rate self-adaption method, which ensures the real-time performance and anti-interference performance of serial port communication under the condition that an internal clock source is unstable.
Referring to fig. 1, a flowchart of a serial port communication baud rate adaptive method disclosed in the embodiment of the present invention is shown in fig. 1, and includes:
s101: judging whether a communication module of the serial port is in a self-adaptive state or not; if yes, entering S102; if not, the step S103 is entered;
in specific implementation, when the serial port performs reset operation or the communication module has an error in communication at the current baud rate, the communication module is in a self-adaptive state. Of course, those skilled in the art may also be able to put the communication module in an adaptive state when other events are triggered according to the actual situation, and the details are not limited herein. And when the communication module of the serial port is in the self-adaptive state, the step S102 is entered, otherwise, the step S103 is entered.
S102: calculating the baud rate of the communication module through preset bytes;
in specific implementation, the baud rate can be calculated through the first special byte 0x7D of the communication protocol, the baud rate is stored after the current baud rate of the communication module is calculated, the serial port can communicate with the baud rate next, until a communication error occurs, that is, the communication module is in a self-adaptive state, the current baud rate and the current HRC value are cleared, and the S102 is entered again.
It should be noted that, in this embodiment, the preset byte is not specifically limited, and the preset byte may be the above-mentioned 0x7D byte, and of course, may also be other bytes with similar functions, and those skilled in the art may flexibly select the preset byte according to actual situations.
S103: judging whether the communication module is in correct communication at the baud rate; if yes, entering S104; if not, entering S102;
s104: measuring the current HRC value inside the serial port through the preset byte;
in specific implementation, on the premise of correct communication, the current HRC value inside the serial port is measured through the preset byte.
S105: judging whether the difference value between the current HRC value and the HRC value at the last moment is smaller than a preset value; if yes, the current HRC value is used as the HRC value of the last time.
In specific implementation, comparing the current HRC value with the HRC value at the previous moment, if the difference between the current HRC value and the HRC value at the previous moment is smaller than a preset value, considering that the frequency of the HRC in the serial port is changed along with the change of temperature or other conditions, and needing to finely adjust the baud rate; if the measured value is larger than the preset value, the HRC value measurement error is considered to be caused by EMC or other interference, and the data is discarded. It should be noted that, this embodiment does not limit the preset value, and is preferably 5% of the current HRC value, and of course, those skilled in the art can flexibly set the preset value according to actual situations.
The baud rate self-adaption method for serial port communication provided by the embodiment of the invention adopts a baud rate fine adjustment technology, is suitable for occasions which do not adopt a stable clock source as a system clock, and carries out fine adjustment on the baud rate by accurately measuring the change of the HRC. Therefore, the serial port communication baud rate self-adaption method provided by the embodiment of the invention ensures the real-time performance and anti-interference performance of serial port communication under the condition that an internal clock source is unstable.
The embodiment of the invention discloses a serial port communication baud rate self-adaption method, and compared with the previous embodiment, the embodiment further explains and optimizes the technical scheme. Specifically, the method comprises the following steps:
referring to fig. 2, a flowchart of another serial port communication baud rate adaptive method according to an embodiment of the present invention is shown in fig. 2, and includes:
s201: judging whether the serial port carries out reset operation or not, and judging whether the communication module has errors in communication at the current baud rate or not; if yes, entering S202; if not, the step S203 is entered;
s202: calculating a first collection point number between two falling edges of a communication waveform of the communication module through the 0x7D bytes;
in specific implementation, in order to ensure that communication is normal under various environments, a plurality of filter circuits are usually added at the periphery, and the circuits can distort communication waveforms in different situations according to changes of working environments, as shown in fig. 3, if T1 is used as a calculated waveform of a baud rate, a large error is generated, and since the same edge distortion is basically the same, the calculated waveform with T2 as the baud rate is more accurate. Therefore, the special character 0x7D can generate two falling edges at the start bit and the first bit, thereby ensuring the accuracy of baud rate measurement and the real-time performance of communication.
The baud rate calculation formula is as follows:
Figure BDA0001530732070000061
wherein f isHRCThe parameter is unknown for the frequency of the actual internal clock source HRC; n is a radical ofT2The number of sampling points between two falling edges, namely the number of first acquisition points. It can be seen from the formula that if the baud rate is constant, the magnitude of the value is actually fHRCThe influence of (c).
Then the baud rate formula in practical application:
Figure BDA0001530732070000062
by testing the number of two falling edges, the number of the falling edges is divided by 2 to obtain how many clock counts the system samples every other clock frequency, so that even at the current fHRCEven in the case of unknown, correct communication can be achieved. When the baud rate changes, the sampling interval also changes, thereby achieving the effect of baud rate self-adaption.
S203: judging whether the communication module is in correct communication at the baud rate; if yes, entering S204; if not, the step S202 is entered;
s204: calculating a second collecting point number of a communication waveform 8bit falling edge of the communication waveform through 0x7D bytes;
in specific implementation, the serial communication circuit samples three times at the middle point of a data waveform, and acquires data according to the principle of taking two out of three. Therefore, even if the waveform is interfered to generate some small glitches, the communication is not influenced. However, in the baud rate adaptation mechanism, the glitch may cause errors in the baud rate calculation.
However, if the chip is clocked with an internal HRC, when the external temperature changes, fHRCThere is a variation of around + -5%. As can be seen from the Baud rate formula in the practical application, if fHRCChange is made, then NT2Bias will also occur, but the system will not always perform baud rate adaptation, NT2Does not follow fHRCChange of N, and therefore a reliable method for N is neededT2Fine adjustment is carried out, and a calculation formula of the compensated baud rate is as follows:
Figure BDA0001530732070000071
wherein N isT3Is the number of acquisition points for the falling edge of 8 bits in real time, i.e. the second acquisition point, relative to N measured at baud rate adaptationT2The precision is higher; n isT2To pass through NT3New baud values are calculated.
S251: judging whether the HRC value at the previous moment exists, if so, entering S252; if not, the process goes to S253;
s252: judging whether the difference value of the second collection point at the current moment and the second collection point at the previous moment is less than 5% of the second collection point at the current moment; if so, taking the second collection point number at the current moment as the second collection point number at the previous moment;
s253: calculating the proportional relation between the first collection points and the second collection points; judging whether the proportional relation is 4: 1; and if so, taking the second collection point number as the second collection point number at the last moment.
When the last moment exists, comparing the current moment NT3And N of the previous momentT3If the two differ by less than + -5%. Then it is considered to be fHRCAnd (4) adjusting the change of the measured value caused by the change by using the compensated baud rate calculation formula, otherwise, considering the change as interference, and not adjusting.
When recording N for the first timeT3At value, by comparison of NT2And NT3If the proportional relation is 1:4, the data is considered to be correct data, otherwise, the data is considered to be interference data, and no record is made.
Through the adjustment mode, the internal HRC can be compensated in real time along with temperature change, and error compensation of the baud rate under the severe EMC condition can be avoided.
In the following, the serial communication baud rate adaptive system provided by the embodiment of the present invention is introduced, and a serial communication baud rate adaptive system described below and a serial communication baud rate adaptive method described above may refer to each other.
Referring to fig. 4, a structure diagram of a serial port communication baud rate adaptive system according to an embodiment of the present invention is shown in fig. 4, and includes:
a first judging module 401, configured to judge whether a communication module of the serial port is in a self-adaptive state; if yes, the workflow of the calculation module 402 is started; if not, starting the working process of the second judgment module 303;
the calculating module 402 is configured to calculate a baud rate of the communication module by using a preset byte;
the second determining module 403 is configured to determine whether the communication module communicates correctly at the baud rate; if yes, starting the working process of the measurement module; if not, starting the working process of the calculation module;
the measurement module 404 is configured to measure a current HRC value inside the serial port through the preset byte;
an adjusting module 405, configured to determine whether a difference between the current HRC value and the HRC value at the previous time is smaller than a preset value; if yes, the current HRC value is used as the HRC value of the last time.
The baud rate self-adaptive system for serial communication provided by the embodiment of the invention adopts the baud rate fine adjustment technology, is suitable for occasions which do not adopt a stable clock source as a system clock, and carries out fine adjustment on the baud rate by accurately measuring the change of the HRC. Therefore, the serial port communication baud rate self-adaption method provided by the embodiment of the invention ensures the real-time performance and anti-interference performance of serial port communication under the condition that an internal clock source is unstable.
On the basis of the foregoing embodiment, as a preferred implementation manner, the first determining module 401 specifically determines whether the serial port performs a reset operation, and determines whether the communication module performs communication at the current baud rate erroneously; if yes, starting the work flow of the calculation module 402; otherwise, the workflow of the second judging module 403 is started.
On the basis of the foregoing embodiment, as a preferred implementation manner, the calculating module 402 is specifically a module that calculates the first collection point number between two falling edges of the communication waveform of the communication module through the 0x7D bytes.
In addition to the above embodiments, as a preferred embodiment, the method further includes:
and the third judgment module is used for judging whether the HRC value at the previous moment exists or not, and if so, starting the working process of the adjustment module.
On the basis of the foregoing embodiment, as a preferred implementation manner, the measurement module 404 is specifically a module that calculates the second collection point number of the communication waveform 8bit falling edge of the communication waveform through 0x7D bytes.
On the basis of the foregoing embodiment, as a preferred implementation manner, if the HRC value at the previous time exists, the adjusting module 405 specifically determines whether a difference value between the second collection point number at the current time and the second collection point number at the previous time is less than 5% of the second collection point number at the current time; and if so, taking the second collection point at the current moment as the second collection point at the last moment.
In addition to the above-mentioned embodiments, as a preferred embodiment, if there is no HRC value at the previous time, the method further includes:
the proportion module is used for calculating the proportion relation between the first collection points and the second collection points; judging whether the proportional relation is 4: 1; and if so, taking the second collection point number as the second collection point number at the last moment.
The present application further provides a serial communication baud rate adaptive device, referring to fig. 5, a structure diagram of the serial communication baud rate adaptive device provided in the embodiment of the present invention, as shown in fig. 5, includes:
a memory 501 for storing a computer program;
the processor 502, when executing the computer program, may implement the steps provided by the above embodiments. Certainly, the serial port communication baud rate adaptive device may further include various network interfaces, power supplies and other components.
The baud rate self-adaption device for serial communication provided by the embodiment of the invention adopts a baud rate fine-tuning technology, is suitable for occasions which do not adopt a stable clock source as a system clock, and carries out fine tuning on the baud rate by accurately measuring the change of the HRC. Therefore, the serial port communication baud rate self-adaption method provided by the embodiment of the invention ensures the real-time performance and anti-interference performance of serial port communication under the condition that an internal clock source is unstable.
The present application also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, may implement the steps provided by the above-described embodiments. The storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. For the system disclosed by the embodiment, the description is relatively simple because the system corresponds to the method disclosed by the embodiment, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.
It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

Claims (7)

1. A serial port communication baud rate self-adaption method is characterized by comprising the following steps:
s101: judging whether a communication module of the serial port is in a self-adaptive state or not; if yes, entering S102; if not, the step S103 is entered; when a serial port carries out reset operation or a communication module has errors in communication at the current baud rate, the communication module is in a self-adaptive state;
s102: calculating the baud rate of the communication module through preset bytes;
s103: judging whether the communication module is in correct communication at the baud rate; if yes, entering S104; if not, entering S102;
s104: measuring the current HRC value inside the serial port through the preset byte;
s105: judging whether the difference value between the current HRC value and the HRC value at the last moment is smaller than a preset value; if so, taking the current HRC value as the HRC value of the last moment;
wherein the S102 includes: calculating a first collection point number between two falling edges of a communication waveform of the communication module through 0x7D bytes;
the S104 includes: calculating a second collecting point number of a communication waveform 8bit falling edge of the communication waveform through 0x7D bytes;
the S105 includes: judging whether the difference value of the second collection point at the current moment and the second collection point at the previous moment is less than 5% of the second collection point at the current moment; and if so, taking the second collection point number at the current moment as the second collection point number at the previous moment.
2. The serial port communication baud rate self-adaption method of claim 1, wherein judging whether a communication module of the serial port is in a self-adaption state comprises:
judging whether the serial port carries out reset operation or not, and judging whether the communication module has errors in communication at the current baud rate or not;
and if the serial port number is equal to the preset value, the communication module of the serial port is in a self-adaptive state.
3. The serial port communication baud rate adaptive method according to claim 1, further comprising, before S105:
and judging whether the HRC value at the previous moment exists, if so, executing the step S105.
4. The serial port communication baud rate adaptive method of claim 1, wherein if there is no HRC value at the previous time, after calculating the second collection point number of the communication waveform 8bit falling edge of the communication waveform by 0x7D bytes, the method further comprises:
calculating the proportional relation between the first collection points and the second collection points;
judging whether the proportional relation is 4: 1;
and if so, taking the second collection point number as the second collection point number at the last moment.
5. A serial port communication baud rate adaptive system is characterized by comprising:
the first judgment module is used for judging whether the communication module of the serial port is in a self-adaptive state or not; if yes, starting the working process of the calculation module; if not, starting the working process of the second judgment module; when a serial port carries out reset operation or a communication module has errors in communication at the current baud rate, the communication module is in a self-adaptive state;
the computing module is used for computing the baud rate of the communication module through preset bytes;
the second judging module is used for judging whether the communication module is correct in the baud rate; if yes, starting the working process of the measurement module; if not, starting the working process of the calculation module;
the measurement module is used for measuring the current HRC value inside the serial port through the preset byte;
the adjusting module is used for judging whether the difference value between the current HRC value and the HRC value at the last moment is smaller than a preset value; if so, taking the current HRC value as the HRC value of the last moment;
the calculation module is specifically a module for calculating a first collection point number between two falling edges of a communication waveform of the communication module through 0x7D bytes;
the measuring module is specifically a module for calculating a second acquisition point number of a communication waveform 8bit falling edge of the communication waveform through 0x7D bytes;
the adjusting module is used for judging whether the difference value of the second collecting point at the current moment and the second collecting point at the previous moment is less than 5% of the second collecting point at the current moment; and if so, taking the second collection point at the current moment as the second collection point at the last moment.
6. A serial port communication baud rate self-adaptation device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the serial communication baud rate adaptation method according to any one of claims 1 to 4 when executing said computer program.
7. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, implements the serial communication baud rate adaptation method according to any one of claims 1 to 4.
CN201711463331.9A 2017-12-28 2017-12-28 Serial port communication baud rate self-adaption method, system and equipment Active CN108170630B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711463331.9A CN108170630B (en) 2017-12-28 2017-12-28 Serial port communication baud rate self-adaption method, system and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711463331.9A CN108170630B (en) 2017-12-28 2017-12-28 Serial port communication baud rate self-adaption method, system and equipment

Publications (2)

Publication Number Publication Date
CN108170630A CN108170630A (en) 2018-06-15
CN108170630B true CN108170630B (en) 2021-02-02

Family

ID=62519579

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711463331.9A Active CN108170630B (en) 2017-12-28 2017-12-28 Serial port communication baud rate self-adaption method, system and equipment

Country Status (1)

Country Link
CN (1) CN108170630B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111314018B (en) * 2019-11-01 2021-07-13 珠海格力电器股份有限公司 Baud rate self-adaptive adjustment processing system and method and information data processing terminal
CN111258514A (en) * 2020-01-20 2020-06-09 东莞炜煌打印机有限公司 Baud rate self-adaption method and device and printer
CN112511334B (en) * 2020-10-13 2024-05-07 博流智能科技(南京)有限公司 Method and system for improving communication rate
CN115776365A (en) * 2021-09-07 2023-03-10 合肥移瑞通信技术有限公司 Method and system for correcting serial port baud rate, communication module and storage medium
CN115061969A (en) * 2022-08-15 2022-09-16 追觅创新科技(苏州)有限公司 Cleaning equipment and baud rate self-adaptive adjusting method and system thereof

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103412615A (en) * 2013-08-22 2013-11-27 中国航天科工集团第三研究院第八三五七研究所 Glitch-free self-adaptive clock switching method for UART (Universal Asynchronous Receiver Transmitter) interface chip
CN103684678A (en) * 2012-11-01 2014-03-26 国网电力科学研究院 Baud rate adaptive method for UART, device and UART
US8817933B2 (en) * 2013-01-09 2014-08-26 Rockwell Automation Technologies, Inc. Method and apparatus for clock data recovery from Manchester coded serial data stream
CN104199799A (en) * 2014-08-29 2014-12-10 天津市亚安科技股份有限公司 Baud rate self-adaptation method and device based on CPLD
CN105959093A (en) * 2016-04-25 2016-09-21 成都大学 Serial communication baud rate real-time self-adaption method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102467477B (en) * 2010-11-12 2014-10-15 施耐德电器工业公司 Baud rate self-adapting Modbus relay and Baud rate self-adapting system and method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103684678A (en) * 2012-11-01 2014-03-26 国网电力科学研究院 Baud rate adaptive method for UART, device and UART
US8817933B2 (en) * 2013-01-09 2014-08-26 Rockwell Automation Technologies, Inc. Method and apparatus for clock data recovery from Manchester coded serial data stream
CN103412615A (en) * 2013-08-22 2013-11-27 中国航天科工集团第三研究院第八三五七研究所 Glitch-free self-adaptive clock switching method for UART (Universal Asynchronous Receiver Transmitter) interface chip
CN104199799A (en) * 2014-08-29 2014-12-10 天津市亚安科技股份有限公司 Baud rate self-adaptation method and device based on CPLD
CN105959093A (en) * 2016-04-25 2016-09-21 成都大学 Serial communication baud rate real-time self-adaption method

Also Published As

Publication number Publication date
CN108170630A (en) 2018-06-15

Similar Documents

Publication Publication Date Title
CN108170630B (en) Serial port communication baud rate self-adaption method, system and equipment
WO2020253175A1 (en) Formaldehyde concentration measurement method and apparatus, and air purifier
US8831145B2 (en) Hart transmitter/receiver systems
CN107147553B (en) Method, device and equipment for adjusting Baud rate and frame format of slave station
US10892911B2 (en) Controller area network receiver
CA2736453C (en) Systems and methods for impulse noise characterization
CN107181300B (en) Charge protector, the method and apparatus for calibrating charging equipment
JP2011010053A (en) Device and method for detecting information
CN109217922B (en) Method and device for reporting loss alarm of received signal by optical module
CN112069098B (en) Baud rate identification method and device
JP2011010244A (en) Device and method for detecting information
CN101001077A (en) Timing adjusting method and timing adjusting apparatus
CN103559164A (en) Method and device for identifying serial port baud rate
CN110308644B (en) Smart electric meter clock timing precision compensation method, device and equipment
CN114024795B (en) Baud rate self-adaption method, device, computer equipment and storage medium
CN114039807B (en) Baud rate self-adaption method, device, computer equipment and storage medium
CN109768792B (en) Anti-interference detection device and method for capacitive touch key
TW202303410A (en) Automatic threshold adjustment for usb power delivery to work with cables out of specification
CN212364801U (en) RTC calibration circuit of smoke detector MCU
CN111568419B (en) Detection method, detector and terminal equipment
CN109150489B (en) Calibration method for built-in transmission clock of universal asynchronous receiver-transmitter
CN109167736B (en) High-uniformity data packet sending method and device
CN111765964A (en) Numerical value correction method based on cloud storage
CN101582862B (en) Method for recovering baseband signals
CN109782057A (en) Frequency-conversion domestic electric appliances single phase poaer supply inputs wattful power messurement circuit and method

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