CN109032015B - MCU interface control method and device - Google Patents
MCU interface control method and device Download PDFInfo
- Publication number
- CN109032015B CN109032015B CN201810864134.6A CN201810864134A CN109032015B CN 109032015 B CN109032015 B CN 109032015B CN 201810864134 A CN201810864134 A CN 201810864134A CN 109032015 B CN109032015 B CN 109032015B
- Authority
- CN
- China
- Prior art keywords
- analog
- digital conversion
- interface
- mcu
- setting
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G05—CONTROLLING; REGULATING
- G05B—CONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
- G05B19/00—Programme-control systems
- G05B19/02—Programme-control systems electric
- G05B19/04—Programme control other than numerical control, i.e. in sequence controllers or logic controllers
- G05B19/042—Programme control other than numerical control, i.e. in sequence controllers or logic controllers using digital processors
- G05B19/0423—Input/output
-
- G—PHYSICS
- G05—CONTROLLING; REGULATING
- G05B—CONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
- G05B2219/00—Program-control systems
- G05B2219/20—Pc systems
- G05B2219/25—Pc structure of the system
- G05B2219/25257—Microcontroller
Abstract
The invention relates to an MCU interface control method and a device, wherein the MCU interface control method comprises the following steps: judging whether analog-to-digital conversion parameters need to be read or not; if the judgment result is negative, setting the state of an analog-to-digital conversion interface in the MCU as an output state; and setting the output voltage of the analog-to-digital conversion interface to be high level or low level. Because the power consumption of the I/O interface in the output state is lower than that in the input state due to the I/O interface structure of the MCU, the MCU interface control method and the device set the state of the analog-to-digital conversion interface in the MCU to be the output state and set the output voltage of the analog-to-digital conversion interface to be a high level or a low level when the analog-to-digital conversion parameters do not need to be read, thereby effectively reducing the power consumption of the MCU.
Description
Technical Field
The invention relates to the technical field of electronics, in particular to a method and a device for controlling an MCU interface.
Background
The excessive use of petroleum and coal not only causes global warming and seriously threatens social and economic development and health of people's life, but also leads to increasingly tense global energy situation, so that countries in the world set increasingly strict energy consumption standards to obtain sustainable development. For example, the U.S. department of energy has put new energy efficiency requirements on external power supplies such as battery chargers, however, many battery chargers fail to meet the requirements. In order to enable a product to meet energy efficiency requirements, power consumption of each part of a battery charger needs to be reduced, wherein an important part of the power consumption of the battery charger is power consumption of an MCU (micro controller Unit), and therefore how to reduce the power consumption of the MCU of the battery charger is an urgent problem to be solved.
Disclosure of Invention
Therefore, it is necessary to provide an MCU interface control method and apparatus for reducing the MCU power consumption of a battery charger, in order to solve the problem of large power consumption of the conventional battery charger MCU.
An MCU interface control method, comprising: judging whether analog-to-digital conversion parameters need to be read or not; if the judgment result is negative, setting the state of an analog-to-digital conversion interface in the MCU as an output state; and setting the output voltage of the analog-to-digital conversion interface to be high level or low level.
In one embodiment, after determining whether the analog-to-digital conversion parameters need to be read, the method further includes: if the judgment result is yes, setting the state of the analog-digital conversion interface as an input state; the analog-to-digital conversion function is enabled and the analog-to-digital conversion parameters are read.
In one embodiment, the determining whether the analog-to-digital conversion parameter needs to be read includes: and judging whether the time interval between the current time and the last time of reading the analog-to-digital conversion parameters reaches a preset time threshold value, if so, judging that the analog-to-digital conversion parameters need to be read.
In one embodiment, setting the output voltage of the analog-to-digital conversion interface to a high level or a low level includes: calculating a first current value when the analog-to-digital conversion interface outputs a high level and a second current value when the analog-to-digital conversion interface outputs a low level; and if the first current value is smaller than the second current value, setting the output voltage of the analog-to-digital conversion interface to be a high level, otherwise, setting the output voltage of the analog-to-digital conversion interface to be a low level. In the output state, the output voltage of the analog-to-digital conversion interface is further set to be the voltage with smaller corresponding current, so that the power consumption of the MCU can be reduced to the maximum extent.
In one embodiment, the output voltage corresponding to the high level is the power voltage VDD, and the output voltage corresponding to the low level is the ground voltage GND.
In one embodiment, the MCU is a micro control unit of a battery charger.
In one embodiment, the MCU is a micro-control unit of a nickel-hydrogen battery charger.
An MCU interface control device, comprising: the judging module is used for judging whether the analog-to-digital conversion parameters need to be read or not; the first setting module is used for setting the state of an analog-to-digital conversion interface in the MCU as an output state when the judgment result of the judgment module is negative; and the second setting module is used for setting the output voltage of the analog-to-digital conversion interface to be high level or low level.
In one embodiment, the MCU interface control device further includes: the third setting module is used for setting the state of the analog-digital conversion interface as an input state when the judgment result of the judgment module is yes; and the enabling module is used for enabling the analog-to-digital conversion function and reading the analog-to-digital conversion parameters.
In one embodiment, the determining module is configured to determine whether a time interval between the current time and the last time of reading the analog-to-digital conversion parameter reaches a preset time threshold, and if so, determine that the analog-to-digital conversion parameter needs to be read.
In one embodiment, the second setting module includes a calculating unit and a setting unit, wherein the calculating unit is configured to calculate a first current value when the analog-to-digital conversion interface outputs a high level and a second current value when the analog-to-digital conversion interface outputs a low level; the setting unit is used for setting the output voltage of the analog-to-digital conversion interface to be high level if the first current value is smaller than the second current value, otherwise, setting the output voltage of the analog-to-digital conversion interface to be low level.
In one embodiment, the output voltage corresponding to the high level is the power voltage VDD, and the output voltage corresponding to the low level is the ground voltage GND.
In one embodiment, the MCU is a micro control unit of a battery charger.
The I/O interface structure of the MCU causes that when the voltage of the I/O interface is between a high level and a low level, the power consumption of the I/O interface is larger than that when the voltage of the interface is at the high level or the low level.
Drawings
FIG. 1 is a schematic flow chart of an MCU interface control method according to an embodiment of the present invention;
FIG. 2 is a schematic flowchart of an MCU interface control method according to another embodiment of the present invention;
FIG. 3 is a schematic structural diagram of an MCU interface control device according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an MCU interface control device according to another embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
For example, an MCU interface control method includes: judging whether analog-to-digital conversion parameters need to be read or not; if the judgment result is negative, setting the state of an analog-to-digital conversion interface in the MCU as an output state; and setting the output voltage of the analog-to-digital conversion interface to be high level or low level.
For another example, an MCU interface control apparatus includes: the judging module is used for judging whether the analog-to-digital conversion parameters need to be read or not; the first setting module is used for setting the state of an analog-to-digital conversion interface in the MCU as an output state when the judgment result of the judgment module is negative; and the second setting module is used for setting the output voltage of the analog-to-digital conversion interface to be high level or low level.
The analog-to-digital conversion interface is an input/output (I/O) interface connected with the analog-to-digital conversion module in the MCU. The I/O interface structure of the MCU results in: when the I/O interface voltage is between a high level and a low level, i.e., the interface voltage is neither a high level nor a low level, the power consumption of the I/O interface itself may increase. The interface voltage of the I/O interface in the input state is between the high level and the low level, and the power consumption is larger than that in the output state. The traditional MCU sets the state of the analog-to-digital conversion interface as an input state by default, so that the power consumption of the traditional MCU is larger. According to the embodiment, when the analog-to-digital conversion parameters do not need to be read, the state of the analog-to-digital conversion interface in the MCU is set to be the output state, and the output voltage of the analog-to-digital conversion interface is set to be the high level or the low level, so that the power consumption of the MCU is reduced.
In one embodiment, as shown in fig. 1, there is provided an MCU interface control method, including the steps of:
s110, judging whether the analog-to-digital conversion parameters need to be read.
The analog-to-digital conversion parameters are analog quantity, and the analog quantity can be converted into digital quantity through an analog-to-digital conversion module in the MCU. For example, the analog-to-digital conversion parameter includes at least one of voltage, charging current, battery temperature, and the like.
One embodiment determines that the analog-to-digital conversion parameter needs to be read when a preset trigger condition is reached, and otherwise determines that the analog-to-digital conversion parameter does not need to be read. For example, when the preset time is reached, it is determined that the analog-to-digital conversion parameter needs to be read, otherwise it is determined that the analog-to-digital conversion parameter does not need to be read. For another example, when an instruction to read the analog-to-digital conversion parameter is received, it is determined that the analog-to-digital conversion parameter needs to be read, otherwise, it is determined that the analog-to-digital conversion parameter does not need to be read. For another example, when the preset time is reached or an instruction for reading the analog-to-digital conversion parameter is received, it is determined that the analog-to-digital conversion parameter needs to be read, otherwise, it is determined that the analog-to-digital conversion parameter does not need to be read.
And S120, if the judgment result is negative, setting the state of the analog-to-digital conversion interface in the MCU as an output state.
The analog-to-digital conversion interface is an I/O interface connected with the analog-to-digital conversion module in the MCU. And when the analog-digital conversion parameters do not need to be read, setting the state of the analog-digital conversion interface as an output state.
And S130, setting the output voltage of the analog-to-digital conversion interface to be high level or low level.
The output voltage corresponding to the high level is a power voltage VDD, and the output voltage corresponding to the low level is a ground voltage GND.
The I/O interface structure of the MCU causes the power consumption of the I/O interface to be greater when the I/O interface voltage is between a high level and a low level than when the I/O interface voltage is at a high level or a low level, especially when the I/O interface voltage is at an intermediate value between the high level and the low level. The traditional MCU sets the state of the analog-to-digital conversion interface as an input state by default, so that the power consumption of the traditional MCU is larger. In the embodiment, when the analog-to-digital conversion parameters do not need to be read, the state of the analog-to-digital conversion interface in the MCU is set to the output state, and the output voltage of the analog-to-digital conversion interface is set to the high level or the low level, so that the power consumption of the MCU is reduced.
In one embodiment, the MCU is a micro control unit of a battery charger, for example a nickel-hydrogen battery charger. And the MCU is a nickel-cadmium battery charger, a nickel-zinc battery charger, a lead-acid battery charger, a lithium battery charger or a lithium iron phosphate charger.
In an embodiment, as shown in fig. 2, if the determination result in step S110 is yes, the MCU interface control method further includes the following steps:
and S140, setting the state of the analog-to-digital conversion interface as an input state.
S150, enable the analog-to-digital conversion function and read the analog-to-digital conversion parameter.
When the analog-to-digital conversion parameters need to be read, the state of the analog-to-digital conversion interface is set to be an input state, and the voltage of the analog-to-digital conversion interface is between a high level and a low level, for example, between a power supply voltage VDD and a ground voltage GND. When the analog-to-digital conversion parameter needs to be read, the preset time is reached, or an instruction for reading the analog-to-digital conversion parameter is received.
After the analog-to-digital conversion function is enabled, the analog-to-digital conversion parameters can be read, for example, at least one of the battery voltage, the charging current, the battery temperature, and the like can be read.
Further, after reading the analog-to-digital conversion parameter, the MCU interface control method further includes: and converting the analog-to-digital conversion parameters into digital quantities. For example, the analog-to-digital conversion parameters are converted into digital quantities by an analog-to-digital conversion module in the MCU.
In this embodiment, when the analog-to-digital conversion parameter needs to be read, the state of the analog-to-digital conversion interface is set as an input state, so that the analog-to-digital conversion function is enabled and the analog-to-digital conversion parameter is read. The normal use of the analog-to-digital conversion function can be ensured on the premise of reducing the power consumption of the MCU.
In one embodiment, step S11O includes: and judging whether the time interval between the current time and the last time of reading the analog-to-digital conversion parameters reaches a preset time threshold value or not. If the time interval between the current time and the last time of reading the analog-to-digital conversion parameters reaches a preset time threshold, the analog-to-digital conversion parameters are judged to need to be read.
That is, the state of the analog-to-digital conversion interface is set to the output state by default, and the output voltage of the analog-to-digital conversion interface is set to the high level or the low level. And judging that the analog-to-digital conversion parameters need to be read every preset time, setting the state of the analog-to-digital conversion interface as an input state, enabling the analog-to-digital conversion function and reading the analog-to-digital conversion parameters. After reading the analog-to-digital conversion parameters, the state of the analog-to-digital conversion interface is switched back to the output state. In this way, the analog-to-digital conversion interface is in an input state only at certain time points and is in an output state in most of the time, so that the power consumption of the MCU is effectively reduced.
In one embodiment, step S130 includes: calculating a first current value when the analog-to-digital conversion interface outputs a high level and a second current value when the analog-to-digital conversion interface outputs a low level; and if the first current value is smaller than the second current value, setting the output voltage of the analog-to-digital conversion interface to be a high level, otherwise, setting the output voltage of the analog-to-digital conversion interface to be a low level. The first current value and the second current value can be calculated according to a peripheral circuit of the analog-to-digital conversion interface.
Because the power consumption is smaller when the current of the I/O interface is smaller in the output state, the output voltage of the analog-to-digital conversion interface is further set to be the voltage with the smaller corresponding current in the output state, so that the power consumption of the analog-to-digital conversion interface is further ensured to be the lowest, and the power consumption of the MCU is reduced to the maximum extent.
In one embodiment, as shown in fig. 3, an MCU interface control apparatus is provided, which includes a determination module 310, a first setting module 320, and a second setting module 330. The determining module 310 is configured to determine whether an analog-to-digital conversion parameter needs to be read; the first setting module 320 is configured to set the state of the analog-to-digital conversion interface in the MCU to an output state when the determination result of the determining module is negative; the second setting module 330 is used to set the output voltage of the analog-to-digital conversion interface to a high level or a low level.
The analog-to-digital conversion interface is an input/output (I/O) interface connected with the analog-to-digital conversion module in the MCU. The I/O interface structure of the MCU results in: when the I/O interface voltage is between a high level and a low level, i.e., the interface voltage is neither a high level nor a low level, the power consumption of the I/O interface itself may increase. The interface voltage of the I/O interface in the input state is between the high level and the low level, and the power consumption is larger than that in the output state. The traditional MCU sets the state of the analog-to-digital conversion interface as an input state by default, so that the power consumption of the traditional MCU is larger. According to the embodiment, when the analog-to-digital conversion parameters do not need to be read, the state of the analog-to-digital conversion interface in the MCU is set to be the output state, and the output voltage of the analog-to-digital conversion interface is set to be the high level or the low level, so that the power consumption of the MCU is reduced.
In an embodiment, as shown in fig. 4, the MCU interface control device further includes a third setting module 340 and an enabling module 350, where the third setting module 340 is configured to set the state of the analog-to-digital conversion interface to be an input state when the determination result of the determining module is yes; the enabling module 350 is used for enabling the analog-to-digital conversion function and reading the analog-to-digital conversion parameter.
In one embodiment, the determining module 310 is configured to determine whether a time interval between the current time and the last time of reading the analog-to-digital conversion parameter reaches a preset time threshold, and if so, determine that the analog-to-digital conversion parameter needs to be read.
In one embodiment, the second setting module comprises a calculating unit and a setting unit, wherein the calculating unit is used for calculating a first current value when the analog-to-digital conversion interface outputs a high level and a second current value when the analog-to-digital conversion interface outputs a low level; the setting unit is used for setting the output voltage of the analog-to-digital conversion interface to be high level if the first current value is smaller than the second current value, otherwise, setting the output voltage of the analog-to-digital conversion interface to be low level.
In one embodiment, the output voltage corresponding to the high level is the power voltage VDD, and the output voltage corresponding to the low level is the ground voltage GND.
In one embodiment, the MCU is a micro control unit of a battery charger. For example, the MCU is a micro control unit of a nickel-hydrogen battery charger. For another example, the MCU may be a nickel-cadmium battery charger, a nickel-zinc battery charger, a lead-acid battery charger, a lithium battery charger, or a lithium iron phosphate charger.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.
Claims (10)
1. An MCU interface control method, comprising:
judging whether analog-to-digital conversion parameters need to be read or not;
if the judgment result is negative, setting the state of an analog-to-digital conversion interface in the MCU as an output state;
setting the output voltage of the analog-to-digital conversion interface to be a high level or a low level;
the setting of the output voltage of the analog-to-digital conversion interface to a high level or a low level includes:
calculating a first current value when the analog-to-digital conversion interface outputs a high level and a second current value when the analog-to-digital conversion interface outputs a low level;
and if the first current value is smaller than the second current value, setting the output voltage of the analog-to-digital conversion interface to be a high level, otherwise, setting the output voltage of the analog-to-digital conversion interface to be a low level.
2. The MCU interface control method of claim 1, wherein after determining whether the analog-to-digital conversion parameters need to be read, the method further comprises:
if the judgment result is yes, setting the state of the analog-digital conversion interface as an input state;
enabling an analog-to-digital conversion function and reading the analog-to-digital conversion parameters.
3. The MCU interface control method of claim 2, wherein the determining whether the analog-to-digital conversion parameters need to be read comprises:
and judging whether the time interval between the current time and the last time of reading the analog-to-digital conversion parameters reaches a preset time threshold value, if so, judging that the analog-to-digital conversion parameters need to be read.
4. The MCU interface control method of claim 1, further comprising: and converting the analog-to-digital conversion parameters into digital quantities.
5. The MCU interface control method according to any one of claims 1-4, wherein the output voltage corresponding to the high level is a power supply voltage VDD, and the output voltage corresponding to the low level is a ground voltage GND.
6. An MCU interface control method according to any of claims 1-4, characterized in that the MCU is a micro control unit of a battery charger.
7. The MCU interface control method of claim 6, wherein the MCU is a micro control unit of a nickel-hydrogen battery charger.
8. An MCU interface control apparatus, comprising:
the judging module is used for judging whether the analog-to-digital conversion parameters need to be read or not;
the first setting module is used for setting the state of an analog-to-digital conversion interface in the MCU as an output state when the judgment result of the judgment module is negative;
the second setting module is used for setting the output voltage of the analog-to-digital conversion interface to be a high level or a low level, and calculating a first current value when the analog-to-digital conversion interface outputs the high level and a second current value when the analog-to-digital conversion interface outputs the low level; and if the first current value is smaller than the second current value, setting the output voltage of the analog-to-digital conversion interface to be a high level, otherwise, setting the output voltage of the analog-to-digital conversion interface to be a low level.
9. The MCU interface control device of claim 8, further comprising:
the third setting module is used for setting the state of the analog-digital conversion interface as an input state when the judgment result of the judgment module is yes;
and the enabling module is used for enabling the analog-to-digital conversion function and reading the analog-to-digital conversion parameters.
10. The MCU interface control device of claim 9, wherein the determining module is configured to determine whether a time interval between a current time and a last time of reading the analog-to-digital conversion parameter reaches a preset time threshold, and if so, determine that the analog-to-digital conversion parameter needs to be read.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810864134.6A CN109032015B (en) | 2018-08-01 | 2018-08-01 | MCU interface control method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810864134.6A CN109032015B (en) | 2018-08-01 | 2018-08-01 | MCU interface control method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109032015A CN109032015A (en) | 2018-12-18 |
CN109032015B true CN109032015B (en) | 2020-04-17 |
Family
ID=64647526
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810864134.6A Active CN109032015B (en) | 2018-08-01 | 2018-08-01 | MCU interface control method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109032015B (en) |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101470173B (en) * | 2007-12-29 | 2012-09-26 | 鸿富锦精密工业(深圳)有限公司 | Battery detection apparatus and method |
CN101393542B (en) * | 2008-10-08 | 2012-01-25 | 上海华勤通讯技术有限公司 | Embedded equipment and method for supporting USB interface by GPIO terminal port |
CN102005791B (en) * | 2010-11-12 | 2013-12-25 | 深圳和而泰智能控制股份有限公司 | Charging detection method and device for small-capacity battery |
CN104407954A (en) * | 2014-11-24 | 2015-03-11 | 深圳市振邦智能科技有限公司 | Method for detecting I/O (input/output) interface faults in MCU (microprogrammed control unit) |
CN107391379B (en) * | 2017-07-28 | 2021-01-01 | 武汉斗鱼网络科技有限公司 | Automatic interface testing method and device |
-
2018
- 2018-08-01 CN CN201810864134.6A patent/CN109032015B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN109032015A (en) | 2018-12-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105990866B (en) | Charging method, device and terminal | |
CN104539005B (en) | A kind of mobile terminal charge control system and method | |
JPWO2011061902A1 (en) | Charge control circuit, battery pack, and charging system | |
CN106965761A (en) | A kind of mobile unit system cut-off protection device | |
CN103730915A (en) | Charging control method and electronic equipment adopting method | |
CN105337374A (en) | Method for prolonging power supply time | |
CN102788959B (en) | Method for detecting charge-discharge state of storage battery of stand-alone photovoltaic power generation system | |
CN104765396A (en) | Mobile terminal based shutdown voltage dynamic adjusting method and system | |
CN109756018A (en) | Battery charger and method for charging batteries | |
CN105826959B (en) | A kind of method, device and mobile terminal of charging | |
CN101986502A (en) | Mobile phone battery charging circuit | |
CN205248853U (en) | Power supply circuit | |
JP2010124547A (en) | Apparatus and method for charge control and photovoltaic power generating system | |
CN109032015B (en) | MCU interface control method and device | |
CN103124097A (en) | Intelligent lithium ion charger | |
JP2013537027A (en) | Method for charging the battery | |
JP2011160635A (en) | Storage battery charging method and photovoltaic power generation system | |
CN105429258A (en) | Charger capable of automatically adjusting charging current and charging method | |
CN104882946B (en) | A kind of mobile phone charge management module and its charging management method | |
KR102269106B1 (en) | Method for control battery power limit | |
CN105699909A (en) | Battery power management method for power consumption information acquisition terminal | |
CN102624950B (en) | Mobile phone | |
CN201323464Y (en) | Electronic equipment charger and charging device for electronic equipment | |
CN201616699U (en) | Charger | |
CN102148524B (en) | Charger |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |