Control function switching method of controller and controller thereof

By recording the duration timing when the control function is interrupted and performing according to the original control function rules at the recovery time, combining step and duration adjustment methods, the seamless connection and resource occupation problems in controller function switching are solved, achieving uniform adjustment and optimized user experience.

CN120295090APending Publication Date: 2025-07-11KEBODA TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410043724.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-11
Publication Date
2025-07-11

AI Technical Summary

Technical Problem

In the process of switching controller functions, the existing technology has problems that the operation rules when the function is restored and before interruption are inconsistent, resulting in difficulty in seamless connection, or the function is running in the background to occupy too much system resources, increasing hardware costs.

Method used

By recording the duration timing when the control function is interrupted, the output value during recovery is calculated, and the original control function rules will be continued at the recovery time. Combined with step and duration adjustment methods, the remainder will be evenly allocated to avoid jumps and seamless switching will be achieved.

Benefits of technology

It realizes seamless connection of different control functions, avoids the jump of output values, reduces system resource occupation, and is suitable for a variety of embedded platforms and application scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120295090A_ABST
    Figure CN120295090A_ABST
Patent Text Reader

Abstract

The invention discloses a control function switching method of a controller and the controller. The method comprises the following steps: outputting a control signal digital quantity according to a control rule of a first control function; when an effective request for starting the second control function is received, switching to the second control function, and outputting a control signal digital quantity according to a control rule of the second control function; when an effective request for closing the second control function is received, according to the duration time F1Tcnt of the first control function when the controller receives the effective closing request and the time consumed for switching the second control function to the first control function, the duration time F1Tin when the second control function is switched to the first control function is calculated; the first control function is switched at the F1Tin time, and the control signal digital quantity is output according to the control rule of the first control function from the F1Tin time. When the previous control function is interrupted by the next control function and then is recovered, the previous control function continues to be executed according to the output value of the previous control function at the recovery moment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a controller, and in particular to a technology for switching control functions of a controller. Background Art

[0002] When a controller drives a load (such as an LED or a motor), the controller uses different magnitudes of numbers to represent different characteristics of the controlled operating parameters. For example, when the controller outputs 10000, it means that the duty cycle of the PWM signal output by the controller is 100%, and when the controller outputs 7500, it means that the duty cycle of the PWM signal output by the controller is 75%.

[0003] In a complex function switching process, for example, in the process of LED dimming, there are the following requirements: during the execution of a certain dimming function (set as function one, such as an animation effect) by the controller, the controller is requested to be interrupted by another dimming function (set as function two), and the controller needs to adjust the control rule and output the digital quantity of the control signal according to the control rule of function two; when the request of function two is executed, the controller needs to resume from the interruption process and continue to execute function one. For the foregoing interruption / resumption process, there are two processing methods in the existing algorithms: The first method is to record the output value A of function one at this moment when function one is interrupted, stop running the algorithm of function one, and then execute function two. After function two is executed, function two is turned off, and function one is resumed from the foregoing output value A; The second method is that when function one is interrupted, function one switches to background operation, and then the system executes function two. At this time, the algorithm of function one is still running completely. After function two is executed, function two is turned off, and function one is restored to foreground operation, that is, during the interruption of function one, the algorithms of function one and function two run simultaneously and calculate the output value, and only the output value of one of them is selected through state switching.

[0004] The disadvantages of the prior art are as follows: In the first method, when function one resumes running, it starts running from the output value at the interruption, which results in inconsistent running rules / rhythms before and after the interruption of function one, that is, the control curve (or line segment) of function one after resumption is offset by a certain phase from the control curve (or line segment) of function one before interruption, and the seamless connection between function one and function two cannot be realized; The disadvantage of the second method is that function one needs to be completely executed during background operation, which occupies more system resources, has higher requirements for hardware, and increases costs. Summary of the Invention

[0005] The technical problem to be solved by the present invention is to provide a method for switching control functions of a controller and the controller thereof, which can realize the switching of different control functions, and when the previous control function resumes execution after being interrupted by the subsequent control function, continue to execute the previous control function according to the output value of the previous control function at the resumption moment.

[0006] Another technical problem to be solved by the present invention is to provide a control function switching method for a controller and the controller, which can meet the requirements of various complex output regulations, can also adjust the digital quantity of the output control signal more evenly based on the execution cycle of the controller, avoid the occurrence of jump phenomena, and can be applied to a variety of embedded platforms and various application scenarios.

[0007] In a first aspect, a control function switching method for a controller according to an embodiment of the present invention includes the following steps:

[0008] Output the digital quantity of the control signal according to the control rule of the first control function. The first control function includes one or more control stages, and the one or more control stages are continuously executed in sequence without being interrupted; after each control stage starts to execute, start timing the duration F1_Tcnt consumed by this control stage; according to the control rule, the output value of the digital quantity of the control signal corresponding to any duration timing of any control stage can be calculated;

[0009] When receiving a valid request to enable the second control function, interrupt the first control function and switch to the second control function, and output the digital quantity of the control signal according to the control rule of the second control function; the duration timing F1_Tcnt of the control stage where the first control function is interrupted remains timed during the interruption of the first control function;

[0010] When receiving a valid request to disable the second control function, calculate the duration timing F1_Tin of the control stage where the first control function is interrupted at the time when the controller receives the valid disable request and the switching time t_21 from the second control function to the first control function, F1_Tin = F1_Tcnt + t_21, and define the moment after the duration timing F1_Tin from the start of the duration timing of the control stage where the first control function is interrupted as the F1_Tin moment;

[0011] If, in the case where the first control function is not interrupted, the control stage of the first control function that should be executed at the F1_Tin moment is d, and the duration timing at the F1_Tin moment corresponding to this control stage d is A, then use this control stage d as the to-be-executed control stage, and use the duration timing A as the duration timing of the to-be-executed control stage at the F1_Tin moment; switch to the first control function at the F1_Tin moment, and continue to output the digital quantity of the control signal according to the control rule of the first control function from the time point when the duration timing of the to-be-executed control stage d is A;

[0012] If, when the first control function is not interrupted and there is no unfinished control stage of the first control function at time F1_Tin, the digital quantity of the control signal is output in a pre-specified manner starting from time F1_Tin.

