A task scheduling method and device of a single-chip microcomputer, an electronic device, and a storage medium

By automatically acquiring and updating collected data in the microcontroller's data storage area and task execution area, and selecting the optimal task based on device status information, the problem of error-prone and inefficient task scheduling in microcontrollers is solved, and efficient and automated task scheduling is achieved.

CN116880322BActive Publication Date: 2026-06-19HANGZHOU KEENCOOL INTELLIGENT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HANGZHOU KEENCOOL INTELLIGENT TECH CO LTD
Filing Date
2023-08-09
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing microcontrollers are prone to scheduling errors and low task scheduling efficiency during task scheduling.

Method used

By setting up a data storage area and a task execution area in the internal registers of the microcontroller, the system acquires and collects data using data acquisition tasks, compares and updates the stored data, and automatically selects the preferred task to control the controlled device based on the device status information and alarm status, thus achieving automatic scheduling without the need for manual input of task execution instructions.

Benefits of technology

It improves the accuracy and efficiency of task scheduling, and solves the problems of error-prone and inefficient task scheduling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116880322B_ABST
    Figure CN116880322B_ABST
Patent Text Reader

Abstract

This application provides a task scheduling method, apparatus, electronic device, and storage medium for a microcontroller. The method includes: acquiring first data using a data acquisition task; comparing the first data with second data to obtain a comparison result; updating the second data using the first data if the comparison result meets data update conditions; acquiring device status information corresponding to a target parameter from the updated second data; determining the target device based on the device status information; selecting a preferred task corresponding to an alarm state from normal execution tasks and special execution tasks; controlling the controlled device using the preferred task; selecting a new target parameter; and returning to the step of acquiring the first data using the data acquisition task. By employing the above-mentioned task scheduling method, apparatus, electronic device, and storage medium for a microcontroller, the problems of error-prone task scheduling and low task scheduling efficiency in the prior art are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of microcontroller technology, and more specifically, to a task scheduling method, apparatus, electronic device, and storage medium for a microcontroller. Background Technology

[0002] A microcontroller is an integrated circuit chip that uses very large-scale integrated circuit technology to integrate a central processing unit (CPU) with data processing capabilities, random access memory (RAM), read-only memory (ROM), various I / O ports and interrupt systems, timers / counters, and other functions (and may also include display driver circuits, pulse width modulation circuits, analog multiplexers, A / D converters, etc.) onto a single silicon chip to form a small but complete microcomputer system. It is widely used in the field of industrial control.

[0003] In current microcontrollers, task execution commands are typically used to execute the corresponding program code during task scheduling. When there are many tasks to be scheduled, scheduling errors and low task scheduling efficiency are likely to occur. Summary of the Invention

[0004] In view of this, the purpose of this application is to provide a task scheduling method, device, electronic device and storage medium for a microcontroller, so as to solve the problems of easy error and low efficiency in task scheduling in the prior art.

[0005] In a first aspect, embodiments of this application provide a task scheduling method for a microcontroller, applied to a microcontroller. The microcontroller's internal registers include a data storage area and a task execution area. The task execution area stores data acquisition tasks, normal execution tasks, and special execution tasks, including:

[0006] In this round of task scheduling, the data acquisition task is used to obtain the first data collected from multiple controlled devices, and the first data collected is compared with the second data collected in the data storage area to obtain the comparison result;

[0007] If the comparison result meets the data update condition, the second collected data is updated using the first collected data to obtain the updated second collected data.

[0008] Select the target parameter from multiple candidate parameters, obtain the device status information of the controlled device corresponding to the target parameter from the updated second collection data, and determine the target device based on the device status information;

[0009] Select the preferred task corresponding to the alarm state of the target parameter from the normal execution task and special execution task, and use the preferred task to control the controlled equipment;

