Voltage detection method and device, terminal equipment and computer readable storage medium
By controlling the voltage detection signal through the push-pull output of the MCU controller, the high cost and high power consumption problems of existing voltage detection schemes are solved, and low cost and low power consumption voltage detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANDONG YOU INTERNET OF THINGS CO LTD
- Filing Date
- 2022-12-29
- Publication Date
- 2026-04-24
AI Technical Summary
Existing voltage detection solutions require additional boost ICs and peripheral components, resulting in high current consumption during sleep mode, increased size, and leakage current when the ADC channel is directly connected to the battery, leading to high cost and power consumption.
The voltage detection signal is controlled by the push-pull output of the MCU controller. By connecting the MCU controller to the reference module, the additional boost IC and its peripheral circuits are avoided. The input reference value of the reference module is obtained through the digital-to-analog conversion channel of the MCU controller, and the on/off state of the ADC channel is controlled.
It effectively reduces the cost and power consumption of voltage detection, avoids leakage current caused by direct connection of the ADC channel to the battery, and achieves low-cost and low-power voltage detection.
Smart Images

Figure CN115902379B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of integrated circuit technology, and in particular to a voltage detection method, apparatus, terminal equipment, and computer-readable storage medium. Background Technology
[0002] With the continuous development of integrated circuit technology, people have increasingly higher requirements for the power consumption of voltage detection. In other words, low-power voltage detection has become a research hotspot for IC (Integrated Circuit Chip) chips.
[0003] Currently, conventional voltage detection schemes require a boost IC and peripheral circuitry such as inductors, resistors, and capacitors. When the device is in standby mode, the boost IC needs to remain operational to maintain the MCU's wake-up function. This circuitry is commonly used in devices like wireless mice. Therefore, to extend battery life, these products typically include a toggle switch for power-off. The stable 3.3V power supply from the boost IC can then provide a reference source for the MCU's VREF+ pin (in some MCUs, VREF+ is directly connected internally to VSS), and the battery voltage can be directly input to the ADC channel for voltage detection. However, this conventional voltage detection scheme has significant drawbacks. Firstly, it requires an additional boost IC and peripheral components, resulting in higher current consumption during sleep mode and increased space requirements. Secondly, the ADC channel is directly connected to the battery, meaning there is no switch control or battery on / off mechanism. This means it cannot be disconnected when the ADC channel's charge level is not being monitored, leading to leakage current at the ADC pins.
[0004] In summary, conventional voltage detection schemes suffer from high costs and high power consumption. Summary of the Invention
[0005] The main objective of this invention is to provide a voltage detection method, apparatus, device, and computer-readable storage medium, with the aim of reducing the cost and power consumption of voltage detection.
[0006] To achieve the above objectives, the present invention provides a voltage detection method, which is applied to a voltage detection circuit. The voltage detection circuit includes a battery module, a control module, and a reference module. The control module includes an MCU controller. The battery module is connected to the operating voltage terminal of the MCU controller, and the push-pull output terminal of the MCU controller is connected to the reference module.
[0007] The voltage detection method includes:
[0008] When the battery module supplies power to the MCU controller, a voltage detection signal is obtained based on the push-pull output terminal of the MCU controller;
[0009] The MCU controller supplies power to the reference module based on the voltage detection signal, and obtains the input reference value of the reference module through the first digital-to-analog conversion channel of the MCU controller;
[0010] The voltage value of the battery voltage provided by the battery module is determined based on the input reference value and the register value of the first digital-to-analog conversion channel;
[0011] The voltage value of the pin corresponding to the second digital-to-analog conversion channel in the MCU controller is detected based on the voltage value.
[0012] Optionally, the push-pull output terminal is packaged with a push-pull output unit, which includes: a first effector and a second effector;
[0013] The first effect transistor is placed on the second effect transistor, and the second end of the first effect transistor and the first end of the second effect transistor are connected to the push-pull output terminal.
[0014] The first terminal of the first effect transistor is connected to the operating voltage terminal, and the second terminal of the second effect transistor is connected to the ground terminal of the MCU controller;
[0015] The third terminal of the first effect transistor and the third terminal of the second effect transistor are respectively connected to the output control unit inside the MCU controller.
[0016] Optionally, both the first and second effect transistors are MOSFETs.
[0017] Optionally, the step of acquiring the voltage detection signal based on the push-pull output terminal of the MCU controller includes:
[0018] The MCU controller determines the conduction information of the first effect transistor and the cutoff information of the second effect transistor based on the high-level signal of the output control unit, and uses the conduction information and the cutoff information as voltage detection signals.
[0019] Optionally, the step of determining the voltage value of the battery voltage provided by the battery module based on the input reference value and the register value of the first digital-to-analog conversion channel includes:
[0020] Determine the first ADC bit width corresponding to the first digital-to-analog conversion channel;
[0021] The product of the reciprocal of the register value of the first digital-to-analog conversion channel and the number of bits of the first ADC is multiplied by the input reference value to obtain the voltage value of the battery voltage, wherein the voltage value is greater than the input reference value.
[0022] Optionally, the step of detecting the pin voltage value corresponding to the second digital-to-analog conversion channel in the MCU controller based on the voltage value includes:
[0023] Read the pin register value of the second digital-to-analog converter channel in the MCU controller, and determine the second ADC bit width corresponding to the second digital-to-analog converter channel;
[0024] Multiply the reciprocal of the second ADC bit value and the pin register value by the voltage value to obtain the pin voltage value corresponding to the second digital-to-analog conversion channel.
[0025] Optionally, the voltage detection circuit further includes one or more external devices;
[0026] One or more of the external devices are connected to the battery module, and one or more of the external devices have established a communication connection with the MCU controller.
[0027] Furthermore, to achieve the above objectives, the present invention also provides a voltage detection device, which includes:
[0028] The acquisition module is used to acquire a voltage detection signal based on the push-pull output terminal of the MCU controller when the battery module supplies power to the MCU controller;
[0029] The power supply module is used to supply power to the reference module through the MCU controller based on the voltage detection signal, and to obtain the input reference value of the reference module through the first digital-to-analog conversion channel of the MCU controller;
[0030] A voltage determination module is used to determine the voltage value of the battery voltage provided by the battery module based on the input reference value and the register value of the first digital-to-analog conversion channel;
[0031] The detection module is used to detect the pin voltage value corresponding to the second digital-to-analog conversion channel in the MCU controller based on the voltage value.
[0032] Each functional module of the voltage detection device of the present invention implements the steps of the voltage detection method of the present invention as described above during operation.
[0033] In addition, to achieve the above objectives, the present invention also provides a terminal device, the terminal device including a memory, a processor, and a voltage detection program stored in the memory and executable on the processor, wherein the voltage detection program, when executed by the processor, implements the steps of the voltage detection method described above.
[0034] In addition, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing a voltage detection program, which, when executed by a processor, implements the steps of the voltage detection method described above.
[0035] In this invention, the voltage detection circuit includes a battery module, a control module, and a reference module. The control module includes an MCU controller. The battery module is connected to the operating voltage terminal of the MCU controller, and the push-pull output terminal of the MCU controller is connected to the reference module. Furthermore, it should be noted that when the battery module supplies power to the MCU controller, the voltage detection signal is obtained based on the push-pull output terminal of the MCU controller. Since the reference module consumes very little current, and the push-pull output terminal structure does not cause a voltage drop, the MCU controller can supply power to the reference module based on the voltage detection signal, and obtain the input reference value of the reference module through the first digital-to-analog conversion channel of the MCU controller. The battery voltage value provided by the battery module is determined based on the input reference value and the register value of the first digital-to-analog conversion channel. Finally, the voltage value of the corresponding pin in the second digital-to-analog conversion channel of the MCU controller is detected based on the battery voltage value.
[0036] Unlike traditional voltage detection schemes, this application uses the push-pull output of the MCU controller to control the connection between the MCU controller and the reference source. In other words, after obtaining the voltage detection signal through the push-pull output of the MCU controller, the MCU controller provides the battery voltage corresponding to the battery module to the reference module based on the voltage detection signal. Then, the input reference value provided by the reference module can be obtained through the first digital-to-analog conversion channel of the MCU controller. This eliminates the need to add an additional boost IC and its peripheral circuits, and effectively avoids the leakage current phenomenon caused by the ADC channel being directly connected to the battery. This greatly reduces the cost of voltage detection and also reduces the power consumption of voltage detection. Attached Figure Description
[0037] Figure 1 This is a flowchart illustrating the first embodiment of the voltage detection method of the present invention;
[0038] Figure 2 This is a structural block diagram of an embodiment of the voltage detection method of the present invention;
[0039] Figure 3 This is a block diagram of a push-pull output structure according to an embodiment of the voltage detection method of the present invention;
[0040] Figure 4 This is a schematic diagram of the voltage detection device module of the present invention;
[0041] Figure 5 This is a schematic diagram of the structure of the terminal device involved in the embodiment of the present invention;
[0042] Figure 6 This is a schematic diagram of the structure of a computer-readable storage medium involved in an embodiment of the present invention.
[0043] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0044] This invention provides a voltage detection method, referring to... Figure 1 As shown, Figure 1 This is a flowchart illustrating the first embodiment of the voltage detection method of the present invention.
[0045] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application.
[0046] In this embodiment, the voltage detection method of the present invention is applied to a terminal device that performs voltage detection on each digital-to-analog conversion channel in the MCU controller, and is specifically executed by the MCU controller of the terminal device. Furthermore, it should be noted that the voltage detection method of the present invention is applied to a voltage detection circuit, which includes: a battery module, a control module, and a reference module. The control module includes an MCU controller, the battery module is connected to the operating voltage terminal of the MCU controller, and the push-pull output terminal of the MCU controller is connected to the reference module.
[0047] In this embodiment, the battery module is a dry cell battery. Common dry cell batteries include ordinary zinc-manganese dry cell batteries, alkaline zinc-manganese dry cell batteries, magnesium-manganese dry cell batteries, zinc-air batteries, zinc-mercury oxide batteries, zinc-silver oxide batteries, and lithium-manganese batteries.
[0048] The control module includes an MCU (Microcontroller Unit) controller, also known as a single-chip microcomputer or microcontroller.
[0049] The reference module is a reference source, which can be understood as a high-precision, high-stability independent voltage source.
[0050] In this embodiment, the voltage detection circuit of this application does not require additional dedicated boost IC and peripheral devices, thereby effectively reducing the cost and power consumption of the entire system.
[0051] The voltage detection method of the present invention includes:
[0052] Step S10: When the battery module supplies power to the MCU controller, a voltage detection signal is obtained based on the push-pull output terminal of the MCU controller;
[0053] In this embodiment, based on the connection between the battery module and the operating voltage terminal of the MCU controller, the battery voltage of the battery module is supplied to the MCU controller via the operating voltage terminal of the MCU controller. In other words, the battery module provides a power supply to the MCU controller. After determining that the battery module is supplying power to the MCU controller, a voltage detection signal is obtained based on the push-pull output terminal of the MCU controller.
[0054] It should be noted that, referring to Figure 2 , Figure 2 This is a structural block diagram of an embodiment of the voltage detection method of the present invention. The operating voltage terminal of the MCU controller can be represented by VDD; the push-pull output terminal of the MCU controller is also called the IO port of the MCU controller.
[0055] Additionally, it should be noted that, referring to Figure 3 , Figure 3 This is a block diagram of a push-pull output structure according to an embodiment of the voltage detection method of the present invention. The IO port is packaged with a push-pull output unit, wherein the push-pull output unit includes: a first effect transistor and a second effect transistor. The first effect transistor is placed on the second effect transistor. The second end of the first effect transistor and the first end of the second effect transistor are connected to the push-pull output terminal of the MCU controller. The first end of the first effect transistor is connected to the working voltage terminal of the MCU controller. The second end of the second effect transistor is connected to the ground terminal of the MCU controller. The third end of the first effect transistor and the third end of the second effect transistor are respectively connected to the output control unit inside the MCU controller.
[0056] The output control unit inside the MCU controller can be understood as a signal output terminal, that is, a port that outputs a high or low level signal from the MCU controller.
[0057] Furthermore, in another embodiment, when the MCU controller detects an external pulse signal, it feeds this pulse signal back to the output control unit, causing the output control unit to output a high-level signal. At this time, the MCU controller will obtain the conduction information of the first effect transistor and the cutoff information of the second effect transistor, and then use the conduction information of the first effect transistor and the cutoff information of the second effect transistor as voltage detection signals. In other words, when the output control unit inside the MCU controller outputs a high-level signal, the first effect transistor is turned on and the second effect transistor is turned off, thereby pulling up the IO port to the working voltage terminal of the MCU controller, that is, providing the battery voltage of the battery module to the reference module through the IO port of the MCU controller.
[0058] Furthermore, in another embodiment, the output control unit of this application may also include a timer. When the timer determines whether the current time of the MCU controller is at the voltage detection time, if the current time of the MCU controller is at the voltage detection time, the output control unit outputs a high-level signal. At this time, the MCU controller will obtain the conduction information of the first effect transistor and the cutoff information of the second effect transistor, and then use the conduction information of the first effect transistor and the cutoff information of the second effect transistor as the voltage detection signal.
[0059] Furthermore, in another embodiment, when voltage detection is not required, the output control unit will output a low-level signal, that is, the first effect transistor is turned off and the second effect transistor is turned on. This can be used to determine that the IO port is pulled down to the ground terminal of the MCU controller (i.e., the VSS terminal), that is, the IO port cannot supply power to the reference module. At this time, no leakage current will be generated, thereby effectively reducing the power consumption of voltage detection.
[0060] Step S20: The MCU controller supplies power to the reference module based on the voltage detection signal, and obtains the input reference value of the reference module through the first digital-to-analog conversion channel of the MCU controller;
[0061] In this embodiment, after the voltage detection signal is obtained from the push-pull output of the MCU controller, the battery voltage of the battery module is provided to the reference module through the push-pull output of the MCU controller, based on the connection between the push-pull output of the MCU controller and the reference module. This confirms that the reference module is in working mode after being powered on. In other words, the battery voltage is provided to the reference module through the push-pull output of the MCU controller so that the reference module can start working (i.e., the reference module is in working mode). Based on the connection between the reference module and the digital-to-analog conversion channel of the MCU controller, the input reference value provided by the reference module is obtained through the first digital-to-analog conversion channel of the MCU controller.
[0062] It should be noted that, referring to Figure 2 The first digital-to-analog conversion channel of the MCU controller can be represented by ADC0.
[0063] Step S30: Determine the voltage value of the battery voltage provided by the battery module based on the input reference value and the register value of the first digital-to-analog conversion channel;
[0064] In this embodiment, the MCU controller first reads the register value of the first digital-to-analog conversion channel, and then determines the voltage value of the battery voltage provided by the battery module based on the input reference value and the register value. In other words, the voltage value of the battery voltage can be calculated by the following formula (1).
[0065]
[0066] Wherein, VBAT represents the battery voltage value, VAL represents the register value of the digital-to-analog conversion channel, REF represents the input reference value, and ADC_RES represents the first ADC bit number. The first ADC bit number can be understood as the ADC bit number corresponding to the digital-to-analog conversion channel, for example, the ADC bit number corresponding to ADC0.
[0067] In this embodiment, as shown in formula (1), if the input reference value of the ADC channel is constant and lower than the voltage value of VREF+, the register value VAL of the ADC channel will increase as VREF+ decreases, where VREF+ can be equivalent to the battery voltage.
[0068] Step S40: Detect the pin voltage value corresponding to the second digital-to-analog conversion channel in the MCU controller based on the voltage value.
[0069] In this embodiment, the MCU controller first reads the pin register value of the second digital-to-analog conversion channel in the MCU controller and determines the second ADC bit number corresponding to the second digital-to-analog conversion channel. Then, based on the pin register value, the battery voltage value, and the second ADC bit number, the pin voltage value corresponding to the second digital-to-analog conversion channel in the MCU controller is determined.
[0070] It should be noted that there may be multiple second digital-to-analog conversion channels. For example, the second digital-to-analog conversion channels may include, but are not limited to, those mentioned above. Figure 2 ADC1 and ADC2 in the example.
[0071] In addition, it should be noted that the pin voltage values corresponding to each second digital-to-analog conversion channel can be calculated using the following formula (2).
[0072]
[0073] Wherein, ADC_IN represents the voltage value of the ADC pin corresponding to each digital-to-analog conversion channel, VBAT represents the voltage value of the battery, VAL_ADC_IN represents the register value of the ADC channel corresponding to each ADC pin, and ADC_RES' represents the second ADC bit number. The second ADC bit number can be understood as the ADC bit number corresponding to each second digital-to-analog conversion channel. For example, ADC1 corresponds to the ADC1 bit number, and ADC2 corresponds to the ADC2 bit number.
[0074] In this embodiment, the voltage value of the pin corresponding to the second digital-to-analog conversion channel in the MCU controller is detected based on the voltage value of the battery voltage. In other words, the ADC pin voltage corresponding to each second digital-to-analog conversion channel can be measured through the conversion of formula (2), thereby achieving the maximum utilization of on-chip resources at low cost.
[0075] In summary, the voltage detection circuit of this invention includes a battery module, a control module, and a reference module. The control module includes an MCU controller. The battery module is connected to the operating voltage terminal of the MCU controller, and the push-pull output terminal of the MCU controller is connected to the reference module. Furthermore, it should be noted that when the battery module supplies power to the MCU controller, the voltage detection signal is obtained based on the push-pull output terminal of the MCU controller. Since the reference module consumes very little current, and the push-pull output terminal structure does not cause a voltage drop, the MCU controller can supply power to the reference module based on the voltage detection signal, and obtain the input reference value of the reference module through the first digital-to-analog conversion channel of the MCU controller. The battery voltage value provided by the battery module is determined based on the input reference value and the register value of the first digital-to-analog conversion channel. Finally, the voltage value of the corresponding pin in the second digital-to-analog conversion channel of the MCU controller is detected based on the battery voltage value.
[0076] Unlike traditional voltage detection schemes, this application uses the push-pull output of the MCU controller to control the connection between the MCU controller and the reference source. In other words, after obtaining the voltage detection signal through the push-pull output of the MCU controller, the MCU controller provides the battery voltage corresponding to the battery module to the reference module based on the voltage detection signal. Then, the input reference value provided by the reference module can be obtained through the first digital-to-analog conversion channel of the MCU controller. This eliminates the need to add an additional boost IC and its peripheral circuits, and effectively avoids the leakage current phenomenon caused by the ADC channel being directly connected to the battery. This greatly reduces the cost of voltage detection and also reduces the power consumption of voltage detection.
[0077] Furthermore, based on the first embodiment of the voltage detection method of the present invention, a second embodiment of the voltage detection method of the present invention is proposed.
[0078] The voltage detection method is applied to a voltage detection circuit. The push-pull output terminal is packaged with a push-pull output unit, which includes a first effect transistor and a second effect transistor.
[0079] In this embodiment, the push-pull output terminal of the MCU controller is packaged with a push-pull output unit, which includes a first effect transistor and a second effect transistor.
[0080] The first effect transistor is placed on the second effect transistor, and the second end of the first effect transistor and the first end of the second effect transistor are connected to the push-pull output terminal.
[0081] The first terminal of the first effect transistor is connected to the operating voltage terminal, and the second terminal of the second effect transistor is connected to the ground terminal of the MCU controller;
[0082] The third terminal of the first effect transistor and the third terminal of the second effect transistor are respectively connected to the output control unit inside the MCU controller.
[0083] In this embodiment, the first effect transistor is placed on the second effect transistor, and the second end of the first effect transistor and the first end of the second effect transistor are connected to the push-pull output terminal (i.e., the IO terminal); the first end of the first effect transistor is connected to the working voltage terminal of the MCU controller, and the second end of the second effect transistor is connected to the ground terminal of the MCU controller; the third end of the first effect transistor and the third end of the second effect transistor are respectively connected to the output control unit inside the MCU controller.
[0084] For example, when the output control unit outputs a high level, the first effect transistor in the push-pull output unit is turned on and the second effect transistor is turned off, meaning that the reference module can be powered through the push-pull output terminal; when the output control unit outputs a low level, the first effect transistor in the push-pull output unit is turned off and the second effect transistor is turned on, meaning that the push-pull output terminal is pulled down to the ground terminal, preventing the reference source (i.e., the reference module) from being constantly connected to the power supply, effectively avoiding leakage current.
[0085] Furthermore, in some other feasible embodiments, the voltage detection method is applied to a voltage detection circuit, wherein both the first effect transistor and the second effect transistor are MOSFETs.
[0086] In this embodiment, both the first and second effect transistors are MOSFETs (Metal-Oxide-Semiconductor Field-Effect Transistors). This application does not limit the type and model of the first and second effect transistors.
[0087] Furthermore, in some feasible embodiments, step S10 above: obtaining the voltage detection signal based on the push-pull output terminal of the MCU controller may also include the following implementation steps.
[0088] Step S101: Based on the high-level signal of the output control unit, the MCU controller determines the conduction information of the first effect transistor and the cutoff information of the second effect transistor, so as to use the conduction information and the cutoff information as voltage detection signals.
[0089] In this embodiment, when the MCU controller detects an external pulse signal, it feeds this pulse signal back to the output control unit, causing the output control unit to output a high-level signal. At this time, the MCU controller acquires the conduction information of the first transistor and the cutoff information of the second transistor. Then, the MCU controller uses the conduction information of the first transistor and the cutoff information of the second transistor as a voltage detection signal. In other words, referring to... Figure 3When the output control unit outputs a high level, the first effect transistor is turned on and the second effect transistor is turned off, which can pull the IO port up to the working voltage terminal of the MCU controller. In other words, the MCU controller can provide the battery voltage of the battery module to the reference source through the MCU controller's IO port according to the voltage detection signal.
[0090] Furthermore, in some other feasible embodiments, step S30 above, which involves determining the voltage value of the battery voltage provided by the battery module based on the input reference value and the register value of the first digital-to-analog conversion channel, may also include the following implementation steps.
[0091] Step S301: Determine the first ADC bit depth corresponding to the first digital-to-analog conversion channel;
[0092] In this embodiment, the MCU controller first determines the number of bits of the first ADC corresponding to the first digital-to-analog conversion channel. For example, the MCU controller first determines the number of bits of ADC0 corresponding to ADC0.
[0093] Step S302: Multiply the product of the reciprocal of the register value of the first digital-to-analog conversion channel and the number of bits of the first ADC by the input reference value to obtain the voltage value of the battery voltage, wherein the voltage value is greater than the input reference value.
[0094] In this embodiment, referring to the above formula (1), the product of the reciprocal of the register value of the first digital-to-analog conversion channel and the number of bits of the first ADC is multiplied by the input reference value to obtain the voltage value of the battery voltage, wherein the voltage value is greater than the input reference value.
[0095] Furthermore, in some feasible embodiments, step S40 above, which involves detecting the pin voltage value corresponding to the second digital-to-analog conversion channel in the MCU controller based on the voltage value, may also include the following implementation steps.
[0096] Step S401: Read the pin register value of the second digital-to-analog conversion channel in the MCU controller, and determine the second ADC bit width corresponding to the second digital-to-analog conversion channel;
[0097] In this embodiment, the pin register value of the second digital-to-analog conversion channel in the MCU controller is read, and the number of bits of the second ADC corresponding to the second digital-to-analog conversion channel is determined.
[0098] It should be noted that there may be multiple second digital-to-analog conversion channels. For example, the second digital-to-analog conversion channels may include, but are not limited to, those mentioned above. Figure 2 In the context of ADC1 and ADC2, the second ADC bit depth can be understood as the ADC bit depth corresponding to each ADC channel, for example, the ADC1 bit depth corresponding to ADC1 and the ADC2 bit depth corresponding to ADC2.
[0099] Step S402: Multiply the product of the reciprocal of the second ADC bit number and the pin register value by the voltage value to obtain the pin voltage value corresponding to the second digital-to-analog conversion channel.
[0100] In this embodiment, referring to the above formula (2), the product of the reciprocal of the second ADC bit number and the pin register value is multiplied by the battery voltage value to obtain the pin voltage value corresponding to other digital-to-analog conversion channels.
[0101] In this embodiment, the present application makes full use of each ADC channel (i.e., the second ADC channel) other than the first digital-to-analog conversion channel to measure the corresponding pin voltage value of each ADC channel, thereby maximizing the use of on-chip resources.
[0102] Furthermore, in some other feasible embodiments, the voltage detection circuit further includes one or more external devices;
[0103] In this embodiment, one or more external devices can be understood as electronic products that interact with the MCU controller, including but not limited to mice, keyboards, etc.
[0104] One or more of the external devices are connected to the battery module, and one or more of the external devices have established a communication connection with the MCU controller.
[0105] In this embodiment, one or more external devices are connected to the battery module to provide power to the external devices; one or more external devices establish a communication connection with the MCU controller to control the operation of the external devices according to instructions issued by the MCU controller. For example, after the mouse or keyboard receives a low-power operation instruction issued by the MCU controller, the MCU controller can determine that the mouse or keyboard has responded to the low-power operation instruction, that is, the mouse or keyboard is in low-power operation mode at this time.
[0106] In summary, the MCU controller of this application is directly connected to the battery module (i.e., dry cell battery), wherein the push-pull output terminal of the MCU controller is configured as a push-pull output, and the push-pull output terminal (i.e., IO terminal) of the MCU controller is connected to the reference module (i.e., reference source). When it is necessary to detect the pin voltage of each digital-to-analog conversion channel in the MCU controller, the pin of the IO terminal is set high, and the reference source is made to work normally by the voltage provided by the IO terminal. After obtaining the constant reference voltage output by the reference source through the first digital-to-analog conversion channel of the MCU controller, the register value of the ADC channel is read. In other words, the IO terminal of the MCU controller of this application integrates a push-pull output unit, that is, the IO terminal can be configured to push-pull output mode. By setting the high pin, the reference source is powered to work and a reference source is provided for the system. When the detection function is not used, the IO pin is set low, which effectively avoids the occurrence of leakage current. This power supply method makes the power supply voltage of the reference source almost equal to the battery voltage. Then, the voltage value of the battery voltage is obtained according to formula (1), and the pin voltage value of other digital-to-analog conversion channels in the MCU controller is detected according to the voltage value of the battery voltage and formula (2), which greatly reduces the cost of voltage detection and saves the power consumption of voltage detection.
[0107] Furthermore, the present invention also provides a voltage detection device. (Refer to...) Figure 4 , Figure 4 This is a schematic diagram of the voltage detection device module of the present invention.
[0108] The voltage detection device of the present invention includes:
[0109] The acquisition module H01 is used to acquire a voltage detection signal based on the push-pull output terminal of the MCU controller when the battery module supplies power to the MCU controller;
[0110] The power supply module H02 is used to supply power to the reference module through the MCU controller based on the voltage detection signal, and to obtain the input reference value of the reference module through the first digital-to-analog conversion channel of the MCU controller;
[0111] The voltage determination module H03 is used to determine the voltage value of the battery voltage provided by the battery module based on the input reference value and the register value of the first digital-to-analog conversion channel;
[0112] The detection module H04 is used to detect the pin voltage value corresponding to the second digital-to-analog conversion channel in the MCU controller based on the voltage value.
[0113] Optionally, the acquisition module H01 may further include:
[0114] The voltage detection unit is used to determine the conduction information of the first effect transistor and the cutoff information of the second effect transistor based on the high-level signal of the output control unit by the MCU controller, so as to use the conduction information and the cutoff information as voltage detection signals.
[0115] Optionally, the reading module H03 may further include:
[0116] The first bit-determining unit is used to determine the first ADC bit-determining unit corresponding to the first digital-to-analog conversion channel;
[0117] A voltage value calculation unit is used to multiply the product between the reciprocal of the register value of the first digital-to-analog conversion channel and the number of bits of the first ADC by the input reference value to obtain the voltage value of the battery voltage, wherein the voltage value is greater than the input reference value.
[0118] Optionally, the detection module H04 may further include:
[0119] The second bit determination unit is used to read the pin register value of the second digital-to-analog conversion channel in the MCU controller and determine the second ADC bit number corresponding to the second digital-to-analog conversion channel;
[0120] The pin voltage calculation unit is used to multiply the product of the second ADC bit number and the pin register value by the voltage value to obtain the pin voltage value corresponding to the second digital-to-analog conversion channel.
[0121] Each functional module of the voltage detection device of the present invention implements the steps of the voltage detection method of the present invention as described above during operation.
[0122] Furthermore, the present invention also provides a terminal device. Please refer to... Figure 5 , Figure 5 This is a schematic diagram of the terminal device involved in an embodiment of the present invention. Specifically, the terminal device in this embodiment can be a device for local voltage detection.
[0123] like Figure 5 As shown, the terminal device in this embodiment of the invention may include: a processor 1001, such as a CPU; a communication bus 1002; a user interface 1003; a network interface 1004; a memory 1005; and a sensing unit 1006. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen and an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).
[0124] The memory 1005 is disposed on the main body of the terminal device. The memory 1005 stores a program that performs corresponding operations when executed by the processor 1001. The memory 1005 is also used to store parameters for use by the terminal device. The memory 1005 can be a high-speed RAM or a stable, non-volatile memory, such as a disk drive. Optionally, the memory 1005 can also be a storage device independent of the aforementioned processor 1001.
[0125] Those skilled in the art will understand that Figure 5 The terminal device structure shown does not constitute a limitation on the terminal device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0126] like Figure 5 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a network communication module, a user interface module, and a voltage detection program for terminal devices.
[0127] exist Figure 5 In the terminal device shown, the processor 1001 can be used to call the voltage detection program of the terminal device stored in the memory 1005 and execute the steps of the various embodiments of the voltage detection method of the present invention described above.
[0128] Furthermore, the present invention also provides a computer-readable storage medium. Please refer to... Figure 6 , Figure 6 This is a schematic diagram of the structure of a computer-readable storage medium involved in an embodiment of the present invention.
[0129] The present invention also provides a computer-readable storage medium storing a voltage detection program, which, when executed by a processor, implements the steps of the voltage detection method described above.
[0130] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0131] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0132] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a computer-readable storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0133] The above are merely preferred embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A voltage detection method, characterized in that, The voltage detection method is applied to a voltage detection circuit, which includes a battery module, a control module, and a reference module. The control module includes an MCU controller. The battery module is connected to the operating voltage terminal of the MCU controller, and the push-pull output terminal of the MCU controller is connected to the reference module. The voltage detection method includes: When the battery module supplies power to the MCU controller, a voltage detection signal is obtained based on the push-pull output terminal of the MCU controller; The MCU controller supplies power to the reference module based on the voltage detection signal, and obtains the input reference value of the reference module through the first digital-to-analog conversion channel of the MCU controller; The voltage value of the battery voltage provided by the battery module is determined based on the input reference value and the register value of the first digital-to-analog conversion channel; The voltage value of the pin corresponding to the second digital-to-analog conversion channel in the MCU controller is detected based on the voltage value.
2. The voltage detection method as described in claim 1, characterized in that, The push-pull output terminal is encapsulated with a push-pull output unit, which includes: a first effector and a second effector. The first effect transistor is placed on the second effect transistor, and the second end of the first effect transistor and the first end of the second effect transistor are connected to the push-pull output terminal. The first terminal of the first effect transistor is connected to the operating voltage terminal, and the second terminal of the second effect transistor is connected to the ground terminal of the MCU controller; The third terminal of the first effect transistor and the third terminal of the second effect transistor are respectively connected to the output control unit inside the MCU controller.
3. The voltage detection method as described in claim 2, characterized in that, Both the first effect transistor and the second effect transistor are MOSFETs.
4. The voltage detection method as described in claim 2, characterized in that, The step of acquiring the voltage detection signal based on the push-pull output terminal of the MCU controller includes: The MCU controller determines the conduction information of the first effect transistor and the cutoff information of the second effect transistor based on the high-level signal of the output control unit, and uses the conduction information and the cutoff information as voltage detection signals.
5. The voltage detection method as described in claim 1, characterized in that, The step of determining the voltage value of the battery voltage provided by the battery module based on the input reference value and the register value of the first digital-to-analog conversion channel includes: Determine the first ADC bit width corresponding to the first digital-to-analog conversion channel; The product of the reciprocal of the register value of the first digital-to-analog conversion channel and the number of bits of the first ADC is multiplied by the input reference value to obtain the voltage value of the battery voltage, wherein the voltage value is greater than the input reference value.
6. The voltage detection method as described in claim 1, characterized in that, The step of detecting the pin voltage value corresponding to the second digital-to-analog conversion channel in the MCU controller based on the voltage value includes: Read the pin register value of the second digital-to-analog converter channel in the MCU controller, and determine the second ADC bit width corresponding to the second digital-to-analog converter channel; Multiply the reciprocal of the second ADC bit value and the pin register value by the voltage value to obtain the pin voltage value corresponding to the second digital-to-analog conversion channel.
7. The voltage detection method as described in claim 1, characterized in that, The voltage detection circuit also includes: one or more external devices; One or more of the external devices are connected to the battery module, and one or more of the external devices have established a communication connection with the MCU controller.
8. A voltage detection device, characterized in that, The voltage detection device includes: The acquisition module is used to acquire a voltage detection signal based on the push-pull output terminal of the MCU controller when the battery module supplies power to the MCU controller; The power supply module is used to supply power to the reference module through the MCU controller based on the voltage detection signal, and to obtain the input reference value of the reference module through the first digital-to-analog conversion channel of the MCU controller; A voltage determination module is used to determine the voltage value of the battery voltage provided by the battery module based on the input reference value and the register value of the first digital-to-analog conversion channel; The detection module is used to detect the pin voltage value corresponding to the second digital-to-analog conversion channel in the MCU controller based on the voltage value.
9. A terminal device, characterized in that, The terminal device includes a memory, a processor, and a voltage detection program stored in the memory and executable on the processor. When the processor executes the voltage detection program, it implements the steps of the voltage detection method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a voltage detection program, which, when executed by a processor, implements the steps of the voltage detection method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Lithium battery power supply control protection circuit and control protection method
CN101159375A
MCU (microprogrammed control unit) chip detecting method and circuit
CN103970117A