Asynchronous serial communication method and system

By uniformly initializing and sending fixed frequency pulses to confirm the baud rate in asynchronous serial communication, the problem of time-consuming and labor-consuming baud rate configuration of master and slave stations is solved, and more efficient baud rate setting and communication startup are achieved.

CN120200868APending Publication Date: 2025-06-24WUHAN SINE ELECTRIC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510181901.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-19
Publication Date
2025-06-24

AI Technical Summary

Technical Problem

In asynchronous serial communication, the baud rate configuration of the master and slave stations is time-consuming and labor-intensive, and the configuration of the master and slave stations needs to be set one by one, which is time-consuming and labor-intensive.

Method used

The master station pulls down the initialization signal, and after the slave station is initialized uniformly, a fixed frequency pulse of the predetermined communication baud rate is sent to the slave station. The slave station detects the pulse stability and confirms the communication baud rate, uploads the slave configuration status step by step. The master station confirms that all slave stations are configured successfully and conducts normal communication.

Benefits of technology

It greatly shortens the time for setting baud rate in asynchronous communication, avoids baud rate configuration for master and slave stations one by one, and saves manpower and material resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120200868A_ABST
    Figure CN120200868A_ABST
Patent Text Reader

Abstract

The invention provides an asynchronous serial communication method and system, and the method comprises the steps: a master station pulls down an initialization signal, and transmits the initialization signal to each slave station; when the slave station detects that the initialization signal is lowered, the slave station communication baud rate is initialized, and a low-level state signal is output; when the master station detects a low-level state signal of the slave station, the initialization signal is pulled up, and a pulse with a predetermined baud rate is sent to each slave station through a data line; if the slave station detects that the fixed-frequency pulse received by the data line is kept stable within a preset duration, it is judged that the slave station communication baud rate is confirmed successfully, a next-level slave station state signal is obtained, and if the next-level slave station state signal is in a high level, the current slave station state signal is set to be in a high level; and the master station detects that the state line signals of the slave stations are high levels, judges that all the slave stations are successfully configured, and starts communication. Through the scheme, the Baud rate configuration efficiency of asynchronous serial communication can be improved, the Baud rate configuration time is shortened, and manpower and material resources are saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of communication technologies, and particularly relates to an asynchronous serial communication method and system. Background Art

[0002] As an important part of modern industry, the automation industry is experiencing rapid development in digitalization and intelligentization. As a mature and widely used data transmission method, serial communication plays a crucial role in the automation industry. For example, in industrial control systems, serial communication is often used to connect field devices to exchange data in real time, enabling precise control and monitoring; in remote monitoring systems, through serial communication, the operating status and data of field devices can be transmitted to a remote monitoring center to achieve remote management and maintenance of the devices; in data acquisition and transmission systems, serial communication is used to connect data acquisition devices and computer systems, and through serial communication, data acquisition devices can transmit the acquired data to the computer system for processing and analysis. As a mature and reliable data transmission method, serial communication can bring higher efficiency and lower costs to the automation industry.

[0003] However, asynchronous serial communication schemes generally need to ensure that the master and slave stations maintain the same communication baud rate to ensure the stability of data transmission. Due to different specific on-site environments, usage scenarios, and application requirements, the baud rates of serial communication in actual use are also different, and it is often necessary to set the configurations of the master station and slave stations one by one, which is time-consuming and laborious. At the same time, during actual use, there are often different interferences. The lower the baud rate of serial communication, the stronger the stability. The higher the communication baud rate, the more vulnerable it is to interference. Therefore, in order to pursue higher communication efficiency and stability, it is necessary to continuously test different communication baud rates to find the most suitable one. During the testing process, both the master station and each slave station need to be set, which also requires a large amount of time. Summary of the Invention

[0004] In view of this, embodiments of the present invention provide an asynchronous serial communication method and system for solving the problem of time-consuming and laborious baud rate configuration of the master station and slave stations in current asynchronous serial communication.

[0005] In the first aspect of the embodiments of the present invention, an asynchronous serial communication method is provided, including: The master station pulls down the initialization signal and sends the initialization signal to each slave station; When the slave station detects that the initialization signal is pulled down, it initializes the communication baud rate of the slave station and outputs a status signal with a low level; When the master station detects the status signal with a low level from the slave station, it pulls up the initialization signal and sends fixed-frequency pulses of a predetermined communication baud rate to each slave station through the data line; If the slave station detects that the fixed-frequency pulses received on the data line remain stable within a predetermined duration, it is determined that the communication baud rate of the slave station is successfully confirmed; The slave station obtains the status signal of the next-level slave station. If the status signal of the next-level slave station is high level, it is determined that the communication baud rate of the next level is successfully confirmed, and the status signal of the current slave station is set to high level; Among them, the master station and each slave station are cascaded through the status signal line. When the slave station is the last level and the communication baud rate is successfully confirmed, a status signal of high level is output; When the master station detects that the status line signal of the nearest slave station is high level, it is determined that the communication baud rates of all slave stations are successfully set, and communication starts.