[0010] If the iteration stop condition is not met, a new target parameter is selected from multiple candidate parameters, and the process returns to the step of obtaining the device status information of the controlled device corresponding to the target parameter from the updated second collection data. If the iteration stop condition is met, the current round of task scheduling is completed, and the next round of task scheduling begins.

[0011] Optionally, a preferred task corresponding to the alarm state of the target device is selected from normal execution tasks and special execution tasks, including: determining the alarm state of the target device, where alarm states include no alarm state and alarm state, and alarm state includes multiple alarm levels; if the target device is in no alarm state or at a low alarm level, the normal execution task corresponding to the target parameter is selected as the preferred task; if the target device is at an alarm level higher than the low alarm level, the special execution task corresponding to the target parameter is selected as the preferred task.

[0012] Optionally, special execution tasks include extreme execution tasks and shutdown tasks; selecting the special execution tasks corresponding to the target parameters as preferred tasks includes: determining the task level of each execution task in the special execution tasks; and selecting the task corresponding to the task level that matches the alarm level from the extreme execution tasks and shutdown tasks as the preferred task.

[0013] Optionally, before the comparison result satisfies the data update condition, the method further includes: if the ratio of the parameter value in the first collected data to the corresponding parameter value in the second collected data is not within a set range, determining that the comparison result satisfies the data update condition; if the ratio of the parameter value in the first collected data to the corresponding parameter value in the second collected data is within a set range, determining that the comparison result does not satisfy the data update condition.

[0014] Optionally, the equipment status information includes operating status and in-situ status; determining the target equipment based on the equipment status information includes: selecting, from the controlled equipment corresponding to the target parameters, the controlled equipment whose operating status is normal and whose in-situ status is true as the target equipment.

[0015] Optionally, the internal register also includes a main program area, which stores the main program. The method further includes: in response to a program update instruction, executing the main program to detect whether there is a matching update file, the program update instruction including update location information; if there is a matching update file, the main program uses the update file to update the task in the task execution area corresponding to the update location information.

[0016] Optionally, the microcontroller's internal registers also include a main program area, which stores the main program. The task execution area also stores the main program area update task. The method further includes: in response to the main program update instruction, using the main program area update task to update the main program in the main program area.

[0017] Secondly, this application also provides a task scheduling device for a microcontroller, applied to a microcontroller. The microcontroller's internal registers include a data storage area and a task execution area. The task execution area stores data acquisition tasks, normal execution tasks, and special execution tasks. The task scheduling device includes:

[0018] The data comparison module is used in this round of task scheduling to acquire the first data collected from multiple controlled devices using the data acquisition task, compare the first data collected with the second data collected in the data storage area, and obtain the comparison result.

[0019] The data update module is used to update the second collected data using the first collected data if the comparison result meets the data update condition, so as to obtain the updated second collected data.

[0020] The device selection module is used to select a target parameter from multiple candidate parameters, obtain the device status information of the controlled device corresponding to the target parameter from the updated second acquisition data, and determine the target device based on the device status information.

[0021] The task execution module is used to select the preferred task corresponding to the alarm status of the target device from normal execution tasks and special execution tasks, and use the preferred task to control the controlled device.

[0022] The loop control module is used to select a new target parameter from multiple candidate parameters if the iteration stop condition is not met, and return to the step of obtaining the device status information of the controlled device corresponding to the target parameter from the updated second acquisition data. If the iteration stop condition is met, the current round of task scheduling is completed and the next round of task scheduling is started.

[0023] Thirdly, embodiments of this application also provide an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, the steps of the microcontroller task scheduling method described above are performed.

[0024] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the microcontroller task scheduling method described above.

[0025] The embodiments of this application bring the following beneficial effects:

[0026] This application provides a task scheduling method, apparatus, electronic device, and storage medium for a microcontroller. It can automatically acquire first collected data using a data acquisition task, update second collected data in the data storage area, and then filter the controlled devices based on the device status information of the controlled devices corresponding to the target parameters. The task corresponding to the alarm status of the filtered target devices is selected as the preferred task, and the controlled devices are controlled using the preferred task. The entire task scheduling process requires no input of task execution instructions; it automatically selects the task to be executed based on the device status information and alarm status. Compared with existing microcontroller task scheduling methods, this solves the problems of error-prone task scheduling and low task scheduling efficiency.

