Baud rate automatic identification method based on UART waveform bit width measurement

By measuring the UART data bit width and using a waveform bit width measurement method to automatically identify the baud rate, the problem of complex baud rate identification in ship communication and navigation equipment is solved, and the equipment installation is simplified and efficiency is improved.

CN121690478APending Publication Date: 2026-03-17SHANGHAI YONZOE ELECTRONICS & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-16
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

In ship communication and navigation equipment, existing technologies struggle to efficiently and accurately identify and adapt to the baud rates of different navigation instruments under the NMEA-0183 protocol, resulting in complex and inefficient equipment installation.

Method used

By measuring the UART data bit width, a waveform-based bit width measurement method is used to automatically identify the baud rate, including sampling initialization, parameter initialization, data acquisition, bit width counting, calculation and judgment, and baud rate identification steps. Dynamic baud rate adaptive adjustment is achieved using MCU or FPGA.

Benefits of technology

It achieves simple, efficient, and accurate automatic identification of the baud rate of nautical instruments, improves the convenience and adaptability of equipment installation, and can adapt to baud rate changes in real time without restarting the receiving equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121690478A_ABST
    Figure CN121690478A_ABST
Patent Text Reader

Abstract

The invention provides a Baud rate automatic identification method based on UART waveform bit width measurement, and belongs to the technical field of communication, and the method comprises the steps: S1, carrying out the sampling initialization; s2, initializing parameters; s3, triggering data acquisition, and carrying out falling edge detection; s4, triggering bit width counting and data acquisition, and carrying out rising edge detection; s5, updating the number of bit width sample points; s6, carrying out calculation and judgment operation; step S7, Baud rate judgment is carried out; s8, Baud rate recognition is conducted, the transmission Baud rate of data is automatically recognized by measuring the UART data bit width, matching with the transmission Baud rate is automatically set, and therefore the data is correctly received, the method is simple, effective, high in accuracy and high in adaptability, equipment installation becomes simpler and more efficient, meanwhile, the method can adapt to the change of the Baud rate of the sending end in real time, receiving equipment does not need to be restarted, and the cost is reduced. And the adaptability and the convenience are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of communication technology, and more specifically, to an automatic baud rate identification method based on UART waveform bit width measurement. Background Technology

[0002] Ship communication and navigation equipment is crucial for ensuring safe and efficient navigation. This equipment typically communicates using data in the NMEA-0183 format. NMEA-0183 is a communication standard for electronic devices developed by the National Marine Electronics Association (NMEA). Originally applied to data transmission between shipboard electronic devices, this standard has since been extended to land-based applications.

[0003] The NMEA-0183 extensively uses UART (Universal Asynchronous Receiver / Transmitter) signals with RS422 / 485 electrical interfaces. UART is an asynchronous communication device based on a universal serial data bus, supporting full-duplex data transmission and widely used in embedded systems, industrial control, and communication equipment. UART transmits serial data, with communication frames composed of start bits, data bits, optional parity bits, and stop bits. The receiving end parses the data and performs verification using a synchronous clock.

[0004] The UART data frame structure consists of a 1-bit start bit, 5-8 bits of data, 0-1 bits of parity, and 1-2 bits of stop. The start bit is low, the stop bit is high, and the data and parity bits vary depending on the transmitted data. The NMEA-0183 protocol uses ASCII code for data transmission and employs an 8-bit data frame format with no parity. In UART, the width and duration of each data bit correspond to the baud rate, which determines the maximum data transmission capacity. To facilitate data communication, fixed baud rates (baud or bps, the reciprocal of the bit width) are used. Commonly used rates include 1200bps, 2400bps, 4800bps, 9600bps, 19200bps, 38400bps, 57600bps, and 115200bps, as well as higher rates such as 230400bps and even 1Mbps and above. The NMEA-0183 typically has a baud rate of 4800–38400 bps.

[0005] The NMEA-0183 data format of nautical instrument output devices is fixed, but the baud rate is a variable, limited by the amount of data. For example, GPS / BDS satellite positioning signals use 9600bps, while AIS (Automatic Identification System, i.e., collision avoidance system) generally uses 38400bps. In reality, the baud rate is not a rigidly fixed setting; it may differ between devices and is generally user-configurable. For equipment such as marine radar and electronic charts, which require access to data from many marine communication and navigation devices, accurately obtaining the baud rate for each device is sometimes a complex and difficult task, significantly reducing work efficiency. Summary of the Invention