[0013] The control function switching method of the above-mentioned controller, wherein, for each control stage with a given initial adjustment value and a given adjustment target value, both the initial adjustment value and the adjustment target value being digital quantities of the control signal and the initial adjustment value and the adjustment target value being unequal, the adjustment is performed according to the following steps:

[0014] Calculate the absolute value Dim_diff of the difference between the adjustment target value and the adjustment starting value;

[0015] If Dim_diff is greater than the total number of execution cycles Dim_tim for adjustment and the quotient of Dim_diff and Dim_tim has a remainder Dim_remainder1, Dim_remainder1≥1, then control the current output value to change by Dim_delta1+1 every execution cycle in m execution cycles and change by Dim_delta1 every execution cycle in Dim_tim−m execution cycles in the direction approaching the adjustment target value, where m is equal to Dim_remainder1 and Dim_delta1 is the integer part of the quotient of Dim_diff and Dim_tim; if Dim_diff is less than the total number of execution cycles Dim_tim for adjustment and the quotient of Dim_tim and Dim_diff has a remainder Dim_remainder2, Dim_remainder2≥1, then control the current output value to change by 1 every Dim_delta2+1 execution cycles in n execution cycles and change by 1 every Dim_delta2 execution cycles in Dim_tim−n execution cycles in the direction approaching the adjustment target value, where n is equal to (Dim_delta2+1)*Dim_remainder2 and Dim_delta2 is the integer part of the quotient of Dim_tim and Dim_diff.

[0016] In a second aspect, the controller according to an embodiment of the present invention includes: a memory for storing a program; and a processor for loading the program to execute the foregoing control function switching method.

[0017] The present invention has at least the following advantages:

[0018] 1. The embodiment of the present invention realizes the switching of different control functions. When the previous control function is interrupted by the subsequent control function and resumes execution, the previous control function continues to execute according to the output value of the previous control function at the recovery time, realizing seamless connection;

[0019] 2. When adjusting the current output value of the controller in steps in the embodiments of the present invention, the remainder of the step size is evenly distributed among the fixed step sizes executed in multiple execution cycles. When adjusting the current output value of the controller by duration, the remainder of the duration is evenly distributed among multiple durations, thereby avoiding the jump phenomenon of the output value and improving the adjustment effect and user experience.

[0020] 3. The embodiments of the present invention are applicable to the adjustment of various digital output values. Users can flexibly adjust the target value and the total number of execution cycles for adjustment to meet the requirements of various complex output adjustment.

[0021] 4. The present invention calculates and adjusts the output data through the number of system execution cycles, and can be applied to the switching and restoration of different control functions, and flexibly realizes the switching effect of different scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 FIG. shows a schematic flowchart of a control function switching method of a controller according to a first embodiment of the present invention.

[0023] Figure 2 FIG. shows a schematic diagram of the relationship between the output value and time when the controller executes the switching of two control functions in a specific embodiment of the present invention.

[0024] Figure 3 FIG. shows a schematic flowchart of a control function switching method of a controller according to a specific embodiment of the present invention.

[0025] Figure 4 FIG. shows a schematic diagram of the relationship between the output value and time when the controller executes the switching of two control functions in another specific embodiment of the present invention.

[0026] Figure 5 FIG. shows a schematic diagram of the relationship between the output value and time when the controller executes the switching of two control functions in still another specific embodiment of the present invention.

[0027] Figure 6 FIG. shows a schematic diagram of the relationship between the output value and time when the controller executes the switching of two control functions in yet another specific embodiment of the present invention.

[0028] Figures 7 to 9 FIG. shows a schematic flowchart of a specific embodiment of a digital quantity adjustment method for the control signal of a controller. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0029] Figure 1 FIG. shows a schematic flowchart of a control function switching method of a controller according to a first embodiment of the present invention. Please refer to Figure 1 , the control function switching method of the controller according to the first embodiment of the present invention includes the following steps:

[0030] Output the digital quantity of the control signal according to the control rules of the first control function. The first control function includes one or more control stages, and the one or more control stages are continuously executed in sequence without interruption; after each control stage starts to execute, the duration F1_Tcnt consumed by this control stage is timed; according to the control rules, the output value of the digital quantity of the control signal corresponding to the timing of any duration in any control stage can be calculated.

[0031] When a valid request to enable the second control function is received, interrupt the first control function and switch to the second control function, and output the digital quantity of the control signal according to the control rules of the second control function; the duration timing F1_Tcnt of the control stage interrupted by the first control function remains timed during the interruption of the first control function.

[0032] When a valid request to disable the second control function is received, calculate the duration timing F1_Tin of the control stage interrupted by the first control function at the time when the controller receives the valid disable request and the switching time t_21 from the second control function to the first control function, F1_Tin = F1_Tcnt + t_21. Define the moment after the duration timing F1_Tin from the start of the duration timing of the control stage interrupted by the first control function as the F1_Tin moment.

[0033] If, in the case where the first control function is not interrupted, the control stage of the first control function that should be executed at the F1_Tin moment is d, and the duration timing at the F1_Tin moment corresponds to the duration timing A in this control stage d, then use this control stage d as the control stage to be executed, and use the duration timing A as the duration timing of the control stage to be executed at the F1_Tin moment; switch to the first control function at the F1_Tin moment, and continue to output the digital quantity of the control signal according to the control rules of the first control function from the time point when the duration timing of the control stage d to be executed is A.

[0034] If, in the case where the first control function is not interrupted, there is no unfinished control stage of the first control function at the F1_Tin moment, then output the digital quantity of the control signal in a pre-specified manner from the F1_Tin moment.

[0035] In this embodiment, both the first control function and the second control function include one or more control stages. Each control stage has a corresponding adjustment start value, the total number of execution cycles for adjustment, and an adjustment target value. When running to the corresponding control stage, the system adjusts the output of the digital quantity of the control signal according to the corresponding adjustment start value, the total number of execution cycles for adjustment, and the adjustment target value, so that the digital quantity of the control signal changes from the adjustment start value to the adjustment target value within the given adjustment time (i.e., the total number of execution cycles for adjustment) according to the corresponding control rule. Among them, according to the control rule, the system can calculate the output value of the digital quantity of the control signal at any moment within the given adjustment time (i.e., the total number of execution cycles for adjustment) of any control stage.