[0027] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0028] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0029] Figure 1 A flowchart of the task scheduling method for a microcontroller provided in an embodiment of this application is shown;

[0030] Figure 2 This paper shows a schematic diagram of the structure of the task scheduling device for a microcontroller provided in an embodiment of this application;

[0031] Figure 3 A schematic diagram of the structure of the electronic device provided in the embodiments of this application is shown. Detailed Implementation

[0032] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. Based on the embodiments of this application, every other embodiment obtained by those skilled in the art without inventive effort falls within the scope of protection of this application.

[0033] It is worth noting that prior to this application, a microcontroller was an integrated circuit chip. It was a small but complete microcomputer system constructed using very large-scale integrated circuit (VLSI) technology, integrating a central processing unit (CPU) with data processing capabilities, random access memory (RAM), read-only memory (ROM), various I / O ports and interrupt systems, timers / counters, and other functions (and possibly display driver circuits, pulse width modulation circuits, analog multiplexers, A / D converters, etc.) onto a single silicon chip. These microcontrollers were widely used in industrial control. Currently, in microcontrollers, task execution commands are typically used to execute corresponding program code during task scheduling. For example, by viewing status and alarm information in the collected data, the user manually determines the tasks to be executed and then schedules them by manually inputting task execution commands. However, when there are many tasks to be scheduled, scheduling errors and low task scheduling efficiency are prone to occur.

[0034] Based on this, this application provides a task scheduling method for a microcontroller to improve scheduling accuracy and task scheduling efficiency.

[0035] Please see Figure 1 , Figure 1 This is a flowchart illustrating a task scheduling method for a microcontroller provided in an embodiment of this application. Figure 1 As shown in the embodiments of this application, the task scheduling method for a microcontroller is applied to a microcontroller. The internal registers of the microcontroller include a data storage area and a task execution area. The task execution area stores data acquisition tasks, normal execution tasks, and special execution tasks. The method includes:

[0036] Step S101: In this round of task scheduling, the data acquisition task is used to acquire the first acquisition data of multiple controlled devices, and the first acquisition data is compared with the second acquisition data in the data storage area to obtain the comparison result.

[0037] In this step, the data acquisition task can refer to the task of acquiring sensor data, which is a program stored in the task execution area.

[0038] The controlled device can refer to multiple devices controlled by a microcontroller. For example, the controlled device can be a valve or a pump.

[0039] The controlled equipment is controlled by various tasks in the task execution area. For example, when the shutdown task is selected as the preferred task, the controlled equipment will stop running according to the shutdown task.

[0040] The first acquired data may refer to the current data of the controlled device obtained by the data acquisition task. The first acquired data is used to compare with the second acquired data to determine whether the second acquired data should be updated.

[0041] The second type of data acquisition can refer to the historical data of the controlled device stored in the data storage area.

[0042] In this embodiment, the microcontroller's internal registers are divided into three areas: the main program area, the data storage area, and the task execution area. The main program area stores the main program, the data storage area stores the collected data obtained after executing the data acquisition task, and the task execution area stores multiple tasks, namely the data acquisition task, the normal execution task, the special execution task, and the main program update task.

[0043] The executable program for each task in the task execution area is stored in a fixed address range, so that the task can be updated according to the storage address of the executable program. For example, the executable program for the data acquisition task is stored at addresses 1001-1005, and the executable program for the normal execution task is stored at addresses 1006-1009.

[0044] The data acquisition task is the first task stored in the task execution area, the normal execution task is the second task stored in the task execution area, the extreme execution task is the third task stored in the task execution area, the power saving execution task is the fourth task stored in the task execution area, the shutdown task is the fifth task stored in the task execution area, and the main program update task is the sixth task stored in the task execution area.

