Intelligent controller data processing method

By converting the keywords of JSON data into fixed-length N-ary data and using binary search, the problem of high computational complexity in JSON data processing by microcontrollers is solved, thus improving the processing efficiency of microcontrollers.

CN121996823APending Publication Date: 2026-05-08ZHEJIANG DAYUAN PUMPS IND +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHEJIANG DAYUAN PUMPS IND
Filing Date
2026-01-19
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

When microcontrollers process JSON data, the comparison of keywords character by character leads to high retrieval complexity, consumes a lot of resources, and affects real-time performance.

Method used

Convert the keywords into N-ary data of a fixed number of digits and use binary search to retrieve them, thus reducing computational complexity.

Benefits of technology

By comparing numerical data, the computational overhead of the microcontroller is reduced, the efficiency of data storage and retrieval is improved, and resource consumption is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121996823A_ABST
    Figure CN121996823A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of development of single-chip microcomputers and intelligent controllers, in particular to an intelligent controller data processing method, which is characterized by comprising the following steps of: for the interior of a single-chip microcomputer, calculating all keywords into specific N-ary data with a fixed bit number, and storing the specific N-ary data in the single-chip microcomputer according to a size sequence; after the JSON information is received, the keywords are taken out, and the keywords are calculated as specific N-system data; n-ary data corresponding to keywords in the JSON information is retrieved in the single-chip microcomputer through a binary search method, and the found storage position is the corresponding variable data position. All keywords are calculated in a certain mode, character strings are changed into numerical data, and the numerical data are stored according to the size sequence. The single-chip microcomputer compares character strings one by one, and after the character strings are changed into data, the comparison becomes very simple. The controller is suitable for occasions where a single-chip microcomputer serves as a core controller.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of microcontroller and intelligent controller development, and specifically to an intelligent controller data processing method. Background Technology

[0002] With the increasing number of smart products using IoT functionality (such as smart water pumps), smart controllers can be operated remotely. When there are many operating parameters, information is usually transmitted using JSON or similar data formats, so it is necessary to retrieve the received information.

[0003] Because some microcontrollers have limited processing capabilities, and extensive data retrieval processes can consume a significant amount of their resources, severely impacting the real-time performance of the microcontroller in handling product functionalities, a suitable solution is needed to reduce the resource consumption of information retrieval.

[0004] For JSON data in the format of "keyword + data", it is necessary to first search for the keyword, find the matching variable name, and then put the corresponding data into the variable name. The complexity of the search process is O(n). Since the microcontroller's comparison process is a character-by-character comparison process, n here is the number of characters of all keywords, not the number of keywords. This greatly increases the search complexity and will consume a lot of the microcontroller's computing power.

[0005] After receiving parameters from the host computer, the microcontroller needs to determine which variable to assign the received data to based on the keywords. Therefore, keyword comparison is required. For example: The received string is: {"CURRENT_VOLT", "380.0"; "MOTOR_SPEED", "3180"; "CURRENT_POWER", "92000"; ...} If we want to retrieve the data following the keyword "MOTOR_SPEED", and use direct comparison of ASCII characters, the microcontroller must first compare whether the first character is "M", then whether the second character is "O", then whether the second character is "T", and so on, requiring 11 comparisons to compare the entire keyword. After finding the keyword, the data "3180" is retrieved. This data "3180" needs to be stored in the corresponding position in the variable array.

[0006] The storage location is typically a list containing keywords, followed by the storage address. For example: {CURRENT_VOLT,0;MOTOR_SPEED,1;CURRENT_POWER,2;……}, so the microcontroller still needs to find MOTOR_SPEED in this array, read the number 1 after it, which is the newly stored address offset. Then, according to the offset, the data is stored in the corresponding position in the array. For example, according to the corresponding position, it is stored in the Parameter[] array Parameter[1]=3180.

[0007] This calculation results in a large amount of work required for comparisons, which consumes a significant portion of the microcontroller's limited resources. Summary of the Invention

[0008] To address the technical problems and shortcomings of existing technologies, this invention provides a data processing method for intelligent controllers that can significantly reduce the computing power overhead of intelligent controllers. Under the premise of limited overhead, it can continuously reduce the computational complexity in data storage, retrieval, and matching, thereby saving computing power.

[0009] To achieve the above and other related objectives, the present invention adopts the following technical solution: A data processing method for an intelligent controller, comprising: Step 1: For the microcontroller, calculate all the keywords into a fixed number of N-ary data, and store these N-ary data in the microcontroller in order of size. Step 2: After receiving the JSON information, extract the keywords and convert them into specific N-ary data. Step 3: The N-ary data corresponding to the keywords in the JSON information is retrieved within the microcontroller using a binary search method. The storage location found is the location of the corresponding variable data.