[0006] In the second aspect of the embodiments of the present invention, an asynchronous serial communication system is provided, including: A master station, configured to pull down the initialization signal, send the initialization signal to each slave station, when detecting the status signal of low level of the slave station, pull up the initialization signal, and send fixed-frequency pulses of a predetermined communication baud rate to each slave station through the data line; and when detecting that the status line signal of the nearest slave station is high level, determine that the communication baud rates of all slave stations are successfully set, and start communication; A slave station, configured to initialize the communication baud rate of the slave station when detecting that the initialization signal is pulled down, and output a status signal of low level; if it detects that the fixed-frequency pulses received on the data line remain stable within a predetermined duration, it is determined that the communication baud rate of the slave station is successfully confirmed, and obtain the status signal of the next-level slave station. If the status signal of the next-level slave station is high level, it is determined that the communication baud rate of the next level is successfully confirmed, and the status signal of the current slave station is set to high level; Among them, the master station and each slave station are cascaded through the status signal line. When the slave station is the last level and the communication baud rate is successfully confirmed, a status signal of high level is output.

[0007] In the third aspect of the embodiments of the present invention, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method described in the first aspect of the embodiments of the present invention are implemented.

[0008] In the fourth aspect of the embodiments of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method provided in the first aspect of the embodiments of the present invention are implemented.

[0009] In the embodiments of the present invention, after uniformly initializing each slave station through the initialization signal line, the communication baud rate is uniformly sent to the slave station. After the slave station detects that the data frequency is stable, it uploads the slave station configuration status step by step. After the master station confirms that all slave stations are successfully configured, normal communication is carried out, thus greatly shortening the time for setting the baud rate in asynchronous communication, avoiding configuring the baud rate for the master station and slave stations one by one, and saving the consumption of manpower and material resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the following described drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0011] Figure 1 It is a schematic flowchart of an asynchronous serial communication method provided by an embodiment of the present invention; Figure 2 It is a schematic diagram of a master station provided by an embodiment of the present invention; Figure 3 It is a schematic diagram of a slave station provided by an embodiment of the present invention; Figure 4 It is a schematic diagram of the connection relationship between the master station and the slave station provided by an embodiment of the present invention; Figure 5 It is a schematic diagram of a timing signal provided by an embodiment of the present invention; Figure 6 It is a schematic structural diagram of an asynchronous serial communication system provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0012] In order to make the objectives, features, and advantages of the present invention more obvious and understandable, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the following described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.

[0013] It should be understood that the term "including" and other similar expressions in the specification or claims of the present invention and the above drawings mean covering non-exclusive inclusion. For example, a process, method, system, or device including a series of steps or units is not limited to the listed steps or units. In addition, "first" and "second" are used to distinguish different objects and are not used to describe a specific order.

[0014] Please refer to Figure 1, a flow chart of an asynchronous serial communication method provided by an embodiment of the present invention includes: S101, the master station pulls down the initialization signal and sends the initialization signal to each slave station; The master station generally refers to the data center in the automation system, such as a computer system, monitoring center or controller, and the slave station refers to the field equipment used to perform specific tasks, such as sensors, data acquisition equipment, etc. Pulling down the initialization signal is to convert the high-level signal into a low-level signal, which can be achieved by pull-down resistors, turn-on transistors, etc. The low level refers to the maximum input low level allowed when the input of the logic gate is low, and the high level refers to the minimum input high level allowed when the input of the logic gate is high.

[0015] Before the master station is initialized, the initialization signal needs to be reduced to a low level, and the low-level initialization signal is sent to each slave station through the initialization signal line.

[0016] S102, when the slave detects that the initialization signal is pulled low, the slave communication baud rate is initialized and a low level status signal is output; When the slave station receives the low-level initialization signal, the communication baud rate of the slave station is initialized and the status signal is pulled low, that is, the slave station status signal is set to a low level.

