A baud rate adjustment method and device, electronic equipment and storage medium

By obtaining the current and previous ambient temperatures of the air conditioning equipment, calculating the coarse baud rate adjustment value and clock frequency, and adjusting the baud rate of UART communication, the problem of baud rate error caused by temperature changes is solved, ensuring the accuracy and stability of communication.

CN119788241BActive Publication Date: 2025-11-28GREE ELECTRIC APPLIANCE INC OF ZHUHAI +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411772057.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-11-28
Estimated Expiration
2044-12-04

AI Technical Summary

Technical Problem

In UART communication of air conditioning equipment, the influence of ambient temperature on the RC oscillator causes the baud rate to deviate from the actual requirement by a certain range at high or low temperatures, resulting in communication reception or transmission failure.

Method used

By acquiring the current and previous ambient temperatures of the device, the coarse adjustment value of the current baud rate, the clock frequency, and the number of samplings for the communication rate are determined. Based on these parameters, the target baud rate is calculated, and the current baud rate is adjusted to the target baud rate to adapt to temperature changes.

Benefits of technology

Adjusting the baud rate promptly when the temperature changes prevents communication reception or transmission failures, ensuring the accuracy and stability of communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119788241B_ABST
    Figure CN119788241B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a baud rate adjustment method and device, electronic equipment and storage medium, the method comprising: obtaining the current environment temperature of the device and the environment temperature of the last time; when the temperature difference between the current environment temperature and the environment temperature of the last time is greater than a preset temperature, determining the current baud rate coarse adjustment value, the current clock frequency and the sampling number of the communication rate of the device; determining the target baud rate according to the current baud rate coarse adjustment value, the current clock frequency and the sampling number; determining the current baud rate and adjusting the current baud rate to the target baud rate. Thus, when the current temperature environment changes, the target baud rate can be determined and the current baud rate adjusted in time through the current baud rate coarse adjustment value, the current clock frequency and the sampling number, avoiding the phenomenon that the communication receiving or sending fails due to the error between the current baud rate and the actual requirement exceeding a certain range.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of communication, in particular to a baud rate adjustment method, a baud rate adjustment device, an electronic device and a computer readable storage medium. BACKGROUND

[0002] With the development of smart home, air conditioning equipment has become an essential household appliance in people's life. When the indoor unit and the outdoor unit of the air conditioning equipment communicate, they generally communicate based on the UART (Universal Asynchronous Receiver / Transmitter) interface. The internal chip of the air conditioning equipment generally uses a crystal oscillator or a ceramic oscillator as a clock source. Currently, the crystal oscillator inside the chip is mostly an RC (Resistor-Capacitor) oscillator. However, due to the significant influence of environmental temperature on the RC oscillator, when the clock corresponding to the UART interface uses the RC oscillator, it may cause the baud rate of the UART to exceed a certain range of error from the actual requirement when working at high or low temperature, thereby causing the phenomenon of communication reception or transmission failure. SUMMARY

[0003] In view of the above problems, the present application embodiments are proposed to provide a baud rate adjustment method, a baud rate adjustment device, an electronic device and a computer readable storage medium that overcome the above problems or at least partially solve the above problems.

[0004] To solve the above problems, the present application embodiments disclose a baud rate adjustment method, which comprises:

[0005] obtaining a current environmental temperature of a device and an environmental temperature at a previous time;

[0006] when the temperature difference between the current environmental temperature and the environmental temperature at the previous time is greater than a preset temperature, determining a current baud rate coarse adjustment value, a current clock frequency and a sampling number of a communication rate of the device;

[0007] determining a target baud rate according to the current baud rate coarse adjustment value, the current clock frequency and the sampling number;

[0008] determining a current baud rate, and adjusting the current baud rate to the target baud rate.

[0009] Optionally, the determination of the current baud rate coarse adjustment value, the current clock frequency and the sampling number of the communication rate of the device comprises:

[0010] obtaining a current clock frequency, a sampling number of a communication rate of the device, a clock frequency at a previous time and a baud rate at a previous time;

[0011] determining a baud rate coarse adjustment value of the last time according to the sampling number, the clock frequency of the last time and the baud rate of the last time;

[0012] determining a current baud rate coarse adjustment value according to the baud rate coarse adjustment value of the last time.

[0013] Optionally, the determining the current baud rate coarse adjustment value according to the baud rate coarse adjustment value of the last time comprises:

[0014] determining the current baud rate coarse adjustment value according to the clock frequency of the last time, the current environment temperature, the sampling number and the baud rate of the last time.

[0015] Optionally, the determining the current baud rate, and adjusting the current baud rate to a target baud rate, comprises:

[0016] determining a current baud rate according to the baud rate coarse adjustment value of the last time, the current clock frequency and the sampling number;

[0017] adjusting the current baud rate to a target baud rate.