[0006] In view of the aforementioned problems, and in conjunction with the first aspect of the present invention, embodiments of the present invention provide an automatic baud rate identification method based on UART waveform bit width measurement, the method comprising:

[0007] S1: Sampling initialization;

[0008] S2: Parameter initialization;

[0009] S3: Trigger data acquisition and perform falling edge detection;

[0010] S4: Trigger bit width counting and data acquisition, and perform rising edge detection;

[0011] S5: Bit width sample count update;

[0012] S6: Perform calculation and judgment operations;

[0013] S7: Determine the baud rate;

[0014] S8: Perform baud rate identification.

[0015] As a further aspect of the present invention, the sampling initialization includes:

[0016] Based on the maximum baud rate, the sampling rate and sampling period are set. The sampling rate is set to k * maximum baud rate, where k is a constant, and the sampling period is set to 1 / sampling rate.

[0017] Based on the sampling rate, calculate the table B[i] of commonly used baud rate nominal points, where i is the index of the supported baud rate types;

[0018] Determine the sample point judgment error, and obtain the judgment interval for each baud rate based on the sample point judgment error;

[0019] Enable UART waveform acquisition.

[0020] As a further aspect of the present invention, the parameter initialization includes:

[0021] The sampled value, bit width count, bit width sample number, sample number count, and statistical count are defined respectively.

[0022] As a further aspect of the present invention, the triggering of data acquisition and falling edge detection includes:

[0023] If the test result is yes, proceed to step S3;

[0024] If the test result is otherwise, proceed to step S4.

[0025] As a further aspect of the present invention, the trigger bit width counting and data acquisition, and rising edge detection, include:

[0026] If the test result is yes, proceed to step S5;

[0027] If the test result is otherwise, proceed to step S4.

[0028] As a further aspect of the present invention, the calculation and judgment operation includes:

[0029] Determine whether the number of sample points counted is equal to the total number of samples counted.

[0030] If the number of sample points equals the number of statistical points, proceed to step S7;

[0031] If the sample count is not equal to the total number of samples, increment the sample count by one and proceed to step S3.

[0032] As a further aspect of the present invention, the step of determining the baud rate includes:

[0033] If the judgment result is yes, proceed to step S8;

[0034] If the result is negative, proceed to step S2.

[0035] As a further aspect of the present invention, the baud rate identification includes:

[0036] Obtain the UART data baud rate based on the index of the supported baud rate types, set the UART receiver to that baud rate, and receive data.

[0037] Compared with the prior art, the present invention has the following beneficial effects:

[0038] This invention proposes a simple method for correctly receiving data by measuring the UART data bit width, automatically identifying the data transmission baud rate, and automatically setting a matching baud rate. Automatic reception of data from navigation instruments output by NMEA-0183, such as compasses, GPS / BDS navigators, AIS collision avoidance systems, LOG logs, WIND anemometers, and depth sounders, on radar demonstrates that this method is simple, effective, accurate, and highly adaptable, making equipment installation simpler and more efficient. This invention also proposes a method that can adapt to changes in the transmitting baud rate in real time without requiring restarting the receiving equipment, greatly improving adaptability and convenience. Attached Figure Description

[0039] Figure 1 This is a flowchart of the steps of an automatic baud rate identification method based on UART waveform bit width measurement according to the present invention;

[0040] Figure 2 This is a waveform diagram of the UART signal in this invention.

[0041] Figure 3 This is a schematic diagram of identifying the received baud rate in this invention.

[0042] Figure 4 This is a signal flow diagram of an automatic baud rate identification method based on UART waveform bit width measurement according to the present invention.

[0043] Figure 5 This is a signal flow diagram of an automatic baud rate identification method based on UART waveform bit width measurement in this invention, which uses GPIO input and configures the UART as a dedicated serial port receiver.

[0044] Figure 6 This is a connection block diagram for method verification in this invention. Detailed Implementation

[0045] The present invention will now be described in detail with reference to the accompanying drawings, such as... Figure 1 , Figure 2 , Figure 3 , Figure 4 , Figure 5 , Figure 6 As shown.