[0017] S103, when the master station detects a low-level status signal from the slave station, it pulls up the initialization signal and sends a fixed-frequency pulse of a predetermined communication baud rate to each slave station through the data line; After the master station detects the low-level status signal sent by the slave station, it converts the initialization signal into a high-level signal and sends the pulse signal of the predetermined communication baud rate to be used directly to each slave station through the data line, that is, the signal in the data line is a fixed-frequency pulse of the predetermined communication baud rate.

[0018] Among them, each slave station feeds back the slave station status signal to the upper layer step by step until the master station receives the status signal fed back by the slave station, that is, each slave station feeds back its low-level status signal to the upper layer.

[0019] S104, if the slave station detects that the fixed frequency pulse received by the data line remains stable within a predetermined time period, it is determined that the slave station communication baud rate is confirmed successfully; When the slave station receives a fixed-frequency pulse signal of a predetermined communication baud rate, it detects whether the pulse signal frequency remains stable within a certain period of time. When the data line signal frequency can remain stable within the predetermined time, it is determined that the slave station communication baud rate confirmation is successful, that is, the slave station confirms that it has received a pulse signal of the predetermined communication baud rate, and uses the communication baud rate as the slave station communication baud rate.

[0020] S105. The slave station obtains the status signal of the next-level slave station. If the status signal of the next-level slave station is high level, it is determined that the communication baud rate confirmation of the next level is successful, and the current slave station status signal is set to high level; Among them, the master station and each slave station are cascaded through the status signal line. When the slave station is the last level and the communication baud rate confirmation is successful, a status signal of high level is output; The next-level slave station is the slave station directly connected to the current slave station. Each adjacent slave station is directly connected through the status signal. Generally, the level of the slave station can be determined according to the number of the slave station or the distance between the slave station and the master station.

[0021] After the communication baud rate of the slave station is confirmed successfully, it will judge whether the communication baud rate of the next-level slave station is also confirmed successfully. If the status signal of the next-level slave station is high, the current slave station status signal can be set to high level.

[0022] It can be understood that for the last-level slave station or the slave station farthest from the master station, after the communication baud rate is confirmed successfully, since there is no next-level slave station, the status signal of the bottom-level slave station will be directly set to high level, and then the status signals of the slave stations will be fed back level by level until the master station is reached.

[0023] S106. When the master station detects that the status line signal of the nearest slave station is high level, it is determined that the communication baud rates of all slave stations are set successfully, and communication starts.

[0024] When the master station receives the status signal returned by the slave station, if the status line signal of the slave station is high level, it is determined that the communication baud rates of all slave stations are set successfully; otherwise, the baud rate of the slave station needs to be set again.

[0025] It should be understood that the asynchronous serial communication method is applied to an asynchronous serial communication system. The asynchronous serial communication system includes a master station and multiple slave stations. The master station and each slave station are cascaded through the status signal line in sequence, and the master station and each slave station are directly connected through the initialization signal line and the data line.

[0026] In this embodiment, after uniformly initializing each slave station, a pulse signal with a specific communication baud rate is directly sent to the slave station. According to the status signals returned by each level of slave stations, the unified setting of the communication baud rates of all slave stations is realized, which can not only effectively improve the baud rate configuration efficiency of the master station and the slave stations, shorten the time for setting the baud rate in asynchronous communication, but also save manpower and material resources.

[0027] In one embodiment, the master station model is as Figure 2 shown, and the slave station model is as Figure 3 shown. The master station includes at least three signal lines, namely the initialization signal line Init, the data line Data, and the slave station status signal reading line Done-In; The slave station includes at least four signal lines, namely the initialization signal line Init, the data line Data, the signal line Done-In for reading the status of the next-level slave station, and the signal line Done-Out for outputting the status of the current slave station.

[0028] The connection relationship between the master station and multiple slave stations is as Figure 4 shown. The slave stations include slave station 1, slave station 2,..., slave station n, that is, n slave stations are connected to the master station.

[0029] Among them, the master station is directly connected to each slave station through the initialization signal line. The signal in the initialization signal line is a transparent transmission signal, the signal sending end is the master station, and the signal receiving end is the slave station, that is, the master station is directly connected to n slave stations through the initial signal line Init.

[0030] Among them, the master station is directly connected to each slave station through the data line. The master station sends fixed-frequency pulses of a predetermined communication baud rate to the slave station through the data line, that is, the master station is directly connected to n slave stations through the data line Data.