[0036] The following combines a specific implementation manner and Figure 2 and Figure 3 to describe the above method in detail. Figure 2 shows a schematic diagram of the relationship between the output value and time when the controller executes the switching of two control functions. Figure 3 shows a schematic flowchart of this implementation manner.

[0037] Please refer to Figure 2 . Figure 2 In, the horizontal axis represents time t, and the vertical axis represents the output value OutValue of the digital quantity of the control signal of the controller. The first control function includes a control inclined line segment 1 (i.e., one control stage), and the second control function includes a plurality of control pulses 2 (that is, includes a plurality of control stages). Each pulse top 2a, pulse front edge segment 2b, and pulse trailing edge segment 2c is a control stage respectively, and the connection segments are between the pulses. The control inclined line segment 1, pulse top 2a, pulse front edge segment 2b, pulse trailing edge segment 2c, and each connection segment all have a given adjustment start value, a given adjustment target value, and a given total number of execution cycles for adjustment. Both the adjustment start value and the adjustment target value are digital quantities of the control signal.

[0038] Please refer to Figure 3 . The working process of the control function switching method of the controller in this specific implementation manner is described as follows.

[0039] Step S1: The controller receives a request for a first control function, the first control function includes one or more control stages, the one or more control stages are executed in sequence and continuously, the controller performs adjustment initialization according to the adjustment start value, the total number of adjustment execution cycles and the adjustment target value of the control stage to be executed, and outputs the control signal digital quantity according to the control rule of the first control function, that is, the control signal digital quantity changes from the adjustment start value to the adjustment target value according to the corresponding control rule within a given adjustment time (i.e., the total number of adjustment execution cycles); after each control stage starts, the time F1_Tcnt consumed by the control stage (i.e., the consumed execution cycle count) is counted; wherein, according to the control rule, the system can calculate the output value of the control signal digital quantity at any time within the given adjustment time (i.e., the total number of adjustment execution cycles);

[0040] Furthermore, Figure 2 In the illustrated embodiment, the first control function is a control stage, the adjustment start value is 0, the total number of adjustment execution cycles is F1_Ton and the adjustment target value is F1_tg; if the first control function includes multiple control stages, such as a curve (which may be composed of multiple line segments), then starting from the second control stage, the adjustment target value of the previous control stage is taken as the adjustment start value of the control stage.

[0041] Step S2: The controller determines whether a high priority request (i.e., a second control function request) is received. If not, the controller continues to adjust the output of the first control function. If a second control function request (i.e., a second control function request in this embodiment) is received, the controller continues to adjust the output of the first control function. Figure 2 The trapezoidal wave part), then enter step S3;

[0042] Step S3: recording the adjustment start value, the total number of adjustment execution cycles, and the adjustment target value of the current control stage (i.e., the interrupted control stage) of the first control function, stopping the calculation and output of the control signal digital quantity of the current control stage (i.e., the interrupted control stage) of the first control function, and at the same time, the duration timer F1_Tcnt of the interrupted control stage keeps timing in the background (i.e., F1_Tcnt is always running in the background);

[0043] The second control function includes one or more control phases, and the one or more control phases are executed sequentially and continuously. The controller performs adjustment initialization according to the adjustment start value, the total number of execution cycles for adjustment, and the adjustment target value of the control phase to be executed, and outputs a digital control signal according to the control rules of the second control function from the time when a valid start request is received by the controller, that is, adjusts the output of each control phase of the second control function, so that the digital control signal of the second control function changes from the adjustment start value to the adjustment target value within the given adjustment time (i.e., the total number of execution cycles for adjustment) according to the corresponding control rules; wherein, when a valid request to start the second control function is received, the digital control signal obtained based on the control rules of the first control function when the controller receives the valid start request is used as the adjustment start value of the first control phase of the second control function. If the second control function includes multiple control phases, the adjustment target value of the previous control phase is taken as the adjustment start value of this control phase starting from the second control phase;

[0044] Step S4: Determine whether the request for the second control function is to be closed (i.e., whether a request to close the second control function is received). If the request is valid, continue the output adjustment of the second control function. If the request is to close, enter the closing process:

[0045] S41: The controller receives a valid request to close the second control function, and calculates the duration count F1_Tin (background count time) of the control phase interrupted by the first control function when the controller receives the valid close request and the switching time t_21 for the second control function to switch to the first control function. F1_Tin = F1_Tcnt + t_21;

[0046] It should be noted that the duration count F1_Tin may be less than or equal to the total number of execution cycles for adjustment of the control phase interrupted by the first control function (such as Figure 2 the shown situation), which is equivalent to the control phase interrupted when switching back to the first control function not being completed in the background; or it may be greater than the total number of execution cycles for adjustment of the control phase interrupted by the first control function and less than or equal to the sum of the total number of execution cycles for adjustment of all remaining control phases of the first control function starting from the interrupted control phase, which is equivalent to the control phase interrupted when switching back to the first control function being completed in the background, and currently a certain control phase after the interrupted control phase is being executed in the background; or it may be greater than the sum of the total number of execution cycles for adjustment of all remaining control phases of the first control function starting from the interrupted control phase, which is equivalent to all control phases of the first control function being completed in the background;

[0047] S42: If the duration timer F1_Tin is less than or equal to the total number of execution cycles for adjustment in the control phase where the first control function is interrupted, then determine the control phase where the first control function is interrupted as the control phase to be executed by the first control function when switching back to the first control function. Based on F1_Tin calculated in step S41, the adjustment start value, the total number of execution cycles for adjustment, and the adjustment target value of the control phase where the first control function is interrupted recorded in step S3, calculate the output value F1_SWin of the duration timer for the control phase to be executed corresponding to the cut-in point (i.e., the F1_Tin moment) when the second control function cuts into the first control function according to the control rule of the first control function (i.e., the adjustment method of control slant line 1 in this embodiment);

[0048] If the duration timer F1_Tin is greater than the total number of execution cycles for adjustment in the control phase where the first control function is interrupted and less than or equal to the sum of the total number of execution cycles for adjustment of all remaining control phases of the first control function starting from the interrupted control phase, then determine the k-th control phase of the first control function as the control phase to be executed by the first control function when switching back to the first control function, where k satisfies the following conditions:

[0049] The sum of the total number of execution cycles for adjustment of the first control function from the interrupted control phase to the (k - 1)-th control phase < F1_Tin ≤ the sum of the total number of execution cycles for adjustment of the first control function from the interrupted control phase to the k-th control phase;

[0050] Based on F1_Tin calculated in step S41, the adjustment start value, the total number of execution cycles for adjustment, and the adjustment target value of the k-th control phase of the first control function, calculate the output value F1_SWin of the duration timer A for the k-th control phase corresponding to the cut-in point (i.e., the F1_Tin moment) when the second control function cuts into the first control function according to the control rule of the first control function; the duration timer A for the k-th control phase corresponding to the aforementioned F1_Tin moment is equal to F1_Tin minus the sum of the total number of execution cycles for adjustment of the first control function from the interrupted control phase to the (k - 1)-th control phase;

[0051] If the duration timer F1_Tin is greater than the sum of the total number of execution cycles for adjustment of all remaining control phases of the first control function starting from the interrupted control phase, it is considered that all control phases of the first control function have been executed. Then, use the value specified by the system or the output value of the third control function as the output value F1_SWin at the cut-out point (i.e., the F1_Tin moment) of the second control function. For example, the adjustment target value of the last control phase of the first control function can be used as the output value F1_SWin at the cut-in point (i.e., the F1_Tin moment) when the second control function cuts into the first control function;

[0052] S43: When the controller receives a valid request to turn off the second control function, use the output value of the digital quantity of the control signal of the second control function as the adjustment starting value, use the output value F1_SWin calculated in step S42 as the adjustment target value, and use the switching time t_21 as the total number of execution cycles for adjustment to initialize the shutdown process of the second control function;

[0053] Step S5: Based on the control rules of the second control function, perform output adjustment on the shutdown process of the second control function;

[0054] Step S6: Determine whether the shutdown process of the second control function is completed. If the shutdown process is not completed, continue with step S5. If the shutdown process is completed, proceed to step S7;

[0055] Step S7: According to the first control function's pending control phase determined in step S42, restore / set the adjustment information of the first control function's pending control phase and perform adjustment initialization for the first control function, that is, initialize with the adjustment starting value, total number of execution cycles for adjustment, and adjustment target value of the first control function's pending control phase determined in step S42; if all control phases of the first control function determined in step S42 have been executed, then perform initialization in the system-specified manner (such as outputting the system-specified output value, or the third control function), for example, prepare to continuously output the constant value F1_SWin;

[0056] After step S7 is completed, if step S42 determines the first control function's pending control phase, then starting from the first control function's pending control phase determined in step S42, continue the output adjustment of the first control function starting from the timing of the duration of the pending control phase corresponding to F1_Tin; that is, based on the previously initialized values, starting from the timing of the duration of the pending control phase corresponding to F1_Tin determined in step S42, calculate the output value of the pending control phase based on the control rules of the first control function, and continue the output adjustment of the first control function (i.e., simulate the effect of the first control function running in the background during the operation of the second control function, but actually the first control function does not actually run, only F1_tcnt runs in the background);

[0057] After step S7 is completed, if all control phases of the first control function determined in step S42 have been executed, then perform output in the system-specified manner, such as continuously outputting the constant value F1_SWin, or executing the third control function and outputting the corresponding digital quantity of the control signal;

[0058] Step S9: Determine whether the output adjustment of the first control function is completed. If the output adjustment is not completed, jump back to step S2 to continue execution.

[0059] In this embodiment, the first control function is the animation effect of vehicle lights, such as the running light control of the vehicle, and the second control function is the turn signal control of the vehicle.

[0060] Furthermore, a valid request to turn off the second control function can be received at any time when the second control function is running. More preferably, a valid request to turn off the second control function can be received at the end point of a certain control stage of the digital quantity of the control signal of Function 2. For example, a valid request to turn off the second control function is received at the end of the stage where the digital quantity of the control signal of Function 2 remains constant after rising or at the end of the stage where the digital quantity of the control signal of Function 2 remains constant after falling, so as to ensure that the rising stage or falling stage of Function 2 is completely run, making the entire function switching process more regular / rhythmic. Figure 2 In the shown embodiment, when a valid request to turn off the second control function is received when the second control function is at the bottom of the pulse front edge (as shown by the downward-slanting arrow in Figure 2 ), the switching time t_21 for switching the second control function to the first control function is taken as the execution duration (total number of execution cycles for adjustment) F2_Ton of the pulse front edge segment, that is, F1_Tin = F1_Tcnt + F2_Ton; in another embodiment, as shown in Figure 4 , when a valid request to turn off the second control function is received when the second control function is at the top of the pulse trailing edge, the switching time t_21 for switching the second control function to the first control function is taken as the execution duration (total number of execution cycles for adjustment) F2_Toff of the pulse trailing edge segment, that is, F1_Tin = F1_Tcnt + F2_Toff.

[0061] Furthermore, for t_21, its value can be calculated so that the closing process of Function 2 runs according to the original rule (for example, the changing frequency remains unchanged, or both the frequency + waveform remain unchanged). However, for the sake of simplifying the calculation and reducing the resources occupied by the system, it is preferred that t_21 is a preset fixed value, such as the cases shown in Figure 3 and Figure 4 . In addition, t_21 can also be set to zero, such as the rectangular pulse or sine wave pulse shown in Figure 5 and Figure 6 .

[0062] This embodiment realizes the switching of different dimming functions. When the previous dimming function is interrupted by the next dimming function and resumes execution, the previous dimming function continues to execute according to the output value at the recovery moment, achieving seamless connection.