[0010] Preferably, the N-ary data is binary or hexadecimal data.

[0011] Preferably, in step four, the parameters following the keywords in the information are extracted and placed into the corresponding positions in the array of variable data.

[0012] Preferably, the number of parameters in the JSON information is judged. If the number of parameters is less than or equal to a set value, 16-bit binary data is used for calculation, and a simple CRC algorithm is adopted. If the number of parameters exceeds the set value, the calculation is performed using 24-bit or 32-bit data or more, and a hash algorithm is used for conversion.

[0013] Preferably, the ASCII code value of the keywords of all information is taken, and the ASCII code value is calculated into numerical data according to a fixed algorithm. After sorting, it is placed in an array in order.

[0014] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention directly converts the information stored in the microcontroller into numerical data for storage and sorting. When matching and retrieval are needed, after receiving the information, the keywords in the information are also converted into numerical data. By comparing the two numerical data, the complexity of retrieval can be reduced, the computational overhead can be reduced, the retrieval efficiency can be improved, the location of the corresponding data can be found, and some parameters can be stored in the corresponding location. This overcomes the computational overhead of character retrieval, reduces computational complexity, and saves the computing power resources of the microcontroller.

[0015] 2. In this invention, strings are converted into data and stored in ascending order. Microcontrollers typically compare strings character by character, but converting them into data simplifies the comparison process. This is suitable for applications where a microcontroller serves as the core controller.

[0016] Other additional advantages and benefits of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description

[0017] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a schematic diagram showing the connection between the intelligent controller and the IoT module; Figure 2 This is a flowchart of the microcontroller data processing method. Detailed Implementation

[0018] The specific embodiments of the present invention will be further described below with reference to the accompanying drawings. The following specific examples illustrate the embodiments of the present invention, and those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that, unless otherwise specified, the following embodiments and features in the embodiments can be combined with each other.

[0019] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. The illustrations only show the components related to the present invention and are not drawn according to the number, shape and size of the components in actual implementation. In actual implementation, the form, quantity and proportion of each component can be changed at will, and the layout of the components may also be more complex.

[0020] It should be noted that in the description of this application, the terms "upper," "lower," "left," "right," "inner," and "outer," etc., indicating directional or positional relationships, are based on the directional or positional relationships shown in the accompanying drawings. These are merely for ease of description and do not indicate or imply that the device or element must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limiting the invention. Furthermore, it should be noted that in the description of this application, unless otherwise explicitly specified and limited, the terms "installed," "connected," "linked," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal communication between two elements. Those skilled in the art can understand the specific meaning of the above terms in the invention based on the specific circumstances.

[0021] Example: This invention discloses a data processing method for an intelligent controller. An intelligent controller refers to a circuit module, hardware module, intelligent module, and communication module that includes chips such as a microcontroller and a microprocessor. Specifically, for example, the microcontroller, model FS026C7L, has an internal CRC32 function module that can convert characters into numerical values.

[0022] In a specific example, all keywords such as CURRENT_VOLT, MOTOR_SPEED, and CURRENT_POWER are pre-calculated according to certain rules, such as using CRC16, to obtain a value corresponding to each keyword. For example, the calculation result is: The value of CURRENT_VOLT is 0x3255; The value of MOTOR_SPEED is 0x7C34; The value of CURRENT_POWER is 0x05AE; ...; 0x32550x7C340x05AE represents specific hexadecimal data. Comparison of these data only requires one comparison, because the microcontroller can directly perform comparisons such as whether 0x3255 is equal to 0x7C34, requiring only one operation.

[0023] After receiving the string, extract the keywords and calculate the numerical value directly.

[0024] The array {CURRENT_VOLT, 0; MOTOR_SPEED, 1; CURRENT_POWER, 2; ...} becomes: the array {0x05AE, 2; 0x3255, 0; 0x7C34, 1 ...} is stored in ascending order. When the microcontroller retrieves the address, for example, 0x7C34 can be quickly found using binary search, and the address offset 1 after it can be retrieved.

[0025] For situations with many keywords, if CRC16 results in duplicate values, CRC32 can be used. If the microcontroller has an internal CRC32 function module, the consumption of microcontroller resources can be further reduced. For example, the FS026C7L we use has an internal CRC32 function module, so there is no need to occupy the MCU's computing resources for CRC32 calculation.

