Knob dimming method

By using a timer and a ring buffer storage method, the problems of signal jitter and misjudgment caused by rapid rotation of the rotary encoder were solved, thus achieving smoothness and accuracy of rotary dimming.

CN120980752APending Publication Date: 2025-11-18XIAMEN DNAKE INTELLIGENT TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202511185913.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-22
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

The existing rotary encoder has switching characteristic level jitter in the A and B level signals output during rotation, which causes abnormal signal pulses, sudden changes in dimming effect during rapid rotation, serious misjudgment, and affects the dimming effect.

Method used

A timer is used to detect falling edge interrupts. The pulse period time is marked by Ts and Te. Combined with a ring buffer storage method, the timer value is dynamically adjusted to avoid misjudgment and record rotation information.

Benefits of technology

It enables the rapid acquisition of a valid level after the level returns to a stable state, avoiding misjudgment and solving the problem of pulse signal count overlay caused by rapid knob rotation, thus ensuring the stability of the dimming effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120980752A_ABST
    Figure CN120980752A_ABST
Patent Text Reader

Abstract

The invention provides a knob dimming method which comprises the following steps: S1, when a falling edge is detected in each interruption of a program, performing input falling edge interruption on a pin A, and then starting a timer; s2, judging whether the timing time of the timer is up or not, if not, returning to S1, and if so, reading the signal level of the pin A; and S3, judging whether the signal level of the pin A read in S2 is a low level or not, if not, returning to S1, and if so, judging that the level of the pin A is valid. According to the invention, the effective level can be rapidly obtained after the level recovers to be stable, the maximum delay time or pulse period is not measured again by means of device replacement, the knob level is read by dynamically setting timing, misjudgment is greatly avoided, and in addition, the problem of pulse signal counting coverage caused by rapid rotation of the knob is also solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of smart home technology, and in particular to a method for adjusting the brightness using a knob. Background Technology

[0002] As an important sensor, rotary encoders have a wide range of applications and diverse types. The basic working principle of rotary encoders is to generate electrical signals through rotational mechanical motion. These signals can be analog or digital signals and are usually used to measure rotation angle, position, or speed. Rotary encoders are generally divided into two types: incremental encoders and absolute encoders. 1. Incremental encoders output pulse signals, while 2. Absolute encoders output digital signals at specific positions.

[0003] This dimming panel uses an incremental encoder for brightness adjustment. This solution has the following problems: (1) When rotating, the output A and B level signals have switching characteristics and level jitter occurs at T1 and T3. The signal pulse diagram at this time is as follows: Figure 1 As shown, this causes the output pulse signal to be abnormal, and the software misjudges the valid action during acquisition; 2. When rotating back and forth quickly, the dimming is not executed in time before being overwritten by the new count value of the rotation, and the brightness adjustment has no transition effect and abrupt changes. The above problems lead to unsatisfactory dimming effect. Based on this, we propose a knob dimming method. Summary of the Invention

[0004] The present invention proposes a knob dimming method, which solves the problems existing in the prior art.

[0005] To achieve the above objectives, the present invention adopts the following technical solution:

[0006] A method for adjusting brightness using a knob includes the following steps:

[0007] S1: Whenever the program detects a falling edge during an interrupt, it inputs a falling edge interrupt on pin A and then starts a timer;

[0008] S2: Determine whether the timer has expired. If the time has not expired, return to S1. If the time has expired, read the signal level of pin A.

[0009] S3: Determine whether the signal level of pin A read in S2 is low. If it is not low, return to S1. If it is low, determine that the level of pin A is valid. At this time, the condition is that the level is active low and marked as Ts. Otherwise, it is determined as invalid and exits to wait for the next pulse to re-mark Ts. When Ts is successfully marked, mark it as Te when the next valid falling edge is detected.

[0010] S4: After a complete marking process in S3, Ts and Te are obtained. The pulse period time is calculated by T = Te - Ts until the signal A level is read as valid.

[0011] S5: After signal A is active, read the level of signal B. The rotation direction can be distinguished based on the level of B, and the circular buffer storage method is used for storage.

[0012] Preferably, in step S1, the initial value of the timer is 3ms.

[0013] Preferably, in step S1, if a falling edge interrupt is triggered multiple times consecutively, a new timer is started to overwrite the previous timer, and the timer is reset.

[0014] Preferably, in S4, the timing judgment value can be dynamically changed according to the T / 4 value, the purpose of which is to make the judgment closer to the point where signal A stabilizes by adjusting the timing.

[0015] Preferably, in step S5, the specific steps for storing data using the circular buffer storage method are as follows:

[0016] S501: First, a basic buffer unit is constructed, which includes three parameters: number of dimming paths, dimming mode, and pulse count value;

[0017] S502: Store each valid rotation information generated. The stored information is retrieved sequentially in the main program loop. The main program is responsible for consuming the recorded information, and the interrupt detection is responsible for generating the recorded information.

[0018] Preferably, in step S502, when the amount of information to be recorded increases during rapid rotation, the complete information can be recorded without loss by adjusting the size of the buffer group.

