Filtering control method and device for air conditioner communication software and storage medium
By using technical means of tolerance duration and bit verification in UART communication, the problems of data transmission distortion and reception misalignment are solved, ensuring the data reliability and accuracy of the receiver, and improving the stability and efficiency of the program.
Patent Information
- Application Number
- CN202411332514.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2024-12-27
AI Technical Summary
When using UART communication, data transmission is prone to distortion and reception misalignment, resulting in increased program execution time and suppression of the baud rate limit, making it difficult to ensure that the receiver can receive data reliably.
By determining the tolerance time at the receiver based on the target baud rate and data length, performing bit verification on each bit in each frame of data, using the tolerance time to achieve delay compensation, ensuring accurate data reception, and storing verification results Enter the array for judgment.
Improve the accuracy and reliability of data transmission, avoid program disorders caused by reception misalignment, and improve the work efficiency of the receiver.
Smart Images

Figure CN119210653A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data transmission, and in particular to a filtering control method, device and storage medium for air conditioner communication software. Background Art
[0002] With the diversification and upgrading of customer expectations, the cooling and heating functions of air conditioners have become basic needs. AI, voice, WIFI, Bluetooth, and other intelligent functions have gradually become the stepping stone for air conditioners to enter the market. UART, as an important communication method for data transmission, needs to occupy the hardware resources of the controller CPU. As the main IC, serial port resources are usually limited. The development of UART-related functions will inevitably face the embarrassing problem of insufficient chip configuration resources. Taking into account the hardware cost, the research and utilization of ordinary IO ports has gradually become a breakthrough direction. Using ordinary IO ports as UART communication ports can perfectly release CPU resources and expand the iterative derivation of new controller functions. However, using ordinary IO ports as UART communication faces many problems such as data transmission distortion and occupying program execution time, which leads to the suppression of the baud rate upper limit. Therefore, how to ensure that the receiver can reliably receive data when using UART communication is one of the technical problems that technicians in this field urgently need to solve. Summary of the invention
[0003] The problem solved by the present invention is how to ensure that a receiving party can reliably receive data when using UART communication.
[0004] To solve the above problems, the present invention provides a filtering control method for air conditioner communication software, the control method comprising: when a data sending demand is detected, the main control party sends the first data to the receiving party according to the target baud rate; the tolerance time for the receiving party to receive the first data is determined according to the target baud rate and the data length of the first data; when the receiving party receives the first data, the bit number of each bit in each frame of data is verified according to the tolerance time; each frame of data that has been verified is stored in an array, and after the first data is completely received, the parsing status of the first data is judged according to the result of the bit number verification.
[0005] Compared with the existing technology, the technical effects achieved by adopting this technical solution are as follows: the setting of the target baud rate enables the master control party to transmit in a specified manner, thereby improving the accuracy of directional transmission; the acquisition of the tolerance duration enables the receiver to automatically trigger the tolerance mechanism when receiving the first data, thereby achieving delay compensation and ensuring reliable data reception; the receiver sets the bit number verification so as to verify each frame of data received and avoid program confusion due to misaligned data reception.
[0006] In one embodiment of the present invention, the tolerance time for a receiver to receive the first data is determined based on a target baud rate and a data length of the first data, specifically comprising: determining the first moment at which the receiver receives each bit based on the target baud rate and the data length; obtaining the number of bits in each frame of data in the first data, and calculating a unit difference between two adjacent bits received by the receiver based on the number of bits and the target baud rate; dividing the unit difference into a plurality of acquisition cycles, and calculating the tolerance time based on the number of acquisition cycles and the unit difference.
[0007] Compared with the existing technology, the technical effect achieved by adopting this technical solution is as follows: the setting of the first moment can obtain the specific time when the receiver receives each bit, making the work of bit verification more convenient; the calculation of the unit difference can ensure that in the transmission state of the first data, the misalignment of the position of each bit can be detected; the setting of multiple acquisition cycles improves the accuracy of misalignment detection.
[0008] In one embodiment of the present invention, the first moment when the receiver receives each bit is determined based on the target baud rate and the data length, specifically including: calculating the total time taken by the receiver to receive the first data based on the data length and the target baud rate; calculating the unit time taken by the receiver to receive each bit based on the total time and the number of bits; obtaining the start time when the master sends the first data, and determining the first moment of each bit based on the start time and the unit time.
[0009] Compared with the prior art, the technical effect achieved by adopting this technical solution is as follows: the determination of the total time and the unit time can intuitively obtain the theoretical time for the receiver to receive each bit at the target baud rate, making it easier for the receiver to compare the theoretical time with the actual time.
[0010] In one embodiment of the present invention, the number of bits in each frame of data in the first data is obtained, and the unit difference between two adjacent bits received by the receiver is calculated based on the number of bits and the target baud rate, specifically including: T=1÷B×S; wherein T is the unit difference, B is the target baud rate, and S is the number of bits.
[0011] Compared with the prior art, the technical effect achieved by adopting this technical solution is as follows: the unit difference is determined by the target baud rate and the number of bits, so that the unit difference is more consistent with the working condition of the receiver receiving the first data, thereby improving the reliability of data transmission.
[0012] In one embodiment of the present invention, the unit difference is divided into multiple acquisition cycles, and the tolerance time is calculated according to the number of acquisition cycles and the unit difference, specifically including: △t=1÷B÷X; wherein △t is the tolerance time, and X is the number of acquisition cycles.
[0013] Compared with the prior art, the technical effect achieved by adopting this technical solution is as follows: the tolerance duration is determined by the number of acquisition cycles, so that the tolerance duration is more consistent with the working condition of the receiving party receiving the first data, and the possibility of misalignment during data transmission is reduced.
[0014] In one embodiment of the present invention, after the receiving party receives the first data, the number of bits in each frame of data is verified according to the tolerance period, specifically including: recording the bit being verified as the target bit, and obtaining the current moment when the receiving party receives the target bit; comparing the current moment with the first moment corresponding to the target bit; when the time difference between the current moment and the first moment is less than the tolerance period, the target bit can be correctly parsed; when the time difference between the current moment and the first moment is greater than or equal to the tolerance period, the target bit cannot be correctly parsed.
[0015] Compared with the prior art, the technical effect achieved by adopting this technical solution is as follows: after the receiver receives the first data, the number of bits in each frame of data is verified according to the tolerance duration, specifically including: recording the bit being verified as the target bit, and obtaining the current moment when the receiver receives the target bit; comparing the current moment with the first moment corresponding to the target bit; when the time difference between the current moment and the first moment is less than the tolerance duration, the target bit can be correctly parsed; when the time difference between the current moment and the first moment is greater than or equal to the tolerance duration, the target bit cannot be correctly parsed.
[0016] In one embodiment of the present invention, by comparing the current moment with the first moment, the reception status of the target bit by the receiver can be intuitively obtained, and by comparing the time difference with the tolerance duration, it can be directly determined whether there is a possibility of occupancy of the target bit.
[0017] In one embodiment of the present invention, each frame of data that has been verified is stored in an array. After all the first data are received, the parsing status of the first data is determined based on the result of the bit verification, specifically including: when each bit in each frame of data can be correctly parsed, the first data can be correctly parsed by the receiver; when there are bits in each frame of data that cannot be correctly parsed, the current parsing status is fed back to the main control party.
[0018] Compared with the existing technology, the technical effect achieved by adopting this technical solution is as follows: after statistics are collected on the analysis results of each frame of data, the overall analysis results of the first data are fed back, and no subsequent modification is required after the feedback, thereby improving the work efficiency of the recipient in verification.
[0019] The present invention also provides a control device for an air conditioner, the control device comprising: a detection module, the detection module is used to detect changes in the external environment; a control module, the control module is used to control the main control direction to send first data to a receiving party according to changes in the external environment, and the control device is used to execute the control method described in the above-mentioned embodiment.
[0020] The present invention also provides an air conditioner, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor. When the program or instruction is executed by the processor, the steps of the above control method are implemented.
[0021] The present invention also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the control method in the above embodiment are implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 is a flow chart of the control method of the present invention; Figure 2 It is a module schematic diagram of the control method of the present invention; Figure 3 It is a schematic diagram of a module of the air conditioner of the present invention; Description of reference numerals: 100 - air conditioner; 120 - control module; 121 - processor; 130 - detection module; 131 - memory. DETAILED DESCRIPTION
[0023] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0024] [First embodiment] See also Figure 1 In a specific embodiment, the present invention provides a filtering control method for air conditioner communication software, the control method comprising: S100, when a data transmission requirement is detected, the master sends first data to the receiver at a target baud rate; S200, determining a tolerance time for a receiver to receive the first data according to a target baud rate and a data length of the first data; S300, after receiving the first data, the receiving party verifies the bit position of each bit in each frame of data according to the tolerance time length; S400, storing each frame of verified data into an array, and after all first data are received, determining the parsing status of the first data according to the result of the bit verification.
[0025] In step S100, the need to send data will occur in real time during the operation of the air conditioner. Before the sending begins, in order to ensure the accuracy of the received data, the receiving ports of the master control party and the receiver need to be software filtered. Normally, the master control party is the main controller of the air conditioner, and the receiver is the refrigerant sensor. The main controller sends the first data to the refrigerant sensor according to the adjustment of the working state that the air conditioner needs to make. The adjustment of the working state includes but is not limited to temperature adjustment, humidity adjustment and wind speed adjustment.
[0026] In step S200, the target baud rate can be adjusted according to the operating status and hardware equipment of the air conditioner. The usual target baud rate is 2400, and the length of the data is in bytes. After the content of the first data and the target baud rate are determined, the time required for the receiver to receive the first data can be calculated, as well as the tolerance time for the receiver to correctly parse the first data under the current working state. The tolerance time is used to determine whether the receiver can correctly parse the first data.
[0027] In step S300, when the master sends the first data, the receiver verifies the number of frames received in bits to ensure that the number of bits in each frame of data has not changed and the time for receiving each bit is within the tolerance time.
[0028] In step S400, the receiver stores the received data into the Uart_Rx_Data array. The length of data that the array can receive can be adjusted according to actual needs. Each time a Byte is received, the storage position moves back one position. Each time before receiving the serial port, the Uart_Rx_Data array needs to be cleared.
[0029] The setting of the target baud rate allows the master to transmit in the specified manner, improving the accuracy of directional transmission. The acquisition of the tolerance time allows the receiver to automatically trigger the tolerance mechanism when receiving the first data, achieve delay compensation, and ensure reliable data reception. The receiver sets the bit verification to verify each frame of data received to avoid program confusion due to misaligned data reception.
[0030] Further, determining the tolerance time for the receiver to receive the first data according to the target baud rate and the data length of the first data specifically includes: S210, determining the first moment when the receiver receives each bit according to the target baud rate and the data length; S220, obtaining the number of bits in each frame of data in the first data, and calculating the unit difference between two adjacent bits received by the receiver according to the number of bits and the target baud rate; S230: Divide the unit difference into a plurality of collection cycles, and calculate the tolerance duration according to the number of collection cycles and the unit difference.
[0031] In step S210, after the data length and target bit rate of the first data sent by the master direction to the receiver are determined, the time required to send each frame of data in the first data can be accurately calculated, that is, under ideal conditions, the first moment when the receiver receives each bit can be calculated.
[0032] In step S220, the number of bits in each frame of data can be modified according to the operating needs of the air conditioner. Normally, each frame of data contains 12 bits. According to the order, the first bit is the start bit, the second to ninth bits are data bits, the tenth bit is the check bit, and the eleventh and twelfth bits are stop bits. When the target bit rate is determined, the time required for the receiver to receive each frame is the same. However, if the number of bits in each frame is different, the time required to receive each bit is different. Therefore, it is necessary to calculate the unit difference of receiving two adjacent bits to facilitate the smooth execution of the tolerance mechanism.
[0033] In step S230, in order to avoid misalignment of the received bits, the tolerance time needs to be less than the unit difference. By dividing the time period of each unit difference into multiple acquisition cycles, the number of acquisition cycles is recorded as X. In the process of first data reception, since each bit is divided into X equal parts, theoretically the received data should change according to the bit time, that is, one bit is received after X acquisition cycles. However, in reality, there may be errors in time, and one bit change is received in X-1 acquisition cycles or one bit appears in X+1 acquisition cycles. In order to allow a certain error, the number of acquisition cycles can be changed as needed. The larger X is, the more accurate the time is, and the more MCU resources are occupied.
[0034] The setting of the first moment can obtain the specific time when the receiver receives each bit, making the bit verification work more convenient. The calculation of the unit difference can ensure that the misalignment of the position of each bit can be detected under the transmission state of the first data. The setting of multiple acquisition cycles improves the accuracy of misalignment detection.
[0035] Further, determining the first moment at which the receiver receives each bit according to the target baud rate and the data length specifically includes: S211, calculating the total time taken by the receiver to receive the first data according to the data length and the target baud rate; S212, calculating the unit time taken by the receiver to receive each bit according to the total time and the number of bits; S213: Obtain the start time when the master control party sends the first data, and determine the first moment of each bit according to the start time and the unit time.
[0036] In step S211 to step S213, the total time for receiving the first data is related to the data length and the target baud rate. The higher the target baud rate, the faster the data transmission speed. After the data length is determined, the number of frames corresponding to the first data is also determined, that is, the number of bits required to be transmitted for the first data is also determined. The total time taken for the receiver to receive the first data can be calculated based on the number of bits.
[0037] After the total time is acquired, the time required to receive each bit can be calculated based on the number of bits, and the first moment corresponding to each bit can be calculated based on the time when the first data starts to be sent.
[0038] The determination of the total time and the unit time can intuitively obtain the theoretical time for the receiver to receive each bit at the target baud rate, which is convenient for the receiver to compare the theoretical time with the actual time.
[0039] Further, the number of bits in each frame of data in the first data is obtained, and a unit difference between two adjacent bits received by the receiver is calculated according to the number of bits and the target baud rate, specifically including: S221, T = 1 ÷ B × S, where T is the unit difference, B is the target baud rate, and S is the number of bits.
[0040] In step S221, the number of bits is taken as 12 and the target baud rate is 2400. At this time, the corresponding unit difference is 0.005, that is, the receiver can receive one bit of data within 0.005 seconds. Then, in order to prevent data misalignment, the tolerance time of each bit needs to be less than 0.005 seconds, otherwise misjudgment will occur, because the receiver's data must be parsed after the master data is sent. At this time, the tolerance setting can use the upper deviation.
[0041] The unit difference is determined by the target baud rate and the number of bits, so that the unit difference is more consistent with the working condition of the receiver receiving the first data, thereby improving the reliability of data transmission.
[0042] Furthermore, the unit difference is divided into multiple collection cycles, and the tolerance duration is calculated according to the number of collection cycles and the unit difference, specifically including: S231, △t=1÷B÷X; wherein △t is the tolerance time, and X is the number of collection cycles.
[0043] In step S231, X defaults to 5. In actual project tests, 3≤X≤5. In the process of receiving data, in order to avoid the influence of interference waves, the receiver sets the sampling number ≥X-1 times for high level to determine data 1, and the sampling number ≥X-1 times for low level to determine data 0.
[0044] The tolerance duration is determined by the number of acquisition cycles, so that the tolerance duration is more consistent with the working condition of the receiver receiving the first data, and the possibility of misalignment during data transmission is reduced.
[0045] Further, after receiving the first data, the receiving party verifies the number of bits of each bit in each frame of data according to the tolerance time, specifically including: S310, recording the bit being verified as the target bit, and obtaining the current time when the receiver receives the target bit; S320, comparing the current moment with the first moment corresponding to the target bit; S330: When the time difference between the current moment and the first moment is less than the tolerance time, the target bit can be correctly parsed; when the time difference between the current moment and the first moment is greater than or equal to the tolerance time, the target bit cannot be correctly parsed.
[0046] In step S310 to step S330, during the operation of the air conditioner, the first data is continuously sent, the verification process of the target bit is also carried out according to the receiving time, and information is fed back to the main control party after the overall verification of the first data is completed. The theoretical arrival time of the target bit can be obtained through the first moment, and according to the time difference between the first moment and the current moment, it can be obtained whether the target bit has a delayed arrival. If there is no delayed arrival, it means that the target bit has been correctly parsed by the receiver. If there is a delayed arrival, it is necessary to judge according to the tolerance time. If the delay time exceeds the tolerance time, it means that the target bit delay time is long, and the number of frames corresponding to the target bit may be delayed as a whole, which will also affect the overall parsing of the first data.
[0047] By comparing the current moment with the first moment, the receiving party's reception status of the target bit can be intuitively obtained. By comparing the time difference with the tolerance duration, it can be directly determined whether there is a possibility that the target bit is occupied.
[0048] Furthermore, each frame of data that has been verified is stored in an array. After all the first data has been received, the parsing status of the first data is determined according to the result of the bit verification, specifically including: S410: When each bit in each frame of data can be correctly parsed, the first data can be correctly parsed by the receiving party; S420: When there are bits in each frame of data that cannot be correctly parsed, the current parsing situation is fed back to the main control party.
[0049] In step S410 and step S420, when a first data cannot be parsed correctly, it will not affect the receiver's parsing of the next first data. After the receiver feeds back the parsing situation to the main control party, the receiver's verification task for the first data has been completed, that is, the receiver only needs to feed back to the main control party whether it can be parsed correctly. For the first data that cannot be parsed correctly, the main control party can parse it by sending it again, so as to ensure the work efficiency of the receiver.
[0050] After collecting statistics on the analysis results of each frame of data, the overall analysis results of the first data are fed back, and no subsequent modification is required after the feedback, thereby improving the work efficiency of the recipient's verification.
[0051] See also Figure 2 Furthermore, the present invention also provides a control device for an air conditioner 100, the control device comprising: a detection module 130, the detection module 130 is used to detect changes in the external environment; a control module 120, the control module 120 is used to control the main control direction to send the first data to the receiving party according to the changes in the external environment, and the control device is used to execute the control method described in the above-mentioned embodiment.
[0052] See also Figure 3 The present invention also provides an air conditioner 100, which includes a processor 121, a memory 131, and a program or instruction stored in the memory 131 and executable on the processor 121. When the program or instruction is executed by the processor 121, the steps of the above-mentioned control method are implemented.
[0053] The present invention further provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by the processor 121, the steps of the control method in the above embodiment are implemented.
[0054] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the claims.
Claims
1. A filtering control method for air conditioner communication software, characterized in that: The control method comprises: When a data transmission requirement is detected, the master sends first data to the receiver at a target baud rate; Determine a tolerance time for the receiver to receive the first data according to the target baud rate and the data length of the first data; After receiving the first data, the receiving party verifies the bit position of each bit in each frame of data according to the tolerance time length; Each frame of data that has been verified is stored in an array, and after all of the first data are received, the parsing status of the first data is determined according to the result of the bit verification.
2. The control method according to claim 1, characterized in that: The step of determining the tolerance time for the receiver to receive the first data according to the target baud rate and the data length of the first data specifically includes: Determine the first time when the receiving party receives each bit according to the target baud rate and the data length; Obtaining the number of bits in each frame of data in the first data, and calculating a unit difference between two adjacent bits received by the receiver according to the number of bits and the target baud rate; The unit difference is divided into a plurality of acquisition cycles, and the tolerance duration is calculated according to the number of the acquisition cycles and the unit difference.
3. The control method according to claim 2, characterized in that: The determining, according to the target baud rate and the data length, the first moment at which the receiving party receives each bit specifically includes: Calculate the total time taken by the receiver to receive the first data according to the data length and the target baud rate; Calculate the unit time taken by the receiver to receive each bit according to the total time and the number of bits; The start time when the master control party sends the first data is obtained, and the first moment of each bit is determined according to the start time and the unit time.
4. The control method according to claim 3, characterized in that: The obtaining of the number of bits in each frame of data in the first data, and calculating the unit difference between two adjacent bits received by the receiver according to the number of bits and the target baud rate, specifically includes: T = 1 ÷ B × S; Wherein, T is the unit difference, B is the target baud rate, and S is the number of bits.
5. The control method according to claim 4, characterized in that: The dividing the unit difference into a plurality of collection cycles, and calculating the tolerance duration according to the number of the collection cycles and the unit difference, specifically includes: △t=1÷B÷X; Wherein, Δt is the tolerance time, and X is the number of acquisition cycles.
6. The control method according to claim 2, characterized in that: After the receiving party receives the first data, performing a bit verification on each bit in each frame of data according to the tolerance time length specifically includes: Recording the bit being verified as a target bit, and obtaining a current time when the receiver receives the target bit; When the current moment is compared with the first moment corresponding to the target bit; When the time difference between the current moment and the first moment is less than the tolerance time, the target bit can be correctly parsed; When the time difference between the current moment and the first moment is greater than or equal to the tolerance duration, the target bit cannot be correctly parsed.
7. The control method according to claim 6, characterized in that: The step of storing each frame of data that has been verified in an array and, after all of the first data has been received, determining the parsing status of the first data according to the result of the bit verification specifically includes: When each bit in each frame of data can be correctly parsed, the first data can be correctly parsed by the receiving party; When the bits in each frame of data cannot be correctly parsed, the current parsing status is fed back to the main control party.
8. A control device for an air conditioner, characterized in that: The control device is used to execute the control method according to any one of claims 1 to 7, and the control device includes: A detection module, wherein the detection module is used to detect changes in the external environment; A control module, wherein the control module is used to control the main control direction to send the first data to the receiving party according to the change of the external environment.
9. An air conditioner, characterized in that: The air conditioner includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the control method as described in any one of claims 1 to 7.
10. A readable storage medium, characterized in that: The readable storage medium stores a program or an instruction, and when the program or the instruction is executed by the processor, the steps of the control method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Data validation method and related devices
CN107426156A
Fast charge protocol chip, method executed by same, and electronic device
CN116742763A
Data detection method, storage medium and electronic equipment
CN116915367A