[0046] Specifically, an automatic baud rate identification method based on UART waveform bit width measurement includes:

[0047] Step S1, sampling initialization.

[0048] Furthermore, based on the highest baud rate B max The sampling rate and sampling period are set to f. s =k*B maxk≥4, k is a constant, and the sampling period t s =1 / f s .

[0049] Furthermore, according to t s Calculate the table B[i] of commonly used baud rate nominal points, where i is the index of the supported baud rate type. Determine the sample point judgment error, and obtain the judgment interval for each baud rate based on the sample point judgment error. The judgment difference is represented as (int N) min [i], intN max [i]), enable UART waveform acquisition.

[0050] Step S2, parameter initialization.

[0051] Furthermore, the sampled value, bit width count, bit width sample number, sample number count and statistical count are defined respectively. The sampled value is defined as int S[1] = 0 and int S[0] = 0, where S[0] is the current sampled value and S[1] is the previous sampled value. The bit width count, bit width sample number, sample number count and statistical count are defined as intn = 0, intN = 0 and intm = 0 respectively, and the statistical count is defined as M.

[0052] Step S3: Trigger data acquisition and perform falling edge detection.

[0053] Further, determine whether S[1] = 1 && S[0] = 0. If the detection result is yes, proceed to step S3; otherwise, proceed to step S4.

[0054] Step S4: Trigger bit width counting and data acquisition, and perform rising edge detection.

[0055] Furthermore, f s Trigger bit width counting and data acquisition, specifically n = n + 1; S[1] = S[0]; S[0] = new sampled value, then determine S[1] = 0 && S[0] = 1?, if the detection result is yes, proceed to step S5, otherwise proceed to step S4.

[0056] Step S5: Update the bit width sample count.

[0057] Furthermore, the bit width sample count update is specifically as follows: if(N==0); elseif(N<n)N=n; that is, N takes min(n), min represents the minimum value, the bit width count is reset, and n=0.

[0058] Step S6: Perform calculation and judgment operations.

[0059] Further, determine whether the sample count is equal to the statistical count, specifically by determining (m == M). If the sample count is equal to the statistical count, proceed to step S7; if the sample count is not equal to the statistical count, increment the sample count by one and proceed to step S3.

[0060] Step S7: Determine the baud rate.

[0061] Furthermore, the baud rate determination specifically refers to N∈(N min [i], N max [i])? If the judgment result is yes, proceed to step S8; if the judgment result is no, proceed to step S2.

[0062] Step S8: Perform baud rate identification.

[0063] Furthermore, the UART data baud rate is obtained according to the index i of the supported baud rate types, the UART receiver is set to this baud rate, data is received, and then the process ends.

[0064] In this embodiment, regarding the principle analysis, such as Figure 2 As shown, by Figure 2 As we know, in the time-domain waveform of UART transmission, the start bit is fixed at a low level, while the stop bit and idle time are fixed at a high level. The data bits and parity bit (optional) are determined by the content of the transmitted data, starting with the most significant bit (msb) and ending with the least significant bit (lsb). Since the transmitted data content is variable, the data bits and parity bit are also "random." If you observe the UART data waveform with an oscilloscope, you can see an "eye diagram." By measuring the duration of the eye diagram, i.e., the minimum interval T of the UART data, the baud rate can be obtained using 1 / T. This is the automatic baud rate identification method based on waveform bit width measurement.

[0065] In this embodiment, based on the principle analysis, the measurement of the "eye diagram" of the UART time-domain waveform is crucial to the implementation method. A digital decision method is employed, which involves sampling the UART waveform and identifying the received baud rate by calculating the time (T) between the rising and falling edges of the waveform, as illustrated below. Figure 3As shown, T is the data bit width, determined by the data baud rate, fs is the sampling rate, and to maintain accuracy, a frequency several times higher than the highest baud rate is generally used. S[0] is the current sample value, and S[1] is the previous sample value. 1 represents a high level, and 0 represents a low level. Then (S[1]==1&&S[0]==0) can represent a falling edge, and (S[1]==0&&S[0]==1) can represent a rising edge. By utilizing the randomness of the data (forming a waveform "eye diagram") and calculating the minimum number of samples N, the UART baud rate can be accurately identified. The above is the basic principle of determining the baud rate using the UART time-domain waveform bit width measurement method. In addition, the baud rates of commonly used UARTs are not arbitrary, but rather a limited number of conventional (i.e., discrete) rates. Therefore, based on this characteristic and combined with the judgment error range, the baud rate can be more accurately identified or determined.