[0063] Furthermore, in the actual operation of adjusting the working parameters of a load by changing the digital quantity of the control signal output by a controller (such as PWM, current, voltage, or a control quantity corresponding to the aforementioned physical quantity), there often occurs a problem that the difference between the given adjustment target value and the adjustment starting value of the controller cannot be evenly divided by the total number of given adjustment execution cycles (the total number of given adjustment execution cycles is the given adjustment time). The conventional approach is to add the remainder of the quotient of the two to a fixed step size or a fixed duration at once. This adjustment method is likely to cause jumps in the working parameters of the load, affecting the user experience. Taking the dimming of a vehicle headlight controller as an example, assume that the given adjustment target value is 105, the adjustment starting value is 0, and the total number of given adjustment execution cycles is 20. Then the remainder of the quotient of the difference between the adjustment target value and the adjustment starting value of the controller divided by the total number of given adjustment execution cycles is 5. Using the existing adjustment method, in the first 19 execution cycles when the controller performs the adjustment task, the controller adjusts according to a fixed step size, that is, the controller increases the control output value by 5 every time it goes through an execution cycle. In the last execution cycle, the controller uses the sum of the remainder and the fixed step size as the adjustment step size, and the control output value increases by 10. Since the duty cycle of the dimming PWM signal output by the controller in the last cycle changes significantly, it will cause the LED lamp to flicker violently, thus affecting the user experience.

[0064] In order to evenly adjust the digital quantity of the control signal output in the control stage where each adjustment initial value and adjustment target value are not equal and avoid the occurrence of jump phenomena, the control signal digital quantity adjustment method in the control stage of the basic invention embodiment (i.e., the control rules of the aforementioned first control function and the second control function) includes the following steps:

[0065] Calculate the absolute value Dim_diff of the difference between the adjustment target value and the adjustment starting value;

[0066] If Dim_diff is greater than the total number of execution cycles for adjustment Dim_tim and the quotient of Dim_diff and Dim_tim has a remainder Dim_remainder1, Dim_remainder1 ≥ 1, then control the current output value to change by Dim_delta1 + 1 every other execution cycle among m execution cycles in the direction approaching the adjustment target value, and change by Dim_delta1 every other execution cycle among Dim_tim - m execution cycles. m is equal to Dim_remainder1, and Dim_delta1 is the integer part of the quotient of Dim_diff and Dim_tim. If Dim_diff is less than the total number of execution cycles for adjustment Dim_tim and the quotient of Dim_tim and Dim_diff has a remainder Dim_remainder2, Dim_remainder2 ≥ 1, then control the current output value to change by 1 every Dim_delta2 + 1 execution cycles among n execution cycles in the direction approaching the adjustment target value, and change by 1 every Dim_delta2 execution cycles among Dim_tim - n execution cycles. n is equal to (Dim_delta2 + 1) * Dim_remainder2, and Dim_delta2 is the integer part of the quotient of Dim_tim and Dim_diff.

[0067] The aforementioned m execution cycles can be m consecutive execution cycles or non - consecutive ones. The aforementioned n execution cycles can be n consecutive execution cycles or non - consecutive ones.

[0068] Furthermore, if Dim_tim is equal to 0, then make the adjustment starting value change by Dim_diff in the direction approaching the adjustment target value.

[0069] The digital quantity of the control signal includes but is not limited to PWM, current, voltage, or their corresponding control quantities.

[0070] The above - mentioned adjustment method can avoid the phenomenon of output value jump when Dim_remainder1 > 1 and Dim_remainder2 > 1. When Dim_remainder1 > 3 and Dim_remainder2 > 3, the effect of avoiding the output value jump obtained by this adjustment method is more obvious.

[0071] It should be noted that when Dim_diff = Dim_tim, the current output value is controlled to change by 1 in the direction approaching the adjustment target value every execution cycle. When Dim_diff > Dim_tim and the quotient of Dim_diff and Dim_tim has no remainder, it changes by Dim_delta1 every execution cycle, where Dim_delta1 is the quotient of Dim_diff and Dim_tim. When Dim_diff < Dim_tim and the quotient of Dim_tim and Dim_diff has no remainder, it changes by 1 every Dim_delta2 execution cycles, where Dim_delta2 is the quotient of Dim_tim and Dim_diff.

[0072] Figures 7 to 9 Fig. shows a schematic flow chart of a specific embodiment of the method for adjusting the digital quantity of the control signal of the controller (i.e., the method for adjusting the digital quantity of the control signal adopted for controlling the inclined line segment 1, the pulse front edge segment 2b, and the pulse trailing edge segment 2c), where Figure 7 shows the initialization process of the adjustment. Combining Figures 7 to 9 as shown, the method for adjusting the digital quantity of the control signal of the controller includes the following steps:

[0073] Step S1:

[0074] The controller receives the externally input adjustment target value Dim_Stop_Val and the given total number of execution cycles for adjustment Dim_tim (the given total number of execution cycles for adjustment Dim_tim is equal to the adjustment time divided by the execution cycle of the preset controller adjustment task). If the adjustment target value Dim_Stop_Val is equal to the current output value Dim_Start_Val of the controller, no adjustment is performed. If the adjustment target value Dim_Stop_Val is not equal to the current output value Dim_Start_Val, adjustment initialization is performed. Here, both the adjustment target value Dim_Stop_Val and the adjustment starting value Dim_Start_Val are integers. For example, when the controller adjusts the load of an automobile, the adjustment target value Dim_Stop_Val equal to 10000 represents that the controller outputs a PWM signal with a duty cycle of 100%.

[0075] Step S2:

[0076] If it is determined in step S1 that adjustment is required, calculate the absolute value Dim_diff of the difference between the adjustment target value and the current output value and determine the adjustment direction: If Dim_Stop_Val > Dim_Start_Val, determine that the adjustment direction is upward; if Dim_Stop_Val < Dim_Start_Val, determine that the adjustment direction is downward. Dim_diff = |Dim_Stop_Val - Dim_Start_Val|. In the figure, Dim_direction = 1 represents the upward adjustment direction, and Dim_direction = 0 represents the downward adjustment direction.

[0077] Step S3:

[0078] The controller compares Dim_diff with Dim_tim: If Dim_tim is equal to 0, the controller enters the step size adjustment mode, and the fixed step size Dim_delta1 (i.e., the adjustment value) is equal to Dim_diff;

[0079] If Dim_diff is less than Dim_tim, the controller enters the duration adjustment mode, calculates the fixed duration Dim_delta2 (the fixed duration for adjustment) and the remainder value Dim_remainder2 that cannot be divided evenly. Dim_delta2 = the integer value of Dim_tim / Dim_diff; Dim_remainder2 = Dim_tim - Dim_delta2 * Dim_diff;

