Baud rate determination method, nonvolatile readable storage medium and electronic equipment

By acquiring and classifying the transmission time of communication data, determining the target time array to calculate the baud rate, the problem of poor adaptability of baud rate adjustment in the prior art is solved, and efficient baud rate adjustment under various communication protocols is realized , improves the stability and flexibility of communication.

CN119109815APending Publication Date: 2024-12-10GUANGZHOU SHIYUAN ELECTRONICS CO LTD +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310630530.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-30
Publication Date
2024-12-10

AI Technical Summary

Technical Problem

The prior art has poor adaptability when adjusting the baud rate, especially in scenarios where communication protocols are not followed.

Method used

By obtaining the transmission time when the communication data sent by the host appears with a preset number of specified edge signals, classifying and filtering out the target time array to determine the baud rate, avoiding detection of the data packet header, and realizing in multiple communication protocol scenarios adaptive adjustment.

Benefits of technology

It improves the accuracy and adaptability of the baud rate, can be flexibly adjusted in different communication scenarios, and enhances the stability and reliability of communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119109815A_ABST
    Figure CN119109815A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of communication, and discloses a baud rate determination method, a nonvolatile readable storage medium and electronic equipment. The baud rate determination method comprises the following steps: acquiring communication data sent by a host and transmission time when specified edge signals with preset times appear on the communication data, classifying the transmission time into time arrays matched with the transmission time, and determining a time array meeting an array screening condition in a plurality of time arrays as a target time array, and determining the baud rate according to at least one transmission time included in the target time array. According to the embodiment of the invention, the Baud rate can be comprehensively determined by utilizing at least one transmission time contained in the target time array, so that the obtained Baud rate is relatively reliable and accurate. Besides, the baud rate can be adaptively determined without detecting a data packet header in the process of determining the baud rate, so that the baud rate can be adaptively determined in various communication protocol scenes, and the adaptive capability is relatively high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a baud rate determination method, a non-volatile readable storage medium and an electronic device. Background Art

[0002] The host and the slave communicate via serial port at a fixed baud rate. When the host chip fails, the baud rate of the host and the slave may change, resulting in abnormal communication.

[0003] The prior art can adaptively adjust the baud rate when communication is abnormal. The prior art extracts the data packet header from the communication data according to the communication protocol and detects the data packet header to obtain the baud rate. This method is subject to the communication protocol. In some communication scenarios, the communication between the host and the slave does not follow the corresponding communication protocol. Therefore, the adaptability of this method is poor and it is not easy to meet the requirements of adaptively adjusting the baud rate in various communication scenarios. Summary of the invention

[0004] An object of an embodiment of the present invention is to provide a baud rate determination method, a non-volatile readable storage medium and an electronic device, aiming to solve the technical problem that the prior art has poor adaptability in adjusting the baud rate.

[0005] In a first aspect, an embodiment of the present invention provides a baud rate determination method, comprising:

[0006] Acquire communication data sent by the host and the transmission time when the communication data has a specified edge signal for a preset number of times, wherein the communication data includes at least one bit of data, and the preset number of times is an integer greater than or equal to 2;

[0007] sorting the transmission time into a time array matching the transmission time;

[0008] Determine a time array that meets an array screening condition as a target time array among the multiple time arrays;

[0009] The baud rate is determined according to at least one transmission time included in the target time array.

[0010] Optionally, the acquiring the transmission time when the communication data has a specified edge signal that appears a preset number of times includes:

[0011] Determine the first time when the specified edge signal appears for the first time in the communication data;

[0012] Determine the second time when the specified edge signal appears for the nth time in the communication data, where n is equal to a preset number of times;

[0013] The difference between the second time and the first time is calculated to obtain the transmission time.

[0014] Optionally, n is 2.

[0015] Optionally, the designated edge signal is a rising edge signal.

[0016] Optionally, each of the time arrays is configured with a preset time range, and classifying the transmission time into a time array matching the transmission time comprises:

[0017] Traversing each of the time arrays to determine a time range within which the transmission time falls as a reference time range;

[0018] The transmission times are sorted into a time array corresponding to the reference time range.

[0019] Optionally, each of the time arrays is configured with a priority, and determining a time array satisfying an array screening condition as a target time array among the multiple time arrays includes: determining a time array with a highest priority among the multiple time arrays as a target time array.

[0020] Optionally, each of the time arrays is used to collect the transmission time of a specified bit of data;

[0021] When the designated bit of the data collected by the time array is smaller, the priority of the time array is higher, and when the designated bit of the data collected by the time array is larger, the priority of the time array is lower.

[0022] Optionally, determining a time array with the highest priority among the multiple time arrays as the target time array comprises:

[0023] Determine whether the highest priority time array is an empty array, where the empty array is a time array that does not include a transmission time;

[0024] If yes, lower the priority of the time array with the highest priority, and re-determine the time array with the highest priority among the multiple time arrays as the target time array;

[0025] If not, the time array with the highest priority is determined as the target time array.

[0026] Optionally, determining the baud rate according to at least one transmission time included in the target time array comprises:

[0027] Selecting a transmission time satisfying a median condition from at least one transmission time in the target time array as a target transmission time;

[0028] Determining a designated bit corresponding to the target time array;

[0029] A baud rate is determined according to the designated bits and the target transmission time.

[0030] Optionally, before determining the target time array, the method further includes:

[0031] Determine the time when the specified edge signal appears for the i-th time in the communication data as the start time and the current time, where i is an integer greater than 0;

[0032] Calculate the time interval between the current time and the start time;

[0033] Determine whether the communication data has an i+1th designated edge signal;

[0034] If not, determine whether the time interval is greater than a preset time threshold; if so, enter the step of determining a time array that satisfies the array screening condition as a target time array among the multiple time arrays; if less than, return to the step of determining whether the communication data has the i+1th specified edge signal;

[0035] If it occurs, assign i=i+1, and return to the step of determining the time when the designated edge signal appears for the i-th time in the communication data as the starting time.

[0036] Optionally, the method further comprises:

[0037] Sending serial data to the host based on the baud rate so that the host returns communication feedback information;

[0038] If the communication feedback information is communication success information, communicating with the host based on the baud rate;

[0039] If the communication feedback information is communication failure information, continue to determine the baud rate.

[0040] In a second aspect, an embodiment of the present invention provides a non-volatile readable storage medium storing computer executable instructions, wherein the computer executable instructions are used to enable an electronic device to execute the above baud rate determination method.

[0041] In a third aspect, an embodiment of the present invention provides an electronic device, including:

[0042] at least one processor; and,

[0043] a memory communicatively connected to the at least one processor; wherein,

[0044] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the above baud rate determination method.

[0045] In the baud rate determination method provided by the embodiment of the present invention, first, the present embodiment obtains the communication data sent by the host and the transmission time when the communication data appears a preset number of designated edge signals, the communication data includes at least one bit of data, the preset number of times is an integer greater than or equal to 2, and the present embodiment uses the preset number of designated edge signals as the sampling standard, which can effectively intercept the transmission time corresponding to the complete at least one bit of data, and lays the foundation for the subsequent use of the transmission time and the complete at least one bit of data to derive the baud rate. Then, the present embodiment classifies the transmission time into a time array that matches the transmission time, which is conducive to classifying one or more transmission times into the same time array. Then, the present embodiment determines the time array that meets the array screening condition as the target time array in multiple time arrays, and determines the baud rate according to at least one transmission time included in the target time array. The present embodiment can use the at least one transmission time included in the target time array to comprehensively determine the baud rate, and the baud rate obtained in this way is more reliable and accurate. In addition, the present embodiment does not need to detect the data packet header in the above process of determining the baud rate, and can adaptively determine the baud rate. Therefore, the present embodiment can adaptively determine the baud rate in various communication protocol scenarios, and has a high adaptive ability. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0047] Figure 1 A schematic diagram of the structure of a communication system provided by an embodiment of the present invention;

[0048] Figure 2 A flow chart of a baud rate determination method provided by an embodiment of the present invention;

[0049] Figure 3 A schematic diagram of the structure of a baud rate determination device provided by an embodiment of the present invention;

[0050] Figure 4 A schematic structural diagram of a baud rate determination device provided by another embodiment of the present invention;

[0051] Figure 5 A schematic diagram of a circuit structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0052] In order to make the purpose, technical scheme and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0053] It should be noted that, if there is no conflict, the various features in the embodiments of the present invention can be combined with each other, all within the scope of protection of the present invention. In addition, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in a different order from the module division in the device or the flow chart. Furthermore, the words "first", "second", "third", etc. used in the present invention do not limit the data and execution order, but only distinguish the same items or similar items with basically the same functions and effects.

[0054] The embodiment of the present invention provides a communication system. Figure 1 The communication system 10 includes a host 11 and a slave 12. The host 11 and the slave 12 perform serial communication, and the serial communication can be synchronous serial communication or asynchronous serial communication. When it is detected that the slave 12 meets the baud rate calibration trigger condition, the slave 12 executes the baud rate determination method of the parameters of each embodiment below.

[0055] In some embodiments, when the slave 12 receives a baud rate calibration command sent by the host 11, the slave 12 satisfies the baud rate calibration trigger condition. In some embodiments, when the slave 12 detects a power-on command, the slave 12 satisfies the baud rate calibration trigger condition. In some embodiments, when the slave 12 detects a power-on command, the slave 12 satisfies the baud rate calibration trigger condition. In some embodiments, when the slave 12 detects a timing calibration command, the slave 12 satisfies the baud rate calibration trigger condition. In some embodiments, when the slave 12 detects that the host 11 is in an abnormal communication state, the slave 12 satisfies the baud rate calibration trigger condition.

[0056] As another aspect of the present invention, the present invention provides a baud rate determination method. Figure 2 , the baud rate determination method comprises the following steps:

[0057] S21: Acquire the communication data sent by the host and the transmission time when the communication data has a specified edge signal for a preset number of times, the communication data includes at least one bit of data, and the preset number of times is an integer greater than or equal to 2.