[0018] Optionally, the determining the baud rate coarse adjustment value of the last time according to the sampling number, the clock frequency of the last time and the baud rate of the last time comprises:

[0019] the baud rate coarse adjustment value of the last time is calculated according to the following formula:

[0020] Br1=UC1 / (STV*BC1)

[0021] Wherein, the Br1 is the baud rate of the last time; the UC1 is the clock frequency of the last time; the STV is the sampling number; the BC1 is the baud rate coarse adjustment value of the last time.

[0022] Optionally, the determining the current baud rate according to the baud rate coarse adjustment value of the last time, the current clock frequency and the sampling number comprises:

[0023] the current baud rate is calculated according to the following formula:

[0024] Br2=UC2 / (STV*BC1)

[0025] Wherein, the Br2 is the current baud rate; the UC2 is the current clock frequency; the STV is the sampling number; the BC1 is the baud rate coarse adjustment value of the last time.

[0026] Optionally, the determining the current baud rate coarse adjustment value according to the clock frequency of the last time, the current environment temperature, the sampling number and the baud rate of the last time comprises:

[0027] The current baud rate coarse adjustment value is calculated according to the following formula:

[0028] BC2=UC1(1+N*Temp-M) / (STV*Br1)

[0029] Wherein, the BC2 is the current baud rate coarse adjustment value; the UC1 is the clock frequency of the last time; the Temp is the current environment temperature; the STV is the sampling number; the Br1 is the baud rate of the last time; the N is a first preset parameter; and the M is a second preset parameter.

[0030] Optionally, the determining the target baud rate according to the current baud rate coarse adjustment value, the current clock frequency and the sampling number comprises:

[0031] The target baud rate is calculated according to the following formula:

[0032] Br2=UC2 / (STV*BC2)

[0033] Wherein, the Br2 is the target baud rate; the UC2 is the current clock frequency; the STV is the sampling number; and the BC2 is the current baud rate coarse adjustment value.

[0034] The embodiment of the application further discloses a baud rate adjustment device, the device comprises:

[0035] The acquisition module is used for acquiring the current environment temperature and the environment temperature of the last time.

[0036] The first determination module is used for determining the current baud rate coarse adjustment value, the current clock frequency and the sampling number of the communication rate of the device when the temperature difference between the current environment temperature and the environment temperature of the last time is greater than a preset temperature.

[0037] The second determination module is used for determining the target baud rate according to the current baud rate coarse adjustment value, the current clock frequency and the sampling number.

[0038] The adjustment module is used for determining the current baud rate and adjusting the current baud rate to the target baud rate.

[0039] Optionally, the first determination module comprises:

[0040] The acquisition sub-module is used for acquiring the current clock frequency, the sampling number of the communication rate of the device, the clock frequency of the last time and the baud rate of the last time.

[0041] a first determining sub-module, configured to determine a baud rate coarse adjustment value at a previous moment according to the sampling number, a clock frequency at the previous moment and a baud rate at the previous moment;

[0042] a second determining sub-module, configured to determine a current baud rate coarse adjustment value according to the baud rate coarse adjustment value at the previous moment.

[0043] Optionally, the second determining sub-module comprises:

[0044] a determining unit, configured to determine the current baud rate coarse adjustment value according to the clock frequency at the previous moment, the current environment temperature, the sampling number and the baud rate at the previous moment.

[0045] Optionally, the adjusting module comprises:

[0046] a third determining sub-module, configured to determine a current baud rate according to the baud rate coarse adjustment value at the previous moment, the current clock frequency and the sampling number.

[0047] an adjusting sub-module, configured to adjust the current baud rate to a target baud rate.

[0048] Optionally, the first determining sub-module comprises:

[0049] a first calculating unit, configured to calculate the baud rate coarse adjustment value at the previous moment according to the following formula:

[0050] Br1 = UC1 / (STV * BC1)

[0051] wherein the Br1 is the baud rate at the previous moment; the UC1 is the clock frequency at the previous moment; the STV is the sampling number; and the BC1 is the baud rate coarse adjustment value at the previous moment.

[0052] Optionally, the third determining sub-module comprises:

[0053] a second calculating unit, configured to calculate the current baud rate according to the following formula:

[0054] Br2 = UC2 / (STV * BC1)

[0055] wherein the Br2 is the current baud rate; the UC2 is the current clock frequency; the STV is the sampling number; and the BC1 is the baud rate coarse adjustment value at the previous moment.

[0056] Optionally, the determining unit comprises:

[0057] a calculating sub-unit, configured to calculate the current baud rate coarse adjustment value according to the following formula:

[0058] BC2 = UC1 (1 + N * Temp - M) / (STV * Br1)

[0059] Wherein, the BC2 is the current baud rate rough adjustment value; the UC1 is the clock frequency of the last moment; the Temp is the current environment temperature; the STV is the sampling times; the Br1 is the baud rate of the last moment; the N is the first preset parameter; the M is the second preset parameter.