[0045] After all devices (microcontroller and controlled devices) are powered on, the main program is executed first. The main program checks for program update instructions. If no update instruction is found, it exits the main program and checks the data storage area for alarm status. If no alarm status is found, it enters the first round of task scheduling (excluding program updates). It automatically retrieves the first task from the task execution area for execution, namely the data acquisition task. This task reads sensor data to obtain initial data from multiple controlled devices, such as pump temperature, valve pressure, pump alarm status, and valve alarm status. The initial data is then compared with the second data in the data storage area to obtain the comparison result for each data item. If an alarm status is found, the corresponding task is scheduled from the task execution area based on the alarm level.

[0046] Step S102: If the comparison result meets the data update condition, then the second collected data is updated using the first collected data to obtain the updated second collected data.

[0047] In this step, the data update condition can refer to the condition for updating the second collected data in the data storage area.

[0048] In this embodiment, if the data update condition is met, it indicates that the second collected data stored in the data storage area needs to be updated. Therefore, the existing second collected data in the data storage area is replaced with the first collected data to update the second collected data. It should be noted that the first collected data includes the values ​​of multiple parameters. When updating the second collected data, each parameter needs to be judged individually to determine whether to update that parameter.

[0049] In an optional embodiment, before the comparison result satisfies the data update condition, the method further includes: if the ratio of the parameter value in the first collected data to the corresponding parameter value in the second collected data is not within a set range, determining that the comparison result satisfies the data update condition; if the ratio of the parameter value in the first collected data to the corresponding parameter value in the second collected data is within a set range, determining that the comparison result does not satisfy the data update condition.

[0050] Specifically, to determine whether the data update conditions are met, it is necessary to calculate the ratio of the value of each parameter in the first collected data to the corresponding parameter value in the second collected data. For example, calculate the ratio of the temperature value in the first collected data to the temperature value in the second collected data, and then determine whether the ratio is within the set interval [0.95, 1.05]. If the ratio is not within the set interval, it indicates that there is a significant difference between the temperature in the first collected data and the temperature in the second collected data, and data updating is required. Therefore, the temperature in the first collected data is used as the new temperature in the second collected data. If the ratio is within the set interval, it indicates that there is little difference between the temperature in the first collected data and the temperature in the second collected data, and data updating is not required. Then, for each parameter in the first collected data other than temperature, the value of that parameter is also compared with the value of the corresponding parameter in the second collected data to determine whether the ratio is within the set interval, so as to decide whether to update the data for that parameter. Those skilled in the art can choose the size of the set interval according to the actual situation, and this application does not impose any limitations on it.

[0051] Step S103: Select the target parameter from multiple candidate parameters, obtain the device status information of the controlled device corresponding to the target parameter from the updated second collection data, and determine the target device based on the device status information.

[0052] In this step, the candidate parameters can refer to the parameters of the controlled device collected by the sensor. For example, the candidate parameters can be temperature, pressure, or flow rate.

[0053] The target parameter can refer to one of the candidate parameters; for example, the target parameter is temperature.

[0054] Equipment status information includes the operating status and on-site status of the controlled equipment.

[0055] The "in-place" status refers to whether a device is in a normal connected state. For example, a microcontroller control board may have many interfaces, and it is necessary to detect whether each interface is connected to a corresponding sensor. For instance, if information about a pump cannot be read, it indicates that the pump is not in place. Or, if there is a problem with the intermediate circuit between the sensor and the device, causing the sensor signal to be lost, it is also considered that the device is missing and not in place.

[0056] In this embodiment of the application, the second collection data includes the value of each collected parameter, the controlled device corresponding to the value, the device status information of the controlled device, and the alarm status. For example, the temperature of controlled device A is 20°C, and the pressure of controlled device B is 1 MPa. Therefore, if the target parameter is temperature, the device status information of controlled device A with the collected temperature can be obtained from the updated second collection data, and the device status information can be used to determine whether controlled device A is the target device.