[0066] In this embodiment, the device's UART reception is mostly implemented using the on-chip UART resources of the MCU (microprocessor including single-chip microcomputer), or through programmable devices (PLDs) including FPGAs. The above methods are suitable for both MCUs and FPGAs. For FPGAs, the baud rate calculation and determination can be directly performed using the aforementioned UART baud rate automatic identification logic flowchart.

[0067] Furthermore, its signal flow diagram is as follows: Figure 4 As shown, by Figure 4 As can be seen, real-time baud rate identification can also dynamically monitor changes in baud rate, ensuring that the UART transmitter can adaptively and dynamically adjust the baud rate during operation without needing to restart the receiving device.

[0068] In some possible implementations, modern MCUs (such as widely used ARM chips) typically have multiple UART resources, and UART pins can be configured as GPIO (General Purpose Input / Output) pins. Simultaneously, a timer resource can be enabled to generate a sampling frequency (fs) for level sampling of the GPIO pins. The aforementioned UART baud rate automatic identification logic flowchart is used for baud rate identification, and then the pins are configured back to UART function, setting the obtained baud rate for correct reception. Alternatively, the UART signal can be simultaneously connected to another GPIO input, configuring the UART as a dedicated serial receiver to monitor baud rate changes in real time, allowing the receiver to adaptively adjust the baud rate.

[0069] Furthermore, its signal flow diagram is as follows: Figure 5As shown, in the above MCU processing schemes, the solid lines (paths a and b) represent the time-sharing scheme of UART and GPIO multiplexing, while the dashed lines (paths a and c) represent the scheme of simultaneous independent pin operation of UART and GPIO. The advantage of simultaneous independent pin operation is that it can adapt to changes in baud rate in real time without requiring a restart of the receiving device.

[0070] In this embodiment, for method verification, the method of this patent was verified and applied in the company's marine ARPA navigation radar and NMEA-0183 data distributor in FPGA and MCU (STM32 processor) respectively, and achieved very good results, proving the advanced nature, reliability and practicality of this patent.

[0071] Taking the ARPA marine radar as an example, it uses FPGA to expand multiple UART receiving ports and employs automatic baud rate identification technology to achieve automatic reception of NMEA-0183 signals at different UART baud rates. Its connection block diagram is as follows: Figure 6 As shown, by Figure 6 It is known that the ARPA radar receives more than 8 types of NEMA-0183 data, which use RS422 / 485 differential UART data. The data format is consistent, with 1 stop bit, 8 data bits, 0 parity bits, and 1 stop bit. However, the data baud rates vary, ranging from 4800bps to 115200bps.

[0072] In this application, a differential signal receiving module first performs level conversion, uniformly converting the signal into a TTL single-ended signal for input to the FPGA. The FPGA employs the time-domain bit-width measurement baud rate adaptive identification algorithm of this patent to determine the data baud rate. At this baud rate, serial-to-parallel conversion and reception are performed, and the data is buffered for use by the host computer's SoC processor. The multi-functional SoC processor receives the FPGA data, performs protocol parsing and parameter extraction, and then sends this data to the radar signal processing and system display and control.

[0073] Based on the baud rate distribution, specific parameters were calculated and determined. To ensure a certain level of measurement accuracy while reducing implementation difficulty and computational load, a sampling rate (fs) approximately 4-8 times higher than the highest baud rate (115.2Kbps) was adopted, with a period ts = 1 / fs, ensuring that one bit width ("eye diagram") has 4-8 sampled values ​​for calculation. In this typical case, the highest baud rate is 115200bps, using approximately 4 times the sampling frequency, 115.2K * 4 = 460.8KHz, with a final sampling rate fs = 0.5MHz and a sampling period ts = 2us. To reduce false positives and false negatives, the allowable bit width tolerance (error) E is 20% of the bit width, i.e., if the bit width is T, then:

[0074] Tmin = T * (1 - 20%);