[0060] Optionally, the second determining module comprises:

[0061] A third calculating unit is configured to calculate the target baud rate according to the following formula:

[0062] Br2 = UC2 / (STV * BC2)

[0063] Wherein, the Br2 is the target baud rate; the UC2 is the current clock frequency; the STV is the sampling times; the BC2 is the current baud rate rough adjustment value.

[0064] The application further discloses an electronic device, which comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the baud rate adjustment method when executing the computer program.

[0065] The application further discloses a computer readable storage medium, which stores a computer program, and the computer program implements the steps of the baud rate adjustment method when executed by a processor.

[0066] The application has the following advantages:

[0067] In the embodiment of the application, the current environment temperature of the device and the environment temperature of the last moment are acquired first, and when the difference between the current environment temperature and the environment temperature of the last moment is greater than a preset temperature, the current baud rate needs to be adjusted, at this time, the current baud rate rough adjustment value, the current clock frequency and the sampling times of the communication rate of the device are determined, then the target baud rate is determined according to the current baud rate rough adjustment value, the current clock frequency and the sampling times, and finally the current baud rate is determined, the current baud rate is adjusted to the target baud rate, so that when the current temperature environment changes, the target baud rate can be determined and the current baud rate can be adjusted in time through the current baud rate rough adjustment value, the current clock frequency and the sampling times, and the phenomenon that the communication receiving or sending fails due to the error between the current baud rate and the actual requirement exceeding a certain range is avoided. BRIEF DESCRIPTION OF DRAWINGS

[0068] Figure 1is a step flow chart of a baud rate adjustment method provided by an embodiment of the present application;

[0069] Figure 2 is a step flow chart of another baud rate adjustment method provided by an embodiment of the present application;

[0070] Figure 3 is a structural block diagram of a baud rate adjustment device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0071] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the present application will be further described in detail below with reference to the drawings and specific embodiments.

[0072] In related technologies, because the environment temperature has a greater impact on the oscillator, it can cause the error of the baud rate of the UART and the actual requirement to exceed a certain range when working at high or low temperature, thereby causing the phenomenon of communication receiving or sending failure. In order to solve the above technical problems, the present application provides a baud rate adjustment method, first obtains the current environment temperature of the device and the environment temperature at the last time, when the difference between the current environment temperature and the environment temperature at the last time is greater than a preset temperature, the current baud rate needs to be adjusted, at this time, the current baud rate coarse adjustment value, the current clock frequency and the sampling number of the communication rate of the device can be determined, then the target baud rate is determined according to the current baud rate coarse adjustment value, the current clock frequency and the sampling number, finally the current baud rate is determined, and the current baud rate is adjusted to the target baud rate, so that when the current temperature environment changes, the target baud rate can be determined and the current baud rate can be adjusted in time through the current baud rate coarse adjustment value, the current clock frequency and the sampling number, avoiding the phenomenon of communication receiving or sending failure caused by the error of the current baud rate and the actual requirement exceeding a certain range.

[0073] The influence of environment temperature on baud rate (Baud Rate) mainly reflects on the frequency stability of the oscillator. The frequency of the oscillator can change with the change of temperature, thereby affecting the clock frequency of the system, and further affecting the baud rate. The influence of temperature on baud rate is clock frequency change: temperature change will cause the frequency of the oscillator to change, thereby affecting the clock frequency of the system. Since the baud rate is calculated based on the clock frequency, the change of the clock frequency will cause the change of the baud rate. Communication error: the change of the baud rate will cause the increase of the communication error, especially in asynchronous communication, the sending and receiving devices must use the same baud rate to communicate correctly. System stability: temperature change will affect the stability of the system, especially in industrial environments or automotive electronics with large temperature changes.

[0074] Reference Figure 1, a step flow chart of a baud rate adjustment method provided by an embodiment of the present application is shown, and the method can specifically include the following steps:

[0075] In step 101, the current environment temperature of the device and the environment temperature at the last time are obtained.

[0076] In the embodiment of the present application, the device can be a device using a UART interface for communication, and the clock corresponding to the UART interface adopts an oscillator, for example, an air conditioner. When the device is in operation, the current environment temperature of the device and the environment temperature at the last time can be obtained in real time. In the present application, the environment temperature at the last time can be the environment temperature corresponding to the last time when the baud rate is adjusted.

[0077] In the present application, a temperature sensor and an analog-to-digital converter can be installed on the device. When the device is running, the chip in the device can read the temperature on the temperature sensor in real time through the analog-to-digital converter, and then obtain the current environment temperature of the device and the environment temperature at the last time according to the corresponding conversion.