[0058] In this step, the communication data is the data sent by the host to the slave. It is understandable that the communication data may or may not satisfy the corresponding communication protocol. It is also understandable that the communication data may be a frame of data packets or more than two frames of data packets. The preset number of times may be 2 or more times, and the specified edge signal may be a rising edge signal or a falling edge signal. The transmission time is the time required for the communication data to have a preset number of specified edge signals. For example, the time required for the communication data to have a rising edge signal appear twice is T, and the transmission time is T.

[0059] Before obtaining the communication data sent by the host, the baud rate determination method also includes the following steps: controlling the slave to enter a capture mode of a specified edge signal, obtaining the communication data sent by the host and the transmission time when the communication data appears a preset number of specified edge signals in the capture mode.

[0060] Obtaining the transmission time when a specified edge signal appears in communication data for a preset number of times includes: determining a first time when the specified edge signal appears in the communication data for the first time, determining a second time when the specified edge signal appears in the communication data for the nth time, where n is equal to the preset number of times, and calculating the difference between the second time and the first time to obtain the transmission time.

[0061] Determining the first time when the specified edge signal appears for the first time in the communication data includes: recording the first time when the specified edge signal appears for the first time in the communication data in a capture mode.

[0062] Determining the second time when the specified edge signal appears for the nth time in the communication data includes: accumulating the number of times the specified edge signal appears each time in the communication data to obtain an accumulated number of times, and when the accumulated number of times is equal to n, recording the second time.

[0063] In some embodiments, n can be an integer of 2 or more. It can be understood that when n=2, that is, the slave needs to collect the time interval of two rising edge signals in the communication data as the transmission time, because the time interval of the two rising edge signals is usually relatively small, and the bits of the communication data corresponding to the two rising edge signals are usually relatively small, therefore, relative to the method of setting n to 3 or 4 or 5, this embodiment can use a frame of communication data to extract multiple transmission times, so that a considerable amount of transmission time can be collected in a relatively short time, which is conducive to improving the efficiency of baud rate adjustment.

[0064] It is understandable that when the communication data has a preset number of designated edge signals, the number of bits of the communication data transmitted by the host to the slave may be equal to the preset number or may not be equal to the preset number. For example, when the preset number is 2 and the designated edge signal is a rising edge signal, the slave records the time interval between two rising edge signals in the communication data and uses the time interval as the transmission time. If the high level signal is 1 and the low level signal is 0, the communication data with two rising edge signals may be 10 or 110 or 111110, etc., where "10" is 2-bit data, "110" is 3-bit data, and "111110" is 6-bit data.

[0065] The host or the slave usually uses an optocoupler for signal isolation to transmit a high-level signal or a low-level signal. When the optocoupler is turned on, the optocoupler can transmit a high-level signal. When the optocoupler is disconnected, the optocoupler can transmit a low-level signal. Among them, due to the characteristics of the optocoupler, the delay from the high level to the low level will be greater than the delay from the low level to the high level, that is, the delay of the falling edge signal is large, which is not conducive to the subsequent derivation of the accurate baud rate. Therefore, this embodiment selects the rising edge signal as the designated edge signal, which is conducive to obtaining the transmission time that can reflect the number of bits, and then the accurate baud rate can be derived.

[0066] S22: Classify the transmission time into a time array matching the transmission time.

[0067] In this step, the time array is used to collect the transmission time belonging to the same time range, wherein the slave may be configured with multiple time arrays, each time array is configured with a preset time range, for example, see Table 1:

[0068] Table 1

[0069] Time Array Time Range f1 [0.09,0.11] f2 [0.135,0.165] f3 [0.18,0.22] f4 [0.225,0.275]

[0070] As shown in Table 1, different time arrays correspond to different time ranges, wherein the time range corresponding to the time array f1 is 0.09 ms to 0.11 ms, the time range corresponding to the time array f2 is 0.135 ms to 0.165 ms, and so on.

[0071] Classifying the transmission time into a time array matching the transmission time includes the following steps: traversing each time array to determine the time range into which the transmission time falls as a reference time range, and classifying the transmission time into a time array corresponding to the reference time range.

[0072] For example, when the transmission time T1 is 0.1, the reference time range is [0.09, 0.11], and the present embodiment places the transmission time T1 in the time array f1. When the transmission time T2 is 0.14, the reference time range is [0.135, 0.165], and the present embodiment places the transmission time T2 in the time array f2. When the transmission time T3 is 0.2, the reference time range is [0.18, 0.22], and the present embodiment places the transmission time T3 in the time array f3, and so on, which will not be described in detail here.

[0073] In some embodiments, the time range of each time array is used to describe the reasonable fluctuation range of the data of a specified bit in the transmission time. In this embodiment, the time range is generated according to the reference time of a single bit, the specified bit and the preset time fluctuation ratio. The preset time fluctuation ratio is customized by the designer based on experience, for example, the preset time fluctuation ratio is 10%.