[0019] Compared with the prior art, the present invention can quickly obtain the effective level after the level returns to stability, and is not limited by replacing the device and re-measuring the maximum delay time or pulse period. It can dynamically set the timing to read the knob level, which greatly avoids misjudgment. In addition, it also solves the problem of pulse signal count overlay caused by rapid knob rotation. Attached Figure Description

[0020] Figure 1 This is a signal pulse diagram of a knob dimming method in the prior art;

[0021] Figure 2 This is a signal pulse diagram of signal A and signal B in a knob dimming method proposed in this invention;

[0022] Figure 3 This is a flowchart of a knob dimming method proposed in this invention. Detailed Implementation

[0023] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0024] Reference Figure 2-3 A method for adjusting the brightness using a knob includes the following steps:

[0025] S1: Each time the program detects a falling edge during an interrupt, it inputs a falling edge interrupt on pin A and then starts a timer with an initial value of 3ms. If the falling edge interrupt is triggered multiple times in a row, a new timer is started to overwrite the previous timer and the timer is reset.

[0026] S2: Determine whether the timer has expired. If the time has not expired, return to S1. If the time has expired, read the signal level of pin A.

[0027] S3: Determine whether the signal level of pin A read in S2 is low. If it is not low, return to S1. If it is low, determine that the level of pin A is valid. At this time, the condition is that the level is active low and marked as Ts. Otherwise, it is determined as invalid and exits to wait for the next pulse to re-mark Ts. When Ts is successfully marked, mark it as Te when the next valid falling edge is detected.

[0028] S4: After a complete marking in S3, Ts and Te are obtained. The pulse period time is obtained by calculating T = Te - Ts. The timing judgment value can be dynamically changed according to the T / 4 value. The purpose is to make the judgment by adjusting the timing closer to the point where the signal A stabilizes, until the signal A level is read as valid.

[0029] S5: After signal A is active, read the level of signal B. The rotation direction can be distinguished based on the level of B, and the rotation direction can be stored using a circular buffer storage method. The specific steps of storing the rotation direction using the circular buffer storage method are as follows:

[0030] S501: First, a basic buffer unit is constructed, which includes three parameters: number of dimming paths, dimming mode, and pulse count value;

[0031] S502: Store each valid rotation information when it is generated. The stored information is retrieved sequentially in the main loop of the program. The main program is responsible for consuming the recorded information, and the interrupt detection is responsible for generating the recorded information. When the amount of information to be recorded increases during rapid rotation, the complete information can be recorded without loss by adjusting the size of the buffer group.

[0032] This embodiment can quickly obtain a valid level after the level returns to a stable state, and is not limited by replacing the device and having to remeasure the maximum delay time or pulse period. It can dynamically set the timing to read the knob level, which greatly avoids misjudgment. In addition, it also solves the problem of pulse signal count overlay caused by rapid knob rotation.

[0033] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A method for adjusting brightness using a knob, characterized in that, Includes the following steps: S1: Whenever the program detects a falling edge during an interrupt, it inputs a falling edge interrupt on pin A and then starts a timer; S2: Determine whether the timer has expired. If the time has not expired, return to S1. If the time has expired, read the signal level of pin A. S3: Determine whether the signal level of pin A read in S2 is low. If it is not low, return to S1. If it is low, determine that the level of pin A is valid. At this time, the condition is that the level is active low and marked as Ts. Otherwise, it is determined as invalid and exits to wait for the next pulse to re-mark Ts. When Ts is successfully marked, mark it as Te when the next valid falling edge is detected. S4: After a complete marking process in S3, Ts and Te are obtained. The pulse period time is calculated by T = Te - Ts until the signal A level is read as valid. S5: After signal A is active, read the level of signal B. The rotation direction can be distinguished by the level of B, and the circular buffer storage method is used for storage.

2. The method for adjusting brightness using a knob according to claim 1, characterized in that, In S1, the initial value of the timer is 3ms.

3. The method for adjusting brightness using a knob according to claim 1, characterized in that, In S1, if a falling edge interrupt is triggered multiple times consecutively, a new timer is started to overwrite the previous timer, and the timer is reset.

4. The method for adjusting the brightness using a knob according to claim 1, characterized in that, In S4, the timing judgment value can be dynamically changed according to the T / 4 value. The purpose is to make the judgment by adjusting the timing closer to the point where signal A has stabilized.

5. The method for adjusting the brightness using a knob according to claim 1, characterized in that, In step S5, the specific steps for storing data using the circular buffer storage method are as follows: S501: First, a basic buffer unit is constructed, which includes three parameters: number of dimming paths, dimming mode, and pulse count value; S502: Store each valid rotation information generated. The stored information is retrieved sequentially in the main program loop. The main program is responsible for consuming the recorded information, and the interrupt detection is responsible for generating the recorded information.

6. The method for adjusting brightness using a knob according to claim 5, characterized in that, In step S502, when the amount of information to be recorded increases during rapid rotation, the complete information can be recorded without loss by adjusting the size of the buffer group.

Citation Information

Cited By

  • Centrifugal pump control method and system based on knob adjustment

    CN121408235A

  • A knob-adjustment-based centrifugal pump control method and system

    CN121408235B