[0080] If Dim_diff is greater than Dim_tim, the controller enters the step size adjustment mode, calculates the fixed step size Dim_delta1 (the adjustment value) and the remainder value Dim_remainder1 that cannot be divided evenly. Dim_delta1 = the integer value of Dim_diff / Dim_tim, Dim_remainder1 = Dim_diff - Dim_delta1 * Dim_tim.

[0081] Step S4:

[0082] The controller determines whether the adjustment process is completed based on the comparison result between the execution cycle count Dim_tim_cnt consumed by the adjustment and Dim_tim. If Dim_tim_cnt is greater than or equal to Dim_tim, the adjustment process ends; if Dim_tim_cnt is less than Dim_tim, the adjustment process continues.

[0083] Step S5: If the adjustment direction is downward, enter the downward adjustment process, which includes:

[0084] Step S51: The controller determines whether to enter the step adjustment mode or the duration adjustment mode for adjustment. In the figure, Dim_method = 1 represents entering the duration adjustment mode, and Dim_method = 0 represents entering the step adjustment mode;

[0085] Step S52: If entering the duration adjustment mode, the adjustment steps are as follows:

[0086] If the execution cycle count Dim_tim_cnt consumed for adjustment is greater than (Dim_delta2 + 1) * Dim_remainder2, and the remainder of the quotient of (Dim_tim_cnt - Dim_remainder2) and Dim_delta2 [i.e., ((Dim_tim_cnt - Dim_remainder2) % Dim_delta2)] is equal to 0, the current output value Dim_output_val = Dim_start_val - (Dim_tim_cnt - Dim_remainder2) / Dim_delta2, that is, the controller reduces the current output value by 1 every Dim_delta2 execution cycles; where "(Dim_delta 2 + 1) * Dim_remainder2" is the time point where the execution time remainder is distributed forward, and "((Dim_tim_cnt - Dim_remainder2) % Dim_delta2)" is the fixed duration point;

[0087] If the execution cycle count Dim_tim_cnt consumed for adjustment is less than or equal to (Dim_delta2 + 1) * Dim_remainder2, and the remainder of Dim_tim_cnt and (Dim_delta2 + 1) [i.e., Dim_tim_cnt % (Dim_delta2 + 1)] is equal to 0, the current output value Dim_output_val = Dim_start_val - Dim_tim_cnt / (Dim_delta2 + 1), that is, the controller reduces the current output value by 1 every Dim_delta2 + 1 execution cycles;

[0088] Step S53: If entering the step adjustment mode, the adjustment steps are as follows:

[0089] If the execution cycle count Dim_tim_cnt consumed for adjustment is greater than Dim_remainder1, the current output value Dim_output_val = Dim_start_val - Dim_remainder1 - Dim_delta1 * Dim_tim_cnt, that is, the controller reduces the current output value by Dim_delta1 every execution cycle;

[0090] If the execution cycle count Dim_tim_cnt consumed by the regulation is less than or equal to Dim_remainder1, the current output value Dim_output_val=Dim_start_val-(Dim_delta1+1)*Dim_tim_cnt, that is, the controller reduces the current output value by Dim_delta1+1 every time an execution cycle passes.

[0091] Step S6: If the adjustment direction is upward, enter the upward adjustment process, which includes:

[0092] Step S61: The controller determines whether to enter the step length adjustment mode or the duration adjustment mode. In the figure, Dim_method=1 represents entering the duration adjustment mode, and Dim_method=0 represents entering the step length adjustment mode;

[0093] Step S62: If the duration adjustment mode is entered, the adjustment steps are as follows:

[0094] If the execution cycle count Dim_tim_cnt consumed by the adjustment is greater than (Dim_delta2+1)*Dim_remainder2, and the remainder of the quotient of (Dim_tim_cnt-Dim_remainder2) and Dim_delta2 [i.e., ((Dim_tim_cnt-Dim_remainder2)%Dim_delta2)] is equal to 0, the current output value Dim_output_val=Dim_start_val+(Dim_tim_cnt-Dim_remainder2) / Dim_delta2, that is, the controller increases the current output value by 1 every Dim_delta2 execution cycles; among which "(Dim_delta2+1)*Dim_remainder2" is the time point allocated in front of the execution time remainder, and "((Dim_tim_cnt-Dim_remainder2)%Dim_delta2)" is the fixed time point;

[0095] If the execution cycle count Dim_tim_cnt consumed by the adjustment is less than or equal to (Dim_delta2+1)*Dim_remainder2, and the remainder of Dim_tim_cnt and (Dim_delta2+1) [i.e. Dim_tim_cnt%(Dim_delta2+1)] is equal to 0, the current output value Dim_output_val=Dim_start_val+Dim_tim_cnt / (Dim_delta2+1), that is, the controller increases the current output value by 1 every Dim_delta2+1 execution cycle;

[0096] Step S63: If entering the step adjustment mode, the adjustment steps are as follows:

[0097] If the execution cycle count Dim_tim_cnt consumed for adjustment is greater than Dim_remainder1, the current output Dim_output_val = Dim_start_val + Dim_remainder1 + Dim_delta1 * Dim_tim_cnt, that is, the controller increases the current output value by Dim_delta1 for each execution cycle passed;

[0098] If the execution cycle count Dim_tim_cnt consumed for adjustment is less than or equal to Dim_remainder1, the current output value Dim_output_val = Dim_start_val + (Dim_delta 1 + 1) * Dim_tim_cnt, that is, the controller increases the current output value by Dim_delta1 + 1 for each execution cycle passed.

[0099] It should be noted that when Dim_diff = Dim_tim, the current output value is controlled to change by 1 in the direction approaching the adjustment target value for each execution cycle passed. When Dim_diff > Dim_tim and the quotient of Dim_diff and Dim_tim has no remainder, it changes by Dim_delta1 for each execution cycle passed, and Dim_delta1 is the quotient of Dim_diff and Dim_tim. When Dim_diff < Dim_tim and the quotient of Dim_tim and Dim_diff has no remainder, it changes by 1 for every Dim_delta2 execution cycles passed, and Dim_delta2 is the quotient of Dim_tim and Dim_diff.

[0100] The digital quantity of the control signal includes but is not limited to PWM, current, voltage, or their corresponding control quantities.

[0101] In a specific implementation manner, the aforementioned controller is the headlight controller of an automotive lighting system. This headlight controller uses a single-chip microcomputer, but is not limited thereto. This headlight controller can also use an ECU, etc.