[0078] In the present application, UART is a widely used serial communication interface. It is used for full-duplex communication between two devices, and is usually used for short-distance communication, such as communication between a computer and peripheral devices (such as modems, printers, microcontrollers, etc.). The main features of UART are as follows: asynchronous communication: UART communication does not require a clock signal to synchronize data transmission. Instead, it relies on the start bit and stop bit contained in the data frame to synchronize the receiving device. Full duplex: UART can send and receive data at the same time. Point-to-point communication: usually used for direct communication between two devices, rather than a multi-device network. Simple hardware interface: usually only two lines (transmission line and reception line), and an optional ground line are required. The data transmission rate in UART communication is called baud rate. The sending and receiving devices must use the same baud rate to communicate correctly.

[0079] In the present application, baud rate refers to the number of symbols transmitted per second, commonly used in serial communication. Baud rate is an important parameter to measure the data transmission rate, which determines how many symbols can be transmitted per second. In UART communication, baud rate is particularly important, as it determines the speed and accuracy of data transmission. Baud rate has the following characteristics: data transmission rate: baud rate determines how many symbols can be transmitted per second. Symbols can be bits, characters or other data units. Synchronization: in asynchronous communication, the sending and receiving devices must use the same baud rate to communicate correctly. Error rate: the choice of baud rate will affect the error rate of communication. Higher baud rate may increase the error rate, especially in noisy environments. Selecting the appropriate baud rate requires considering the following factors: communication distance: longer communication distance may require lower baud rate to reduce the impact of signal attenuation and noise. Data volume: larger data volume may require higher baud rate to improve transmission speed. Noise environment: in noisy environment, lower baud rate can reduce the error rate. Device compatibility: ensure that the sending and receiving devices support the same baud rate.

[0080] Step 102, when the temperature difference between the current environment temperature and the environment temperature at the last time is greater than the preset temperature, the current baud rate coarse adjustment value, the current clock frequency and the sampling number of the communication rate of the device are determined.

[0081] In the embodiment of the present application, after obtaining the current environment temperature and the environment temperature at the last time of the device, it can be judged whether the temperature difference between the current environment temperature and the environment temperature at the last time is greater than the preset temperature, for example, the preset temperature is 10℃, when the temperature difference between the current environment temperature and the environment temperature at the last time is greater than 10℃, it proves that the baud rate needs to be adjusted, at this time, the current baud rate coarse adjustment value, the current clock frequency and the sampling number of the communication rate of the device can be determined.

[0082] In the present application, the baud rate coarse adjustment value refers to the parameter value of the baud rate coarse adjustment in serial communication in order to adapt to different communication requirements or compensate for the change of system clock frequency.

[0083] In the present application, the clock frequency refers to the frequency of the periodic signal generated by the oscillator, usually measured in Hertz (Hz). An oscillator is an electronic device that generates a stable periodic signal as the clock source of an electronic system. The clock frequency determines the operating speed, data transmission rate and timing accuracy of the system. The clock frequency of the oscillator needs to have high stability to ensure that the system can work normally under different environmental conditions (such as temperature changes, power fluctuations, etc.). The accuracy of the clock frequency determines the timing accuracy of the system and the accuracy of data transmission. High-precision clock frequency is particularly important for applications that require precise timing (such as communication systems, data acquisition systems). The clock frequency of the oscillator ranges widely, from a few hertz to several hundred megahertz, depending on the application requirements. The power consumption of the oscillator directly affects the overall power consumption of the system. Low-power oscillators are suitable for battery-powered devices.

[0084] In the present application, UART is a serial communication protocol, and the conventional data format is 1 bit start bit + 8 bit data bit + 1 bit check bit (or no check bit) + 1 bit stop bit. The communication parties can communicate according to the agreed baud rate (without external clock signal), and the chip receives and processes according to 16 times the communication rate, that is, 16 times per bit of data sampling.

[0085] In an embodiment, determining the current baud rate coarse adjustment value, the current clock frequency, and the sampling number of the communication rate for the device comprises: obtaining the current clock frequency, the sampling number of the communication rate for the device, the clock frequency at the last moment, and the baud rate at the last moment; determining the baud rate coarse adjustment value at the last moment according to the sampling number, the clock frequency at the last moment, and the baud rate at the last moment; and determining the current baud rate coarse adjustment value according to the baud rate coarse adjustment value at the last moment.

[0086] Specifically, in the present application, the current clock frequency and the sampling number of the communication rate for the device can be obtained directly, and the baud rate coarse adjustment value at the last moment needs to be obtained first. The sampling number, the clock frequency at the last moment, and the baud rate at the last moment are obtained, then the baud rate coarse adjustment value at the last moment is determined according to the sampling number, the clock frequency at the last moment, and the baud rate at the last moment, and finally the current baud rate coarse adjustment value is determined according to the coarse adjustment value at the last moment.

[0087] In an embodiment, the baud rate coarse adjustment value at the last moment is determined according to the sampling number, the clock frequency at the last moment, and the baud rate at the last moment, comprising:

[0088] The baud rate coarse adjustment value at the last moment is calculated according to the following formula (1):

[0089] Br1=UC1 / (STV*BC1) Formula (1)

[0090] Wherein, Br1 is the baud rate of the last time; UC1 is the clock frequency of the last time; STV is the sampling number; and BC1 is the baud rate coarse adjustment value of the last time.

[0091] In an embodiment, determining the current baud rate coarse adjustment value according to the baud rate coarse adjustment value of the last time can include determining the current baud rate coarse adjustment value according to the clock frequency of the last time, the current ambient temperature, the sampling number and the baud rate of the last time.

[0092] In the present application, after the baud rate coarse adjustment value of the last time is determined, the current baud rate coarse adjustment value can be determined according to the clock frequency of the last time, the current ambient temperature, the sampling number and the baud rate of the last time.

[0093] In an embodiment, determining the current baud rate coarse adjustment value according to the clock frequency of the last time, the current ambient temperature, the sampling number and the baud rate of the last time includes:

[0094] The current baud rate coarse adjustment value is calculated according to the following formula (2):

[0095] BC2 = UC1 (1 + N*Temp - M) / (STV*Br1) Formula (2)

[0096] Wherein, BC2 is the current baud rate coarse adjustment value; UC1 is the clock frequency of the last time; Temp is the current ambient temperature; STV is the sampling number; Br1 is the baud rate of the last time; and N is the first preset parameter; and M is the second preset parameter.

[0097] In the present application, the first preset parameter N and the second preset parameter M can be determined by checking the frequency of the oscillator of the sample chip under a certain temperature range, and then counting the trend line and the linear equation, and then determining the error value of the ambient temperature and the actual temperature, so as to determine the specific values of the first preset parameter N and the second preset parameter M. In the present application, the specific value of the first preset parameter N can be 0.0002, and the specific value of the second preset parameter M can be 0.0055.

[0098] Step 103, determining a target baud rate according to the current baud rate coarse adjustment value, the current clock frequency and the sampling number.

[0099] In the embodiment of the present application, after the current baud rate coarse adjustment value, the current clock frequency and the sampling number are determined, the target baud rate can be determined according to the current baud rate coarse adjustment value, the current clock frequency and the sampling number.

[0100] In an embodiment, determining the target baud rate according to the current baud rate coarse adjustment value, the current clock frequency and the sampling number includes:

[0101] The target baud rate is calculated according to the following formula (3) :

[0102] Br2 = UC2 / (STV*BC2) Formula (3)

[0103] Wherein, Br2 is the target baud rate; UC2 is the current clock frequency; STV is the sampling number; BC2 is the current baud rate coarse adjustment value.

[0104] In step 104, the current baud rate is determined, and the current baud rate is adjusted to the target baud rate.

[0105] In the embodiment of the present application, after the target baud rate is determined, the current baud rate can be determined, and the current baud rate is adjusted to the target baud rate.

[0106] In an embodiment, the current baud rate is determined, and the current baud rate is adjusted to the target baud rate, which can include: determining the current baud rate according to the baud rate coarse adjustment value of the last moment, the current clock frequency and the sampling number; and adjusting the current baud rate to the target baud rate.

[0107] In the present application, the current baud rate can be calculated according to the baud rate coarse adjustment value of the last moment, the current clock frequency and the sampling number, and after the current baud rate is calculated, the current baud rate can be adjusted according to the target baud rate.

[0108] In an embodiment, the current baud rate is determined according to the baud rate coarse adjustment value of the last moment, the current clock frequency and the sampling number, which includes:

[0109] The current baud rate is calculated according to the following formula (4) :

[0110] Br2 = UC2 / (STV*BC1) Formula (4)

[0111] Wherein, Br2 is the current baud rate; UC2 is the current clock frequency; STV is the sampling number; BC1 is the baud rate coarse adjustment value of the last moment.

[0112] For better understanding of the embodiments of the present application, specific examples are given below. For example, the environment temperature at the last moment is 25℃, the clock frequency at the last moment is 8MHz, the baud rate at the last moment is 1200bps, and the sampling number is 16. Then, the baud rate coarse adjustment value BC1 at the last moment can be calculated according to the above formula (1) as 416.66, i.e. approximately equal to 416. When the environment temperature rises to 85℃, the current clock frequency is increased by 0.8% compared with the clock frequency at the last moment, i.e. the current environment temperature is 85℃, and the current clock frequency is 8.064MHz. At this moment, the current baud rate Br2 can be calculated according to formula (4) as 8064000 / (16*416)≈1211. When adjusting the current baud rate, the current baud rate coarse adjustment value can be calculated according to formula (2), wherein the first preset parameter N is 0.0002, and the second preset parameter M is 0.0055, i.e. BC2=8000000(1+0.0002*85-0.0055)(16*1200)≈421. Then, the target baud rate can be calculated according to formula (3) as Br2=8064000 / (16*421)≈1197. Finally, the current baud rate is adjusted to the target baud rate 1197, thereby completing the adjustment of the baud rate.