[0031] Among them, the slave stations are connected through the signal line Done-In for reading the status of the next-level slave station and the signal line Done-Out for outputting the status of the current slave station. As Figure 4 shown, the signal line Done-In for reading the status of the next-level slave station of slave station 1 is connected to the signal line Done-Out for outputting the status of the current slave station of slave station 2, and so on. The signal line Done-In for reading the status of the next-level slave station of slave station n-1 is connected to the signal line Done-Out for outputting the status of the current slave station of slave station n.

[0032] The slave station closest to the master station is regarded as the top-level slave station. The top-level slave station is connected to the signal line of the master station for reading the status of the slave station through the signal line for outputting the current status, so as to obtain the status signals of all levels of slave stations. As Figure 4 shown, the signal line Done-In for reading the status of the next-level slave station of the master station is connected to the signal line Done-Out for outputting the status of the current slave station of slave station 1.

[0033] It can be understood that the difference between this embodiment and the traditional asynchronous serial bus is that there is one more Init - initialization signal line and one more Done status signal line. The Init initialization signal line is a transparent transmission signal, all slave stations are the receiving ends, and the master station is the sending end. The Done signal line is a cascading signal from the back end to the front end, and it needs to be confirmed level by level, input through Done-In and output through Done-Out.

[0034] Among them, the timing signals of the initialization signal Init, the data line signal Data of the master station, and the signal line Done-In of the slave station status (i.e., the master station Done-In), the signal line Done-In of the status of the next-level slave station of the slave station, and the signal line Done-Out of the status of the current slave station are asFigure 5 As shown, the figure shows the timing of pulling up and pulling down the master station signal and the slave station signal.

[0035] Exemplarily, the master station Init is pulled low, and after detecting that the master station Done-In is pulled low, Init is pulled high; the master station Data data line starts to send fixed-frequency pulses of the communication baud rate to be used.

[0036] After the slave station detects that Init is pulled low, it initializes the communication baud rate and pulls Done-Out low; the slave station starts to detect the Data data line and detect the Data frequency. If the Data frequency is detected to be stable for a certain period of time, it is determined that the communication baud rate confirmation is successful; if the current slave station communication baud rate confirmation is successful, it is detected whether Done-In is at a high level. If it is at a high level, it means that the communication baud rate of the next level is also confirmed successfully (that is, the slave station X+1 is at a high level), and the Done-Out of the current slave station is set to a high level (that is, the slave station X).

[0037] When the master station detects that Done-In is at a high level, it determines that the communication baud rates of all slave stations are set successfully and starts normal communication.

[0038] It should be understood that the sequence numbers of the steps in the above embodiments do not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.

[0039] Figure 6 It is a schematic structural diagram of an asynchronous serial communication system provided by an embodiment of the present invention. The system includes: A master station 610, configured to pull down the initialization signal, send the initialization signal to each slave station, when detecting the status signal of the slave station at a low level, pull up the initialization signal, and send fixed-frequency pulses of a predetermined communication baud rate to each slave station through the data line; and, when detecting that the status line signal of the nearest slave station is at a high level, determine that the communication baud rates of all slave stations are set successfully and start communication; A slave station 620, configured to initialize the communication baud rate of the slave station and output a status signal at a low level when detecting that the initialization signal is pulled down; if it is detected that the fixed-frequency pulses received by the data line remain stable within a predetermined time duration, determine that the communication baud rate of the slave station is confirmed successfully, and obtain the status signal of the next-level slave station. If the status signal of the next-level slave station is at a high level, determine that the communication baud rate of the next level is confirmed successfully and set the status signal of the current slave station to a high level; Wherein, the master station 610 is cascaded with each slave station 610 through the status signal line. When the slave station is the last level and the communication baud rate is confirmed successfully, a status signal at a high level is output.

[0040] Among them, the master station 610 includes at least three signal lines, namely an initialization signal line, a data line, and a slave station status reading signal line; The slave station 620 includes at least four signal lines, namely an initialization signal line, a data line, a next-level slave station status reading signal line, and a current slave station status output signal line.

[0041] Preferably, the master station is directly connected to each slave station through the initialization signal line. The signal in the initialization signal line is a transparent transmission signal, with the signal sending end being the master station and the signal receiving end being the slave station.

[0042] Among them, the master station is directly connected to each slave station through the data line. The master station sends fixed-frequency pulses of a predetermined communication baud rate to the slave station through the data line.

[0043] Preferably, the slave stations are connected through the next-level slave station status reading signal line and the current slave station status output signal line; The slave station closest to the master station is regarded as the top-level slave station. The top-level slave station is connected to the slave station status reading signal line of the master station through the current status output signal line to obtain the status signals of all levels of slave stations.