[0102] To make the technical solution of the control signal digital quantity adjustment method of the controller in the above embodiments of the present invention clearer, the following gives four specific application examples for illustration. In these four application examples, the controller is the headlight controller of an automotive lighting system, and the dimming task execution cycle of the headlight controller is 5 ms.

[0103] Application Example 1:

[0104] The adjusted target value of the external input received by the controller is 10000 (representing a duty cycle of 100% for the PWM adjustment signal), the adjustment starting value is 5000, so the adjustment direction is upward. The adjustment time is 100 ms, and the total number of execution cycles Dim_tim given for adjustment is 100 ms / 5 ms = 20, that is, it is required that the controller adjust the current output value from the adjustment starting value to the adjustment target value after 20 execution cycles of adjustment. The controller calculates Dim_diff = 5000. Since Dim_tim > 0 and Dim_diff > Dim_tim, it enters the step adjustment mode, with a fixed step size Dim_delta1 = 5000 / 20 = 250. The current output value Dim_output_val = 5000 + Dim_tim_cnt (the execution cycle count consumed by adjustment) * Dim_delta1 (fixed step size) = 5000 + Dim_tim_cnt * 250.

[0105] Application Example 2:

[0106] The adjusted target value of the external input received by the controller is 105, the adjustment starting value is 0, the adjustment time is 100 ms, and the total number of execution cycles Dim_tim given for adjustment is 100 ms / 5 ms = 20. The controller calculates Dim_diff = 105. Since Dim_tim > 0 and Dim_diff > Dim_tim, it enters the step adjustment mode, with a fixed step size Dim_delta1 = 5, and the remainder value of the fixed step size Dim_remainder1 = 105 - 5 * 20 = 5. When the execution cycle count consumed by adjustment is less than or equal to 5 (Dim_remainder1), the current output value = Dim_start_val + (Dim_delta1 + 1) * Dim_tim_cnt = 6 * Dim_tim_cnt; when the execution cycle count consumed by adjustment is greater than Dim_remainder1, the adjusted output value = Dim_start_val + Dim_remainder1 + Dim_delta1 * Dim_tim_cnt = 5 + 5 * Dim_tim_cnt. That is, in the first five execution cycles when the controller performs the adjustment task, the output value of the controller increases by 6 for each execution cycle passed, and starting from the sixth execution cycle, the output value of the controller increases by 5 for each execution cycle passed. The controller realizes the adjustment of the output value according to the running time.

[0107] Application Example 3:

[0108] The controller receives an externally input adjustment target value of 20, an adjustment starting value of 0, an adjustment time of 500 ms, and the total number of execution cycles Dim_tim for the given adjustment is 500 ms / 5 ms = 100. The controller calculates Dim_diff = 20. Since Dim_tim > 0 and Dim_diff < Dim_tim, it enters the duration adjustment mode. The fixed duration Dim_delta2 is the integer value obtained by rounding Dim_tim / Dim_diff, Dim_delta2 = 5, and the remainder value of the fixed duration Dim_remainder2 = 0. The adjustment output value = Dim_Start_Val + Dim_tim_cnt / Dim_delta2 = Dim_tim_cnt / Dim_delta2. That is, every time the execution cycle count Dim_tim_cnt for the adjustment consumption increases by 5 (i.e., the controller passes through 5 execution cycles), the current output value Dim_output_val increases by 1.

[0109] Application Example 4:

[0110] The controller receives an externally input adjustment target value of 20, an adjustment starting value of 0, and the total number of execution cycles Dim_tim for the given adjustment is 105. The controller calculates Dim_diff = 20. Since Dim_tim > 0 and Dim_diff < Dim_tim, it enters the duration adjustment mode. The fixed duration Dim_delta2 is the integer value obtained by rounding Dim_tim / Dim_diff, Dim_delta2 = 5, and the remainder value of the fixed duration Dim_remainder2 = 5. When the number of adjustments is less than or equal to Dim_remainder2, every time the execution cycle count Dim_tim_cnt for the adjustment consumption increases by 6 (i.e., the controller passes through 6 execution cycles), the current output value Dim_output_val increases by 1, and the current output value = Dim_start_val + Dim_tim_cnt / (Dim_delta2 + 1) = Dim_tim_cnt / 6; when the number of adjustments is greater than Dim_remainder2, every time the execution cycle count Dim_tim_cnt for the adjustment consumption increases by 5 (i.e., the controller passes through 5 execution cycles), the current output value Dim_output_val increases by 1.

[0111] In summary, the digital quantity adjustment method of the controller of the present invention can meet different dimming requirements, provide a better driving experience for the driver, and also improve the safety of vehicle driving.

[0112] The controller according to an embodiment of the present invention includes a memory and a processor. The memory is used to store a program; the processor is used to load the program to execute the foregoing control function switching method.

[0113] In the embodiment of the present invention, when adjusting the current output value of the controller by a step size, the remainder of the step size is evenly distributed among the fixed step sizes executed in multiple execution cycles. When adjusting the current output value of the controller by a duration, the remainder of the duration is evenly distributed among multiple durations, thereby avoiding the jump phenomenon of the output value and improving the adjustment effect and user experience.

[0114] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and its equivalent technologies, the present invention is also intended to include these changes and modifications.

Claims

1. A control function switching method for a controller, characterized in that, Including the following steps: Output the digital quantity of the control signal according to the control rules of the first control function. The first control function includes one or more control stages, and the one or more control stages are continuously executed in sequence without interruption. After each control stage starts to execute, the duration F1_Tcnt consumed by this control stage is timed. According to the control rules, the output value of the digital quantity of the control signal corresponding to the timing of any duration in any control stage can be calculated. When a valid request to enable the second control function is received, interrupt the first control function, switch to the second control function, and output the digital quantity of the control signal according to the control rules of the second control function. The duration timing F1_Tcnt of the control stage where the first control function is interrupted remains timed during the interruption of the first control function. When a valid request to disable the second control function is received, calculate the duration timing F1_Tin of the control stage where the first control function is interrupted at the time when the controller receives the valid disable request and the switching time t_21 when the second control function switches to the first control function. F1_Tin = F1_Tcnt + t_21. Define the moment after the duration timing F1_Tin from the start of the duration timing of the control stage where the first control function is interrupted as the F1_Tin moment. If, when the first control function is not interrupted, the control stage of the first control function that should be executed at the F1_Tin moment is d, and the duration timing at the F1_Tin moment corresponds to duration timing A in this control stage d, then use this control stage d as the control stage to be executed, and use duration timing A as the duration timing of the control stage to be executed at the F1_Tin moment. Switch to the first control function at the F1_Tin moment, and continue to output the digital quantity of the control signal according to the control rules of the first control function from the time point when the duration timing of the control stage d to be executed is A. If, when the first control function is not interrupted, there is no unfinished control stage of the first control function at the F1_Tin moment, then output the digital quantity of the control signal in a pre-specified manner from the F1_Tin moment.