[0057] It should be noted that this application will detect multiple parameters such as temperature, pressure, and flow rate for each device. However, temperature may be used as the primary metric. For example, only temperature may be collected, while pressure and flow rate are not. Pressure and flow rate are mainly used to characterize the operating status of the pipeline. Detecting pressure and flow rate is only to more accurately display the operating status of the pipeline. However, the vertical measurement of pressure and flow rate cannot accurately understand the operating status of the pipeline; it can only determine whether the pipeline is abnormal. The specific status of the pipeline will ultimately be reflected in the temperature sensor. In addition, the temperature functions of different devices are also different. Some are used as a reference temperature for comparison, while others are used as a reference for environmental monitoring. Different temperatures have different usage methods.

[0058] In one optional embodiment, the device status information includes operating status and in-situ status; determining the target device based on the device status information includes: selecting, from the controlled devices corresponding to the target parameters, the controlled device whose operating status is normal and whose in-situ status is true as the target device.

[0059] Assuming that the controlled devices for collecting temperature data include controlled device A, controlled device C, and controlled device D, the device status information of these three controlled devices is extracted respectively. For each device status information, it is determined whether the operating status is normal and the in-situ status is true. If only controlled device A has a normal operating status and a true in-situ status, then controlled device A is selected as the target device.

[0060] Step S104: Select the preferred task corresponding to the alarm state of the target parameter from the normal execution task and the special execution task, and use the preferred task to control the controlled equipment.

[0061] In this step, "normal execution task" can refer to the task used to control the device to operate in normal mode.

[0062] Special missions include extreme missions, power-saving missions, and missions requiring shutdown.

[0063] Extreme execution tasks refer to tasks used to control equipment to operate in extreme modes, power-saving execution tasks refer to tasks used to control equipment to operate in power-saving modes, and shutdown tasks refer to tasks used to control equipment to stop operating. Normal mode and extreme mode are relative terms and can be distinguished based on the magnitude of the operating parameter values. Different types of equipment have different normal and extreme modes.

[0064] Taking a cooling pump as an example, when rapid heat dissipation is required, the cooling pump can be controlled to operate at its maximum parameter values; this is the extreme mode. If the cooling pump operates at its normal parameter values, it is in normal mode. Similarly, for rotating equipment, the equipment can be controlled to rotate at its maximum speed; this is the extreme mode. If the equipment rotates at a normal speed, it is in normal mode.

[0065] In this embodiment, different alarm states are associated with different execution tasks. This allows for the automatic selection of appropriate execution tasks based on the alarm state, enabling the controlled device to adjust its operating state in a timely manner according to the alarm state, thereby improving task scheduling efficiency.

[0066] In one optional embodiment, selecting a preferred task corresponding to the alarm state of the target device from normal execution tasks and special execution tasks includes: determining the alarm state of the target device, where the alarm state includes a no-alarm state and an alarm state, and the alarm state includes multiple alarm levels; if the target device is in a no-alarm state or at a low alarm level, the normal execution task corresponding to the target parameter is selected as the preferred task; if the target device is at an alarm level higher than the low alarm level, the special execution task corresponding to the target parameter is selected as the preferred task.

[0067] Specifically, the alarm status of each target device is obtained from the updated second data collection. If the alarm status of the target device is no alarm or a low alarm level, the device can be controlled in normal mode, and normal execution tasks are performed. If the alarm status of the target device is a low alarm level or higher, the device needs to be controlled according to special parameter values, and special execution tasks are performed to achieve a rapid response to the alarm. It should be noted that different parameters can correspond to different execution tasks. For example, temperature and pressure parameters can each have their own special execution tasks to achieve precise control of device operation. Alternatively, a certain parameter can be designated as a special parameter, and a corresponding special execution task can be set only for that special parameter, while the alarm status of other parameters is not responded to, i.e., only normal execution tasks are performed.