[0074] For example, the base time of a single bit is 0.05ms, that is, it takes 0.1ms for the host to transmit 1 bit of data to the slave, and the preset time fluctuation ratio is 10%. This embodiment calculates the time range of the corresponding time array according to the following formula: The upper limit of the time range is The lower limit is λ=α*m*(1+η), and the time range is in, is the upper limit, α is the reference time, m is the specified bit, η is the preset time fluctuation ratio, and λ is the lower limit. For example, if the reference time α is 0.05, the time range of the time array f1 is used to describe the reasonable fluctuation range of 2-bit data in the transmission time, that is, m is 2, so the upper limit is 0.09, and the lower limit λ is 0.11, so the time range is [0.09, 0.11].

[0075] According to the above method, Table 2 can be obtained, as shown in Table 2:

[0076] Table 2

[0077] Specified bit Time Array Time Range 2 f1 [0.09,0.11] 3 f2 [0.135,0.165] 4 f3 [0.18,0.22] 5 f4 [0.225,0.275]

[0078] As shown in Table 2, the time range of the time array f2 is used to describe the reasonable fluctuation range of the transmission time of 3-bit data, the time range of the time array f3 is used to describe the reasonable fluctuation range of the transmission time of 4-bit data, and the time range of the time array f4 is used to describe the reasonable fluctuation range of the transmission time of 5-bit data.

[0079] The following is an example to illustrate the process of classifying the transmission time into the corresponding time array, as follows: Assume that the time range of the time array f1 is [0.09, 0.11]. When the transmission time of 2 bits of data is 0.095, the transmission time of 2 bits of data in [0.09, 0.11] is acceptable, and the transmission time "0.095" can be placed on the time array f1. If the transmission time of 2 bits of data is 0.07 or 0.12, since the transmission time of 2 bits of data is not in [0.09, 0.11], the transmission time 0.07 or the transmission time 0.12 is unacceptable, and this embodiment will not place the transmission time 0.07 or the transmission time 0.12 on the time array f1. In other words, the time array f1 is used to collect reasonable transmission times corresponding to 2 bits of data.

[0080] Similarly, assuming that the time range of the time array f2 is [0.135, 0.165], when the transmission time of 3 bits of data is 0.16, the transmission time of 3 bits of data is acceptable in [0.135, 0.165], and the transmission time "0.16" can be placed in the time array f2.

[0081] If the transmission time is 0.2, since the transmission time is not in [0.135, 0.165], this embodiment will not place the transmission time 0.2 in the time array f2. However, the transmission time 0.2 falls in the time range [0.18, 0.22], and the time array corresponding to the time range [0.18, 0.22] is the time array f3. Therefore, this embodiment places the transmission time 0.2 in the time array f3.

[0082] It can be understood that the slave regards the transmission time “0.2” as a 4-bit transmission time, and therefore places the transmission time “0.2” in the time array f3.

[0083] S23: Determine, from among the multiple time arrays, a time array that satisfies the array screening condition as a target time array.

[0084] In this step, the array screening condition is a condition used to screen out the target time array.

[0085] In some embodiments, before determining the target time array, the baud rate determination method further includes the following steps: when it is detected that the slave meets the data stop sampling condition, the step of determining the time array that meets the array screening condition in multiple time arrays as the target time array is entered. When it is detected that the slave does not meet the data stop sampling condition, the transmission time when the specified edge signal of the communication data appears for a preset number of times continues to be obtained.

[0086] Detecting that the slave meets the data stop sampling condition includes the following steps:

[0087] A1: Determine the time when the specified edge signal appears for the i-th time in the communication data as the start time and the current time, where i is an integer greater than 0.

[0088] A2: Calculate the time interval between the current time and the start time.

[0089] A3: Determine whether the communication data has the i+1th specified edge signal.

[0090] A4: If it does not appear, determine whether the time interval is greater than the preset time threshold. If it is greater, enter the step of determining the time array that meets the array screening condition as the target time array among multiple time arrays. If it is less, return to the step of determining whether the communication data has the i+1th specified edge signal.

[0091] A5: If it occurs, assign i=i+1, and return to the step of determining the time when the specified edge signal appears for the i-th time in the communication data as the starting time.

[0092] In A1, i is less than or equal to n, where i can be 1 or 2, etc.

[0093] Determining the time when the designated edge signal appears for the i-th time in the communication data as the start time includes: when it is detected that the designated edge signal appears for the i-th time in the communication data, starting the timer to start the timing operation and recording the start time.

[0094] For example, the preset number is 2, and the designated edge signal is a rising edge signal. When the rising edge signal appears for the first time in the communication data, the slave starts the timer to record the time when the rising edge signal appears for the first time as the starting time t1.

[0095] In A2, the time interval is the difference between the current time and the start time, for example, the time interval Δt=tp-t1, where tp is the current time.

[0096] In A3, the slave continuously detects whether the communication data has the i+1th rising edge signal in the rising edge capture mode.

[0097] In A4, the preset time threshold can be customized by the designer based on experience, for example, the preset time threshold is 0.3ms, 0.4ms, 0.5ms, or 1ms.