[0026] The data processing principle of this solution is as follows: JSON data is formatted as "keyword + data". Therefore, it's necessary to first search for the keywords, find matching variables, and then store the corresponding data in those variables. The search process has a complexity of O(n). Since the microcontroller's comparison process is character-by-character, 'n' represents the total number of characters in the keywords, not the total number of keywords. This significantly increases the search complexity and greatly consumes the microcontroller's processing power. The proposed solution is as follows: Step 1: The microcontroller internally calculates all the keywords into a fixed-length binary number using a hash algorithm. If there are few parameters, 16-bit binary data can be used; if there are many parameters, it can be calculated into 24-bit, 32-bit, or even more bits.

[0027] When there are not many parameters, a simpler CRC (Cyclic Redundancy Check) algorithm can be used instead. These data are stored in the microcontroller in order of size.

[0028] Step 2: After receiving the JSON information, extract the keywords and calculate the specific hexadecimal data using the same algorithm.

[0029] Step 3: Perform a binary search on the numerical data of the keywords mentioned above to find the corresponding variable. The time complexity of this algorithm is only O(logn), although other more suitable algorithms can also be used. Here, n is the number of keywords.

[0030] This method can be applied to IoT smart product systems. For example... Figure 1The product's intelligent controller connects to an IoT module (IoT module). In most cases, the intelligent controller connects to the IoT module via a UART interface and supplies power to the IoT module. The IoT module can be any available type, such as a 4G module, a Wi-Fi module, etc. The product's intelligent controller connects to the Internet of Things (IoT) via the IoT module, interacting with the server and user terminals. User operations on the intelligent controller are sent to the intelligent controller via the IoT in a specific data format (usually JSON), and the intelligent controller returns the data to the server and user terminals in the same way.

[0031] In the aforementioned information and data interaction process, the following methods are employed: Figure 2 The data processing method described above is the core technology of this solution.

[0032] Example of a specific implementation plan: Once the intelligent controller and the IoT system are established, the information to be exchanged is fixed, even if some is intended for future expansion. Based on this, the ASCII code values ​​of all information keywords are taken, and these ASCII code values ​​are calculated into numerical values ​​using a fixed algorithm. The calculation method can take various forms, such as a relatively simple hash algorithm with "vertical redundancy check," or CRC16 (for example, the polynomial of CRC16 is X^16 + X^15 + X^2 + 1).

[0033] For example, the eight keywords are Set_speed, Set_Press, Set_power, Set_on_time, Cur_volt, Cur_tmpr, Cur_power, and Cur_Fault; The calculated results are as follows: 0x4523, 0x2ab6, 0xE088, 0x1106, 0x512b, 0x97AA, 0x0843, 0x6AB8; After sorting the values, place them in an array in order.

[0034] KEY_WORD[]={0x0843,0x1106,0x2ab6,0x4523,0x512b0x6AB8,0x97AA,0xE088}; The keys corresponding to this array are: Cur_power, Set_on_time, Set_Press, Set_speed, Cur_volt, Cur_Fault, Cur_tmpr, and Set_power are also the variables corresponding to these keywords. These variables also correspond to an array paremeter[8] in order; Upon receiving new JSON information, extract the keywords and calculate the corresponding values ​​using the same algorithm.

[0035] For example, it might return 0xE088; The location of the key value is found using the binary search method; For example, the location corresponding to 0xE088 is [7]. Insert the value following the keyword; Simply put the data into paremeter[7].

[0036] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. For those skilled in the art, the present invention can have various modifications and variations. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A data processing method for an intelligent controller, characterized in that, include: Step 1: For the microcontroller, calculate all the keywords into a fixed number of N-ary data, and store these N-ary data in the microcontroller in order of size. Step 2: After receiving the JSON information, extract the keywords and convert them into specific N-ary data. Step 3: The N-ary data corresponding to the keywords in the JSON information is retrieved within the microcontroller using a binary search method. The storage location found is the location of the corresponding variable data.

2. The intelligent controller data processing method according to claim 1, characterized in that, The N-ary data is either binary or hexadecimal.

3. The intelligent controller data processing method according to claim 1, characterized in that, Step 4: Extract the parameters following the keywords from the information and place them into the corresponding positions in the variable data array.

4. The intelligent controller data processing method according to claim 1, characterized in that, The number of parameters in the JSON information is judged. If the number of parameters is less than or equal to the set value, 16-bit binary data is used for calculation, and a simple CRC algorithm is used. If the number of parameters exceeds the set value, the calculation is performed using 24-bit or 32-bit data or more, and a hash algorithm is used for conversion.

5. The intelligent controller data processing method according to claim 1, characterized in that, Take the ASCII code value of the keywords of all information, calculate the numerical data of the ASCII code value according to a fixed algorithm, sort it, and place it in an array in order.