[0113] Referring to Figure 2 , a step flow chart of another baud rate adjustment method provided by the embodiments of the present application is shown. The current environment temperature and the environment temperature at the last moment of the device are obtained, and it is judged whether the temperature difference between the current environment temperature and the environment temperature at the last moment is greater than a preset temperature. When the temperature difference between the current environment temperature and the environment temperature at the last moment is not greater than the preset temperature, the current environment temperature and the environment temperature at the last moment of the device are continuously obtained. When the temperature difference between the current environment temperature and the environment temperature at the last moment is greater than the preset temperature, the current baud rate coarse adjustment value is determined according to a preset formula, the preset formula is formula (2) in the above embodiments. Then, the target baud rate is determined according to the current baud rate coarse adjustment value, the current clock frequency and the sampling number. Finally, the corresponding adjustment is performed according to the target baud rate.

[0114] In the embodiment of the present application, the current environment temperature of the device and the environment temperature at the last time are acquired; when the temperature difference between the current environment temperature and the environment temperature at the last time is greater than a preset temperature, the current baud rate coarse adjustment value, the current clock frequency and the sampling number of the communication rate of the device are determined; the target baud rate is determined according to the current baud rate coarse adjustment value, the current clock frequency and the sampling number; and the current baud rate is determined and adjusted to the target baud rate. Thus, when the current temperature environment changes, the target baud rate can be determined and the current baud rate adjusted in time through the current baud rate coarse adjustment value, the current clock frequency and the sampling number, so as to avoid the phenomenon that the communication receiving or sending fails due to the error between the current baud rate and the actual requirement exceeding a certain range.

[0115] It should be noted that, for the method embodiments, in order to simply describe, they are all expressed as a series of action combinations, but those skilled in the art should know that the embodiments of the present application are not limited by the action sequence described, because according to the embodiments of the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions involved are not necessarily the necessary of the embodiments of the present application.

[0116] Referring to Figure 3 , a structure block diagram of a baud rate adjustment device provided by the embodiment of the present application is shown, which can specifically include the following modules:

[0117] The acquisition module 301 is configured to acquire the current environment temperature of the device and the environment temperature at the last time.

[0118] The first determination module 302 is configured to determine the current baud rate coarse adjustment value, the current clock frequency and the sampling number of the communication rate of the device when the temperature difference between the current environment temperature and the environment temperature at the last time is greater than a preset temperature.

[0119] The second determination module 303 is configured to determine the target baud rate according to the current baud rate coarse adjustment value, the current clock frequency and the sampling number.

[0120] The adjustment module 304 is configured to determine the current baud rate and adjust the current baud rate to the target baud rate.

[0121] In an embodiment, the first determination module 302 includes:

[0122] The acquisition sub-module is configured to acquire the current clock frequency, the sampling number of the communication rate of the device, the clock frequency at the last time and the baud rate at the last time.

[0123] a first determining sub-module, configured to determine a baud rate coarse adjustment value of a previous time according to the sampling times, a clock frequency of the previous time and a baud rate of the previous time;

[0124] a second determining sub-module, configured to determine a current baud rate coarse adjustment value according to the baud rate coarse adjustment value of the previous time.

[0125] In an embodiment, the second determining sub-module comprises:

[0126] a determining unit, configured to determine a current baud rate coarse adjustment value according to the clock frequency of the previous time, the current environment temperature, the sampling times and the baud rate of the previous time.

[0127] In an embodiment, the adjusting module 304 comprises:

[0128] a third determining sub-module, configured to determine a current baud rate according to the baud rate coarse adjustment value of the previous time, the current clock frequency and the sampling times.

[0129] an adjusting sub-module, configured to adjust the current baud rate to a target baud rate.

[0130] In an embodiment, the first determining sub-module comprises:

[0131] a first calculating unit, configured to calculate the baud rate coarse adjustment value of the previous time according to the following formula:

[0132] Br1=UC1 / (STV*BC1)

[0133] wherein the Br1 is the baud rate of the previous time; the UC1 is the clock frequency of the previous time; the STV is the sampling times; and the BC1 is the baud rate coarse adjustment value of the previous time.

[0134] In an embodiment, the third determining sub-module comprises:

[0135] a second calculating unit, configured to calculate the current baud rate according to the following formula:

[0136] Br2=UC2 / (STV*BC1)

[0137] wherein the Br2 is the current baud rate; the UC2 is the current clock frequency; the STV is the sampling times; and the BC1 is the baud rate coarse adjustment value of the previous time.

[0138] In an embodiment, the determining unit comprises:

[0139] a calculating sub-unit, configured to calculate the current baud rate coarse adjustment value according to the following formula:

[0140] BC2 = UC1 (1 + N * Temp - M) / (STV * Br1)

[0141] Wherein, the BC2 is the current baud rate coarse adjustment value; the UC1 is the clock frequency of the last moment; the Temp is the current environment temperature; the STV is the sampling times; the Br1 is the baud rate of the last moment; the N is the first preset parameter; the M is the second preset parameter.

[0142] In an embodiment, the second determining module 303 comprises:

[0143] A third calculating unit, configured to calculate the target baud rate according to the following formula:

[0144] Br2 = UC2 / (STV * BC2)

[0145] Wherein, the Br2 is the target baud rate; the UC2 is the current clock frequency; the STV is the sampling times; the BC2 is the current baud rate coarse adjustment value.

[0146] In the embodiment of the present application, the obtaining module is configured to obtain the current environment temperature of the device and the environment temperature of the last moment; the first determining module is configured to determine the current baud rate coarse adjustment value, the current clock frequency and the sampling times of the communication rate of the device when the temperature difference between the current environment temperature and the environment temperature of the last moment is greater than a preset temperature; the second determining module is configured to determine the target baud rate according to the current baud rate coarse adjustment value, the current clock frequency and the sampling times; and the adjusting module is configured to determine the current baud rate and adjust the current baud rate to the target baud rate. Thus, when the current temperature environment changes, the target baud rate can be determined and the current baud rate can be adjusted in time according to the current baud rate coarse adjustment value, the current clock frequency and the sampling times, so as to avoid the phenomenon that the communication receiving or sending fails due to the error between the current baud rate and the actual requirement exceeding a certain range.

[0147] For the device embodiment, it is basically similar to the method embodiment, so the description is relatively simple, and the related parts refer to the part of the method embodiment.

[0148] The embodiment of the present application further provides an electronic device, comprising:

[0149] The computer program is stored in the memory and can be run on the processor, and when the processor executes the computer program, each process of the baud rate adjustment method embodiment is realized, and the same technical effects are achieved. To avoid repetition, no further description is given here.

[0150] The embodiment of the present application further provides a computer readable storage medium, and the computer readable storage medium stores a computer program. The computer program is executed by a processor to realize each process of the above-mentioned baud rate adjustment method embodiment, and the same technical effects can be achieved. To avoid repetition, details are not described herein.

[0151] Each embodiment in the specification is described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The same or similar parts between each embodiment can be referred to each other.

[0152] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, device or computer program product. Therefore, the embodiments of the present application can be in the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present application can be in the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program codes.

[0153] The embodiments of the present application are described with reference to flowcharts and / or block diagrams of the method, terminal device (system) and computer program product according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be realized by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing terminal device to produce a machine, so that the instructions executed by the computer or other programmable data processing terminal device produce a device for implementing the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in one flow or multiple flows and / or blocks Figure 1 The functions specified in one block or multiple blocks.

[0154] These computer program instructions can also be stored in a computer readable memory capable of guiding the computer or other programmable data processing terminal device to work in a specific way, so that the instructions stored in the computer readable memory produce a product including instruction devices, which realize the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in one flow or multiple flows and / or blocks Figure 1 The functions specified in one block or multiple blocks.

[0155] These computer program instructions can also be loaded into a computer or other programmable data processing terminal device, so that a series of operation steps are performed on the computer or other programmable terminal device to produce a computer implemented process, so that the instructions executed on the computer or other programmable terminal device provide a process for realizing the functions specified in the flowcharts and / or block diagrams. Figure 1one or more processes and / or blocks Figure 1 the steps of a function specified in one or more blocks.

[0156] While preferred embodiments of the application have been described, those skilled in the art will appreciate that other modifications than those specifically described can be made within the scope of the present application. Accordingly, all changes coming within the meaning and equivalency range of the appended claims are intended to be embraced therein.

[0157] Finally, it should be noted that the terms "first", "second", and the like, herein do not denote any order, quantity, combination, or importance, but rather are used to distinguish one element from another, and do not imply singular or plural. Moreover, the term "include", "have", or "contain" or any other variant thereof, are intended to encompass non-exclusive inclusion, such that processes, methods, articles, or apparatuses that comprise a series of elements are not required to comprise only those elements that are explicitly listed, or that are expressly stated to be present. An element proceeded by "comprises a... " does not, without further recitation, preclude the existence of additional elements of the process, method, article, or apparatus that comprises the element.

[0158] The above provides a baud rate adjustment method, a baud rate adjustment device, an electronic device and a computer readable storage medium, the principle and implementation manner of the present application are described by applying specific examples in the present application, the above embodiment is only used for helping to understand the method of the present application and its core idea; meanwhile, for the general skilled in the art, according to the idea of the present application, the specific implementation manner and application range can be changed, and the above description should not be understood as the limitation of the present application.

Claims