[0098] When the communication data does not have the i+1th designated edge signal, the slave continues to determine whether the time interval is greater than the preset time threshold. If it is greater, it means that the slave has not detected the i+1th designated edge signal for a long time since it detected the designated edge signal for the i-th time. This means that the data bits corresponding to the time interval Δt are sufficient. When the data bits are relatively large, the time error will also increase with the increase in the number of bits.

[0099] Since baud rate = 1 bit / 1 bit transmission time = 1 bit / (ty / k), ty is the transmission time of k bits. As mentioned above, ty can be regarded as the time composed of k bits of transmission time. Since there is an error between the transmission time of a single bit and the real time of a single bit, then the ty of k bits is equivalent to "including" the error of k bits, and the error of the transmission time ty will be relatively large. If the baud rate is calculated according to the formula baud rate = 1 bit / (ty / k), it is easy to make the calculated baud rate have a large error with the real baud rate. Therefore, this embodiment sets a preset time threshold. When the time interval is greater than the preset time threshold, even if the subsequent slave detects the i+1th instruction The slave will not include the time between the i+1th designated edge signal and the i-th designated edge signal into the transmission time, that is, it will not consider the time between the i+1th designated edge signal and the i-th designated edge signal. Therefore, in this embodiment, when the time interval is greater than the preset time threshold, the slave does not need to wait for the detection of the i+1th designated edge signal, and directly enters the step of determining the target time array, that is, directly starts calculating the baud rate with the existing transmission time, which can avoid the interference of large errors and improve the accuracy and reliability of the baud rate.

[0100] When the communication data does not have the designated edge signal for the (i+1)th time, and the time interval is less than the preset time threshold, the slave needs to continue to determine whether the communication data has the designated edge signal for the (i+1)th time.

[0101] In A5, since the communication data has the designated edge signal for the i+1th time, this embodiment assigns i=i+1 and continues to determine the time when the communication data has the designated edge signal for the i-th time.

[0102] For example, i=1, this embodiment determines the time when the specified edge signal appears for the first time in the communication data as the starting time, then calculates the time interval between the current time and the starting time, and then determines whether the communication data appears the specified edge signal for the i+1th time. If the specified edge signal appears for the second time, this embodiment can set i=i+1=1+1=2, and continue to use the time when the specified edge signal appears for the second time in the communication data as the starting time, and then repeat the above steps.

[0103] S24: Determine a baud rate according to at least one transmission time included in the target time array.

[0104] In this step, in some embodiments, determining the baud rate based on at least one transmission time included in the target time array includes: calculating the average value of at least one transmission time included in the target time array to obtain the average time, determining the designated bit corresponding to the target time array, and determining the baud rate based on the baud rate formula, the average time and the designated bit.

[0105] In some embodiments, determining the baud rate based on at least one transmission time included in the target time array includes: selecting a transmission time that satisfies a median condition from at least one transmission time in the target time array as the target transmission time, determining a designated bit corresponding to the target time array, and determining the baud rate based on the designated bit and the target transmission time.

[0106] For example, the target time array is the time array f1, and the designated bit of the time array f1 is 2, wherein the time array f1 includes the transmission time c1, the transmission time c2, and the transmission time c3, wherein the transmission times of the time array f1 are arranged in order from small to large, namely: c2, c1, c3. Since the transmission time c1 satisfies the median condition, the transmission time c1 is the target transmission time. This embodiment calculates the baud rate according to the baud rate formula, wherein the baud rate = 1 bit / (ty / k) = 1 / (c1 / 2) = 2 / c1. Since this embodiment selects the transmission time that satisfies the median condition as the target transmission time, the interference of too small transmission time or too large transmission time is excluded, so that the calculated baud rate is relatively accurate and reliable.

[0107] In general, the present embodiment uses the preset number of designated edge signals as the sampling standard, and can effectively intercept the transmission time corresponding to at least one complete bit of data, laying the foundation for the subsequent use of the transmission time and at least one complete bit of data to derive the baud rate. In addition, the present embodiment can use at least one transmission time included in the target time array to comprehensively determine the baud rate, so the baud rate obtained is more reliable and accurate. At the same time, the present embodiment does not need to detect the data packet header in the above process of determining the baud rate, and can adaptively determine the baud rate. Therefore, the present embodiment can adaptively determine the baud rate in various communication protocol scenarios, and has a high adaptive ability.

[0108] It is understandable that in the above process of determining the baud rate, the present embodiment does not need to rely on the detection of fixed codes. One frame of communication data can be detected multiple times or dozens of times, which can increase the number of samples of the transmission time, and the subsequently calculated baud rate will be more accurate, reliable, and more resistant to interference. It is also understandable that the present embodiment can reduce the reliance on the stability of the main frequency of the chip and has strong anti-interference ability. It is also understandable that the above process of determining the baud rate does not need to switch multiple states or modes to detect fixed codes such as header codes. The entire frame of communication data can be used to calculate the baud rate, which can reduce the time loss caused by switching states or modes and improve the calculation efficiency of the baud rate.

[0109] After the baud rate is determined, the present embodiment can also verify whether the determined baud rate meets the communication requirements. In some embodiments, the baud rate determination method further includes: sending serial data to the host based on the baud rate so that the host returns communication feedback information, if the communication feedback information is communication success information, communicating with the host based on the baud rate, if the communication feedback information is communication failure information, continuing to determine the baud rate.