[0044] Those of ordinary skill in the art can understand that all or part of the steps in implementing the method of the above embodiments can be realized by an electronic device. The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed, it realizes part or all of the processes in steps S101 to S106.

[0045] Those of ordinary skill in the art can also understand that all or part of the steps in implementing the method of the above embodiments can be completed by instructing relevant hardware through a program. The program can be stored in a computer-readable storage medium. When the program is executed, it realizes part or all of the processes in steps S101 to S106. The storage medium includes, for example, ROM / RAM, etc. In the above embodiments, the descriptions of the respective embodiments have their own emphases. For parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0046] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the above-described system, device, and module can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.

[0047] In the above embodiments, the descriptions of the respective embodiments have their own emphases. For parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0048] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than limiting it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An asynchronous serial communication method, characterized in that: include: The master station pulls down the initialization signal and sends the initialization signal to each slave station; When the slave detects that the initialization signal is pulled low, it initializes the slave communication baud rate and outputs a low-level status signal; When the master detects a low-level status signal from the slave, it pulls the initialization signal high and sends a fixed-frequency pulse at a predetermined communication baud rate to each slave through the data line; If the slave detects that the fixed frequency pulses received by the data line remain stable within a predetermined time, it is determined that the slave communication baud rate is confirmed successfully; The slave station obtains the next-level slave station status signal. If the next-level slave station status signal is high, it is determined that the next-level communication baud rate is confirmed successfully, and the current slave station status signal is set to high level; Among them, the master station and each slave station are cascaded through the status signal line. When the slave station is the last level and the communication baud rate is confirmed successfully, a high-level status signal is output; When the master detects that the status line signal of the nearest slave is at a high level, it determines that the communication baud rates of all slaves are set successfully and starts communication.

2. The method according to claim 1, characterized in that The master station includes at least three signal lines, namely an initialization signal line, a data line and a slave station status reading signal line; The slave station includes at least four signal lines, which are an initialization signal line, a data line, a signal line for reading the state of the next-level slave station, and a signal line for outputting the state of the current slave station.

3. The method according to claim 2, characterized in that The master station is directly connected to each slave station via an initialization signal line, in which the initialization signal is a transparent signal, the signal sending end is the master station, and the signal receiving end is the slave station.

4. The method according to claim 2, characterized in that: The master station is directly connected to each slave station via a data line, and the master station sends fixed frequency pulses of a predetermined communication baud rate to the slave station via the data line.

5. The method according to claim 2, characterized in that: The slave stations are connected by reading the next-level slave station status signal line and outputting the current slave station status signal line; The slave station closest to the master station is regarded as the uppermost slave station. The uppermost slave station is connected to the master station's slave station status reading signal line through the output current status signal line to obtain the status signals of all hierarchical slave stations.

6. An asynchronous serial communication system, characterized in that: include: The master station is used to pull down the initialization signal and send the initialization signal to each slave station. When a low-level status signal from the slave station is detected, the initialization signal is pulled high and a fixed-frequency pulse with a predetermined communication baud rate is sent to each slave station through the data line; And, when it is detected that the status line signal of the nearest slave station is at a high level, it is determined that the communication baud rates of all slave stations are successfully set, and communication begins; The slave station is used to initialize the communication baud rate of the slave station and output a low-level status signal when the initialization signal is detected to be pulled low; if it is detected that the fixed-frequency pulse received by the data line remains stable within a predetermined period of time, it is determined that the communication baud rate of the slave station is successfully confirmed, and the next-level slave station status signal is obtained. If the next-level slave station status signal is high, it is determined that the next-level communication baud rate is successfully confirmed, and the current slave station status signal is set to a high level; Among them, the master station and each slave station are cascaded through the status signal line. When the slave station is the last level and the communication baud rate is confirmed successfully, a high-level status signal is output.

7. The system according to claim 6, characterized in that The master station includes at least three signal lines, namely an initialization signal line, a data line and a slave station status reading signal line; The slave station includes at least four signal lines, which are an initialization signal line, a data line, a signal line for reading the state of the next-level slave station, and a signal line for outputting the state of the current slave station.

8. The system according to claim 7, characterized in that The master station is directly connected to each slave station via an initialization signal line, in which a transparent signal is carried. The signal sending end is the master station, and the signal receiving end is the slave station.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of an asynchronous serial communication method as claimed in any one of claims 1 to 5 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed, the steps of an asynchronous serial communication method as claimed in any one of claims 1 to 5 are implemented.