[0068] In one optional embodiment, the special execution tasks include extreme execution tasks and shutdown tasks; selecting the special execution tasks corresponding to the target parameters as preferred tasks includes: determining the task level of each execution task in the special execution tasks; and selecting the task corresponding to the task level that matches the alarm level from the extreme execution tasks and shutdown tasks as the preferred task.

[0069] Specifically, different special execution tasks correspond to different task levels. For example, normal execution tasks are low-level tasks, extreme execution tasks are medium-level tasks, and shutdown tasks are high-level tasks. Alarm levels are low-level alarms, medium-level alarms, and high-level alarms. Since low-level alarms do not require special execution tasks, medium-level tasks correspond to medium-level alarms, and high-level tasks correspond to high-level alarms.

[0070] If the alarm level is medium, the extreme task will be the preferred task; if the alarm level is high, the shutdown task will be the preferred task. Additionally, special tasks include power-saving tasks. After determining the target device based on equipment status information, this also includes: when the target parameters meet set conditions, the power-saving task will be the preferred task. For example, if the measured temperature is below 0°C, a power-saving task needs to be executed; or, when the load device is removed and the load is very low, a power-saving task needs to be executed.

[0071] Step S105: If the iteration stop condition is not met, select a new target parameter from multiple candidate parameters and return to the step of obtaining the device status information of the controlled device corresponding to the target parameter from the updated second collection data. If the iteration stop condition is met, complete the current round of task scheduling and start the next round of task scheduling.

[0072] In this step, temperature is first used as the primary target parameter, and task scheduling is performed based on the collected temperatures of each controlled device, completing the first layer of control in this round of task scheduling. Then, the target parameter needs to be changed; a parameter other than temperature is selected from multiple candidate parameters as the second target parameter. For example, pressure is chosen as the new target parameter, and the second layer of control in this round of task scheduling begins for this new target parameter. This process continues until all candidate parameters have been used as target parameters for corresponding device control, at which point the iteration stopping condition is met, thus completing this round of task scheduling and initiating the next round.

[0073] Assuming the first set of collected data contains five types of parameters, once all five types are used as target parameters and corresponding task scheduling is performed based on the device status information and alarm status in this round of task scheduling, the next round of task scheduling will begin. After the next round of task scheduling begins, the first task will be executed again, i.e., the data acquisition task will be re-executed, followed by subsequent control steps. This process of task scheduling is repeated multiple times to achieve cyclical control of the controlled equipment.

[0074] In an optional embodiment, the internal register further includes a main program area storing the main program. The method further includes: in response to a program update instruction, executing the main program to detect whether there is a matching update file, the program update instruction including update location information; if there is a matching update file, the main program uses the update file to update the task in the task execution area corresponding to the update location information.

[0075] Specifically, this application provides a variety of program update commands, which are at least one of the following: network port online download command, network port offline download command, serial port download command, and SD card download command.

[0076] Taking the network port offline download command as an example, when the microcontroller connects to the host computer device carrying the update file, it sends a program update command. In response to the program update command, the main program performs the following processing: The main program checks whether an update file exists. If an update file exists, it searches for a matching task file in the task execution area. If a matching task file exists, it compares the version numbers of the two. If the version number of the update file is higher than that of the task file, it is determined that the requirements are met. At this time, the update file can be used to update the task file in the task execution area. The update file carries the address of the file to be updated, and the matching execution task file can be determined based on this address.

[0077] It should be noted that when a program update command is received, the program will wait for the currently executing task in the task execution area to complete before executing the main program and then performing the program update. After the program update is complete, the program will continue to execute the next task based on the task execution sequence number recorded in the data storage area.

[0078] In an optional embodiment, the microcontroller's internal registers further include a main program area, which stores the main program, and a task execution area that stores main program update tasks; the method further includes: in response to a main program update instruction, updating the main program in the main program area using the main program update task.