[0110] For example, after determining the baud rate, the slave enters the serial port mode and sends serial data to the host based on the baud rate, wherein the host receives the serial data at the baud rate. After receiving the serial data, the host verifies whether the serial data is correct. If correct, the host feeds back communication success information to the slave. After the slave receives the communication success information, it can subsequently communicate with the host based on the baud rate. If incorrect, the host feeds back communication failure information to the slave. After the slave receives the communication failure information, the slave needs to continue to determine the baud rate. The above approach can verify the accuracy of the baud rate and improve the communication reliability between the host and the slave.

[0111] In some embodiments, each time array is configured with a priority, and determining a time array that meets the array screening condition among multiple time arrays as a target time array includes: determining a time array with the highest priority among multiple time arrays as the target time array.

[0112] For example, see Table 3:

[0113] Table 3

[0114] Priority Specified bit Time Array Time Range 1 2 f1 [0.09,0.11] 2 3 f2 [0.135,0.165] 3 4 f3 [0.18,0.22] 4 5 f4 [0.225,0.275]

[0115] As shown in Table 3, the priorities of the time arrays f1 to f4 are sorted in order of priority from high to low, as follows: f1, f2, f3, f4. In Table 3, the priority of the time array f1 is the highest priority.

[0116] As mentioned above, each time array is used to collect the transmission time of a specified bit of data. For example, time array f1 is used to collect the transmission time corresponding to 2 bits of data, time array f2 is used to collect the transmission time corresponding to 3 bits of data, time array f3 is used to collect the transmission time corresponding to 4 bits of data, and time array f4 is used to collect the transmission time corresponding to 5 bits of data.

[0117] When the designated bit of the data collected by the time array is smaller, the priority of the time array is higher, and when the designated bit of the data collected by the time array is larger, the priority of the time array is lower.

[0118] The larger the designated bit of the data collected by the time array, the larger the transmission time corresponding to the data collected by the time array, and the larger the "time error" contained in the transmission time. Therefore, this embodiment also matches the time array with a lower priority. The smaller the designated bit of the data collected by the time array, the smaller the transmission time corresponding to the data collected by the time array, and the smaller the "time error" contained in the transmission time. Therefore, this embodiment also matches the time array with a higher priority. As shown in Table 3, since the priority of time array f1 is the highest priority, this embodiment selects time array f1 as the target time array.

[0119] In some embodiments, determining a time array with the highest priority among multiple time arrays as a target time array includes: determining whether the time array with the highest priority is an empty array, where an empty array is a time array that does not contain a transmission time; if so, lowering the priority of the time array with the highest priority, and re-determining a time array with the highest priority among multiple time arrays as the target time array; if not, determining the time array with the highest priority as the target time array.

[0120] Lowering the priority of the highest priority time array includes setting the priority of the highest priority time array to the lowest priority.

[0121] In this embodiment, the priority "1" of the time array f1 is reduced to the priority "5". At this time, the priorities of the various time arrays are as shown in Table 4:

[0122] Table 4

[0123] Priority Specified bit Time Array Time Range 2 3 f2 [0.135,0.165] 3 4 f3 [0.18,0.22] 4 5 f4 [0.225,0.275] 5 2 f1 [0.09,0.11]

[0124] As shown in Table 4, the priorities of the time arrays f1 to f4 are sorted in order of priority from high to low, as follows: f2, f3, f4, f1. In Table 4, the priority of the time array f2 is the highest priority.

[0125] In some scenarios, there may be occasional situations where the time array does not contain any transmission time, and this situation may also occur in the time array with the highest priority. For example, the slave does not sample the transmission time to fall within the time range [0.09, 0.11], so the time array f1 does not contain any transmission time, and the time array f1 is an empty array. In order to ensure that the baud rate can be reliably calculated, this embodiment needs to lower the priority of the time array f1, and then re-determine the time array with the highest priority among multiple time arrays as the target time array.

[0126] As shown in Table 4, the priority of time array f2 is the highest priority, so time array f2 is the target time array. If time array f2 does not place any transmission time, time array f2 is an empty array. In this embodiment, the priority "2" of time array f2 is reduced to priority "6", and then the time array with the highest priority among multiple time arrays is re-determined as the target time array, and so on.

[0127] This embodiment determines whether the time array with the highest priority is an empty array. If it is an empty array, the priority is readjusted and the target time array is re-determined. This ensures that the target time array found has a corresponding amount of transmission time to calculate the baud rate, thereby improving the reliability of the baud rate calculation.

[0128] It should be noted that, in each of the above-mentioned embodiments, there is not necessarily a certain order between the above-mentioned steps. A person skilled in the art can understand, based on the description of the embodiments of the present invention, that in different embodiments, the above-mentioned steps may have different execution orders, that is, they may be executed in parallel, may be executed interchangeably, and so on.