2. The control function switching method of the controller according to claim 1, wherein, Each control stage of the first control function has a given adjustment starting value, the total number of execution cycles Dim_tim for adjustment, and an adjustment target value, and / or The second control function includes one or more control stages, and the one or more control stages are continuously executed in sequence. Each control stage of the second control function has a given adjustment starting value, the total number of execution cycles Dim_tim for adjustment, and an adjustment target value. After each control stage starts to execute, the duration F1_Tcnt consumed by this control stage is timed. According to the control rules, the output value of the digital quantity of the control signal corresponding to the timing of any duration in any control stage can be calculated.

3. The control function switching method of the controller according to claim 2, characterized in that When the first control function and / or the second control function includes multiple control stages, starting from the second control stage, use the adjustment target value of its previous control stage as the adjustment starting value of this control stage.

4. The control function switching method of the controller according to claim 1, characterized in that, The interruption of the first control function when a valid request to enable the second control function is received includes: stopping the calculation and output of the digital quantity of the control signal for the control phase where the first control function is interrupted.

5. The control function switching method of the controller according to claim 1, characterized in that When a valid request to enable the second control function is received, the digital quantity of the control signal obtained based on the control rules of the first control function when the controller receives the valid enable request is used as the initial adjustment value for the first control phase of the second control function.

6. The control function switching method of the controller according to claim 1, characterized in that, When a valid request to disable the second control function is received, the output value of the digital quantity of the control signal of the second control function when the controller receives the valid request to disable the second control function is used as the starting value for the adjustment during the shutdown process, F1_SWin is used as the target value for the adjustment during the shutdown process, and the switching time t_21 is used as the total number of execution cycles for the adjustment during the shutdown process. The output adjustment of the shutdown process of the second control function is performed based on the control rules of the second control function. Wherein F1_SWin takes the output value of the digital quantity of the control signal when the duration timing for the to-be-executed control phase d is A, or takes the output value of the digital quantity of the control signal output in the specified manner at the F1_Tin moment; the t_21 is a preset fixed value, and t_21≥0.

7. The method for switching the control function of the controller according to claim 1, characterized in that If the duration timing F1_Tin is less than or equal to the total number of execution cycles for the adjustment of the control phase where the first control function is interrupted, then the control phase where the first control function is interrupted is determined as the control phase d to be executed by the first control function when switching back to the first control function, and the duration timing A is equal to F1_Tin. If the duration timing F1_Tin is greater than the total number of execution cycles for the adjustment of the control phase where the first control function is interrupted and less than or equal to the sum of the total number of execution cycles for the adjustment of all remaining control phases of the first control function starting from the interrupted control phase, then the kth control phase of the first control function is determined as the control phase d to be executed by the first control function when switching back to the first control function, and the duration timing A is equal to F1_Tin minus the sum of the total number of execution cycles for the adjustment of the first control function from the interrupted control phase to the (k - 1)th control phase; where k satisfies the following condition: the sum of the total number of execution cycles for the adjustment of the first control function from the interrupted control phase to the (k - 1)th control phase < F1_Tin ≤ the sum of the total number of execution cycles for the adjustment of the first control function from the interrupted control phase to the kth control phase. If the duration timing F1_Tin is greater than the sum of the total number of execution cycles for the adjustment of all remaining control phases of the first control function starting from the interrupted control phase, then it is determined that there is no unfinished control phase of the first control function at the F1_Tin moment, and the specified manner is to output a predetermined constant digital quantity of the control signal or output the digital quantity of the control signal according to the control rules of the third control function.

8. The control function switching method of the controller according to claim 1, characterized in that, For each control stage with a given initial adjustment value and a given target adjustment value, both the initial adjustment value and the target adjustment value being digital quantities of a control signal and the initial adjustment value and the target adjustment value being unequal, the adjustment is performed according to the following steps: Calculate the absolute value Dim_diff of the difference between the target adjustment value and the starting adjustment value; If Dim_diff is greater than the total number of execution cycles Dim_tim for adjustment and there is a remainder Dim_remainder1 when the quotient of Dim_diff and Dim_tim is calculated, and Dim_remainder1 ≥ 1, then control the current output value to change by Dim_delta1 + 1 every other execution cycle among m execution cycles in the direction approaching the target adjustment value, and change by Dim_delta1 every other execution cycle among Dim_tim - m execution cycles. m is equal to Dim_remainder1, and Dim_delta1 is the integer part of the quotient of Dim_diff and Dim_tim. If Dim_diff is less than the total number of execution cycles Dim_tim for adjustment and there is a remainder Dim_remainder2 when the quotient of Dim_tim and Dim_diff is calculated, and Dim_remainder2 ≥ 1, then control the current output value to change by 1 every Dim_delta2 + 1 execution cycles among n execution cycles in the direction approaching the target adjustment value, and change by 1 every Dim_delta2 execution cycles among Dim_tim - n execution cycles. n is equal to (Dim_delta2 + 1) * Dim_remainder2, and Dim_delta2 is the integer part of the quotient of Dim_tim and Dim_diff.

9. The control function switching method of the controller according to claim 8, characterized in that, If Dim_tim is equal to 0, change the starting adjustment value by Dim_diff in the direction approaching the target adjustment value.

10. The control function switching method of the controller according to claim 1, characterized in that, The first control function is the running light control of the vehicle, and the second control function is the turn signal control of the vehicle.

11. A controller, characterized in that, Including: A memory for storing a program; A processor for loading the program to execute the control function switching method according to any one of claims 1 to 10.