1. A method of adjusting a baud rate, characterized by, The method comprises: obtaining the current environment temperature of the device and the environment temperature at the last time; when the temperature difference between the current environment temperature and the environment temperature at the last time is greater than a preset temperature, determining the current clock frequency, the sampling number of the communication rate of the device and the baud rate coarse adjustment value at the last time; determining the current baud rate coarse adjustment value according to the clock frequency at the last time, the current environment temperature, the sampling number and the baud rate at the last time; determining the target baud rate according to the current baud rate coarse adjustment value, the current clock frequency and the sampling number; determining the current baud rate and adjusting the current baud rate to the target baud rate; the determination of the current baud rate coarse adjustment value according to the clock frequency at the last time, the current environment temperature, the sampling number and the baud rate at the last time comprises: the current baud rate coarse adjustment value is calculated according to the following formula: BC2=UC1(1+N*Temp-M) / (STV*Br1) wherein, the BC2 is the current baud rate coarse adjustment value; the UC1 is the clock frequency at the last time; the Temp is the current environment temperature; the STV is the sampling number; the Br1 is the baud rate at the last time; the N is a first preset parameter; and the M is a second preset parameter.

2. The baud rate adjustment method of claim 1, wherein the determination of the current clock frequency, the sampling number of the communication rate of the device and the baud rate coarse adjustment value at the last time comprises: obtaining the current clock frequency, the sampling number of the communication rate of the device, the clock frequency at the last time and the baud rate at the last time; determining the baud rate coarse adjustment value at the last time according to the sampling number, the clock frequency at the last time and the baud rate at the last time.

3. The baud rate adjustment method of claim 1, wherein the determination of the current baud rate and the adjustment of the current baud rate to the target baud rate comprise: determining the current baud rate according to the baud rate coarse adjustment value at the last time, the current clock frequency and the sampling number; adjusting the current baud rate to the target baud rate.

4. The baud rate adjustment method of claim 2, wherein, the determination of the baud rate coarse adjustment value at the last time according to the sampling number, the clock frequency at the last time and the baud rate at the last time comprises: the baud rate coarse adjustment value at the last time is calculated according to the following formula: BC1=UC1 / (STV*Br1) wherein, the Br1 is the baud rate at the last time; the UC1 is the clock frequency at the last time; the STV is the sampling number; and the BC1 is the baud rate coarse adjustment value at the last time.

5. The baud rate adjustment method of claim 3, wherein, the determination of the current baud rate according to the baud rate coarse adjustment value at the last time, the current clock frequency and the sampling number comprises: the current baud rate is calculated according to the following formula: Br2 current = UC2 / (STV * BC1) Wherein, the Br2 current is the current baud rate; the UC2 is the current clock frequency; the STV is the sampling number; the BC1 is the baud rate coarse adjustment value of the last time.

6. The baud rate adjustment method of claim 3, wherein, the determination of the target baud rate according to the current baud rate coarse adjustment value, the current clock frequency and the sampling number comprises: the target baud rate is calculated according to the following formula: Br2 target = UC2 / (STV * BC2) Wherein, the Br2 target is the target baud rate; the UC2 is the current clock frequency; the STV is the sampling number; and the BC2 is the current baud rate coarse adjustment value.

7. A baud rate adjustment apparatus characterized by comprising: the device comprises: an obtaining module, configured to obtain the current environment temperature of the device and the environment temperature at the last time; The first determining module is configured to determine a current clock frequency, a sampling number of a communication rate of the device and a previous baud rate coarse adjustment value when a temperature difference between the current environment temperature and the environment temperature at the previous time is greater than a preset temperature; and determine a current baud rate coarse adjustment value according to the clock frequency at the previous time, the current environment temperature, the sampling number and the baud rate at the previous time. The second determining module is configured to determine a target baud rate according to the current baud rate coarse adjustment value, the current clock frequency and the sampling number. The adjusting module is configured to determine a current baud rate and adjust the current baud rate to the target baud rate. The first determining module comprises: The current baud rate coarse adjustment value is calculated according to the following formula: BC2=UC1(1+N*Temp-M) / (STV*Br1) wherein, the BC2 is the current baud rate coarse adjustment value; the UC1 is the clock frequency at the previous time; the Temp is the current environment temperature; the STV is the sampling number; the Br1 is the baud rate at the previous time; the N is a first preset parameter; and the M is a second preset parameter.

8. An electronic device, comprising: The computer program is stored on the computer readable storage medium and is executed by the processor to implement the steps of the baud rate adjustment method according to any one of claims 1-6. The computer program is stored on the computer readable storage medium and is executed by the processor to implement the steps of the baud rate adjustment method according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, ​

Citation Information

Patent Citations

  • Synchronous data transmission method and device on basis of Baud rate of communication connectors

    CN103970697A

  • Method and device for adjusting baud rate of serial port communication and electronic equipment

    CN116541323A