[0129] As another aspect of the present invention, the present invention provides a baud rate determination device, wherein the baud rate determination device may be a software module, the software module including a plurality of instructions stored in a memory, the processor may access the memory, call the instructions for execution, and complete the baud rate determination method described in each of the above embodiments.

[0130] In some implementations, the baud rate determination device may also be constructed by hardware devices, for example, the baud rate determination device may be constructed by one or more chips, and each chip may work in coordination with each other to complete the baud rate determination method described in each of the above implementations. For another example, the baud rate determination device may also be constructed by various logic devices, such as a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISC Machine) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components.

[0131] See also Figure 3 The baud rate determination device 300 includes a data acquisition module 31 , a time classification module 32 , an array determination module 33 and a baud rate determination module 34 .

[0132] The data acquisition module 31 is used to acquire the communication data sent by the host and the transmission time when the communication data appears a preset number of designated edge signals, the communication data includes at least one bit of data, and the preset number of times is an integer greater than or equal to 2. The time classification module 32 is used to classify the transmission time into a time array that matches the transmission time. The array determination module 33 is used to determine a time array that meets the array screening condition in multiple time arrays as a target time array. The baud rate determination module 34 is used to determine the baud rate according to at least one transmission time included in the target time array.

[0133] This embodiment uses the preset number of designated edge signals as the sampling standard, and can effectively intercept the transmission time corresponding to at least one complete bit of data, laying the foundation for the subsequent use of the transmission time and at least one complete bit of data to derive the baud rate. In addition, this embodiment can use at least one transmission time included in the target time array to comprehensively determine the baud rate, and the baud rate obtained in this way is more reliable and accurate. At the same time, this embodiment does not need to detect the data packet header in the above process of determining the baud rate, and can adaptively determine the baud rate. Therefore, this embodiment can adaptively determine the baud rate in various communication protocol scenarios and has a high adaptive ability.

[0134] In some embodiments, the data acquisition module 31 is specifically used to: determine the first time when the specified edge signal appears for the first time in the communication data, determine the second time when the specified edge signal appears for the nth time in the communication data, where n is equal to a preset number of times, calculate the difference between the second time and the first time, and obtain the transmission time.

[0135] In some embodiments, n is 2.

[0136] In some embodiments, the designated edge signal is a rising edge signal.

[0137] In some embodiments, each time array is configured with a preset time range, and the time classification module 32 is used to: traverse each time array to determine the time range in which the transmission time falls as the reference time range, and classify the transmission time into the time array corresponding to the reference time range.

[0138] In some embodiments, each time array is configured with a priority, and the array determination module 33 is specifically used to: determine the time array with the highest priority among multiple time arrays as the target time array.

[0139] In some embodiments, each time array is used to collect the transmission time of the specified bit of data. When the specified bit of the data collected by the time array is smaller, the priority of the time array is higher, and when the specified bit of the data collected by the time array is larger, the priority of the time array is lower.

[0140] In some embodiments, the array determination module 33 is also specifically used to: determine whether the highest priority time array is an empty array, where an empty array is a time array that does not contain a transmission time. If so, lower the priority of the highest priority time array, and re-determine the time array with the highest priority among multiple time arrays as the target time array. If not, determine the highest priority time array as the target time array.

[0141] In some embodiments, the baud rate determination module 34 is specifically used to: select a transmission time that meets the median condition from at least one transmission time in the target time array as the target transmission time, determine a designated bit corresponding to the target time array, and determine the baud rate based on the designated bit and the target transmission time.

[0142] In some embodiments, before determining the target time array, refer to Figure 4 The baud rate determination device 300 also includes a delay judgment module 35, which is used to: determine the time when the communication data appears the i-th designated edge signal as the start time and the current time, i is an integer greater than 0, calculate the time interval between the current time and the start time, and determine whether the communication data appears the i+1th designated edge signal. If not, determine whether the time interval is greater than the preset time threshold. If greater, determine the time array that meets the array screening condition in multiple time arrays as the target time array. If less, determine whether the communication data appears the i+1th designated edge signal. If it appears, assign i=i+1, and determine the time when the communication data appears the i-th designated edge signal as the start time.

[0143] In some embodiments, please refer to Figure 4 The baud rate determination device 300 also includes a baud rate verification module 36, which is specifically used to: send serial data to the host based on the baud rate so that the host returns communication feedback information, if the communication feedback information is communication success information, communicate with the host based on the baud rate, if the communication feedback information is communication failure information, continue to determine the baud rate.

[0144] It should be noted that the baud rate determination device can execute the baud rate determination method provided in the embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not fully described in the embodiment of the baud rate determination device, please refer to the baud rate determination method provided in the embodiment of the present invention.

[0145] See also Figure 5 , Figure 5 The following is a schematic diagram of a circuit structure of an electronic device provided by an embodiment of the present invention. Figure 5 As shown, the electronic device 500 includes one or more processors 51 and a memory 52. Figure 5A processor 51 is taken as an example.

[0146] The processor 51 and the memory 52 may be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.