[0075] Tmax = T * (1 + 20%);

[0076] Tmin and Tmax represent the minimum and maximum bit widths, respectively. Using the formula:

[0077] N = round(T / ts);

[0078] The round() function performs forensic operations, where N is the number of bit width samples, T is the bit width, and ts is the sampling period. It can obtain the decision intervals Nmin and Nmax of the samples.

[0079] To improve accuracy, taking into account recognition time, the number of statistical entries for the bit width is set to M = 100.

[0080] At a sampling rate of 0.5MHz, the corresponding values ​​for the receiving baud rate, bit width, number of standard samples N, minimum number of samples Nmin, and maximum number of samples Nmax are shown in the table below:

[0081]

[0082] Table 1 is a table of corresponding values.

[0083] Using a closed interval [Nmin, Nmax] for decision-making can effectively achieve baud rate adaptive reception for NMEA-0183.

[0084] Furthermore, based on the above principle analysis, this decision relies solely on the randomness of UART data, identifying the baud rate by measuring the "eye diagram" width of the time-domain waveform, and does not depend on the UART data content. Therefore, this method can be fully applied to UART communication using non-NMEA-0183 signals. It boasts numerous advantages, including simple algorithm, high recognition rate, good reliability, and ease of implementation.

[0085] The above embodiments can be implemented, in whole or in part, by software, hardware (such as circuits), firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via limited means (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more sets of available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. A semiconductor medium can be a solid-state drive.

[0086] It should be understood that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. A and B can be singular or plural. Additionally, the character " / " in this article generally indicates an "or" relationship between the preceding and following related objects, but it can also represent an "and / or" relationship. Please refer to the context for a more accurate understanding.

[0087] It should be understood that, in the embodiments of the present invention, the order of the above-mentioned process numbers does not imply 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 on the implementation process of the embodiments of the present invention.

[0088] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.

Claims

1. A baud rate automatic identification method based on UART waveform bit width measurement, characterized in that, The method comprises the following steps: S1: sample initialization; S2: parameter initialization; S3: triggering data collection and falling edge detection; S4: triggering bit width counting and data collection and rising edge detection; S5: bit width sample point number updating; S6: calculation and judgment operation; S7: baud rate judgment; S8: baud rate identification.

2. The baud rate automatic identification method based on UART waveform bit width measurement according to claim 1, characterized in that, The sample initialization comprises: based on the highest baud rate, setting the sampling rate and the sampling period, the sampling rate is set as k*the highest baud rate, wherein k is a constant, and the sampling period is set as 1 / sampling rate; calculating a commonly used baud rate nominal point table B[i] according to the sampling rate, wherein i is the support baud rate type index subscript; determining the sample point judgment error, and obtaining the judgment interval of each baud rate according to the sample point judgment error; opening the UART waveform collection.

3. The baud rate automatic identification method based on UART waveform bit width measurement of claim 1, wherein, The parameter initialization comprises: respectively defining the sampling value, the bit width count, the bit width sample point number, the sample point number count and the statistical number.

4. The baud rate automatic identification method based on UART waveform bit width measurement of claim 1, wherein, The triggering data collection and falling edge detection comprises: if the detection result is yes, then entering step S3; if the detection result is no, then entering step S4.

5. The baud rate automatic identification method based on UART waveform bit width measurement of claim 1, wherein, The triggering bit width counting and data collection and rising edge detection comprises: if the detection result is yes, then entering step S5; if the detection result is no, then entering step S4.

6. The baud rate automatic identification method based on UART waveform bit width measurement of claim 1, wherein, The calculation and judgment operation comprises: judging whether the sample point number count is equal to the statistical number; if the sample point number count is equal to the statistical number, then entering step S7; if the sample point number count is not equal to the statistical number, then adding one to the sample point number count and entering step S3.

7. The baud rate automatic identification method based on UART waveform bit width measurement of claim 1, wherein, The baud rate judgment comprises: if the judgment result is yes, then entering step S8; if the judgment result is no, then entering step S2.

8. The baud rate automatic identification method based on UART waveform bit width measurement of claim 1, wherein, The baud rate identification comprises: obtaining the UART data baud rate according to the support baud rate type index subscript, setting the UART receiving end to the baud rate, and receiving data.