Toggle switch gear detection circuit and method
By designing a toggle switch gear detection circuit, the gear position is determined using the voltage ratio and the preset resistance ratio, the problem of high power consumption in the existing technology and the single IO port can only identify one gear position, realizing the functions of low power consumption and multi-speed identification.
Patent Information
- Application Number
- CN202411736192.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-14
AI Technical Summary
In the prior art, during the gear recognition process of multi-speed toggle switches, the circuit power consumption is high, and a single IO port can only recognize one gear, resulting in excessive IO port resource utilization and the entry and wake-up of the low-power mode cannot be achieved.
Through pin multiplexing, a toggle switch gear detection circuit is designed, including a voltage identification sampling module, a gear adjustment module and a control module. This circuit detects the voltage ratio and combines the preset resistance ratio to determine the gear position to realize the function of a single IO port to identify multiple gear positions.
It effectively reduces circuit power consumption, reduces the use of IO port resources by gear recognition, and realizes the low-power mode entry and wake-up of the circuit, which is suitable for applications of low-standby power consumption products.
Smart Images

Figure CN119619818A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of multi-position toggle switches, and in particular to a toggle switch position detection circuit and method. Background Art
[0002] Electronic cigarettes currently on the market are usually powered by built-in lithium batteries. When not in use, the circuit system of the electronic cigarette is in low-power mode to minimize the energy consumption of the device, thereby extending battery life and reducing energy costs. When it is needed, the circuit system is awakened by external components, so that the electronic cigarette enters a normal working state. In the prior art, in the gear recognition process of a multi-gear toggle switch, the level change of the corresponding IO port usually corresponds to the different gear switching, and the state level is read through each IO port. The IO port in the gear detection circuit corresponds to the gear one-to-one, realizing level-based gear detection and adjusting different functional settings of the electronic cigarette, such as the output voltage, output power, airflow threshold frequency, output time and other aspects of the selection and gear setting during operation.
[0003] At this time, the number of gears is limited by the number of IO ports of the microcontroller chip. In order to achieve diversified functions and meet the needs of different customers, it is necessary to replace the microcontroller chip with a larger volume, more IO ports, and larger wafers. At the same time, the wiring of the control board is complicated and the hardware cost is high. It is also impossible to enter and wake up the circuit in low power consumption mode, which is not suitable for application in low standby power consumption products.
[0004] Therefore, the prior art still needs to be improved and developed. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, the purpose of the present invention is to provide a toggle switch gear position detection circuit and method, which solves the problems in the prior art of high circuit power consumption, a single IO port can only identify one gear, and requires the IO ports to occupy the same number of IO ports, thereby occupying the IO port resources in the circuit through pin multiplexing.
[0006] The technical solution of the present invention is as follows: A toggle switch gear detection circuit, comprising: a voltage identification sampling module, a gear adjustment module and a control module; wherein the gear adjustment module is connected to the voltage identification sampling module, and is used to convert the resistance value of the corresponding gear into an output voltage when the gear is adjusted, and output the output voltage to the voltage identification sampling module; The voltage identification sampling module is used to sample the output voltage of the gear adjustment module and output the sampled voltage to the control module; The control module is connected to the power supply voltage and is connected to the voltage identification sampling module, so as to obtain a voltage ratio according to the sampling voltage and the power supply voltage, obtain a current resistance ratio according to the voltage ratio, and determine the corresponding gear of the gear adjustment module according to the current resistance ratio and a preset resistance ratio.
[0007] According to a further configuration of the present invention, the voltage identification sampling module includes: the first resistor and the first capacitor, wherein one end of the first resistor is connected to the power supply voltage, the other end of the first resistor is connected to one end of the first capacitor, the common end of the first resistor and the first capacitor is respectively connected to the input end of the control unit and the input end of the gear adjustment module, and the other end of the first capacitor is grounded.
[0008] According to a further configuration of the present invention, the control module comprises: a micro control unit, a power port of the micro control unit is connected to a power supply voltage, and an input end of the micro control unit is connected to the voltage identification sampling module.
[0009] According to a further configuration of the present invention, the gear adjustment module includes: a first multi-speed toggle switch, a second resistor, a third resistor and a fourth resistor, the third pin of the first multi-speed toggle switch is connected to the common end of the first resistor and the first capacitor, at the other end of the first multi-speed toggle switch, the first pin of the first multi-speed toggle switch is connected to one end of the third resistor, the third pin of the first multi-speed toggle switch is connected to the other end of the third resistor and one end of the third resistor, the fourth pin of the first multi-speed toggle switch is connected to the other end of the third resistor and one end of the fourth resistor, and the fifth pin of the first multi-speed toggle switch and the other end of the fourth resistor are grounded.
[0010] According to a further configuration of the present invention, the microcontroller unit includes an analog-to-digital conversion module and a level jump module, wherein the analog-to-digital conversion module and the level jump module are connected to a common end of the gear adjustment module and the voltage identification sampling module via a detection pin of the microcontroller unit, and the detection pin of the microcontroller unit is used for analog-to-digital conversion and level jump.
[0011] According to a further configuration of the present invention, the microcontroller unit includes: an analog-to-digital conversion module and an INT external interrupt module, wherein the analog-to-digital conversion module is connected to a detection pin of the microcontroller unit, and the INT external interrupt module is connected to an interrupt pin of the microcontroller unit, and the detection pin and interrupt pin of the microcontroller unit are respectively connected to a common end of the gear adjustment module and the voltage identification sampling module, the detection pin of the microcontroller unit is used for determining the gear position of a multi-speed toggle switch, and the interrupt pin of the microcontroller unit is used for waking up the microcontroller unit.
[0012] According to a further configuration of the present invention, the micro control unit is SC8F073.
[0013] According to a further configuration of the present invention, the control module also includes: a micro control unit driving module, the micro control unit driving module includes a fifth resistor and a third capacitor, wherein one end of the fourth resistor is connected to the power supply voltage, the other end of the fifth resistor is respectively connected to one end of the third capacitor and the power port of the micro control unit, and the other end of the second capacitor is grounded.
[0014] Based on the same inventive concept, the present invention also provides a multi-speed toggle switch gear position detection method, which includes: Wake up the microprocessor from low power consumption state; Get the power supply voltage and the sampling voltage; Obtaining a voltage ratio according to the power supply voltage and the sampled voltage; A current resistance ratio is obtained according to the voltage ratio, and a corresponding gear of the gear adjustment module is determined according to the current resistance ratio and a preset resistance ratio.
[0015] A further setting of the multi-speed toggle switch gear position detection method, wherein the step of obtaining the power supply voltage and the sampling voltage comprises: Select the ADC channel of the internal reference voltage; Read the ADC value of the reference voltage; Calculating the power supply voltage of the microprocessing unit according to the ADC value of the reference voltage; The sampled voltage at the input terminal of the control module is read.
[0016] The present invention provides a toggle switch gear detection circuit and method, the circuit includes: a voltage identification sampling module, a gear adjustment module and a control module. The gear adjustment module is connected to the voltage identification sampling module, and is used to convert the resistance value of the corresponding gear into an output voltage when adjusting the gear, and output the output voltage to the voltage identification sampling module; the voltage identification sampling module is used to sample the output voltage of the gear adjustment module, and output the sampled voltage to the control module; the control module is connected to the power supply voltage and connected to the voltage identification sampling module, and is used to obtain a voltage ratio according to the sampled voltage and the power supply voltage, obtain a current resistance ratio according to the voltage ratio, and determine the corresponding gear of the gear adjustment module according to the current resistance ratio and the preset resistance ratio. The present invention provides a toggle switch gear detection circuit and method, by detecting the voltage ratio in the current circuit, and comparing it with the corresponding resistance ratio to determine the gear, so as to solve the problem of high circuit power consumption and a single IO port can only identify one gear in the prior art, and reduce the occupation of IO port resources in the circuit by gear identification. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary personnel in this field, other drawings can be obtained based on the structures shown in these drawings without paying any creative work.
[0018] Figure 1 It is a functional module architecture diagram of some preferred embodiments of a toggle switch position detection circuit in the present invention.
[0019] Figure 2 It is a functional module architecture diagram of a first preferred embodiment of a toggle switch position detection circuit in the present invention.
[0020] Figure 3 It is a functional module architecture diagram of a second preferred embodiment of a toggle switch position detection circuit in the present invention.
[0021] Figure 4 The present invention is a schematic circuit diagram of a gear position adjustment module and a voltage identification sampling module of a toggle switch gear position detection circuit in a preferred embodiment of the present invention.
[0022] Figure 5 It is a schematic diagram of a control module of a toggle switch position detection circuit in a preferred embodiment of the present invention.
[0023] Figure 6 It is a flow chart of a toggle switch position detection method in a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0024] The present invention provides a toggle switch position detection circuit and method. To make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0025] In the embodiments and the scope of the patent application, unless the text specifically defines the article, "a", "an", "the" and "the" may also include plural forms. If there are descriptions involving "first", "third", etc. in the embodiments of the present invention, the descriptions of "first", "third", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "third" may explicitly or implicitly include at least one of the features.
[0026] It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element, or there can be intermediate elements. In addition, the "connection" or "coupling" used herein can include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.
[0027] Those skilled in the art will understand that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art in the field to which the present invention belongs. It should also be understood that terms such as those defined in common dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as here.
[0028] In addition, the technical solutions between the various embodiments can be combined with each other, but it must be based on the fact that ordinary technicians in the field can implement it. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0029] See also Figure 1 The present invention provides a preferred embodiment of a detection circuit fluctuation switch gear detection circuit, which includes: a toggle switch gear detection circuit, which includes: a gear adjustment module 200, a voltage identification sampling module 100 and a control module 300; wherein the gear adjustment module 200 is connected to the voltage identification sampling module 100, and is used to adjust the gear, and convert the gear change into the change of the output voltage in the gear adjustment module 200; the voltage identification sampling module 100 is connected to the control module 300, and is used to sample the voltage value in the circuit when the gear changes, and output the sampled voltage VKEY_ADC to the control module 300; the control module 300 is connected to the voltage identification sampling module, and is used to calculate the voltage ratio between the voltage signal sampled by the voltage identification sampling module 100 and the power supply voltage VB+ and correspond it with the resistance ratio to determine the current gear in the gear adjustment module 200.
[0030] Specifically, the power supply voltage VB+ is provided by a lithium battery, and the working voltage fluctuates between 3-4.2V. The voltage identification sampling module 100 is connected to the power supply voltage VB+, the gear adjustment module 200 is grounded, and the gear adjustment module 200 and the voltage identification sampling module 100 divide the power supply voltage VB+. The gear adjustment module 200 is used to switch the gear position through interaction with the user during use. When the user changes the gear position in the gear adjustment module 200, the voltage ratio between the gear adjustment module 200 and the voltage identification sampling module 100 changes accordingly, and the ratio between the sampling voltage VKEY_ADC at the voltage identification sampling module 100 and the power supply voltage VB+ also changes. At the same time, because the ratio between the sampling voltage VKEY_ADC and the power supply voltage VB+ is equal to the resistance ratio between the two end points and the ground, the current resistance ratio can be calculated by calculating the voltage ratio between the sampling voltage VKEY_ADC and the power supply voltage VB+, and the gear position of the toggle switch at this time is obtained by comparing the current resistance ratio with the preset resistance ratio.
[0031] The input end of the control module 300 is connected to the voltage identification sampling module 100. When the power supply voltage VB+ changes, the control module 300 is used to detect the voltage ratio between the sampling voltage VKEY_ADC at the corresponding gear after the change and the power supply voltage VB+, and compare it with the resistance ratio of each gear: when the voltage ratio is equal to the first resistance ratio, the gear adjustment module 200 is in the first gear; when the voltage ratio is equal to the second resistance ratio, the gear adjustment module 200 is in the second gear; when the voltage ratio is equal to the third resistance ratio, the gear adjustment module 200 is in the third gear; when the voltage ratio is equal to the fourth resistance ratio, the gear adjustment module 200 is in the fourth gear. Through the pin multiplexing of the control module 300, a single IO port can output more gear information according to the detected resistance ratio, thereby improving the user's experience of smoking electronic cigarettes.
[0032] Please refer to Figure 4 The voltage identification sampling module 100 includes: the first resistor R1 and the first capacitor C1, wherein one end of the first resistor R1 is connected to the power supply voltage VB+, the other end of the first resistor R1 is connected to one end of the first capacitor C1, the common end of the first resistor R1 and the first capacitor C1 is respectively connected to the input end of the control unit and the input end of the gear adjustment module 200, and the other end of the first capacitor C1 is grounded.
[0033] The gear adjustment module 200 includes: a first multi-speed toggle switch SW1, a third resistor R3, a third resistor R3 and a fourth resistor R4, the third pin of the first multi-speed toggle switch SW1 is connected to the common end of the first resistor R1 and the first capacitor C1, at the other end of the first multi-speed toggle switch SW1, the first pin of the first multi-speed toggle switch SW1 is connected to one end of the third resistor R3, the third pin of the first multi-speed toggle switch SW1 is connected to the other end of the third resistor R3 and one end of the third resistor R3, the fourth pin of the first multi-speed toggle switch SW1 is connected to the other end of the third resistor R3 and one end of the fourth resistor R4, and the fifth pin of the first multi-speed toggle switch SW1 and the other end of the fourth resistor R4 are grounded.
[0034] In a specific implementation, the B+ is a lithium battery as the power supply for the toggle switch position detection circuit, and the power supply voltage VB+ fluctuates between 3 and 4.2V. The first resistor R1 is located at the input end of the power supply voltage VB+, and is used to divide the power supply voltage VB+. The voltage value after the first resistor R1 is divided is the sampling voltage VKEY_ADC. In some preferred embodiments of the present invention, the first multi-speed toggle switch SW1 is a four-speed toggle switch, and the number of gears of the first multi-speed toggle switch SW1, that is, the number of pins on the other side, corresponds to the number of functions set in the specific implementation. The specific number of gears, the corresponding resistance value and the number of resistors in the circuit can change with the change of specific functional requirements, and are not limited here.
[0035] The third pin of the first multi-speed toggle switch SW1 is connected to the first resistor R1. On the other side of the first multi-speed toggle switch SW1, K1 is connected to KEY1, K2 is connected to KEY2, and K3 is connected to KEY3. The second resistor R2, the third resistor R3 and the fourth resistor R4 are connected in series. The first pin, the second pin and the fourth pin of the first multi-speed toggle switch SW1 are respectively connected to one end of the second resistor R2, the third resistor R3 and the fourth resistor R4, and the fifth pin of the first multi-speed toggle switch SW1 is connected to the other end of the fourth resistor R4.
[0036] When the first multi-speed toggle switch SW1 controls the third pin to be connected to the first pin, at this time, the power supply voltage VB+ is connected to the common end through the first resistor R1, the second resistor R2, the third resistor R3 and the fourth resistor R4 to form a loop. After the resistor voltage is divided in the loop, the sampling voltage VKEY_ADC at the voltage identification sampling module 100 is (VB+)*[(R2+R3+R4) / (R1+R2+R3+R4)], then the ratio of the sampling voltage VKEY_ADC to the power supply voltage VB+ is (R2+R3+R4) / (R1+R2+R3+R4), and this resistance ratio is the first resistance ratio. When the first multi-speed toggle switch SW1 controls the third pin to be connected to the second pin or the fourth pin, the second resistor R2 and the third resistor R3 are suspended in sequence, and the calculation method of the voltage ratio of the sampling voltage VKEY_ADC to the power supply voltage VB+ is consistent with the above steps, so it is not repeated here. When the third pin is conductively connected to the second pin, the voltage ratio is (R3+R4) / (R1+R3+R4); when the third pin is conductively connected to the fourth pin, the voltage ratio is R4 / (R1+R4), and the corresponding resistance ratios are the second resistance ratio and the third resistance ratio respectively.
[0037] When the third pin of the first multi-speed toggle switch SW1 is connected to the fifth pin, at this time, the second resistor R2, the third resistor R3 and the fourth resistor R4 are all suspended, one end of the first resistor R1 is connected to the power supply voltage VB+, and the other end of the first resistor R1 is grounded through the first multi-speed toggle switch SW1, the sampling voltage VKEY_ADC is 0V, and the fourth resistor ratio is zero. At this time, the static voltage in the circuit is the maximum power supply voltage VB+, and the static power consumption is the maximum value.
[0038] At the same time, the present invention can identify whether the key has fluctuated to the normal gear position through the input terminal level of the control module 300. If the third pin of the first multi-speed toggle switch SW1 does not normally contact the first pin, the second pin, the fourth pin or the fifth pin, but is located exactly between any two pins, the input terminal of the control module 300 is pulled up by the first resistor R1. At this time, the control module 300 detects the level change of the corresponding pin, and the fluctuation switch gear position detection circuit can be connected to the alarm circuit to alarm when the key has not fluctuated to the normal gear position, reminding the user to re-flip the first multi-speed toggle switch SW1 to the user's target gear position.
[0039] In a further implementation of the above preferred embodiment, the resistance of the first resistor R1 is 1 MΩ, and the resistance of the second resistor R2, the third resistor R3 and the fourth resistor R4 are all 100 kΩ. When the first multi-speed toggle switch SW1 fluctuates to the first pin, the first pin and the third pin are connected, and the sampling voltage VKEY_ADC=(VB+)*[300 / (1000+300)]=0.23*(VB+) is substituted into the formula, and the voltage ratio of the power supply voltage VB+ is 3 / 13; when the first multi-speed toggle switch SW1 fluctuates to the second pin, the sampling voltage VKEY_ADC=0.166*(VB+), and the voltage ratio of the power supply voltage VB+ is 2:12; when the first multi-speed toggle switch SW1 fluctuates to the fourth pin, the sampling voltage VKEY_ADC=0.09*(VB+), and the voltage ratio of the power supply voltage VB+ is 1:11; when the first multi-speed toggle switch SW1 fluctuates to the fourth pin, the sampling voltage VKEY_ADC=0V, and the result of calculating the voltage ratio under the corresponding gear is the current resistance ratio, and the current gear can be reversely deduced by comparing the current resistance ratio with the preset resistance ratio.
[0040] For further information, please also refer to Figure 2 , Figure 4 and Figure 5 In the first preferred embodiment of the toggle switch gear detection circuit of the present invention, the control module 300 includes: a micro control unit U1 and a micro control unit driving module, the micro control unit U1 is SC8F073, the micro control unit driving module includes a fifth resistor and a second capacitor, wherein one end of the fifth resistor is connected to the power supply voltage VB+, the other end of the fifth resistor is respectively connected to one end of the second capacitor and the power port of the micro control unit U1, and the other end of the third capacitor is grounded. The micro control unit U1 includes an analog-to-digital conversion module 310 and a level jump module 320, wherein the analog-to-digital conversion module 310 and the level jump module 320 are connected to the common end of the gear adjustment module and the voltage identification sampling module through the detection pin of the micro control unit U1, and the detection pin of the micro control unit U1 is used for analog-to-digital conversion and level jump.
[0041] Specifically, the power port VDD of the micro control unit U1 is connected to the power supply voltage VB+, and the detection pin of the micro control unit U1 is connected to the common terminal of the first resistor R1, the first capacitor C1 and the first multi-speed toggle switch SW1 as the input terminal of the micro control unit U1, and is used to receive the sampled voltage VKEY_ADC value after the voltage is divided by the first resistor R1. The detection pin of the micro control unit U1 is internally connected to the level jump module 320.
[0042] Furthermore, because the gear voltage of the toggle switch when adjusting the gear is less than the VDD voltage of the MCU, which is less than 0.3 times the power supply voltage VB+, when the toggle switch fluctuates to the next gear, due to the mechanical structure of the key, the third pin of the key floats at the moment of disconnection, and the pull-up resistor becomes a high level, and a level jump occurs at the input end of the microcontroller U1, waking up the microcontroller U1 from low power consumption. Specifically, the microcontroller U1 can enter a low power consumption mode in an idle state to reduce the power consumption of the microcontroller U1. The maximum resistance voltage division value of each gear does not exceed 0.3 times the power supply voltage VB+, which is lower than the maximum value of the low-level input voltage in the microcontroller U1. Therefore, at the moment when the key fluctuates and disconnects, the input end of the microcontroller U1 will change from a low level to a high level due to the pull-up resistor, and can instantly jump to wake up the microcontroller U1 in the low power consumption mode, maintain the gear detection efficiency and reduce the power consumption of the detection circuit.
[0043] The 14th pin KEY_ADC of the microcontroller U1 is connected to the voltage identification sampling module 100, and is used to receive the sampled voltage VKEY_ADC at the current gear position, and obtain the voltage ratio through the sampled voltage VKEY_ADC and the power supply voltage VB+. Because the power port of the microcontroller U1 is connected to the power supply voltage VB+, the power supply voltage value of the microcontroller U1 can be regarded as the power supply voltage VB+ value. The microcontroller U1 can read the internal reference voltage by selecting the ADC channel of the internal reference voltage, and convert the power supply voltage of the microcontroller U1 through the ADC value of the reference voltage. Specifically, the microcontroller U1 selects the ADC channel with an internal reference voltage of 1.2V in the analog-to-digital conversion module 310, and reads the ADC value AVref of the 1.2V internal reference voltage. Then, the power supply voltage value VCC=Vref*4096 / AVref of the microcontroller U1 can be obtained by calculation, and the Vref is the amplified reference voltage ADC value, and the VCC is regarded as the power supply voltage VB+.
[0044] The detection pin of the microcontroller U1 receives the sampling voltage VKEY_ADC, and the microcontroller U1 obtains the converted power supply voltage as the power supply voltage VB+ value to perform voltage ratio calculation, and the calculation result is the current resistance ratio after the user completes the gear switching. The microcontroller U1 compares the current resistance ratio with the internal preset resistance ratio, and reversely determines the current gear of the gear adjustment module 200. Specifically, the number of gears in the electronic cigarette can be set according to functional requirements. In this preferred embodiment, the number of electronic cigarette gears is four gears as an example, and the preset resistance ratio includes a first resistance ratio, a second resistance ratio, a third resistance ratio and a fourth resistance ratio. When the current resistance ratio is equal to the first resistance ratio, the gear adjustment module 200 is in the first gear; when the current resistance ratio is equal to the second resistance ratio, the gear adjustment module 200 is in the second gear; when the current resistance ratio is equal to the third resistance ratio, the gear adjustment module 200 is in the third gear; when the current resistance ratio is equal to the fourth resistance ratio, the gear adjustment module 200 is in the fourth gear. The electronic cigarette can adjust different functional settings such as output voltage, output power, airflow threshold frequency, output time, and oil supply during operation according to the gear position of the gear adjustment module to improve the user experience.
[0045] See also Figure 3 In the second preferred embodiment of the toggle switch position detection circuit, the microcontroller unit U1 can also be configured to include an analog-to-digital conversion module and an INT external interrupt module, wherein the analog-to-digital conversion module is connected to the detection pin of the microcontroller unit U1, the INT external interrupt module is connected to the interrupt pin of the microcontroller unit U1, the detection pin and the interrupt pin of the microcontroller unit U1 are respectively connected to the common end of the position adjustment module and the voltage identification sampling module, the detection pin of the microcontroller unit U1 is used to perform multi-speed toggle switch position detection, and the interrupt pin of the microcontroller unit U1 is used to wake up the microcontroller unit U1. When the microcontroller unit U1 does not have a level change interrupt inside, the microcontroller unit U1 can use a pin with an INT external interrupt function and a pin with an analog-to-digital conversion function to jointly identify. The analog-to-digital conversion module 311 receives the sampled voltage VKEY_ADC at the detection pin of the microcontroller unit U1, and the analog-to-digital conversion module 311 performs a multi-speed toggle switch position judgment of a single IO port, and outputs the judgment result value. When the INT external interrupt module receives a high level change of the gear adjustment at the interrupt pin of the micro control unit U1, it is regarded as an interrupt signal, and the micro control unit U1 enters the interrupt program to wake up the micro control unit U1 in the low power consumption state to reduce power consumption.
[0046] See also Figure 6In some embodiments, the present invention further provides a method for detecting the gear position of a multi-gear toggle switch, which comprises the steps of: S100, waking up the micro-processing unit in low power consumption mode; when the user adjusts the gear in the gear adjustment module, a level jump occurs at the voltage recognition sampling module and is received by the input end of the micro-processing unit, thereby waking up the micro-processing unit in low power consumption mode.
[0047] S200, obtaining the power supply voltage and the sampled voltage; the control module samples the power supply voltage, preferably, selects the lithium battery power supply voltage of the MCU as the reference voltage of the ADC, reads the internal reference voltage, and then converts the power supply voltage of the microcontroller unit U1 through the ADC value of the reference voltage, and uses the power supply voltage as the power supply voltage.
[0048] S300, obtaining a voltage ratio according to the power supply voltage and the sampled voltage; S400. Obtain the current resistance ratio according to the voltage ratio, and determine the corresponding gear of the gear adjustment module according to the current resistance ratio and the preset resistance ratio. The result of calculating the voltage ratio under the corresponding gear is the current resistance ratio. Therefore, by comparing the current resistance ratio with the preset resistance ratio, the current gear can be inferred. The preset resistance ratio is set in a register inside the control module. When the control module detects that the input end is pulled high, it proves that the gear adjustment module is turned. The control module compares and searches the preset resistance ratio in the register based on the voltage ratio. The search method and the address and sorting method of the resistance ratio in the register can be changed according to the needs of actual application, and are not limited here.
[0049] Furthermore, the step of obtaining the power supply voltage and the sampling voltage includes: S210, select the ADC channel with an internal reference voltage of 1.2V; S220, read the ADC value of the 1.2V reference voltage; S230, calculating a supply voltage of a microprocessing unit according to the ADC value of the 1.2V reference voltage, wherein the supply voltage of the microprocessing unit is equivalent to the power supply voltage; S240: Read the sampled voltage at the input end of the control module.
[0050] The above steps are specifically as described in a toggle switch gear position detection circuit, and are not described in detail here.
[0051] The present invention provides a toggle switch gear detection circuit and method, including: a toggle switch gear detection circuit, which includes: a voltage identification sampling module, a gear adjustment module and a control module; the gear adjustment module is connected to the voltage identification sampling module, and is used to convert the resistance value of the corresponding gear into an output voltage when adjusting the gear, and output the output voltage to the voltage identification sampling module; the voltage identification sampling module is used to sample the output voltage of the gear adjustment module, and output the sampled voltage to the control module; the control module is connected to the power supply voltage and connected to the voltage identification sampling module, and is used to obtain a voltage ratio according to the sampled voltage and the power supply voltage, obtain a current resistance ratio according to the voltage ratio, and determine the corresponding gear of the gear adjustment module according to the current resistance ratio and the preset resistance ratio. The present invention provides a toggle switch gear detection circuit and method, which detects the voltage ratio in the current circuit and determines the gear by comparing it with the corresponding resistance ratio, so as to solve the problem of high circuit power consumption and a single IO port can only identify one gear in the prior art, and reduce the occupation of IO port resources in the circuit by gear identification.
[0052] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A toggle switch position detection circuit, characterized in that: include: Voltage identification sampling module, gear adjustment module and control module; wherein, The gear adjustment module is connected to the voltage identification sampling module, and is used to convert the resistance value of the corresponding gear into an output voltage when performing gear adjustment, and output the output voltage to the voltage identification sampling module; The voltage identification sampling module is used to sample the output voltage of the gear adjustment module and output the sampled voltage to the control module; The control module is connected to the power supply voltage and is connected to the voltage identification sampling module, so as to obtain a voltage ratio according to the sampling voltage and the power supply voltage, obtain a current resistance ratio according to the voltage ratio, and determine the corresponding gear of the gear adjustment module according to the current resistance ratio and a preset resistance ratio.
2. The toggle switch position detection circuit according to claim 1, characterized in that: The voltage identification sampling module includes: a first resistor and a first capacitor, wherein: One end of the first resistor is connected to the power supply voltage, the other end of the first resistor is connected to one end of the first capacitor, the common end of the first resistor and the first capacitor is respectively connected to the input end of the control module and the input end of the gear adjustment module, and the other end of the first capacitor is grounded.
3. The toggle switch position detection circuit according to claim 1, characterized in that: The control module comprises: a micro control unit, a power port of the micro control unit is connected to a power supply voltage, and an input end of the micro control unit is connected to the voltage identification sampling module.
4. The toggle switch position detection circuit according to claim 1, characterized in that: The gear adjustment module includes: a first multi-speed toggle switch, a second resistor, a third resistor and a fourth resistor. The third pin of the first multi-speed toggle switch is connected to the voltage identification sampling module. At the other end of the first multi-speed toggle switch, the first pin of the first multi-speed toggle switch is connected to one end of the third resistor, the third pin of the first multi-speed toggle switch is connected to the other end of the third resistor and one end of the third resistor, the fourth pin of the first multi-speed toggle switch is connected to the other end of the third resistor and one end of the fourth resistor, and the fifth pin of the first multi-speed toggle switch and the other end of the fourth resistor are grounded.
5. The toggle switch position detection circuit according to claim 3, characterized in that: The microcontroller unit includes an analog-to-digital conversion module and a level jump module, wherein the analog-to-digital conversion module and the level jump module are connected to the common end of the gear adjustment module and the voltage identification sampling module through the detection pin of the microcontroller unit, and the detection pin of the microcontroller unit is used for analog-to-digital conversion and level jump.
6. The toggle switch position detection circuit according to claim 3, characterized in that: The microcontroller unit includes: an analog-to-digital conversion module and an INT external interrupt module, wherein the analog-to-digital conversion module is connected to a detection pin of the microcontroller unit, and the INT external interrupt module is connected to an interrupt pin of the microcontroller unit. The detection pin and the interrupt pin of the microcontroller unit are respectively connected to the common end of the gear adjustment module and the voltage identification sampling module. The detection pin of the microcontroller unit is used for gear position judgment of a multi-speed toggle switch, and the interrupt pin of the microcontroller unit is used for waking up the microcontroller unit.
7. The toggle switch position detection circuit according to claim 3, characterized in that: The microcontroller unit is SC8F073.
8. The toggle switch position detection circuit according to claim 3, characterized in that: The control module also includes: a micro control unit driving module, the micro control unit driving module includes a fifth resistor and a second capacitor, wherein one end of the fifth resistor is connected to the power supply voltage, the other end of the fifth resistor is respectively connected to one end of the second capacitor and the power port of the micro control unit, and the other end of the second capacitor is grounded.
9. A detection method for a toggle switch position detection circuit according to any one of claims 1 to 8, characterized in that: include: Wake up the microprocessor from low power consumption state; Get the power supply voltage and the sampling voltage; Obtaining a voltage ratio according to the power supply voltage and the sampled voltage; A current resistance ratio is obtained according to the voltage ratio, and a corresponding gear of the gear adjustment module is determined according to the current resistance ratio and a preset resistance ratio.
10. The detection method of the toggle switch position detection circuit according to claim 9, characterized in that: The steps of obtaining the power supply voltage and the sampling voltage include: Select the ADC channel of the internal reference voltage; Read the ADC value of the reference voltage; Calculating the power supply voltage of the microprocessing unit according to the ADC value of the reference voltage; The sampled voltage at the input terminal of the control module is read.
Citation Information
Cited By
Gear indicating circuit of electronic equipment, heating plate circuit and heating plate
CN121711837A