[0147] The memory 52 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules corresponding to the baud rate determination method in the embodiment of the present invention. The processor 51 executes various functional applications and data processing of the baud rate determination device by running the non-volatile software programs, instructions and modules stored in the memory 52, that is, realizes the baud rate determination method provided in the above method embodiment and the functions of each module or unit in the above device embodiment.

[0148] The memory 52 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 52 may optionally include a memory remotely arranged relative to the processor 51, and these remote memories may be connected to the processor 51 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0149] The program instructions / modules are stored in the memory 52, and when executed by the one or more processors 51, the baud rate determination method in any of the above method embodiments is executed.

[0150] An embodiment of the present invention further provides a non-volatile computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are executed by one or more processors, such as Figure 5 A processor 51 in the embodiment may enable the one or more processors to execute the baud rate determination method in any of the above method embodiments.

[0151] An embodiment of the present invention further provides a computer program product, which includes a computer program stored on a non-volatile computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by an electronic device, the electronic device executes any one of the baud rate determination methods.

[0152] The above described device or equipment embodiments are merely illustrative, wherein the unit modules described as separate components may or may not be physically separated, and the components displayed as module units may or may not be physical units, that is, they may be located in one place, or may be distributed on multiple network module units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.

[0153] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0154] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. Under the concept of the present invention, the technical features in the above embodiments or different embodiments may also be combined, the steps may be implemented in any order, and there are many other changes in different aspects of the present invention as described above, which are not provided in detail for the sake of simplicity. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they may still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A baud rate determination method, characterized in that: include: Acquire communication data sent by the host and the transmission time when the communication data has a specified edge signal for a preset number of times, wherein the communication data includes at least one bit of data, and the preset number of times is an integer greater than or equal to 2; sorting the transmission time into a time array matching the transmission time; Determine a time array that meets an array screening condition as a target time array among the multiple time arrays; The baud rate is determined according to at least one transmission time included in the target time array.

2. The method according to claim 1, characterized in that The step of obtaining the transmission time of the communication data when the specified edge signal appears a preset number of times includes: Determine the first time when the specified edge signal appears for the first time in the communication data; Determine the second time when the specified edge signal appears for the nth time in the communication data, where n is equal to a preset number of times; The difference between the second time and the first time is calculated to obtain the transmission time.

3. The method according to claim 2, characterized in that The n is 2.

4. The method according to claim 1, characterized in that: The designated edge signal is a rising edge signal.

5. The method according to claim 1, characterized in that Each of the time arrays is configured with a preset time range, and the classifying of the transmission time into a time array matching the transmission time comprises: Traversing each of the time arrays to determine a time range within which the transmission time falls as a reference time range; The transmission times are sorted into a time array corresponding to the reference time range.

6. The method according to claim 1, characterized in that Each of the time arrays is configured with a priority, and determining a time array that meets an array screening condition among the multiple time arrays as a target time array includes: determining a time array with a highest priority among the multiple time arrays as a target time array.

7. The method according to claim 6, characterized in that Each of the time arrays is used to collect the transmission time of a specified bit of data; When the designated bit of the data collected by the time array is smaller, the priority of the time array is higher, and when the designated bit of the data collected by the time array is larger, the priority of the time array is lower.

8. The method according to claim 6, characterized in that The step of determining a time array with the highest priority among the multiple time arrays as a target time array comprises: Determine whether the highest priority time array is an empty array, where the empty array is a time array that does not include a transmission time; If yes, lower the priority of the time array with the highest priority, and re-determine the time array with the highest priority among the multiple time arrays as the target time array; If not, the time array with the highest priority is determined as the target time array.

9. The method according to claim 1, characterized in that: Determining the baud rate according to at least one transmission time included in the target time array comprises: Selecting a transmission time satisfying a median condition from at least one transmission time in the target time array as a target transmission time; Determining a designated bit corresponding to the target time array; A baud rate is determined according to the designated bits and the target transmission time.

10. The method according to claim 1, characterized in that Before determining the target time array, also include: Determine the time when the specified edge signal appears for the i-th time in the communication data as the start time and the current time, where i is an integer greater than 0; Calculate the time interval between the current time and the start time; Determine whether the communication data has an i+1th designated edge signal; If not, determine whether the time interval is greater than a preset time threshold; if so, enter the step of determining a time array that satisfies the array screening condition as a target time array among the multiple time arrays; if less than, return to the step of determining whether the communication data has the i+1th specified edge signal; If it occurs, assign i=i+1, and return to the step of determining the time when the designated edge signal appears for the i-th time in the communication data as the starting time.

11. The method according to any one of claims 1 to 10, characterized in that: Also includes: Sending serial data to the host based on the baud rate so that the host returns communication feedback information; If the communication feedback information is communication success information, communicating with the host based on the baud rate; If the communication feedback information is communication failure information, continue to determine the baud rate.

12. A non-volatile readable storage medium, characterized in that: Computer executable instructions are stored, and the computer executable instructions are used to enable the electronic device to execute the baud rate determination method according to any one of claims 1 to 11.

13. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the baud rate determination method according to any one of claims 1 to 11.

Citation Information

Cited By

  • RS485 chip transmission parameter confirmation method and device

    CN120216434A