Dimming method based on straight line fitting
By adopting a dimming method based on linear fit in the exponential dimming method and combining curvature adjustment, the problems of large resource consumption and low accuracy in the existing technology are solved, and efficient and accurate exponential dimming is achieved, which improves visual comfort.
Patent Information
- Application Number
- CN202510508772.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2044-12-04
AI Technical Summary
In the prior art, the exponential dimming method requires a large number of computing resources and storage resources, and has low accuracy, making it difficult to achieve linear brightness changes, affecting the user's visual comfort.
The dimming method based on linear fit is adopted. By dividing multiple fitting intervals, using the linear fitting results and combining the curvature adjustment method, the consumption of computing and storage resources is reduced and the dimming accuracy is improved.
The linear fitting results corresponding to the PWM configuration value can be obtained without the need for a computing logic unit, which greatly reduces the consumption of the circuit's computing resources and storage resources, realizes high-precision exponential dimming, and provides a more comfortable visual experience.
Smart Images

Figure CN120076117A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electrical control, and particularly to a dimming method based on line fitting. Background Art
[0002] The luminous brightness of a light-emitting diode (LED) can be achieved by adjusting the driving current of the LED. The pulse width modulation (PWM) dimming method can control the average driving current of the LED by changing the duty cycle of the PWM signal, thereby achieving the adjustment of the luminous brightness of the LED. The higher the duty cycle of the PWM signal, the higher the brightness; otherwise, the lower the duty cycle of the PWM signal, the lower the brightness. The switching frequency of the LED is much higher than the recognition frequency of the human eye, so the human eye will not feel the on-off flicker of the light, but only feel the brightness change. In practical applications, it is required that the LED has a uniform brightness change, that is, a linear brightness change. However, due to the different sensitivities of the human eye to high brightness and low brightness, only when the duty cycle changes exponentially can the human eye recognize the linear change of brightness. In order to make the human eye obtain a more comfortable dimming experience, the exponential dimming method is widely used.
[0003] Existing exponential dimming methods include the look-up table method, the formula method, the line fitting method, etc. The look-up table method can preset the PWM configuration value so that the relationship between the PWM configuration value and the high-level duration of the PWM signal conforms to the exponential mapping relationship. This method requires storing a large amount of data for look-up table output, consuming a large amount of storage resources. The formula method requires a large number of complex operations with devices such as multipliers or adders to achieve exponential dimming, with high implementation difficulty, large operation delay, and requiring a large amount of operation resources; the line fitting method uses multiple lines to fit the exponential dimming curve, which requires a large amount of operation resources and has low accuracy during the fitting process. Summary of the Invention
[0004] In view of the technical problems existing in the prior art, the present application proposes a dimming method based on line fitting, including obtaining a PWM configuration value, where the PWM configuration value is a binary number, and dividing a plurality of fitting intervals based on its possible value range; the serial number of the fitting interval is a decimal number determined at least based on the first part of the PWM configuration value; judging the fitting interval where it is located based on the first part of the PWM configuration value; obtaining a line fitting result based on the PWM configuration value and the fitting interval where it is located; where the number of bits of the line fitting result is greater than the number of bits of the PWM configuration value.
[0005] Specifically, in the method, when the PWM configuration value is in other fitting intervals except the first fitting interval, the straight-line fitting result corresponding to each PWM configuration value sequentially includes a first part, a second part, and a third part from the lowest bit to the highest bit; wherein the first fitting interval is an interval starting from the minimum value of the PWM configuration value; the straight-line fitting result is a binary number with a fixed number of bits, the first part of which includes one or more 0s, and the number of 0s is the sequence number of the fitting interval where the PWM configuration value is located minus 1; the second part includes the lowest X bits of the PWM configuration value, where X is an integer greater than or equal to 5; the lowest bit of the third part is 1, and if there are other bits, they are 0.
[0006] Specifically, in the method, when the PWM configuration value is in the first fitting interval, the PWM configuration value is used as the straight-line fitting result.
[0007] Specifically, in the method, when the PWM configuration value is the maximum value, the straight-line fitting result is a preset fixed value.
[0008] This application also relates to an electronic device, including an LED dimming device, wherein the LED dimming device is configured to execute the method as described in any one of the preceding items.
[0009] Specifically, the electronic device further includes an LED light-emitting element.
[0010] The dimming method based on straight-line fitting proposed in this application can obtain the straight-line fitting result corresponding to the PWM configuration value without an arithmetic logic unit, greatly reducing the consumption of arithmetic resources and storage resources of the circuit. Description of the Drawings
[0011] Next, the preferred embodiments of this application will be further described in detail with reference to the drawings, where: Figure 1 Shown is a schematic diagram of the LED dimming target curve according to an embodiment of this application; Figure 2 Shown is a schematic diagram of the straight-line fitting result curve according to an embodiment of this application; Figure 3 Shown is a flowchart of the straight-line fitting method according to an embodiment of this application; Figure 4 Shown is a schematic diagram of the curve of the trimming value changing with the PWM configuration value according to an embodiment of this application; Figure 5 Shown is a flowchart of the curvature trimming method according to an embodiment of this application; Figure 6The figure shows a schematic diagram of the curve before and after adjusting the straight line fitting result according to an embodiment of the present application; Figure 7 The figure shows a schematic diagram of the dimming simulation result according to an embodiment of the present application. Detailed implementation manners
[0012] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some but not all of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the scope of protection of the present application.
[0013] In the following detailed description, reference may be made to the accompanying drawings that form a part hereof and that show, by way of illustration, specific embodiments in which the application may be practiced. In the drawings, like reference numerals generally refer to like components in different diagrams. The various specific embodiments of the present application have been described in sufficient detail below to enable those of ordinary skill in the art with relevant knowledge and technology to implement the technical solutions of the present application. It should be understood that other embodiments may be utilized or structural, logical, or electrical changes may be made to the embodiments of the present application.
[0014] For technologies, methods, and devices known to those of ordinary skill in the relevant art, they may not be discussed in detail, but where appropriate, the technologies, methods, and devices should be regarded as a part of the description. For the connections between the units in the drawings, it is only for the convenience of description, indicating that at least the units at both ends of the connection communicate with each other, and it is not intended to limit that the units not connected cannot communicate. In addition, the number of lines between two units is intended to represent at least the number of signals involved in the communication between the two units or at least the number of output terminals, rather than being used to limit that the two units can only communicate with the signals shown in the figure.
[0015] In the traditional exponential dimming method, either an arithmetic module such as an adder and a multiplier is used to fit the dimming curve, or a look-up table is used to map the PWM to the arithmetic value of the exponential function, and the final dimming control value corresponding to the PWM configuration value is obtained through one way. In this process, a large amount of arithmetic or storage units are consumed.
[0016] The dimming method based on straight line fitting and curvature adjustment proposed in the present application combines straight line fitting and curvature adjustment, reduces the requirements for storage and arithmetic resources, and realizes exponential dimming with high accuracy through a more optimized algorithm, providing a more comfortable and delicate visual experience for users.
[0017] Figure 1The figure shows a schematic diagram of an LED dimming target curve according to an embodiment of the present application. Figure 1 The shown LED dimming target curve is an exponential curve. Among them, the abscissa represents the PWM configuration value, and its value is the decimal number corresponding to an eight-bit binary number. The ordinate represents the dimming control value corresponding to the PWM configuration value, and its value is the decimal number corresponding to a 12-bit binary number. The LED dimming device generates a PWM signal with a corresponding duty cycle based on the dimming control value. In the LED dimming target curve, the larger the value of the PWM configuration value, the higher the duty cycle of the generated PWM signal, the higher the brightness of the LED, and the higher the curve slope; the smaller the value of the PWM configuration value, the lower the duty cycle of the generated PWM signal, the lower the brightness of the LED, and the lower the curve slope. According to an embodiment of the present application, the number of bits of the dimming control value is greater than the number of bits of the PWM configuration value.
[0018] Figure 2 The figure shows a schematic diagram of a linear fitting result curve according to an embodiment of the present application. Among them, the abscissa represents the PWM configuration value, and the ordinate represents the linear fitting result. As Figure 2 shown, the LED dimming target curve is fitted by M first-order functions. Among them, M is an integer greater than or equal to 1.
[0019] According to an embodiment, the PWM configuration value is sequentially divided into M fitting intervals starting from its minimum value, and the LED dimming target curve is divided into M segments according to the fitting intervals.
[0020] According to an embodiment of the present application, the LED dimming device includes a register. The register is configured to receive a PWM configuration value of N-bit binary numbers. N is an integer greater than or equal to 1.
[0021] In one embodiment of the present application, the register is configured to receive a PWM configuration value of an eight-bit binary number, and the range of the decimal number corresponding to the numerical range of the PWM configuration value is 0 to 255. Starting from the minimum value of the PWM configuration value, the PWM configuration values are sequentially divided into multiple fitting intervals in groups of 32 PWM configuration values each. In the fitting interval starting from the minimum value of the PWM configuration value and an adjacent fitting interval, the change in the dimming control value corresponding to the PWM configuration value is relatively small. Therefore, these two fitting intervals can be combined as the first fitting interval. The first fitting interval includes PWM configuration values 0 to 31 and 32 to 63; the second fitting interval includes PWM configuration values 64 to 95; the third fitting interval includes PWM configuration values 96 to 127; the fourth fitting interval includes PWM configuration values 128 to 159; the fifth fitting interval includes PWM configuration values 160 to 191; the sixth fitting interval includes PWM configuration values 192 to 223; the seventh fitting interval includes PWM configuration values 224 to 254 and the maximum value 255 of the PWM configuration value. In the first fitting interval, as the PWM configuration value increases, the change in the dimming control value is relatively the slowest; from the second to the sixth fitting intervals, as the PWM configuration value increases, the change in the dimming control value gradually becomes faster; in the seventh fitting interval, as the PWM configuration value increases, the change in the dimming control value is the fastest compared to other fitting intervals.
[0022] According to one embodiment, within the fitting interval of each PWM configuration value, a linear fitting is performed on the LED dimming target curve to obtain M linear functions based on different fitting intervals. The linear function can be modeled as: Y = K(X - b) where X represents the PWM configuration value. Y represents the result of the linear fitting. K represents the slope of the linear function, and b represents the offset. Within different fitting intervals, the modeled linear functions have different slopes K, and the corresponding relationship between the PWM configuration value and the result of the linear fitting is also different. In some embodiments of the present application, for two adjacent fitting intervals, the K value of the linear function fitted in the latter fitting interval is twice the K value of the linear function fitted in the former fitting interval; except for the first fitting interval, the difference between the offsets b of the linear functions in two adjacent fitting intervals is 32, corresponding to the width of each fitting interval. Here, the PWM configuration values included in the latter fitting interval are greater than those included in the former fitting interval.
[0023] In the following detailed description, the PWM configuration value includes an eight-bit binary number. Starting from the minimum value of the PWM configuration value, the value range of the PWM configuration value is sequentially divided into seven fitting intervals to illustrate the dimming method proposed in the present application. Among them, the first fitting interval is the fitting interval starting from the minimum PWM configuration value, for example Figure 2the first fitting interval (PWM configuration values 0 to 63); the starting value of the PWM configuration value of the highest serial number fitting interval is greater than the PWM configuration values included in other fitting intervals. For example Figure 2 the seventh fitting interval (PWM configuration values 224 to 255) in Figure 2 . It can be understood that for the division of the fitting intervals, it is also possible to start from the maximum value of the PWM configuration value and divide in the order of gradually decreasing PWM configuration values.
[0024] The PWM configuration value is divided into two parts. The values of the first part of the PWM configuration values corresponding to different fitting intervals are different. The decimal number determined by the content of the first part of the PWM configuration value can be used as the serial number of the fitting interval and the fitting interval where the PWM configuration value is located. The value of the first part of the PWM configuration value corresponding to the highest serial number fitting interval is the largest. The second part of the PWM configuration value corresponds to the trimming points within a fitting interval. It can be understood that the first part and the second part of the PWM configuration value can include different numbers of bits, but the sum of the numbers of bits of the two parts is the total number of bits of the PWM configuration value. For example, when the PWM configuration value is 9 bits, the PWM configuration value can be divided into 16 fitting intervals. The high four bits of the PWM configuration value in each fitting interval are the first part, and the values of the first part of the PWM configuration values in different fitting intervals are different; the low five bits of the PWM configuration value are the second part.
[0025] According to an embodiment, the content of the first part of the PWM configuration value includes the highest N bits of the PWM configuration value; the content of the second part of the PWM configuration value includes the remaining bits of the PWM configuration value except the highest N bits. Wherein, the sum of the numbers of bits of the first part and the second part of the PWM configuration value is the total number of bits of the PWM configuration value, and N is an integer greater than or equal to 3.
[0026] In the following description, the PWM configuration value is divided into the highest three bits and the lowest five bits. The first part corresponds to the fitting interval where the PWM configuration value is located, and the lowest five bits of the PWM configuration value correspond to the trimming points within the fitting interval. Taking Figure 2 as an example, the highest three bits of the PWM configuration values included in the first fitting interval are 000 or 001. Except for the first fitting interval, the highest three bits of the PWM configuration values included in other fitting intervals are the same. For example, when the highest three bits of the PWM configuration value are 010, the PWM configuration value is in the second fitting interval; when the highest three bits of the PWM configuration value are 011, the PWM configuration value is in the third fitting interval; when the highest three bits of the PWM configuration value are 100, the PWM configuration value is in the fourth fitting interval; when the highest three bits of the PWM configuration value are 101, the PWM configuration value is in the fifth fitting interval; when the highest three bits of the PWM configuration value are 110, the PWM configuration value is in the sixth fitting interval; when the highest three bits of the PWM configuration value are 111, the PWM configuration value is in the seventh fitting interval.
[0027] The reason for choosing the lowest five bits of the PWM configuration value as the trimming point is that regardless of the total number of bits of the PWM configuration value, using the lowest five bits to determine the trimming point provides relatively high precision and basically meets the usage requirements. Of course, the user can adjust the number of bits of the PWM configuration value used as the trimming point coordinates within the scope protected by this application according to the needs.
[0028] Figure 3 The figure shows a flowchart of a straight line fitting method according to an embodiment of this application. According to an embodiment, the straight line fitting method can be executed by an LED dimming device.
[0029] Step 301, obtain the PWM configuration value.
[0030] According to an embodiment, the PWM configuration value can be specified by the user.
[0031] Step 302, based on the highest three bits of the PWM configuration value, determine the fitting interval where the PWM configuration value is located.
[0032] Step 303, when the PWM configuration value is within the first fitting interval (for example Figure 2 the first fitting interval 0 - 63 in ), set the value of the straight line fitting result to the current PWM configuration value.
[0033] According to an embodiment, the number of bits of the straight line fitting result is higher than the number of bits of the PWM configuration value.
[0034] Step 304, when the PWM configuration value is within other fitting intervals except the first fitting interval, the value of the straight line fitting result includes a first part, a second part, and a third part in sequence from the lowest bit to the highest bit. The first part includes one or more 0s, and its corresponding decimal number is 0, where the number of 0s is the sequence number of the fitting interval where the PWM configuration value is located minus 1; the second part includes the lowest five bits of the PWM configuration value; the lowest bit of the third part is 1, and if there are other bits, they are 0.
[0035] According to an embodiment of this application, based on the content of the first part of the PWM configuration value, such as the highest three bits, the straight line fitting result can be generated by real-time splicing, or the fitting interval where the PWM configuration value is located and the content of the first part and / or the third part of the straight line fitting result corresponding to the PWM configuration value in this fitting interval can be obtained by looking up a table. The reason for obtaining some content of the straight line fitting result by looking up a table is that this method has a relatively high processing speed. Of course, those skilled in the art can obtain some content of the straight line fitting result by using other methods within the scope protected by this application.
[0036] Step 305, when the value of the PWM configuration value is the maximum value, set the value of the linear fitting result to a fixed value. The fixed value can be obtained based on the LED dimming target curve. According to an embodiment of the present application, the fixed value is the dimming control value corresponding to the maximum value of the PWM configuration value.
[0037] Table 1
[0038] Table 1 shows a list of the corresponding relationships between each fitting interval and its linear fitting result according to an embodiment of the present application. The first column and the second column represent different fitting intervals and the corresponding PWM configuration value ranges, including seven fitting intervals and the maximum value of the PWM configuration value; the third column represents the linear function corresponding to each fitting interval; the fourth column represents the first part of the PWM configuration value, that is, the highest three bits; the fifth column and the sixth column are the minimum value and the maximum value of the PWM configuration value in each fitting interval respectively; the seventh column and the eighth column represent the slope and the offset of the linear function corresponding to each fitting interval, where the slope K is a decimal number; the ninth column is the algorithm for the linear fitting result corresponding to each fitting interval. The linear fitting result corresponding to the maximum value of the PWM configuration value is a fixed value, which can be obtained through the LED dimming target curve. In the first fitting interval, the linear fitting result corresponding to the PWM configuration value is itself.
[0039] In Table 1, when the highest three bits of the PWM configuration value are 111, it is determined that the PWM configuration value is in the seventh fitting interval (224≤X≤254). The linear function corresponding to this fitting interval is Y = 64(X - 192). The slope of this linear function is 64, and the offset is 192 (the corresponding binary number is 11000000). The minimum value and the maximum value of the PWM configuration value are 11100000 and 11111110 respectively. The number of 0s included in the first part of the linear fitting result corresponding to the PWM configuration value is seven minus one. Its second part includes the lowest five bits of the PWM configuration value. Its third part includes one bit of 1, a total of 12 - bit binary numbers. When the highest three bits of the obtained PWM configuration value are 110, the PWM configuration value is in the sixth fitting interval (192≤X≤223). The number of 0s included in the first part of the linear fitting result corresponding to the PWM configuration value is six minus one. Its second part includes the lowest five bits of the PWM configuration value. The lowest bit of its third part is 1 and the rest are 0s; and so on. When the highest three bits of the obtained PWM configuration value are 000 or 001, the PWM configuration value is in the first fitting interval (0≤X≤63). The linear fitting result corresponding to the PWM configuration value is the value of the PWM configuration value. When the maximum value of the PWM configuration value is 255, the corresponding linear fitting result is 4095.
[0040] During the straight-line fitting process, a register is used to store the correspondence between a small number of PWM configuration values and the straight-line fitting results. Without an arithmetic logic unit, the straight-line fitting results corresponding to the PWM configuration values can be obtained, significantly reducing the consumption of the circuit's arithmetic resources and storage resources.
[0041] To improve the fitting accuracy, after obtaining the straight-line fitting results of the PWM configuration values, the curvature adjustment method is used to adjust the straight-line fitting results multiple times to obtain the adjusted results corresponding to the PWM configuration values, and the adjusted results are used as the dimming control values to control the duty cycle of the PWM signal. A smoother exponential curve is obtained by adjusting the straight-line fitting results. Among them, the method for obtaining the straight-line fitting results of the LED dimming target curve is not limited to the straight-line fitting method proposed in the above embodiments, and other methods can also be used.
[0042] In a fitting interval, the lowest five digits of the PWM configuration value correspond to the adjustment points in this fitting interval. Therefore, a correspondence is established between the lowest five digits of the PWM configuration value and the total adjustment value. The straight-line fitting results corresponding to the PWM configuration value are adjusted using the total adjustment value.
[0043] Table 2
[0044] Table 2 shows the correspondence list between the lowest five digits of the PWM configuration value and the total adjustment value according to an embodiment. The first column in pwm_config[4:0] represents the decimal number corresponding to the lowest five digits of the PWM configuration value, and the second column in pwm_config[4:0] represents the lowest five digits of the PWM configuration value. The first to seventh columns of trim_value represent the fitting intervals divided based on the value range of the PWM configuration value, and the total adjustment value corresponding to the PWM configuration value in each fitting interval, where the total adjustment value is a decimal number. For example, in the seventh fitting interval 224 ≤ x ≤ 255, the total adjustment value corresponding to the lowest five digits of the PWM configuration value being 01000 is the decimal number 100. In different fitting intervals, the total adjustment values corresponding to different PWM configuration values are different. The total adjustment value corresponding to the PWM configuration value in the highest serial number fitting interval is greater than the total adjustment values corresponding to the PWM configuration values in other fitting intervals.
[0045] In Table 2, within any fitting interval, the total trimming value has symmetry. When the lowest five bits of the PWM configuration value change from smallest to largest, the total trimming value is symmetric about the middle value of the lowest five bits of the PWM configuration value. Within a fitting interval, based on the binary number of the fifth bit from the low order of the PWM configuration value, the PWM configuration values can be divided into two categories: those with the fifth bit being 0 and those with the fifth bit being 1. The trimming value ranges of the two categories are the same but the changing trends are opposite. For example, in the fitting interval 224 ≤ x ≤ 255, the value of the fifth bit from the low order of the PWM configuration value can divide the lowest five bits of the PWM configuration value into two categories: 00000~01111 and 10000~11111. Within the first category (00000~01111), the lowest four bits of the PWM configuration value change from 0000 to 1111, and the decimal number corresponding to the total trimming value changes from the minimum value (0) to the maximum value (135). Within the second category (10000~11111), the lowest four bits of the PWM configuration value change from 0000 to 1111, and the decimal number corresponding to the total trimming value changes from the maximum value (135) to the minimum value (0). At this time, by corresponding the result of taking the bitwise inversion of the lowest four bits in the second part of the PWM configuration value with the total trimming value, the same result as that of the first category can be obtained. That is to say, among the lowest five bits of the PWM configuration value, the highest one can be used to determine the category where the PWM configuration value is located in a fitting interval, and the remaining four bits are used to determine the trimming points within the fitting interval.
[0046] Figure 4 The figure shows a schematic diagram of the curve of the trimming value changing with the PWM configuration value according to an embodiment of the present application. Among them, the abscissa represents the decimal number corresponding to the lowest five bits of the PWM configuration value; the ordinate represents the total trimming value. Different curves represent the changes of the total trimming values in different fitting intervals.
[0047] As Figure 4 shown, from the minimum value of the lowest five bits of the PWM configuration value to the middle value of the lowest five bits of the PWM configuration value, with the difference between the total trimming values corresponding to two adjacent PWM configuration values as the step value, the step value decreases as the PWM configuration value increases. This decrease in the step value is reflected in that for any curve, when making a tangent line to the curve at the point corresponding to the PWM configuration value, the slope of the tangent line gradually decreases. Based on the symmetric relationship of the total trimming values within the same fitting interval, the step values also have a symmetric relationship. The curvature trimming method changes the slope of the linear function corresponding to each fitting interval by changing the step value between two adjacent total trimming values, and trims the linear function corresponding to each fitting interval into a curve.
[0048] According to an embodiment, when within a fitting interval, the total trimming value first increases and then decreases, the final trimming result can be the difference between the linear fitting result and the total trimming value.
[0049] According to another embodiment of the present application, when in a fitting interval, the total trimming value first decreases and then increases, the final trimming result can be the sum of the linear fitting result and the total trimming value.
[0050] In an embodiment of the present application, the total trimming value corresponding to the PWM configuration value is divided into multiple trimming values, and the linear fitting result is trimmed multiple times.
[0051] Table 3
[0052] Table 3 shows the correspondence table between the trimming times and the lowest five bits of the PWM configuration value according to an embodiment of the present application. The first column is the decimal number corresponding to the lowest five bits of the PWM configuration value, and the second column is the corresponding trimming times. Based on the symmetry of the total trimming value within the same fitting interval, the trimming times also have a symmetric relationship, and the trimming times are symmetric about the middle value of the lowest five bits of the PWM configuration value. For example, when the decimal number corresponding to the lowest five bits of the PWM configuration value increases from 0 to 15, the trimming times increase from 0 to 15; when the decimal number corresponding to the lowest five bits of the PWM configuration value increases from 16 to 31, the trimming times decrease from 15 to 0.
[0053] According to an embodiment, the trimming times are obtained based on the content of the second part of the PWM configuration value. In an embodiment, based on the symmetric relationship of the trimming times within the same fitting interval, the lowest four bits of the PWM configuration value are used to obtain the trimming times. The reason for choosing the value of the lowest four bits of the PWM configuration value to generate the initial value of the trimming times is that regardless of the total number of bits of the PWM configuration value, within the same fitting interval, the accuracy of using the lowest four bits of the PWM configuration value to generate the trimming times is relatively high, basically meeting the usage requirements. Of course, the user can adjust the number of bits of the PWM configuration value used to generate the initial value of the trimming times according to the needs within the scope protected by the present application.
[0054] According to an embodiment of the present application, based on the symmetry of the total trimming value within the same fitting interval, the trimming values used each time also have a symmetric relationship.
[0055] In one embodiment of the present application, the LED dimming device includes a counter configured to cyclically increment the count from zero and output a count value. When the counter starts counting from zero, the PWM outputs a high level until the count value reaches the dimming control value corresponding to the PWM configuration value, after which the PWM outputs a low level, thereby controlling the duty cycle output of the PWM. One or more trimming values are generated based on the count value, and the linear fitting result is trimmed multiple times based on the trimming value to obtain a final trimming result, and the final trimming result is used as the dimming control value. According to one embodiment, the counter may be a component originally included in the electronic device where the LED light-emitting element is located. Therefore, the operating state and value of the counter are not controlled by the dimming device but serve the overall electronic device. Here, it is only required that the number of bits of the value of the binary counter is greater than or equal to, for example, 4 bits. Of course, the user can use other counters as needed and obtain the trimming value using the count value of the counter.
[0056] According to one embodiment, the process of trimming the linear fitting result may include one or more stages. The number of trimming times for each stage is obtained according to the PWM configuration value. The sum of all the trimming values used in each stage is the total trimming value.
[0057] In some embodiments, during the counting process of the counter, different fitting intervals correspond to different algorithms, and a first trimming value is obtained based on different algorithms and the count value of the counter. The first stage of trimming can use the first trimming value to trim the linear fitting result.
[0058] Table 4
[0059] Table 4 shows a list of first trimming values according to one embodiment of the present application. Among them, the first column in the counter pwm_cnt[4:0] represents the decimal number corresponding to the lowest five bits of the count value, and the second column is the lowest five bits of the count value. The second column to the eighth column are the first trimming values used for each trimming from the seventh fitting interval to the first fitting interval, and the sum of the first trimming values used for each previous trimming. The last row is the first trimming value algorithm corresponding to each fitting interval. During the counting process starting from zero, the first stage of curvature trimming is performed during the counting from 0 to 15, and the lowest four bits of the count value change from 0000 (decimal number 0) to 1111 (decimal number 15).
[0060] According to one embodiment, each time the counter counts, a first trimming value is generated based on the lowest four bits of the count value, and one trimming is completed using the first trimming value. Correspondingly, each time a trimming is completed, the number of trimming times is reduced by one.
[0061] The selection of the number of digits of the count value is related to the trimming accuracy and is not limited to the value of its lowest four bits. Here, the value of the lowest four bits of the count value is selected as the first trimming value because the accuracy of the first trimming value generated thereby basically meets the usage requirements. Of course, the user can adjust the number of digits of the count value used as the first trimming value within the scope protected by this application according to the requirements.
[0062] For example, when the count value counts from 0 to 15 in the first-stage trimming, the trimming value algorithm for the PWM configuration value in the seventh fitting interval (224≤x≤255) is to invert each bit of the lowest four bits of the count value. When the first trimming of the PWM configuration value is performed, the count value of the counter is 0, and the decimal number corresponding to the first trimming value obtained based on the trimming value algorithm is 15, and the decimal number corresponding to the accumulated first trimming value is 15. When the second trimming of the PWM configuration value is performed, the count value of the counter is 1, and the decimal number corresponding to the obtained first trimming value is 14, and the decimal number corresponding to the accumulated first trimming value of the two trimmings is 29. When the third trimming of the PWM configuration value is performed, the count value of the counter is 2, and the decimal number corresponding to the obtained first trimming value is 13, and the decimal number corresponding to the accumulated first trimming value of the two trimmings is 42.
[0063] Figure 5 It is a flowchart of a curvature trimming method according to an embodiment of the present application. According to an embodiment, the curvature trimming method can be executed by an LED dimming device.
[0064] Step 501, obtain the linear fitting result and the PWM configuration value.
[0065] Step 502, obtain the initial value of the trimming times based on the second part of the PWM configuration value. Specifically, it may include steps 5021 to 5023.
[0066] Step 5021, determine whether the fifth bit from the low bit of the PWM configuration value is 0. If so, execute step 5022; otherwise, execute step 5023.
[0067] Step 5022, when the fifth bit from the low bit of the PWM configuration value is 0, set the initial value of the trimming times to the decimal number corresponding to the lowest four bits of the PWM configuration value.
[0068] Step 5023, when the fifth bit from the low bit of the PWM configuration value is 1, set the initial value of the trimming times to the decimal number corresponding to the result of inverting each bit of the lowest four bits of the PWM configuration value.
[0069] Step 503: Determine whether the initial value of the adjustment count is 0 or whether the PWM configuration value is within the first fitting interval. When the initial value of the adjustment count is not 0 and the PWM configuration value is within other fitting intervals except the first fitting interval, jump to 505; when the initial value of the adjustment count is 0 or the PWM configuration value is within the first fitting interval, it can directly jump to 504, and use the linear fitting result as the final adjustment result.
[0070] Step 505: Determine the fitting interval where the PWM configuration value is located based on the highest three bits of the PWM configuration value, obtain the first adjustment value algorithm corresponding to this fitting interval, and obtain the first adjustment value based on the first adjustment value algorithm.
[0071] According to one embodiment, set the linear fitting result as the initial value of the adjustment result for the first-stage adjustment.
[0072] Step 506: Determine whether the adjustment enable signal is valid. When the adjustment enable signal is valid, jump to 508 for the first-stage adjustment; if the adjustment enable signal is invalid at this time, it is necessary to execute step 507 to wait for the count value to be updated until the adjustment enable signal is valid and then jump to 508.
[0073] According to one embodiment, when the decimal number corresponding to the lowest four bits of the count value of the counter is 0 and the adjustment count is not 0, the adjustment enable signal jumps from the invalid state to the valid state and remains until the adjustment count is 0. After that, the adjustment enable signal jumps to the invalid state. In this case, the LED dimming control device starts the first-stage adjustment of the linear fitting result.
[0074] According to another embodiment, when the adjustment count is 0, the adjustment enable signal is in the invalid state.
[0075] Step 508: Obtain the first adjustment value based on the first adjustment value algorithm and the lowest four bits of the count value.
[0076] According to one embodiment, when the PWM configuration value is within the highest serial number fitting interval (for example, the seventh fitting interval 224≤x≤255 in Table 4), the lowest four bits of the first adjustment value are the result obtained by taking the bitwise inversion of the lowest four bits of the count value.
[0077] According to one embodiment, when the PWM configuration value is in other fitting intervals outside the highest serial number fitting interval and the second fitting interval, the result obtained by bitwise inverting the lowest four bits of the count value is shifted to the right to obtain the first trimming value. The number of shift times is less than 4 and is the difference between the highest serial number and the serial number of the fitting interval where the PWM configuration value is located, and the remaining bits are 0 bits. Specifically, when the PWM configuration value is in the sixth fitting interval, the lowest three bits of the first trimming value are the result obtained by bitwise inverting the second to fourth bits from the low bit of the count value, and the remaining bits are 0. When the PWM configuration value is in the fifth fitting interval, the lowest two bits of the first trimming value are the result obtained by bitwise inverting the third and fourth bits from the low bit of the count value, and the remaining bits are 0. When the PWM configuration value is in the fourth and third fitting intervals, the lowest one bit of the first trimming value is the result obtained by bitwise inverting the fourth bit from the low bit of the count value, and the remaining bits are 0.
[0078] According to one embodiment, when the PWM configuration value is in the second fitting interval (for example, the second fitting interval 64≤x<96 in Table 4), the result of performing an AND operation on the value obtained by inverting the fourth bit from the low bit of the count value and the value of the first bit from the low bit of the count value is used as the lowest bit of the first trimming value, and the remaining bits are 0.
[0079] Step 509, update the trimming result of the first-stage trimming. Update the difference between the trimming result of the first-stage trimming and the first trimming value as the trimming result of the first-stage trimming.
[0080] Step 510, update the trimming times of the first-stage trimming. Update the value obtained by subtracting 1 from the trimming times as the trimming times.
[0081] According to one embodiment, the first trimming value is obtained based on the fitting interval where the PWM configuration value is located and the current count value of the counter, and the linear fitting result is successively subtracted by the first trimming value to obtain the trimming result, and the trimming times also decrease accordingly.
[0082] Step 511, determine whether the trimming times of the first-stage trimming is equal to 0. If the trimming times is equal to 0, execute step 513; otherwise, jump to step 508.
[0083] In some embodiments, when the first-stage trimming of the linear fitting result is completed and the dimming requirement is met, the trimming result of the first-stage trimming can be used as the final trimming result.
[0084] Optionally, according to other embodiments, the trimming of the linear fitting result may further include a second-stage trimming, and the trimming result of the first-stage trimming is trimmed using the second trimming value to obtain a higher dimming accuracy.
[0085] Table 5
[0086] Table 5 shows a list of second trimming values according to an embodiment of the present application. Among them, the first column of pwm_cnt[4:0] represents the decimal number corresponding to the lowest five bits of the count value, and its value increases successively from 16 to 31; the second column represents the lowest five bits of the count value. The second column to the seventh column are the second trimming values and the cumulative second trimming values corresponding to the count value in each fitting interval from the seventh fitting interval to the first fitting interval. The last row of Table 5 is the second trimming value algorithm corresponding to each fitting interval. According to an embodiment of the present application, when trimming the linear fitting result, the first-stage trimming is performed when the decimal number corresponding to the count value is 0 to 15; the second-stage trimming is performed when the decimal number corresponding to the count value is 16 to 31.
[0087] In Table 5, for the PWM configuration value located in the seventh fitting interval (224 ≤ x ≤ 255), when the count value counts from 16 to 32, the second trimming value is always 1, and the decimal value corresponding to the cumulative second trimming value is 15. For the PWM configuration value located in the sixth fitting interval (192 ≤ x < 224), the second trimming value is the result obtained by inverting the lowest bit of the count value. When the lowest bit of the count value is 0, the second trimming value is 1; when the lowest bit of the count value is 1, the value of the second trimming value is 0. When the count value counts from 16 to 32, the decimal value corresponding to the cumulative second trimming value is 8.
[0088] According to an embodiment, obtain the trimming result of the first-stage trimming as the initial value of the trimming result of the second-stage trimming.
[0089] Step 513, use the second trimming value to perform a second-stage trimming on the first-stage trimming result.
[0090] For the highest serial number fitting interval, to perform a second-stage trimming on the trimming result of the first-stage trimming, the following two methods can be used.
[0091] In one embodiment, the number of trimming times for the second-stage trimming is 1. Take the difference between the trimming result of the first-stage trimming and the second trimming value as the final trimming result. That is, the trimming result of the first-stage trimming is trimmed once to obtain the final trimming result. Among them, the second trimming value is the initial value of the number of trimming times.
[0092] In another embodiment, the trimming result of the first-stage trimming is trimmed multiple times, and the second trimming value for each trimming is 1. The number of trimming times is the number of trimming times during the first-stage trimming.
[0093] According to an embodiment, for fitting intervals other than the highest serial number fitting interval, the trimming result of the first-stage trimming is trimmed multiple times using the second trimming value. The trimming result of the first-stage trimming is successively subtracted by the second trimming value to obtain the trimming result of the second-stage trimming, and the number of trimming times is correspondingly reduced by one. Among them, the number of trimming times in the second-stage trimming can be the same as that in the first-stage trimming. Determine the fitting interval where the PWM configuration value is located based on the highest three bits of the PWM configuration value, and obtain the second trimming value through a corresponding algorithm. When the difference between the serial number of the fitting interval where the PWM configuration value is located and the highest fitting interval serial number is 1 or 3, the second trimming value is the value obtained by inverting the first bit from the low bit of the count value. When the difference between the serial number of the fitting interval where the PWM configuration value is located and the highest fitting interval serial number is 2, the second trimming value is the value obtained by inverting the second bit from the low bit of the count value. When the difference between the serial number of the fitting interval where the PWM configuration value is located and the highest fitting interval serial number is equal to 4, the second trimming value is 0. When the difference between the serial number of the fitting interval where the PWM configuration value is located and the highest fitting interval serial number is equal to 5, and the decimal number corresponding to the lowest four bits from the low bit of the count value is 13, the second trimming value is 1.
[0094] According to an embodiment, the sum of all the first trimming values and all the second trimming values is the total trimming value.
[0095] Step 514, use the trimming result of the second-stage trimming as the final trimming result and set it as the dimming control value.
[0096] Table 6 shows an example list of two-stage trimming for the highest serial number fitting interval according to an embodiment of the present application. Among them, the first column is the decimal number corresponding to the PWM configuration value, which is within the seventh fitting interval (224≤x≤255). The second column is the decimal number corresponding to the lowest five bits of the PWM configuration value, and the third column is the number of trimming times obtained based on the PWM configuration value. The fourth column represents the total trimming value after two-stage trimming of the linear fitting result. The total trimming value is the sum of all the first trimming values and all the second trimming values. The fifth column represents the trimming result of the first-stage trimming obtained by reducing the linear fitting result by the first trimming value multiple times. Among them, the values in each row formula from left to right represent the values of the first trimming value reduced each time during trimming. The sixth column represents the final trimming result obtained by reducing the trimming result of the first-stage trimming by the second trimming value.
[0097] Table 6
[0098] Taking the PWM configuration value of 225 in Table 6 as an example, the fifth binary digit from the low bit is 0, and the initial value of the trimming times is 1 based on the lowest four binary digits 0001. When the trimming enable signal is valid, the first-stage trimming is performed on the linear fitting result corresponding to the PWM configuration value of 225. After obtaining the lowest four bits of the count value and taking the bitwise inversion, the first trimming value obtained is 15. The linear fitting result corresponding to the PWM configuration value of 225 is trimmed once, and the difference between the linear fitting result and the first trimming value (the corresponding decimal number 15) is used as the trimming result of the first-stage trimming. In the second-stage trimming, the trimming times is 1 and the second trimming value is 1, and the difference between the trimming result of the first-stage trimming and the second trimming value is used as the final trimming result. The sum of the first and second trimming values corresponds to the decimal number 16. The lowest five bits of the PWM configuration value are different in different fitting intervals, and the corresponding trimming values are also different.
[0099] According to another embodiment of the present application, the second-stage trimming can also be performed on the linear fitting result first, and the first-stage trimming can be performed on the trimming result of the second-stage trimming, and the final trimming result is used as the dimming control value.
[0100] For the above linear fitting and curvature trimming methods, each step can be freely combined according to actual needs to obtain the dimming control value corresponding to the PWM configuration value.
[0101] According to one embodiment, when the count value output by the counter is 0, the PWM signal jumps to a high level; when the count value reaches the dimming control value, the PWM signal jumps to a low level. At this time, the duty cycle output by the PWM is (exp_value + 1) / 4096, where exp_value represents the dimming control value. In one embodiment, when the PWM configuration value increases from 0 to 255, the duty cycle of the PWM signal increases according to an exponential curve, and the brightness of the LED light increases uniformly. When the PWM configuration value decreases from 255 to 0, the duty cycle of the PWM signal decreases according to an exponential curve, and the brightness of the LED light decreases uniformly.
[0102] Without consuming any computing resources, the linear fitting result is obtained through the correspondence between the PWM configuration value and the linear fitting result. During the curvature trimming process, only one subtractor / adder needs to be added to the original LED dimming device to complete the trimming of the linear fitting result and obtain the final trimming result, making the dimming curve formed by the final trimming result smoother.
[0103] Figure 6 The figure shows a schematic diagram of the curves before and after trimming the linear fitting result according to an embodiment of the present application. Figure 6The abscissa represents the PWM configuration value, and the ordinate represents the trimming result. Curve 1 is the curve formed by the linear fitting result, and Curve 2 is the curve obtained after trimming the linear fitting result. Figure 6 Among them, the LED dimming target curve obtained after trimming the linear fitting result has a smoother transition and is more similar to an exponential curve.
[0104] Figure 7 The figure shows a schematic diagram of the dimming simulation result according to an embodiment of the present application. The value of the PWM configuration value pwm_config[7:0] is 240 (the corresponding binary number is 11110000), and the value of the linear fitting result line_func[11:0] is 3072 (the corresponding binary number is 110000000000). Figure 7 Among them, the trimming of the linear fitting result includes a first-stage trimming and a second-stage trimming. The fifth binary digit of the PWM configuration value is 1. The lowest four binary digits of the PWM configuration value are bitwise inverted to obtain a trimming count value of 15. When the decimal number corresponding to the lowest four bits pwm_cnt[3:0] of the count value is 0, the trimming enable signal sub_en jumps to a high level, and the lowest four bits of the count value are bitwise inverted to obtain the first trimming value 15. At this time, the decimal number corresponding to trim[3:0] is the first trimming value, and the first trimming value is 15. During the first-stage trimming process, the count value pwm_cnt[3:0] counts from 0 to 15. Based on the first trimming value algorithm, the decimal numbers corresponding to the 15 first trimming values are 15, 14, 13... 2, 1 in sequence. The linear fitting result 3072 is successively subtracted by the first trimming values to obtain the trimming result 2952 of the first-stage trimming. When the decimal number corresponding to the lowest four bits pwm_cnt[3:0] of the count value is 16, the second-stage trimming starts. In this case, the decimal number corresponding to trim[3:0] is the second trimming value, and the value of the second trimming value is 1. The trimming result 2952 of the first-stage trimming is successively subtracted by 15 second trimming values to obtain the decimal number corresponding to the final trimming result exp_value[11:0] as 2937. The duty cycle of the PWM signal output by the LED dimming device is (2937 + 1) / 4096.
[0105] The present application further includes an electronic device, including an LED dimming control device and an LED device. The LED dimming control device executes any of the dimming methods described above. Among them, the LED dimming configuration device includes a register and a counter. The counter is configured to count cyclically starting from zero and output a count value, and the range of the count value output by the counter is 0 to 4095.
[0106] In some embodiments, the original circuit of the LED dimming control device includes a register and a timer. The LED dimming control device only needs to additionally add a subtractor to achieve the real-time acquisition of the exponential trimming result through subtraction operations.
[0107] Among the three common exponential dimming methods in the prior art, the PWM configuration value is directly corresponding to the dimming control value through complex operations or look-up tables, which requires a large amount of computing resources or storage resources. The dimming method based on linear fitting and curvature trimming proposed in this application combines linear fitting with real-time trimming, reduces the consumption of storage resources and computing resources, obtains a higher-precision exponential trimming result by using a more optimized algorithm, has higher stability, higher precision, and faster processing speed, and provides a more comfortable and delicate visual experience for users.
[0108] The above embodiments are only for illustrating the present invention and are not intended to limit the present invention. Those of ordinary skill in the relevant technical field can also make various changes and modifications without departing from the scope of the present invention. Therefore, all equivalent technical solutions should also fall within the scope of the disclosure of the present invention.
Claims
1. A dimming method based on straight line fitting, comprising: Acquire a PWM configuration value, wherein the PWM configuration value is a binary number, and a plurality of fitting intervals are divided based on a possible value range thereof; the sequence number of the fitting interval is a decimal number determined based on at least a first part of the PWM configuration value; Determine the fitting interval based on the first part of the PWM configuration value; A straight line fitting result is obtained based on the PWM configuration value and the fitting interval; wherein, The number of bits of the straight line fitting result is greater than the number of bits of the PWM configuration value.
2. The method according to claim 1, wherein: When the PWM configuration value is located in other fitting intervals except the first fitting interval, the straight line fitting result corresponding to each of the PWM configuration values includes a first part, a second part and a third part in order from the lowest bit to the highest bit; wherein the first fitting interval is an interval starting from the minimum value of the PWM configuration value; The straight line fitting result is a binary number with a fixed number of bits, the first part of which includes one or more 0s, where the number of 0s is the serial number of the fitting interval where the PWM configuration value is located minus 1; The second part includes the value of the least significant X bits of the PWM configuration value, where X is an integer greater than or equal to 5; The least significant bit of the third part is 1, and the remaining bits, if any, are 0.
3. The method according to claim 1, wherein: When the PWM configuration value is in the first fitting interval, the PWM configuration value is used as the straight line fitting result.
4. The method according to claim 1, wherein: When the PWM configuration value is a maximum value, the straight line fitting result is a preset fixed value.
5. An electronic device, comprising an LED dimming device, wherein: The LED dimming device is configured to execute the method according to any one of claims 1 to 4. The electronic device according to claim 5 , further comprising an LED light emitting element.
Citation Information
Patent Citations
System and method for non-linear dimming of a light source
CN102026446A
Method for improving optical proximity simulation from exposure result
CN103019027A
Dimming curve generation method, dimming curve generation device, and LED lighting device
CN111511077A