[0079] Specifically, the main program stored in the main program area may also have problems that need to be repaired or upgraded. Therefore, the task execution area also stores the main program update task. By triggering the main program update instruction, the main program can be updated using the main program update task. For example, the main program update task carries the main program code. When the main program update task is executed, the main program code can be directly replaced with the main program in the main program area to update the main program.

[0080] Compared with the task scheduling methods of microcontrollers in the prior art, this application can automatically acquire the first data by using the data acquisition task and update the second data in the data storage area. Then, the controlled devices are filtered according to the device status information of the controlled devices corresponding to the target parameters. The task corresponding to the alarm status of the filtered target devices is selected as the preferred task. The controlled devices are controlled by the preferred task. The entire task scheduling process does not require input of task execution instructions. The task selection is automatically performed according to the device status information and alarm status, which solves the problems of easy error and low efficiency in task scheduling.

[0081] Based on the same inventive concept, this application also provides a task scheduling device for a microcontroller corresponding to the task scheduling method of a microcontroller. Since the principle of the device in this application is similar to the task scheduling method of the microcontroller described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0082] Please see Figure 2 , Figure 2 This is a schematic diagram of the structure of a task scheduling device for a microcontroller provided in an embodiment of this application. Figure 2 As shown, the task scheduling device 200 for the microcontroller is applied to the microcontroller. The internal registers of the microcontroller include a data storage area and a task execution area. The task execution area stores data acquisition tasks, normal execution tasks, and special execution tasks. The task scheduling device 200 for the microcontroller includes:

[0083] The data comparison module 201 is used to acquire first data from multiple controlled devices using the data acquisition task in this round of task scheduling, compare the first data with the second data in the data storage area, and obtain the comparison result.

[0084] The data update module 202 is used to update the second collected data using the first collected data if the comparison result meets the data update condition, so as to obtain the updated second collected data.

[0085] The device selection module 203 is used to select a target parameter from multiple candidate parameters, obtain the device status information of the controlled device corresponding to the target parameter from the updated second acquisition data, and determine the target device based on the device status information;

[0086] The task execution module 204 is used to select the preferred task corresponding to the alarm status of the target device from the normal execution tasks and special execution tasks, and use the preferred task to control the controlled device.

[0087] The loop control module 205 is used to select a new target parameter from multiple candidate parameters if the iteration stop condition is not met, and return to the step of obtaining the device status information of the controlled device corresponding to the target parameter from the updated second acquisition data. If the iteration stop condition is met, the current round of task scheduling is completed and the next round of task scheduling is started.

[0088] Please see Figure 3 , Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 3 As shown, the electronic device 300 includes a processor 310, a memory 320, and a bus 330.

[0089] The memory 320 stores machine-readable instructions executable by the processor 310. When the electronic device 300 is running, the processor 310 and the memory 320 communicate via the bus 330. When the machine-readable instructions are executed by the processor 310, they can perform the operations described above. Figure 1 The steps of the task scheduling method for the microcontroller in the method embodiment shown are described in detail in the method embodiment, and will not be repeated here.

[0090] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can perform the above-described actions. Figure 1 The steps of the task scheduling method for the microcontroller in the method embodiment shown are described in detail in the method embodiment, and will not be repeated here.

[0091] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0092] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the shown or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.

[0093] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0094] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0095] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0096] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The scope of protection of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A task scheduling method for a microcontroller, characterized in that, Applied to microcontrollers, the internal registers of the microcontroller include a data storage area and a task execution area. The task execution area stores data acquisition tasks, normal execution tasks, and special execution tasks, including: In this round of task scheduling, the data acquisition task is used to acquire first collection data from multiple controlled devices, and the first collection data is compared with the second collection data in the data storage area to obtain the comparison result; If the comparison result meets the data update condition, then the second collected data is updated using the first collected data to obtain the updated second collected data; Select a target parameter from multiple candidate parameters, obtain the device status information of the controlled device corresponding to the target parameter from the updated second collection data, and determine the target device based on the device status information; Select a preferred task from the normal execution tasks and the special execution tasks that corresponds to the alarm status of the target device, and use the preferred task to control the controlled device; If the iteration stop condition is not met, a new target parameter is selected from the multiple candidate parameters, and the process returns to the step of obtaining the device status information of the controlled device corresponding to the target parameter from the updated second collection data. If the iteration stop condition is met, the current round of task scheduling is completed, and the next round of task scheduling begins.

2. The method according to claim 1, characterized in that, The selection of the preferred task corresponding to the alarm status of the target device from the normal execution tasks and the special execution tasks includes: Determine the alarm status of the target device, the alarm status including no alarm status and alarm status, the alarm status including multiple alarm levels; If the target device is in a no-alarm state or at a low alarm level, the normal execution task corresponding to the target parameter will be the preferred task. If the target device is at an alarm level higher than the low alarm level, the special execution task corresponding to the target parameter will be selected as the preferred task.

3. The method according to claim 2, characterized in that, The special execution tasks include extreme execution tasks and shutdown tasks; The step of selecting the specific execution task corresponding to the target parameter as the preferred task includes: Determine the task level of each execution task within the aforementioned special execution task; From the extreme execution tasks and the shutdown tasks, the task corresponding to the task level that matches the alarm level is selected as the preferred task.

4. The method according to claim 1, characterized in that, Before the condition that the comparison result satisfies the data update condition, the method further includes: If the ratio of the parameter value in the first collected data to the corresponding parameter value in the second collected data is not within the set range, the comparison result is determined to meet the data update condition. If the ratio of the parameter value in the first collected data to the corresponding parameter value in the second collected data is within a set range, it is determined that the comparison result does not meet the data update conditions.

5. The method according to claim 1, characterized in that, The device status information includes operating status and in-situ status; Determining the target device based on the device status information includes: From the controlled devices corresponding to the target parameters, select the controlled devices whose operating status is normal and whose in-situ status is true as the target devices.

6. The method according to claim 1, characterized in that, The internal register also includes a main program area, which stores the main program; the method further includes: In response to a program update instruction, the main program is executed to detect whether there is an update file that meets the requirements, the program update instruction including update location information; If a matching update file exists, the main program uses the update file to update the task in the task execution area corresponding to the update location information.

7. The method according to claim 1, characterized in that, The microcontroller's internal registers also include a main program area, which stores the main program. The task execution area also stores the main program area update task. The method further includes: In response to the main program update command, the main program in the main program area is updated using the main program area update task.

8. A task scheduling device for a microcontroller, characterized in that, Applied to a microcontroller, the microcontroller's internal registers include a data storage area and a task execution area. The task execution area stores data acquisition tasks, normal execution tasks, and special execution tasks. The task scheduling device includes: The data comparison module is used to acquire first collected data from multiple controlled devices using the data acquisition task in this round of task scheduling, compare the first collected data with the second collected data in the data storage area, and obtain a comparison result. The data update module is used to update the second collected data using the first collected data if the comparison result meets the data update condition, so as to obtain the updated second collected data. The device selection module is used to select a target parameter from multiple candidate parameters, obtain the device status information of the controlled device corresponding to the target parameter from the updated second collection data, and determine the target device based on the device status information; The task execution module is used to select a preferred task corresponding to the alarm state of the target device from the normal execution tasks and the special execution tasks, and use the preferred task to control the controlled device; The loop control module is used to select a new target parameter from the plurality of candidate parameters if the iteration stop condition is not met, and return to the step of obtaining the device status information of the controlled device corresponding to the target parameter from the updated second acquisition data. If the iteration stop condition is met, the current round of task scheduling is completed and the next round of task scheduling is started.

9. An electronic device, characterized in that, include: The device includes a processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the task scheduling method for a microcontroller as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, performs the steps of the task scheduling method for a microcontroller as described in any one of claims 1 to 7.