Power allocation method and related apparatus
Patent Information
- Application Number
- CN202510500066.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-18
- Publication Date
- 2026-10-27
AI Technical Summary
在此过程中,开启时电路中出现瞬态的电流尖峰,依次关闭时电流又会出现多次骤降,使得电流频繁大幅度变化,进而对电池的使用寿命产生显著的负面影响
[0017]可见,在本申请实施例中,首先获取多个功率设备的第一设备信息和可分配的最大功率,所述第一设备信息包括额定功率、优先级和占空需求;然后根据所述第一设备信息和所述可分配的最大功率确定第一功率分布信息,所述第一功率分布信息包括所述多个功率设备在PWM周期的每个时刻的功率输出值;接着根据所述第一功率分布信息确定第一控制计划,所述第一控制计划用于控制所述多个功率设备在所述PWM周期内的工作时间;最后根据所述第一控制计划控制所述多个功率设备运行。
Smart Images

Figure CN122993135A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of power electronics, and more particularly to a power distribution method and related apparatus. Background Technology
[0002] In today's rapidly developing technological landscape, consumers have increasingly higher demands for product functionality and user experience, directly driving up product complexity. Currently, a single product often integrates dozens of power devices to meet diverse functional requirements. However, when implementing a particular function, multiple power devices simultaneously turn on and then sequentially turn off after reaching their corresponding duty cycles. During this process, transient current spikes occur in the circuit upon startup, and the current drops sharply multiple times upon sequential shutdown, resulting in frequent and significant current fluctuations. This, in turn, has a significant negative impact on battery life. Summary of the Invention
[0003] This application provides a power distribution method and related apparatus to achieve balanced power control, reduce battery impact, and improve product lifespan.
[0004] In a first aspect, embodiments of this application provide a power allocation method, including:
[0005] Obtain first device information and maximum allocable power for multiple power devices, wherein the first device information includes rated power, priority, and duty cycle requirement;
[0006] First power distribution information is determined based on the first device information and the maximum allocable power, wherein the first power distribution information includes the power output value of the plurality of power devices at each moment of the PWM cycle;
[0007] A first control plan is determined based on the first power distribution information, and the first control plan is used to control the working time of the plurality of power devices within the PWM cycle;
[0008] The operation of the plurality of power devices is controlled according to the first control plan.
[0009] Secondly, embodiments of this application provide a power distribution device, including:
[0010] An acquisition unit is used to acquire first device information and maximum allocatable power of multiple power devices, wherein the first device information includes rated power, priority, and duty cycle requirement;
[0011] The first determining unit is configured to determine first power distribution information based on the first device information and the maximum allocable power, wherein the first power distribution information includes the power output value of the plurality of power devices at each moment of the PWM cycle;
[0012] The second determining unit is configured to determine a first control plan based on the first power distribution information, wherein the first control plan is used to control the working time of the plurality of power devices within the PWM cycle.
[0013] A control unit is used to control the operation of the plurality of power devices according to the first control plan.
[0014] Thirdly, embodiments of this application provide a massage device, including a memory, a processor, and executable program code stored in the memory and executable on the processor, wherein the processor executes the executable program code and performs the steps of the method described in the first aspect.
[0015] Fourthly, embodiments of this application provide a computer-readable storage medium storing executable program code, the executable program code including execution instructions for performing the steps of the method as described in the first aspect.
[0016] Fifthly, embodiments of this application provide a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps described in the first aspect of embodiments of this application. The computer program product may be a software installation package.
[0017] As can be seen, in this embodiment, firstly, first device information and maximum allocable power of multiple power devices are obtained, the first device information including rated power, priority, and duty cycle requirement; then, first power distribution information is determined based on the first device information and the maximum allocable power, the first power distribution information including the power output value of the multiple power devices at each moment of the PWM cycle; next, a first control plan is determined based on the first power distribution information, the first control plan being used to control the working time of the multiple power devices within the PWM cycle; finally, the operation of the multiple power devices is controlled according to the first control plan.
[0018] This application optimizes the distribution of the PWM signal corresponding to each power device within a single PWM cycle by using the device information and maximum allocable power of the power devices, staggering the start-up time of the power devices, and evenly distributing the working time of different power devices, thereby achieving a stable distribution of the total power of the system, reducing the impact on the battery, and improving product life. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This application provides an architecture diagram of a power distribution system according to an embodiment.
[0021] Figure 2 This is a schematic flowchart of a power allocation method provided in an embodiment of this application;
[0022] Figure 3 This is a schematic flowchart of another power allocation method provided in an embodiment of this application;
[0023] Figure 4 This is a flowchart illustrating a high-frequency task provided in an embodiment of this application;
[0024] Figure 5 This is a flowchart illustrating a low-frequency task provided in an embodiment of this application;
[0025] Figure 6 This is the first power distribution diagram provided in the embodiments of this application;
[0026] Figure 7 This is the second power distribution diagram provided in the embodiments of this application;
[0027] Figure 8 This is the third power distribution diagram provided in the embodiments of this application;
[0028] Figure 9 This is the fourth power distribution diagram provided in the embodiments of this application;
[0029] Figure 10 This is the fifth power distribution diagram provided in the embodiments of this application;
[0030] Figure 11 This is the sixth power distribution diagram provided in the embodiments of this application;
[0031] Figure 12 This is the seventh power distribution diagram provided in the embodiments of this application;
[0032] Figure 13 This is the eighth power distribution diagram provided in the embodiments of this application;
[0033] Figure 14 This is the ninth power distribution diagram provided in the embodiments of this application;
[0034] Figure 15This is a functional unit block diagram of a power distribution device provided in an embodiment of this application;
[0035] Figure 16 This is a functional unit block diagram of another power distribution device provided in the embodiments of this application;
[0036] Figure 17 This is a schematic diagram of the structure of an electronic device proposed in an embodiment of this application. Detailed Implementation
[0037] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0038] The terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0039] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0040] In today's rapidly developing technological landscape, consumers have increasingly higher demands for product functionality and user experience, directly driving up product complexity. Today, a single product often needs to integrate dozens of power devices to meet diverse functional requirements. For example, in massage devices, to enhance the massage experience, heating films, high-power LED lights, and DC vibration motors are often integrated together. Pulse Width Modulation (PWM) is used to control the power of these devices to achieve different massage techniques.
[0041] Under traditional hardware PWM control, multiple power devices will be turned on simultaneously at a certain moment, and then turned off after reaching their duty cycles in sequence. The corresponding system power is at its peak at the moment of activation, and then decreases in sequence until it reaches zero at the end.
[0042] For consumer products, lithium batteries are typically used for power. Therefore, during the process of turning the battery on and off, the current is at its maximum when the battery is turned on, and the current drops sharply multiple times when the battery is turned off. This causes frequent and significant changes in the current, which in turn affects the battery life.
[0043] At the same time, high current will cause the terminal voltage of lithium battery to drop significantly. When the remaining capacity of lithium battery is less than 30% and is under high current, the probability of the terminal voltage dropping to the protection voltage of the battery pack will increase, which will easily trigger the battery protection, making the remaining capacity unusable and reducing the product's battery life.
[0044] Furthermore, in consumer electronics, chips used to detect battery capacity calculate the battery capacity through current sampling. Traditional PWM control current varies significantly at frequencies above tens of hertz, while commercially available fuel gauges typically have a current sampling rate of only a few hertz. This high-frequency current variation will lead to a large error in the battery capacity calculation by the fuel gauge.
[0045] To address the aforementioned issues, this application provides a power distribution method and related apparatus. The embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0046] Please see Figure 1 , Figure 1 This is an architecture diagram of a power distribution system provided in an embodiment of this application. Figure 1 As shown, the power distribution system 100 includes an initialization module 101, a high-frequency task module 102, and a low-frequency task module 103, wherein the initialization module 101, the high-frequency task module 102, and the low-frequency task module 103 are interconnected.
[0047] The initialization module 101 is used to initialize the microcontroller's external devices and multiple variables involved in power allocation, and to record relevant information about multiple power devices in the massage device. Specifically, the microcontroller is the control core of the massage device, and the microcontroller's external devices can be timers. For example, the frequency of the timer is initialized, and the maximum allocable power is set. For instance, the timer frequency F_timer is set to the actual PWM frequency × 100. The multiple variables involved in power allocation also include the power output value and priority of the power devices.
[0048] The relevant information for power devices includes device ID, rated power, and priority. The device ID is a unique identifier for each power device, used to distinguish different devices within the system. Rated power represents the power required for the device to operate normally. Priority indicates the relative importance of the power device in power allocation and scheduling; in situations of limited power, higher-priority power devices will be given priority to receive sufficient power to ensure normal operation and the realization of the system's main functions.
[0049] In addition to recording relevant information of multiple power devices in the massage device, it is also possible to initialize the switching state of each power device and the duty cycle of the power device in the PWM cycle.
[0050] The low-frequency task module 103 is used to allocate the operating time and power output value of each power device, obtaining the switching state of each power device at various moments in the PWM cycle. Specifically, allocation can be made based on the maximum allocable power and information such as the duty cycle, priority, and rated power of the power device. Furthermore, the low-frequency task module 103 can also reallocate power according to actual operating conditions and device requirements. After obtaining the switching state of each power device, the low-frequency task module 103 transmits this information to the high-frequency task module 102.
[0051] The high-frequency task module 102 includes a timer, which is used to continuously increment the counter in the timer. Then, based on the switching status of each power device provided by the low-frequency task module 103 and the value of the current counter, it traverses the switching status array of each power device to determine the power device that needs to be turned on at the current moment, and then controls its operation.
[0052] Based on this, this application provides a power distribution method and related apparatus, which will be described in detail below with reference to the accompanying drawings.
[0053] Please see Figure 2 , Figure 2 This is a flowchart illustrating a power allocation method provided in an embodiment of this application, as shown below. Figure 2 As shown, the method includes the following steps:
[0054] S210: Obtain first device information and maximum allocable power for multiple power devices.
[0055] The first device information includes rated power, priority, and duty cycle requirement.
[0056] Among them, power devices are power components in massage equipment, used to realize multiple functional requirements of the massage equipment. Examples include heating films, high-power LED lights, DC vibration motors, etc. Among them, massage equipment can be shoulder and neck massagers, waist massagers, eye massagers, back massagers, massage sofas, massage chairs, head massagers, massage pillows, leg massagers, etc.
[0057] Different massage modes can correspond to different priorities. The priority of the power device can be preset or customized by the user.
[0058] The duty cycle requirement of the power device is determined based on actual needs. Specifically, the duty cycle requirement can be the ratio of the actual power to be achieved to the rated power. For example, if the power device is a heating film and the temperature needs to be controlled at 40 degrees Celsius, continuing to operate according to the current duty cycle requirement after the heating film reaches 40 degrees Celsius will lead to overheating. In this case, the duty cycle requirement needs to be reduced to stabilize the temperature at 40 degrees Celsius.
[0059] S220, determine the first power distribution information based on the first device information and the maximum allocatable power.
[0060] The first power distribution information includes the power output value of the plurality of power devices at each moment of the PWM cycle.
[0061] In one possible embodiment, the power allocation order is determined according to the rated power of the power devices; specifically, the higher the rated power, the earlier the power allocation order.
[0062] The first power distribution information also includes the operating time of each power device.
[0063] In one possible embodiment, the first power distribution information can be represented by a power output array. An exemplary power output array can be SystemPower
[100] , which has a size of 100 and is used to record the power output values corresponding to 100 moments in the PWM cycle.
[0064] In one possible embodiment, the plurality of power devices includes a first power device and a second power device. Determining the first power distribution information based on the first device information and the maximum allocable power includes: if the rated power of the first power device is greater than the rated power of the second power device, determining second power distribution information based on the duty cycle requirement and rated power of the first power device, the second power distribution information including the power output value of the first power device at each moment of the PWM cycle; sorting the power output values in the second power distribution information according to a preset sorting rule to obtain a first power output sequence, the length of the first power output sequence being the same as the number of moments contained in the PWM cycle; determining third power distribution information based on the second power distribution information, the first power output sequence, the maximum allocable power, the first device information of the second power device, and the priority of the first power device, the third power distribution information including the power output values of the first power device and the second power device at each moment of the PWM cycle; and determining the third power distribution information as the first power distribution information.
[0065] If the rated power of the first power device is greater than that of the second power device, then the first power device is allocated operating time first, and the second power device is allocated time after the first power device's allocation is completed. The PWM cycle comprises multiple moments, and the operating time of each power device includes multiple PWM cycle moments.
[0066] First, the operating time and power output value of the first power device in the PWM cycle are determined. Specifically, the allocated duration of the first power device is determined by the duty cycle requirement of the first power device and the number of time periods divided in the PWM cycle. For example, if the duty cycle requirement of the first power device is 50% and the number of time periods divided in the PWM cycle is 100, then the allocated duration is 50 time periods. Then, following a sequential order, multiple operating times of the first power device are determined in the PWM cycle according to the allocated duration, and then the power output value of the first power device at multiple operating times is determined based on the rated power of the first power device.
[0067] For example, the first power device is a heating film with a duty cycle of 60% and a rated power of 8W. The PWM cycle is divided into 100 moments. In the PWM cycle, the first 1-60 moments are the working moments of the heating film, with a power output value of 8W. In the remaining 40 moments, the power output value is 0, that is, the power output value corresponding to moments 61-100 is 0.
[0068] The preset sorting rule is to sort the power output values at each moment in ascending order. In the first power output sequence, the power output value at each moment corresponds to a sequence number, and each sequence number corresponds to a moment within a PWM cycle. For example, if the PWM cycle is divided into 100 moments, the first power output sequence includes the sorted power output values at 100 moments, with the earlier the sequence number, the smaller the corresponding power output value.
[0069] In one possible embodiment, the first power output sequence can be represented by a power ID array. An exemplary power ID array could be SystemPowerID
[100] , which is 0-99 and stores the positions of the power output values at 100 moments in SystemPower
[100] from smallest to largest. For example, SystemPower[SystemPowerID[0]] is the smallest power output value at 100 moments, and SystemPower[SystemPowerID
[99] ] is the largest power output value at 100 moments.
[0070] In this embodiment, power devices with high rated power are allocated first. After the first power device is allocated, the power output value at each moment is sorted to intuitively understand the power distribution. Then, when allocating the working time of the second power device, the start-up time of the first power device can be staggered to achieve a uniform distribution of the working time of different power devices.
[0071] In one possible embodiment, determining the third power distribution information based on the second power distribution information, the first power output sequence, the maximum allocable power, the first device information of the second power device, and the priority of the first power device includes: determining the mapping relationship between each sequence number of the first power output sequence and each moment of the PWM cycle; determining the allocation duration of the second power device based on the duty cycle requirement of the second power device; determining the allocation period of the second power device in the PWM cycle based on the first power output sequence, the mapping relationship, and the allocation duration; determining the fourth power distribution information based on the second power distribution information, the allocation period, and the rated power of the second power device, wherein the fourth power distribution information is a reference power output value of the first power device and the second power device at each moment of the PWM cycle; and determining the third power distribution information based on the maximum allocable power, the priority of the second power device, the priority of the first power device, and the fourth power distribution information.
[0072] In this process, after reordering the power output values according to a preset sorting rule, each power output value at any given time has a corresponding sequence number. These sorted sequence numbers are then mapped to the timestamps of the PWM cycle. Continuing with the example where the first power device is a heating film, after sorting according to the preset rule, when the sequence number in the first power output sequence is 1-40, it corresponds to timestamps 61-100 of the PWM cycle, and its power output value is 0; when the sequence number in the first power output sequence is 41-100, it corresponds to timestamps 1-60 of the PWM cycle, and its power output value is 8W.
[0073] The allocation duration of the second power device is determined based on the duty cycle and the PWM period. Specifically, the allocation duration of the second power device is the product of the duty cycle and the number of time intervals divided by the PWM period. For example, if the duty cycle of the second power device is 30% and the number of time intervals divided by the PWM period is 100, then the allocation duration is 30 time intervals.
[0074] In one possible embodiment, determining the allocation period of the second power device in the PWM cycle based on the first power output sequence, the mapping relationship, and the allocation duration includes: assigning sequence numbers to the allocation duration in the first power output sequence according to a preset order to obtain multiple sequence numbers; and determining the allocation period based on the multiple sequence numbers and the mapping relationship.
[0075] The preset order is from front to back. In the first power output sequence, a sequence number is assigned to the allocated duration according to the from front to back order. Then, based on the mapping relationship between the sequence number and the PWM cycle time, multiple working times of the second power device are determined, that is, the allocated time period of the second power device.
[0076] For example, if the allocation duration is 30 time points, then the corresponding allocation sequence numbers are 1-30, and the PWM cycle time points are determined to be 61-90 according to the mapping relationship. The corresponding allocation time period includes time points 61-90 within the PWM cycle.
[0077] As can be seen, in the embodiments of this application, the power output sequence records power output values from small to large. By combining the sequence number of the power output sequence with the index relationship between the time of the PWM cycle, the working time of the power devices can be allocated, which can reduce the peak power of the system and achieve a uniform distribution of the working time of different power devices, thereby reducing the impact on the power supply system.
[0078] Specifically, based on the allocation period and rated power of the second power device, the operating time and power output value of the second power device are determined. Combined with the second power distribution information including the operating time and power output value of the first power device, the operating times of the first power device and the second power device, as well as the power output values of the first power device and the second power device at each moment of the PWM cycle, are obtained.
[0079] Using the example above where the first power device is a heating film, and the second power device is an LED lamp with a duty cycle of 40% and a rated power of 2W, then in the PWM cycle, the first 1-60 moments are the working moments of the heating film, with a power output value of 8W; and the 61-100 moments are the working moments of the LED lamp, with a power output value of 2W.
[0080] In one possible embodiment, after the allocation of any power device other than the first allocated power device is completed, it can be first determined whether the operating time of that power device overlaps with that of other already allocated power devices. If they do not overlap, the reference power distribution information obtained after the allocation of that power device can be determined as the target power distribution information. If they overlap, the reference power output value in the reference power distribution information is compared with the maximum allocable power to determine the target power distribution information.
[0081] In one possible embodiment, the plurality of power devices include a first power device and a second power device. If the operating time of the first power device does not coincide with the operating time of the second power device, then the fourth power distribution information is determined as the third power distribution information.
[0082] In one possible embodiment, determining the third power distribution information based on the allocable maximum power, the priority of the second power device, the priority of the first power device, and the fourth power distribution information includes: determining whether the reference power output values of the first power device and the second power device at each moment of the PWM cycle are both less than or equal to the allocable maximum power; if so, determining the fourth power distribution information as the third power distribution information; if not, determining the moments when the reference power output values of the first power device and the second power device at each moment of the PWM cycle are greater than the allocable maximum power, obtaining at least one reference moment; adjusting the power output value of the first power device or the second power device at each reference moment according to the priority of the second power device and the priority of the first power device, obtaining the target power output value of the first power device and the second power device at each reference moment; updating the fourth power distribution information according to the target power output value of the first power device and the second power device at each reference moment, obtaining the third power distribution information.
[0083] If the operating times of the first power device and the second power device overlap, the reference power output value of the overlapping portion refers to the total power output value of the first power device and the second power device.
[0084] Specifically, by comparing the reference power output value at each moment with the maximum allocable power, if the reference power output value at all moments within the PWM cycle does not exceed the maximum allocable power, then the power allocation is safe and feasible.
[0085] If at least one moment the reference power output value exceeds the maximum allocable power, then at each moment of excess, based on the priority of the power devices, the lower-priority power devices are shut down, the power output values of the lower-priority power devices at the moment of excess are cleared, and the power output value at the moment of excess is updated to obtain the target power output value. The reference power output value at each moment of excess is updated using the target power output value at each moment of excess to obtain the power output value at each moment of the PWM cycle.
[0086] As can be seen, by considering the maximum allocable power and priority in this application embodiment, resource allocation can be optimized, preventing the system from overloading due to excessive power allocation, and ensuring the normal operation of critical equipment.
[0087] In one possible embodiment, the plurality of power devices further includes a third power device, wherein the rated power of the second power device is greater than the rated power of the third power device. After determining the third power distribution information based on the second power distribution information, the first power output sequence, the maximum allocable power, the first device information of the second power device, and the priority of the first power device, the method further includes: sorting the power output values in the third power distribution information according to the preset sorting rules to obtain a second power output sequence; determining a fifth power distribution information based on the third power distribution information, the second power output sequence, the maximum allocable power, the first device information of the third power device, the priority of the first power device, and the priority of the second power device, wherein the fifth power distribution information includes the power output values of the first power device, the second power device, and the third power device at each moment of the PWM cycle; and determining the fifth power distribution information as the first power distribution information.
[0088] In one possible embodiment, the multiple power devices may further include other power devices besides the three power devices described above. For the other power devices included in the multiple power devices, the allocation order is first determined according to their rated power. Then, for the first allocated power device, the operating time and power output value are assigned to it according to the time sequence of the PWM cycle. For the other power devices besides the first allocated power device, the power output values obtained at each time after the allocation of the preceding power devices are completed are sorted according to a preset sorting rule to obtain a power output sequence. Then, based on the power output sequence, the operating time and power output value are assigned to the current power device to obtain the power output value at each time.
[0089] Specifically, the allocation process for the second power device is the same as that for the third power device. Specifically, the allocation duration of the third power device is determined based on its duty cycle requirement and the number of time slots divided within the PWM cycle. Then, in the second power output sequence, sequence numbers are assigned to the allocation durations of the third power devices in ascending order, and the allocation time slot for the third power device is determined by combining the mapping relationship. Afterwards, based on the allocation time slot and rated power of the third power device, the operating time and power output value of the third power device are determined. Combined with the third power distribution information, the operating times of the first, second, and third power devices, as well as the total power output value of the first, second, and third power devices at each time point in the PWM cycle, are obtained.
[0090] Furthermore, it is determined whether the operating times of the first, second, and third power devices overlap. If not, the total power output at each time moment is the final power distribution information, i.e., the fifth power distribution information. If they overlap, it is determined whether the total power output at the overlapping time moment exceeds the maximum allocable power. If none of the overlapping time moments exceed the maximum allocable power, the power allocation is safe and feasible, and the total power output at each time moment is the final power distribution information. If the total power output at at least one overlapping time moment exceeds the maximum allocable power, at the time of the excess, according to the priority of the power devices, the lower-priority power devices are shut down, the power output of the lower-priority power devices at the time of the excess is cleared, and the power output value at the time of the excess is updated to obtain the target power output value. The reference power output value at each time of the excess is updated by the target power output value at each time of the excess to obtain the power output value at each time moment of the PWM cycle, i.e., the final power distribution information.
[0091] For example, the first power device is a heating film with a duty cycle of 40% and a rated power of 8W; the second power device is LED1 with a duty cycle of 40% and a rated power of 4W; and the third power device is LED2 with a duty cycle of 20% and a rated power of 2W. The PWM cycle is divided into 100 time periods. In the PWM cycle, the power distribution order is heating film, LED1, and LED2. The power distribution information is as follows: the first 1-40 time periods are the working time of the heating film, with a power output value of 8W; the 41-80 time periods are the working time of LED1, with a power output value of 4W; and the 81-100 time periods are the working time of LED2, with a power output value of 2W.
[0092] As can be seen, in this embodiment, each time a power device is allocated, the power output value at each moment is sorted to obtain the distribution of the allocated power, thereby better allocating the working time of subsequent power devices and making the running time of the power devices evenly distributed in the PWM cycle.
[0093] S230, determine a first control plan based on the first power distribution information.
[0094] In one possible embodiment, determining the first control plan based on the first power distribution information includes: obtaining identification information of each power device among the plurality of power devices; determining the operating period of each power device in the PWM cycle based on the first power distribution information and the identification information, and generating the first control plan.
[0095] The identification information of the power device can be the power device's identification ID, used to distinguish different power devices.
[0096] Specifically, based on the identification information of the power devices, the operating time of each power device is determined in the first power distribution information. Based on the operating time and identification information of each power device, an array of switching states of each power device within the PWM cycle is constructed, thereby generating the first control plan.
[0097] In this configuration, the switch state corresponding to the working state is 1, and the switch state corresponding to the non-working state is 0. The switch state array for each power device can be constructed using a Switch statement, for example, Switch[ID][Cnt] = {Z}, where ID refers to the identifier ID of the power device, Cnt refers to the counted value of the counter, and Z is a variable between 0 and 1, including 1 and 0. If the counted value of the counter corresponds to the working state of power device i, then Z is 1, controlling the output of the microcontroller pin to be high, thus turning on power device i. If the counted value of the counter corresponds to the non-working state of power device i, then Z is 0, controlling the output of the microcontroller pin to be low, thus turning off power device i.
[0098] The first control plan is a timer task, i.e. a high-frequency task. It uses a counter to increment cyclically, then iterates through the switching state array of each power device, reads the switching state of each power device at the current moment, and then controls the high and low levels of the microcontroller pins to realize the operation of multiple power devices.
[0099] As can be seen, in this embodiment of the application, a control plan is generated based on the cyclic increment of the counter and the switching status information of the power device, which is conducive to the rational scheduling of the power device.
[0100] S240, control the operation of the plurality of power devices according to the first control plan.
[0101] In one possible embodiment, the first control plan includes an auto-incrementing counter, and controlling the operation of the plurality of power devices according to the first control plan includes: detecting that the counter value corresponding to the current moment is less than a preset value, then determining whether each of the plurality of power devices is in a working period at the current moment according to the first control plan, obtaining the switching state of each power device at the current moment, wherein the preset value is determined according to the number of moments contained in the PWM cycle; and controlling the operation of each power device according to the switching state.
[0102] The preset value is the same as the number of time intervals divided in the PWM cycle. If the number of time intervals divided in the PWM cycle is 100, then the preset value is 100.
[0103] After determining the first control plan, the first control plan is executed. The counter starts to increment from zero. Each time it increments, it checks whether the current value of the counter is greater than or equal to the preset value. If the value of the counter is less than the preset value, it traverses the switching state array of each power device, reads the switching state of each power device at the current moment, and then controls the high and low levels of the microcontroller pins to realize the operation of the power device.
[0104] As can be seen, in the embodiments of this application, the operation of each power device can be precisely controlled according to the first control plan, thereby improving the operating efficiency of the system and thus improving the overall stability and reliability of the system.
[0105] In one possible embodiment, the method further includes: detecting that the count value corresponding to the current time is greater than or equal to the preset value, and then updating the count value corresponding to the current time; determining whether there is a power device with a changed duty cycle requirement; and determining whether the maximum allocable power has changed; if there is a power device with a changed duty cycle requirement, and the maximum allocable power has not changed, then obtaining the changed duty cycle requirement of the power device; updating the first device information of the plurality of power devices according to the changed duty cycle requirement of the power device, and obtaining the second device information of the plurality of power devices; determining the sixth power distribution information according to the second device information and the maximum allocable power; determining the second control plan according to the sixth power distribution information; and controlling the operation of the plurality of power devices according to the second control plan and the updated count value corresponding to the current time.
[0106] As the counter increments, if the current counter value is greater than or equal to a preset value, a corresponding PWM cycle ends, the counter is reset to zero, and the incrementing starts again from zero. Simultaneously, it determines whether the duty cycle requirements of multiple power devices have changed, or whether the maximum allocable power has changed.
[0107] If there are power devices whose duty cycle changes, such as the duty cycle of the heating film decreasing from 60% to 40%, then the operating time and power output value of each power device need to be reallocated, thereby updating the switching state of each power device at each moment of the PWM cycle.
[0108] Specifically, new duty cycle requirements are obtained, the first device information of multiple power devices is updated, and the second device information is obtained. Following the power allocation method described above, based on the second device information and the maximum allocable power, the operating time and power output value of each power device are determined, resulting in the switching state of each power device at various moments in the PWM cycle. Then, a timer task is executed, with the counter incrementing from zero. Based on the switching state of each power device obtained after the reallocation, the operation of the power devices is controlled.
[0109] As can be seen, in this embodiment of the application, the control plan can be flexibly adjusted according to the occupancy requirements to meet the different needs of different scenarios.
[0110] In one possible embodiment, the method further includes: if there is a power device whose duty cycle demand changes, and the maximum allocable power changes, then obtaining the changed maximum allocable power; determining seventh power distribution information based on the second device information and the changed maximum allocable power; determining a third control plan based on the seventh power distribution information; and controlling the operation of the plurality of power devices based on the third control plan and the updated count value corresponding to the current time.
[0111] If there are power devices whose duty cycle requirements change, and the maximum power that can be allocated also changes, such as the duty cycle requirement of the heating film decreasing from 60% to 40% and the maximum power that can be allocated changing from 30W to 25W, then it is necessary to reallocate the working time and power output value of each power device, and thus update the switching state of each power device at each moment of the PWM cycle.
[0112] Specifically, the new duty cycle requirement and the new maximum allocable power are obtained. The first device information of multiple power devices is updated to obtain the second device information. According to the power allocation method described above, the operating time and power output value of each power device are determined based on the second device information and the new maximum allocable power, thus obtaining the switching state of each power device at various moments in the PWM cycle. Then, a timer task is executed, with the counter incrementing from zero. Based on the switching state of each power device obtained after the reallocation, the operation of the power devices is controlled.
[0113] As can be seen, in this embodiment, the control plan can be flexibly adjusted according to the duty cycle requirement and maximum power to meet the different needs of different scenarios.
[0114] In one possible embodiment, the method further includes: if there are no power devices with changing duty cycles and the maximum allocable power changes, then obtaining the changed maximum allocable power; determining eighth power distribution information based on the first device information and the changed maximum allocable power; determining a fourth control plan based on the eighth power distribution information; and controlling the operation of the plurality of power devices based on the fourth control plan and the updated count value corresponding to the current time.
[0115] If the maximum allocable power changes, the operating time and power output value of each power device need to be reallocated, thereby updating the switching state of each power device at each moment of the PWM cycle.
[0116] Specifically, the new allocable maximum power is obtained. Following the power allocation method described above, the operating time and power output value of each power device are determined based on the first device information and the new allocable maximum power, thus obtaining the switching state of each power device at various moments in the PWM cycle. Then, a timer task is executed, with the counter incrementing from zero. Based on the switching state of each power device obtained after the reallocation, the operation of the power devices is controlled.
[0117] As can be seen, in this embodiment, the control plan can be flexibly adjusted according to the maximum power to meet the different needs of different scenarios.
[0118] In one possible embodiment, the method further includes: if there are no power devices with changing duty cycles and the maximum allocable power remains unchanged, then controlling the operation of the plurality of power devices according to the updated count value corresponding to the current moment and the first control plan.
[0119] If there are no power devices whose duty cycle demand changes and the maximum power that can be allocated has not changed, then the timer task can be executed according to the switching state of each power device determined in the previous PWM cycle.
[0120] As can be seen, in this embodiment of the application, if the duty cycle requirement and the maximum allocable power remain unchanged, the counter increments cyclically, and the system continues to be controlled according to the first control plan to ensure the stability of the system operation.
[0121] As can be seen, in this embodiment, by optimizing the distribution of the PWM signal corresponding to each power device within a single PWM cycle using the device information and maximum allocable power, the startup times of the power devices are staggered, and the operating times of different power devices are evenly distributed, thereby achieving a stable distribution of the total system power. This reduces the impact on the battery and extends product lifespan. Simultaneously, balanced power control is achieved, which helps to further utilize the remaining battery capacity and improve product range. Furthermore, stable current changes are ensured, which helps improve the power estimation accuracy of the fuel gauge chip.
[0122] In one possible embodiment, please refer to Figure 3 , Figure 3 This is a schematic flowchart of another power allocation method provided in an embodiment of this application, as shown below. Figure 3 As shown, when performing power allocation, initialization is performed first, then the device is registered, and finally the high-frequency task and the low-frequency task are started.
[0123] Initialization includes initializing the timer frequency to F_time and setting the maximum allocable power.
[0124] In this embodiment, the power output array SystemPower represents the power distribution information, and the power ID array SystemPowerID represents the power output sequence. Specifically, initialization also includes clearing the power output array and the power ID array.
[0125] In one possible embodiment, multiple power devices can be sorted according to priority order to construct a device priority ID array, and multiple power devices can be sorted according to rated power to construct a device power ID array.
[0126] For example, the priority order is from high to low, and the device priority ID array can be DevicePriorityID[MAX_DEVICE_NUM] = {0~MAX_DEVICE_NUM}, where MAX_DEVICE_NUM is the size of the array, representing the maximum number of power devices that can exist in the system. If MAX_DEVICE_NUM is defined as 10, then the DevicePriorityID array can store the IDs of 10 power devices; {0~MAX_DEVICE_NUM} means that the elements of the array start from 0 and increment sequentially to MAX_DEVICE_NUM-1. The DevicePriorityID array stores the device IDs in descending order of priority. For example, DevicePriorityID[0] is the ID of the device with the lowest priority.
[0127] For example, the rated power is ordered from largest to smallest, and the device power ID array can be DevicePowerID[MAX_DEVICE_NUM] = {0~MAX_DEVICE_NUM}. The DevicePowerID array stores the IDs of the devices in descending order of rated power. For example, DevicePowerID[0] is the ID of the device with the largest power.
[0128] In one possible embodiment, initialization also includes clearing the device priority ID array and the device power ID array.
[0129] The registration device is used to record relevant information about multiple power devices in the massage device, including the ID of each power device, which can be set to DeviceId_n. It also includes reordering the device priority ID array according to priority and the device power ID array according to rated power. Additionally, it can initialize the switching state of each power device to be allocated, and set the PWM duty cycle of the power device to 0, etc.
[0130] Please refer to Figure 4 , Figure 4 This is a flowchart illustrating a high-frequency task provided in an embodiment of this application, such as... Figure 4 As shown, the high-frequency task uses a timer to control a counter that increments cyclically. The counter starts from zero and increments each time, checking if the current counter value is greater than or equal to a preset value. If the counter value is less than the preset value, it iterates through the switching state array of each power device, reads the current switching state of each power device, and then controls the high and low levels of the microcontroller pins to operate multiple power devices. The preset value is the value set by the timer. The switching state of each power device at various moments in its PWM cycle is provided by the low-frequency task.
[0131] If the counter's count is greater than or equal to a preset value, the counter is reset to zero, and it is determined whether the switch state array needs to be updated. Specifically, the update is determined based on the duty cycle requirement and the maximum allocable power. If the duty cycle requirement of any power device changes, or the maximum allocable power changes, the switch state array needs to be updated, and then reallocated power is achieved through a low-frequency task. After the low-frequency task ends, the updated switch state array is obtained, and the switch state of each power device is read according to the updated switch state array to control the operation of the power devices. If the duty cycle requirement of all power devices remains unchanged, and the maximum allocable power remains unchanged, the switch state array does not need to be updated, and the switch state of each power device continues to be read according to the current switch state array to control the operation of the power devices.
[0132] In this embodiment, to facilitate unified management and maintenance of the system, the switch state array can be copied into the IO state array. Then, using the counter value as the ID, the switch state of each power device is retrieved from the IO state array to control the high and low levels of the microcontroller pins. Similarly, after obtaining the updated switch state array, it can also be copied into the IO state array.
[0133] The low-frequency task is used to allocate the operating time and power output value of each power device according to the power allocation method described above, thereby obtaining the switching state of each power device at each moment of the PWM cycle. The switching states of the power devices in adjacent PWM cycles can be the same or different, determined by the duty cycle requirement and the maximum allocable power. If the duty cycle requirement or the maximum allocable power of a power device changes, the switching states of the power devices in the previous PWM cycle will be different from those in the current PWM cycle, requiring re-allocation via the low-frequency task. If the duty cycle requirement and the maximum allocable power of a power device remain unchanged, the switching states of the power devices in the previous PWM cycle will be the same as those in the current PWM cycle, requiring no re-allocation.
[0134] Specifically, please refer to Figure 5 , Figure 5 This is a flowchart illustrating a low-frequency task provided in an embodiment of this application, such as... Figure 5 As shown, when a low-frequency task begins, a judgment process can be set up first to determine whether all power devices have been allocated. If not, the power ID array is updated in ascending order according to the value in the power output array. Then, based on the allocation order, the working time and power output value of the current power device are allocated on the basis of the updated power ID array to obtain the working time and power output value of all allocated power devices, and thus obtain the power output value corresponding to each moment in the PWM cycle.
[0135] After the current power device allocation is completed, it can be determined whether the total power output value at each moment exceeds the maximum allocable power. If it exceeds the maximum allocable power, the power output value in the power output array for the time exceeding the allocable power is updated according to the power output value of the power device with the lowest priority. Specifically, at the time exceeding the allocable power, the lowest priority power device is turned off, the power output value of that power device at the time exceeding the allocable power is cleared, and then the power output value at the time exceeding the allocable power is updated. The power output array is then updated using the updated power output value.
[0136] Furthermore, the updated power output value can be compared with the maximum allocable power again, and the above process can be repeated until the updated power output value is less than or equal to the maximum allocable power.
[0137] If the maximum allocable power is not exceeded, the process returns to the procedure for determining whether all power devices have been allocated. If all power devices have been allocated, the switch state array is determined using the latest power output array, and the current low-frequency task ends.
[0138] In one possible embodiment, the multiple power devices include a large heating film, a small heating film, LED1 lamp and LED2 lamp, LED1 lamp and LED2 lamp have a rated power of 2W and a duty cycle of 40%, the large heating film has a rated power of 8W and a duty cycle of 50%, the small heating film has a rated power of 4W and a duty cycle of 30%, and the PWM cycle is divided into 100 moments.
[0139] First, initialization is performed, and the initialization steps are as described above, so they will not be repeated here. Then, the device IDs of LED1, LED2, the large heating film, and the small heating film are set to 0, 1, 2, and 3, respectively; the switch status arrays are Switch[0]
[100] = {0}, Switch[1]
[100] = {0}, Switch[2]
[100] = {0}, and Switch[3]
[100] = {0}, respectively; after sorting according to device priority, the device priority ID array DevicePriorityID[MAX_DEVICE_NUM] = {0, 1, 3, 2}; after sorting according to rated power, the device power ID array DevicePowerID[MAX_DEVICE_NUM] = {2, 3, 0, 1}.
[0140] Furthermore, a low-frequency task is initiated, and the switching time is allocated sequentially according to the device order stored in the DevicePowerID[MAX_DEVICE_NUM] array, namely, the large heating film, the small heating film, LED1, and LED2.
[0141] First, the operating time and power output value of the large heating film are allocated. Then, the power ID array is sorted according to the power output values in the power output array to obtain the power distribution diagram. Please refer to [link to details]. Figure 6 , Figure 6 This is the first power distribution diagram provided in the embodiments of this application, such as... Figure 6 As shown, the horizontal axis of the power distribution graph includes the PWM cycle time and the power IDs in the power ID array, while the vertical axis represents the power output values in the power output array. The operating time and power output values for the large heating film will then be assigned; please refer to [link to relevant documentation] for details. Figure 7 , Figure 7 This is the second power distribution diagram provided in the embodiments of this application, such as... Figure 7 As shown, based on the duty cycle requirements of the large heating film, the working time of the large heating film is determined to be from time 1 to 50. Based on the rated power of the large heating film, the power output value during time 1 to 50 is determined to be 8W, and the power output array is updated.
[0142] After the large heating film is distributed, the power ID array is sorted according to the updated power output values in the power output array, and the power distribution map is updated. Please refer to [link to details]. Figure 8 , Figure 8 This is the third power distribution diagram provided in the embodiments of this application, such as... Figure 8 As shown, the PWM cycle times corresponding to the large heating film are times 1-50, and the corresponding power IDs are 50-99. Based on the allocation order and the updated power distribution diagram, the operating times and power output values of the small heating film are allocated. Please refer to [link / reference] for details. Figure 9 , Figure 9 This is the fourth power distribution diagram provided in the embodiments of this application, such as... Figure 9 As shown, based on the duty cycle requirement of the small heating film, the working time of the large heating film is determined to be from time 51 to 80. Based on the rated power of the large heating film, the power output value during time 51 to 80 is determined to be 4W, and the power output array is updated again.
[0143] After the small heating film is distributed, the power ID array is sorted according to the power output values of the previously updated power output array, and the power distribution map is updated. Please refer to [link to details]. Figure 10 , Figure 10 This is the fifth power distribution diagram provided in the embodiments of this application, such as... Figure 10 As shown, the PWM cycle time corresponding to the small heating film is 51-80, and the corresponding power ID is 20-49. Based on the allocation order and the updated power distribution diagram, the operating time and power output value of LED1 are allocated. Please refer to [link / reference] for details. Figure 11 , Figure 11 This is the sixth power distribution diagram provided in the embodiments of this application, such as... Figure 11 As shown, based on the duty cycle requirements of LED1, its operating times are determined to be 51-70 and 81-100. Based on the rated power of LED1, the power output value during these two periods is set at 2W. During 51-70, the operating times of the small heating film and LED1 overlap, resulting in a total power output of 6W, which does not exceed the maximum allocable power. Therefore, there is no need to prioritize and shut down any particular power device. The power output array is then updated based on the allocation results for LED1.
[0144] After LED1 lights are allocated, the power ID array is sorted according to the power output values in the previously updated power output array, and the power distribution map is updated. Please refer to [link to details]. Figure 12 , Figure 12 This is the seventh power distribution diagram provided in the embodiments of this application, such as... Figure 12As shown, for LED1, the power ID is 0-19 when the PWM cycle time is between 81-100, and 30-49 when the cycle time is between 51-70. Based on the allocation order and the updated power distribution diagram, the operating time and power output value of LED2 are allocated. Please refer to [link to relevant documentation] for details. Figure 13 , Figure 13 This is the eighth power distribution diagram provided in the embodiments of this application, such as... Figure 13 As shown, based on the duty cycle requirements of LED2, the operating times of LED2 are determined to be 51-60, 71-80, and 81-100. Based on the rated power of LED1, the power output value at 51-60, 71-80, and 81-100 is determined to be 2W.
[0145] Specifically, between times 81 and 100, the operating times of LED2 and LED1 overlap, with a total power output of 4W, which does not exceed the maximum allocable power, so there is no need to shut down any particular power device based on priority. Between times 71 and 80, the operating times of LED2 and the small heating film overlap, with a total power output of 6W, which also does not exceed the maximum allocable power, so there is no need to shut down any particular power device based on priority. Between times 51 and 60, the operating times of the small heating film, LED1, and LED2 overlap, with a total power output of 8W, which does not exceed the maximum allocable power, so there is no need to shut down any particular power device based on priority.
[0146] After the LED2 lights are allocated, all power devices are allocated. Following the PWM cycle sequence, the power distribution map is updated to obtain the operating time and power output value of each power device. For details, please refer to [link to relevant documentation]. Figure 14 , Figure 14 This is the ninth power distribution diagram provided in the embodiments of this application, such as... Figure 14 As shown, the large heating film is turned on at times 1-50; the small heating film, LED1, and LED2 are turned on at times 51-60; the small heating film and LED1 are turned on at times 61-70; the small heating film and LED2 are turned on at times 71-80; and LED1 is turned on at times 81-100.
[0147] After obtaining the working time and power output value of each power device, the switching state array of each power device can be constructed by combining the identification information of each device. The switching state array of LED1 is Switch[0]
[100] , the switching state array of LED2 is Switch[1]
[100] , the switching state array of the large heating film is Switch[2]
[100] , and the switching state array of the small heating film is Switch[3]
[100] ={0}.
[0148] Furthermore, a high-frequency task is initiated, and the counter Cnt increments cyclically from 0 to 99. If the value exceeds the timer's set value, it is reset to zero; if Cnt >= 100, then Cnt = 0. Each time the counter increments, it iterates through the switching state array of each power device, reads the switching state of each device, and then controls the high and low levels of the corresponding pins on the microcontroller to control the operation of the large heating film, small heating film, LED1, and LED2.
[0149] For example, if Switch[0][Cnt] = 1, turn on LED1, otherwise turn off LED1; if Switch[1][Cnt] = 1, turn on LED2, otherwise turn off LED2; if Switch[2][Cnt] = 1, turn on the large heating film, otherwise turn off the large heating film; if Switch[3][Cnt] = 1, turn on the small heating film, otherwise turn off the small heating film.
[0150] For examples consistent with the above embodiments, please refer to... Figure 15 , Figure 15 This is a functional unit block diagram of a power distribution device provided in an embodiment of this application, such as... Figure 15 As shown, the power distribution device 150 includes: an acquisition unit 151, configured to acquire first device information and a maximum allocable power for a plurality of power devices, wherein the first device information includes rated power, priority, and duty cycle requirement; a first determination unit 152, configured to determine first power distribution information based on the first device information and the maximum allocable power, wherein the first power distribution information includes the power output value of the plurality of power devices at each moment of the PWM cycle; a second determination unit 153, configured to determine a first control plan based on the first power distribution information, wherein the first control plan is used to control the operating time of the plurality of power devices within the PWM cycle; and a control unit 154, configured to control the operation of the plurality of power devices according to the first control plan.
[0151] In one possible embodiment, the plurality of power devices includes a first power device and a second power device. Regarding determining the first power distribution information based on the first device information and the maximum allocable power, the first determining unit 152 is specifically configured to: if the rated power of the first power device is greater than the rated power of the second power device, determine second power distribution information based on the duty cycle requirement and rated power of the first power device, the second power distribution information including the power output value of the first power device at each moment of the PWM cycle; sort the power output values in the second power distribution information according to a preset sorting rule to obtain a first power output sequence, the length of the first power output sequence being the same as the number of moments contained in the PWM cycle; determine third power distribution information based on the second power distribution information, the first power output sequence, the maximum allocable power, the first device information of the second power device, and the priority of the first power device, the third power distribution information including the power output values of the first power device and the second power device at each moment of the PWM cycle; and determine the third power distribution information as the first power distribution information.
[0152] In one possible embodiment, in determining the third power distribution information based on the second power distribution information, the first power output sequence, the maximum allocable power, the first device information of the second power device, and the priority of the first power device, the first determining unit 152 is further configured to: determine the mapping relationship between each sequence number of the first power output sequence and each moment of the PWM cycle; determine the allocation duration of the second power device based on the duty cycle requirement of the second power device; determine the allocation period of the second power device in the PWM cycle based on the first power output sequence, the mapping relationship, and the allocation duration; determine the fourth power distribution information based on the second power distribution information, the allocation period, and the rated power of the second power device, wherein the fourth power distribution information is a reference power output value of the first power device and the second power device at each moment of the PWM cycle; and determine the third power distribution information based on the maximum allocable power, the priority of the second power device, the priority of the first power device, and the fourth power distribution information.
[0153] In one possible embodiment, in determining the third power distribution information based on the maximum allocable power, the priority of the second power device, the priority of the first power device, and the fourth power distribution information, the first determining unit 152 is further configured to: determine whether the reference power output values of the first power device and the second power device at each moment of the PWM cycle are both less than or equal to the maximum allocable power; if so, determine the fourth power distribution information as the third power distribution information; if not, determine the moment when the reference power output values of the first power device and the second power device at each moment of the PWM cycle are greater than the maximum allocable power, obtaining at least one reference moment; adjust the power output value of the first power device or the second power device at each reference moment according to the priority of the second power device and the priority of the first power device, obtaining the target power output value of the first power device and the second power device at each reference moment; update the fourth power distribution information according to the target power output value of the first power device and the second power device at each reference moment, obtaining the third power distribution information.
[0154] In one possible embodiment, in determining the allocation period of the second power device in the PWM cycle based on the first power output sequence, the mapping relationship, and the allocation duration, the first determining unit 152 is further configured to: assign sequence numbers to the allocation duration in the first power output sequence according to a preset order to obtain multiple sequence numbers; and determine the allocation period based on the multiple sequence numbers and the mapping relationship.
[0155] In one possible embodiment, the plurality of power devices further includes a third power device, wherein the rated power of the second power device is greater than the rated power of the third power device. After determining the third power distribution information based on the second power distribution information, the first power output sequence, the maximum allocable power, the first device information of the second power device, and the priority of the first power device, the first determining unit 152 is further configured to: sort the power output values in the third power distribution information according to the preset sorting rules to obtain a second power output sequence; determine a fifth power distribution information based on the third power distribution information, the second power output sequence, the maximum allocable power, the first device information of the third power device, the priority of the first power device, and the priority of the second power device, wherein the fifth power distribution information includes the power output values of the first power device, the second power device, and the third power device at each moment of the PWM cycle; and determine the fifth power distribution information as the first power distribution information.
[0156] In one possible embodiment, in determining the first control plan based on the first power distribution information, the second determining unit 153 is specifically configured to: obtain identification information of each power device among the plurality of power devices; determine the operating period of each power device in the PWM cycle based on the first power distribution information and the identification information, and generate the first control plan.
[0157] In one possible embodiment, the first control plan includes an auto-incrementing counter. Specifically, in controlling the operation of the plurality of power devices according to the first control plan, the control unit 154 is configured to: detect that the counter value corresponding to the current moment is less than a preset value; then, according to the first control plan, determine whether each of the plurality of power devices is in a working period at the current moment, obtain the switching state of each power device at the current moment, wherein the preset value is determined based on the number of moments contained in the PWM cycle; and control the operation of each power device according to the switching state.
[0158] In one possible embodiment, in controlling the operation of the plurality of power devices according to the first control plan, the control unit 154 is further configured to: detect that the count value corresponding to the current time is greater than or equal to the preset value, and update the count value corresponding to the current time; determine whether there is a power device whose duty cycle requirement has changed; and determine whether the maximum allocable power has changed; if there is a power device whose duty cycle requirement has changed, and the maximum allocable power has not changed, obtain the changed duty cycle requirement of the power device; update the first device information of the plurality of power devices according to the changed duty cycle requirement of the power device, and obtain the second device information of the plurality of power devices; determine the sixth power distribution information according to the second device information and the maximum allocable power; determine the second control plan according to the sixth power distribution information; and control the operation of the plurality of power devices according to the second control plan and the updated count value corresponding to the current time.
[0159] In one possible embodiment, in controlling the operation of the plurality of power devices according to the first control plan, the control unit 154 is further configured to: if there is a power device whose duty demand changes, and the maximum allocable power changes, obtain the changed maximum allocable power; determine seventh power distribution information based on the second device information and the changed maximum allocable power; determine a third control plan based on the seventh power distribution information; and control the operation of the plurality of power devices according to the third control plan and the updated count value corresponding to the current time.
[0160] In one possible embodiment, in controlling the operation of the plurality of power devices according to the first control plan, the control unit 154 is further configured to: if there are no power devices with changing duty requirements and the maximum allocable power changes, then obtain the changed maximum allocable power; determine eighth power distribution information based on the first device information and the changed maximum allocable power; determine a fourth control plan based on the eighth power distribution information; and control the operation of the plurality of power devices according to the fourth control plan and the updated count value corresponding to the current time.
[0161] In one possible embodiment, in controlling the operation of the plurality of power devices according to the first control plan, the control unit 154 is further configured to: if there are no power devices with changing duty requirements and the maximum allocable power has not changed, then control the operation of the plurality of power devices according to the updated count value corresponding to the current time and the first control plan.
[0162] It is understood that since the method embodiments and the device embodiments are different presentations of the same technical concept, the content of the method embodiment section in this application should be adapted to the device embodiment section, and will not be repeated here.
[0163] In the case of using integrated units, please refer to Figure 16 , Figure 16 This is a functional unit block diagram of another power distribution device provided in the embodiments of this application, such as... Figure 16 As shown, the power distribution device 150 includes a processing module 1502 and a communication module 1501. The processing module 1502 controls and manages the operation of the power distribution device 150, for example, executing the steps of the acquisition unit 151, the first determination unit 152, the second determination unit 153, and the control unit 154, and / or performing other processes of the technology described herein. The communication module 1501 is used for interaction between the power distribution device 150 and other devices. Figure 16 As shown, the power distribution device 150 may further include a storage module 1503, which is used to store the program code and data of the power distribution device 150.
[0164] The processing module 1502 can be a processor or controller, such as a central processing unit (CPU), a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc. The communication module 1501 can be a transceiver, RF circuitry, or a communication interface, etc. The storage module 1503 can be a memory.
[0165] All relevant content in each scenario involved in the above method embodiments can be referenced from the functional descriptions of the corresponding functional modules, and will not be repeated here. The power distribution device 150 described above can perform the above... Figure 2 The power allocation method shown.
[0166] Please see Figure 17 , Figure 17 This is a schematic diagram of the structure of an electronic device proposed in an embodiment of this application, as shown below. Figure 17 As shown, the electronic device 1700 includes a processor 1710, a memory 1720, a communication interface 1730, and one or more programs 1721. The one or more programs 1721 are stored in the memory and configured to be executed by the processor. When the program is executed, it includes some or all of the steps of any of the power distribution methods described in the above method embodiments. The processor, memory, and communication interface are interconnected and complete communication between them.
[0167] The memory can be volatile memory such as Dynamic Random Access Memory (DRAM) or non-volatile memory such as a hard disk drive. The memory stores a set of executable program code, and the processor calls the executable program code stored in the memory to execute some or all of the steps of any power allocation method described in the above power allocation method embodiments.
[0168] As can be seen, the electronic device 1700 described in this application embodiment first obtains first device information and the maximum allocable power of multiple power devices. The first device information includes rated power, priority, and duty cycle requirement. Then, it determines first power distribution information based on the first device information and the maximum allocable power. The first power distribution information includes the power output value of the multiple power devices at each moment of the PWM cycle. Next, it determines a first control plan based on the first power distribution information. The first control plan is used to control the working time of the multiple power devices within the PWM cycle. Finally, it controls the operation of the multiple power devices according to the first control plan.
[0169] This application optimizes the distribution of the PWM signal corresponding to each power device within a single PWM cycle by using the device information and maximum allocable power of the power devices, staggering the start-up time of the power devices, and evenly distributing the working time of different power devices, thereby achieving a stable distribution of the total power of the system, reducing the impact on the battery, and improving product life.
[0170] This application also provides a computer storage medium storing a computer program for electronic data interchange, which causes a computer to perform some or all of the steps of any of the methods described in the above method embodiments, wherein the computer includes an electronic device.
[0171] This application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any of the methods described in the above method embodiments. The computer program product may be a software installation package, and the computer may include an electronic device.
[0172] It should be noted that, for the sake of simplicity, the aforementioned methods are described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are optional, and the actions and modules involved are not necessarily essential to this application.
[0173] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0174] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical or other forms.
[0175] 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, depending on actual needs.
[0176] Furthermore, 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. The integrated unit can be implemented in hardware or as a software program module.
[0177] If the integrated unit is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory 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 memory includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0178] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage device, which may include: a flash drive, a read-only memory, a random access memory, a magnetic disk, or an optical disk, etc.
[0179] The embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The above description of the embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A power distribution method, characterized in that, include: Obtain first device information and maximum allocable power for multiple power devices, wherein the first device information includes rated power, priority, and duty cycle requirement; First power distribution information is determined based on the first device information and the maximum allocable power, wherein the first power distribution information includes the power output value of the plurality of power devices at each moment of the PWM cycle; A first control plan is determined based on the first power distribution information, and the first control plan is used to control the working time of the plurality of power devices within the PWM cycle; The operation of the plurality of power devices is controlled according to the first control plan.
2. The method according to claim 1, characterized in that, The plurality of power devices includes a first power device and a second power device. Determining the first power distribution information based on the first device information and the maximum allocable power includes: If the rated power of the first power device is greater than the rated power of the second power device, then the second power distribution information is determined based on the duty cycle requirement and rated power of the first power device. The second power distribution information includes the power output value of the first power device at each moment of the PWM cycle. The power output values in the second power distribution information are sorted according to a preset sorting rule to obtain a first power output sequence. The length of the first power output sequence is the same as the number of moments contained in the PWM cycle. Based on the second power distribution information, the first power output sequence, the maximum allocable power, the first device information of the second power device, and the priority of the first power device, a third power distribution information is determined, the third power distribution information including the power output values of the first power device and the second power device at each moment of the PWM cycle; The third power distribution information is determined as the first power distribution information.
3. The method according to claim 2, characterized in that, The step of determining the third power distribution information based on the second power distribution information, the first power output sequence, the maximum allocable power, the first device information of the second power device, and the priority of the first power device includes: Determine the mapping relationship between each sequence number of the first power output sequence and each moment of the PWM cycle; The allocation duration of the second power device is determined based on the duty cycle requirement of the second power device; Based on the first power output sequence, the mapping relationship, and the allocation duration, the allocation period of the second power device in the PWM cycle is determined; Based on the second power distribution information, the allocation period, and the rated power of the second power device, fourth power distribution information is determined, wherein the fourth power distribution information is the reference power output value of the first power device and the second power device at each moment of the PWM cycle; The third power distribution information is determined based on the maximum allocatable power, the priority of the second power device, the priority of the first power device, and the fourth power distribution information.
4. The method according to claim 3, characterized in that, The step of determining the third power distribution information based on the allocatable maximum power, the priority of the second power device, the priority of the first power device, and the fourth power distribution information includes: Determine whether the reference power output values of the first power device and the second power device at each moment of the PWM cycle are both less than or equal to the maximum allocable power; If so, the fourth power distribution information is determined as the third power distribution information; If not, then determine the reference power output values of the first power device and the second power device at each moment of the PWM cycle, and obtain at least one reference moment when the reference power output value is greater than the maximum allocable power. Based on the priority of the second power device and the priority of the first power device, adjust the power output value of the first power device or the second power device at each reference time in the at least one reference time to obtain the target power output value of the first power device and the second power device at each reference time; The fourth power distribution information is updated based on the target power output values of the first power device and the second power device at each reference time to obtain the third power distribution information.
5. The method according to claim 3, characterized in that, Determining the allocation period of the second power device in the PWM cycle based on the first power output sequence, the mapping relationship, and the allocation duration includes: According to a preset order, a sequence number is assigned to the allocation duration in the first power output sequence to obtain multiple sequence numbers; The allocated time period is determined based on the plurality of serial numbers and the mapping relationship.
6. The method according to claim 2, characterized in that, The plurality of power devices further includes a third power device, wherein the rated power of the second power device is greater than the rated power of the third power device. After determining the third power distribution information based on the second power distribution information, the first power output sequence, the maximum allocable power, the first device information of the second power device, and the priority of the first power device, the method further includes: The power output values in the third power distribution information are sorted according to the preset sorting rules to obtain the second power output sequence; Based on the third power distribution information, the second power output sequence, the maximum allocable power, the first device information of the third power device, the priority of the first power device, and the priority of the second power device, a fifth power distribution information is determined. The fifth power distribution information includes the power output values of the first power device, the second power device, and the third power device at each moment of the PWM cycle. The fifth power distribution information is determined as the first power distribution information.
7. The method according to any one of claims 1-6, characterized in that, Determining the first control plan based on the first power distribution information includes: Obtain the identification information of each of the plurality of power devices; Based on the first power distribution information and the identification information, the operating period of each power device in the PWM cycle is determined, and the first control plan is generated.
8. The method according to any one of claims 1-6, characterized in that, The first control plan includes an auto-incrementing counter, and controlling the operation of the plurality of power devices according to the first control plan includes: If the count value corresponding to the current moment is detected to be less than the preset value, then according to the first control plan, it is determined whether each of the multiple power devices is in a working period at the current moment, and the switching state of each power device at the current moment is obtained. The preset value is determined according to the number of moments contained in the PWM cycle. Control the operation of each power device according to the switch state.
9. The method according to claim 8, characterized in that, The method further includes: If the count value corresponding to the current time is detected to be greater than or equal to the preset value, then the count value corresponding to the current time is updated. Determine whether there are power devices whose duty cycle demand has changed; and determine whether the maximum allocatable power has changed; If there are power devices whose duty cycle requirements change, but the maximum allocable power remains unchanged, then the duty cycle requirements of the power devices after the change are obtained. Based on the changed duty cycle requirements of the power devices, update the first device information of the plurality of power devices to obtain the second device information of the plurality of power devices; The sixth power distribution information is determined based on the second device information and the maximum allocatable power. A second control plan is determined based on the sixth power distribution information; The operation of the plurality of power devices is controlled according to the second control plan and the updated count value corresponding to the current moment.
10. The method according to claim 9, characterized in that, The method includes: If there are power devices whose duty cycle requirements change, and the maximum allocable power changes, then the changed maximum allocable power is obtained. The seventh power distribution information is determined based on the second device information and the changed maximum allocatable power. The third control plan is determined based on the seventh power distribution information; The operation of the plurality of power devices is controlled according to the third control plan and the updated count value corresponding to the current moment.
11. The method according to claim 9, characterized in that, The method further includes: If there are no power devices whose duty cycle demand changes, and the maximum allocable power changes, then the changed maximum allocable power is obtained. The eighth power distribution information is determined based on the first device information and the changed maximum allocatable power. The fourth control plan is determined based on the eighth power distribution information; The operation of the plurality of power devices is controlled according to the fourth control plan and the updated count value corresponding to the current moment.
12. The method according to claim 9, characterized in that, The method further includes: If there are no power devices whose duty cycle demand changes and the maximum allocable power remains unchanged, then the operation of the multiple power devices is controlled according to the updated count value corresponding to the current time and the first control plan.
13. A power distribution device, characterized in that, include: An acquisition unit is used to acquire first device information and maximum allocatable power of multiple power devices, wherein the first device information includes rated power, priority, and duty cycle requirement; The first determining unit is configured to determine first power distribution information based on the first device information and the maximum allocable power, wherein the first power distribution information includes the power output value of the plurality of power devices at each moment of the PWM cycle; The second determining unit is configured to determine a first control plan based on the first power distribution information, wherein the first control plan is used to control the working time of the plurality of power devices within the PWM cycle. A control unit is used to control the operation of the plurality of power devices according to the first control plan.
14. A massage device, characterized in that, The massage device includes: The memory, the processor, and executable program code stored in the memory and executable on the processor, wherein the processor executes the steps of the power distribution method as described in any one of claims 1-12 when executing the executable program code.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores executable program code, the executable program code including execution instructions for performing the steps of the power allocation method as described in any one of claims 1-12.