Disclosure of Invention
In view of the above drawbacks of the prior art, an object of the present invention is to provide a metering circuit, a working method thereof, and an electronic system, which are used for solving the problem that the system power consumption is large due to frequent wake-up of a CPU in the existing metering circuit system.
To achieve the above and other related objects, the present invention provides a metering circuit comprising:
the low-frequency oscillation module is used for generating a low-frequency oscillation signal;
The high-frequency oscillation module is used for generating a high-frequency oscillation signal;
the main control module is respectively connected with the low-frequency oscillation module and the high-frequency oscillation module and generates a conversion enabling signal after entering a working state;
the analog-to-digital conversion module is respectively connected with the high-frequency oscillation module and the main control module and is used for performing analog-to-digital conversion according to the conversion enabling signal sent by the main control module to generate a conversion result and sending the conversion result to the main control module;
Further comprises: the auxiliary control module is respectively connected with the low-frequency oscillation module, the high-frequency oscillation module and the main control module and is used for triggering and generating a conversion enabling signal and a comparison enabling signal according to the received low-frequency oscillation signal after the main control module sends out an auxiliary control enabling signal; the main control module enters a sleep state from a working state after sending the auxiliary control enabling signal, and the analog-to-digital conversion module also carries out analog-to-digital conversion according to the conversion enabling signal sent by the auxiliary control module to generate a conversion result;
The comparison module is respectively connected with the main control module, the analog-to-digital conversion module and the auxiliary control module and is used for comparing the conversion result sent by the analog-to-digital conversion module with a set threshold value to generate a comparison result after the auxiliary control module sends out the comparison enabling signal and sending the comparison result to the main control module; and the main control module is also used for triggering and waking up to enter a working state from a sleep state according to the comparison result, and invalidating the auxiliary control enabling signal after entering the working state.
Optionally, the metering circuit further comprises: and the threshold module is connected with the comparison module and is used for providing the set threshold.
Optionally, the threshold module is further connected to the main control module, and the set threshold is set and written by the main control module.
Optionally, the low-frequency oscillation module is connected with the main control module, and the low-frequency oscillation module is controlled to be always started by a low-frequency enabling signal sent by the main control module.
Optionally, the high-frequency oscillation module is connected with the main control module and the auxiliary control module, and the high-frequency oscillation module is controlled to work by a high-frequency enabling signal sent by the main control module or the auxiliary control module; the conversion enabling signal, the comparison enabling signal and the high-frequency enabling signal sent by the auxiliary control module are periodic enabling signals, the main control module is further used for setting the continuous clock numbers of the high level and the low level of the three periodic enabling signals, the auxiliary control module is used for triggering and generating the three periodic enabling signals by counting the clock of the low-frequency oscillating signal, and the high-level duration time of the three periodic enabling signals is set by counting the clock of the high-frequency oscillating signal.
Optionally, the main control module is further configured to set conversion accuracy of the analog-to-digital conversion module; the analog-to-digital conversion module performs analog-to-digital conversion of first conversion precision according to the conversion enabling signal sent by the main control module, and performs analog-to-digital conversion of second conversion precision according to the conversion enabling signal sent by the auxiliary control module, wherein the first conversion precision is greater than the second conversion precision.
Optionally, the main control module includes: the system comprises a central processing unit and a program memory, wherein the central processing unit is used as a main control unit, and the program memory is used for storing program instructions when the central processing unit runs.
The invention also provides an electronic device comprising: a sensor and a metering circuit as described above;
the sensor is used for detecting external environment changes and generating an external detection signal;
The metering circuit periodically detects the external environment change through the auxiliary control module, the fast frequency oscillation module, the analog-to-digital conversion module and the comparison module, and wakes the main control module to measure and process the external detection signal when the external environment change.
The invention also provides a working method of the metering circuit, which comprises the following steps:
before the main control module enters a sleep state, the main control module controls the auxiliary control module to be started and allows the comparison module to wake up;
After the main control module enters a sleep state, the auxiliary control module periodically controls the high-frequency oscillation module, the analog-to-digital conversion module and the comparison module to work, so as to periodically detect external environment changes and determine whether to wake up the main control module according to a comparison result;
After the main control module is awakened and enters a working state, the main control module controls the auxiliary control module to be closed, and controls the high-frequency oscillation module and the analog-to-digital conversion module to work so as to measure and process external environment changes.
Optionally, before the main control module enters the sleep state, the main control module is further configured to set the conversion precision of the analog-to-digital conversion module to a second conversion precision; after the main control module is awakened and enters a working state, the main control module controls the analog-to-digital conversion module to work with a first conversion precision, wherein the first conversion precision is larger than the second conversion precision.
Optionally, before the main control module enters the sleep state, the main control module is further configured to write the set threshold into the threshold module.
As described above, the metering circuit, the working method thereof and the electronic system of the invention transfer the control right of periodic detection from the main control module to the auxiliary control module, periodically detect the external environment change through the auxiliary control module, the high-frequency oscillation module, the analog-to-digital conversion module and the comparison module, wake up the main control module when the external environment changes, prolong the time of the main control module in a sleep state, avoid the larger standby power consumption caused by frequent wake-up of the main control module, and realize lower power consumption while maintaining quick response. Compared with the prior art, the invention has lower power consumption on the premise of the same response speed; on the premise of equal power consumption, the invention has faster response speed.
Detailed Description
Other advantages and effects of the present invention will become apparent to those skilled in the art from the following disclosure, which describes the embodiments of the present invention with reference to specific examples. The invention may be practiced or carried out in other embodiments that depart from the specific details, and the details of the present description may be modified or varied from the spirit and scope of the present invention.
Please refer to fig. 2 to fig. 5. It should be noted that, the illustrations provided in the present embodiment are merely schematic illustrations of the basic concepts of the present invention, and only the components related to the present invention are shown in the illustrations, rather than being drawn according to the number, shape and size of the components in actual implementation, and the form, number and proportion of each component in actual implementation may be arbitrarily changed, and the layout of the components may be more complex.
Example 1
As shown in fig. 2, the present embodiment provides a metering circuit 100, including: the device comprises a low-frequency oscillation module 110, a high-frequency oscillation module 120, a main control module 130, an analog-to-digital conversion module 140, an auxiliary control module 150 and a comparison module 160; further, the method further comprises the following steps: a threshold module 170. Wherein,
The low-frequency oscillation module 110 is configured to generate a low-frequency oscillation signal LRC. In this embodiment, the low frequency oscillation module 110 is turned on all the time after the meter circuit 100 is powered on.
As an example, the low-frequency oscillation module 110 is connected to the main control module 130, and the low-frequency enable signal lrc_en sent by the main control module 130 controls the low-frequency oscillation module 110 to be turned on all the time and generates the low-frequency oscillation signal LRC.
The high-frequency oscillation module 120 is configured to generate a high-frequency oscillation signal HRC.
As an example, the high-frequency oscillation module 120 is connected to the main control module 130 and the auxiliary control module 150, and the high-frequency oscillation module 120 is controlled to work and generate the high-frequency oscillation signal HRC by the high-frequency enable signal hrc_en1 sent by the main control module 130 or the high-frequency enable signal hrc_en2 sent by the auxiliary control module 150. It should be noted that the specific frequency values of the low-frequency oscillation signal LRC and the high-frequency oscillation signal HRC are determined by practical application requirements, which is not limited in this embodiment.
The main control module 130 is respectively connected with the low-frequency oscillation module 110 and the high-frequency oscillation module 120, generates a conversion enabling signal ADC_EN1 after entering a working state, sends the conversion enabling signal ADC_EN1 to the analog-digital conversion module 140, and enters a sleep state from the working state after sending an auxiliary control enabling signal AC_EN; the main control module 130 also receives the comparison result cmp_out sent by the comparison module 160, and triggers to wake up to enter the working state from the sleep state according to the comparison result cmp_out, and invalidates the auxiliary control enable signal ac_en after entering the working state.
The main control module 130 uses the low-frequency oscillation signal LRC as its low-frequency clock and uses the high-frequency oscillation signal HRC as its working clock; of course, the main control module 130 may also divide and/or multiply the low-frequency oscillation signal LRC to generate oscillation signals with other frequency values, and similarly, the main control module 130 may also divide and/or multiply the high-frequency oscillation signal HRC to generate oscillation signals with other frequency values, which is not limited in this embodiment. In practical applications, when the main control module 130 enters a sleep state, the clock signal involved is usually a low-frequency oscillation signal LRC; when the main control module 130 enters the operation state, the clock signal involved includes the high-frequency oscillation signal HRC in addition to the low-frequency oscillation signal LRC.
In this embodiment, when the main control module 130 performs the trigger wake-up according to the comparison result cmp_out sent by the comparison module 160, the high-level pulse is used as the effective trigger wake-up signal, and of course, the low-level pulse may also be used as the effective trigger wake-up signal, which has no substantial effect on this embodiment; if the comparison result cmp_out is a low level signal, the low level signal cannot trigger to wake up the main control module 130, and at this time, the main control module 130 keeps in a sleep state; if the comparison result cmp_out is a high level pulse, the high level pulse triggers to wake up the main control module 130, and at this time, the main control module 130 is waken up and enters the working state from the sleep state.
After the main control module 130 enters the working state from the sleep state, the main control module 130 may disable the auxiliary control enable signal ac_en, for example, turn off the auxiliary control module 150 by pulling down the auxiliary control enable signal ac_en; in addition, the main control module 130 also generates a high-frequency enable signal hrc_en1 and a conversion enable signal adc_en1, for example, the high-frequency oscillation module 120 is turned on by pulling the high-frequency enable signal hrc_en1, and the analog-to-digital conversion module 140 is turned on by pulling the conversion enable signal adc_en1; after the main control module 130 receives the conversion result adc_out1 output by the analog-to-digital conversion module 140, the main control module 130 further performs calculation processing and display on the conversion result adc_out1.
When the main control module 130 processes the conversion result adc_out1 and prepares to enter a sleep state, the main control module 130 starts the auxiliary control module 150 by pulling Gao Fu the control enable signal ac_en, so as to ensure that the auxiliary control module 150 is started when the main control module 130 is in the sleep state, and allow the comparison module 160 to wake up, i.e. allow the comparison result cmp_out output by the comparison module 160 to be used as a trigger wake-up signal thereof.
In the solution described in the foregoing embodiment, the main control module 130 does not perform the conversion accuracy setting on the analog-to-digital conversion module 140; regarding the external detection signal generated by the sensor when the main control module 130 controls as a first detection signal, regarding the external detection signal generated by the sensor when the auxiliary control module 150 controls as a second detection signal, the analog-to-digital conversion module 140 performs analog-to-digital conversion on the first detection signal and the second detection signal with the same conversion precision (such as high conversion precision); but in combination with the practical application scene, the measurement of the second detection signal does not need an accurate measurement result, so that the measurement of the second detection signal can be performed quickly, the response speed of the circuit can be reduced, and the power consumption of the circuit can be improved.
In order to improve the circuit response speed and reduce the circuit power consumption, the conversion precision of the analog-to-digital conversion module 140 can be set by the main control module 130, so that the conversion precision of the analog-to-digital conversion module 140 on the first detection signal is higher than the conversion precision on the second detection signal. In this embodiment, after the main control module 130 enters the working state from the sleep state, the main control module 130 generates a first conversion configuration signal after turning on the analog-to-digital conversion module 140, and configures the conversion precision of the analog-to-digital conversion module 140 to be the first conversion precision through the first conversion configuration signal; when the main control module 130 processes the conversion result adc_out1 and prepares to enter a sleep state, the main control module 130 further generates a second conversion configuration signal, and configures the conversion precision of the analog-to-digital conversion module 140 to be a second conversion precision through the second conversion configuration signal; wherein the first conversion accuracy is higher than the second conversion accuracy.
As an example, the main control module 130 includes: a Central Processing Unit (CPU) and a program memory; the CPU is used as a main control unit, and the program memory is used for storing program instructions when the CPU runs. In particular, the program memory is implemented using Read Only Memory (ROM).
The analog-to-digital conversion module 140 is respectively connected with the high-frequency oscillation module 120 and the main control module 130, and is configured to perform analog-to-digital conversion according to a conversion enabling signal adc_en1 sent by the main control module 130 to generate a conversion result adc_out1, and send the conversion result adc_out1 to the main control module 130; the analog-to-digital conversion module 140 further performs analog-to-digital conversion according to the conversion enable signal adc_en2 sent by the auxiliary control module 150 to generate a conversion result adc_out2, which is sent to the comparison module 160. The analog-to-digital conversion module 140 is implemented by an analog-to-digital converter (ADC), and uses the high-frequency oscillation signal HRC as its working clock.
When the main control module 130 does not perform the conversion accuracy setting on the analog-to-digital conversion module 140, the analog-to-digital conversion module 140 is controlled by the conversion enabling signal adc_en1 sent by the main control module 130 or the conversion enabling signal adc_en2 sent by the auxiliary control module 150 to be turned on and perform the analog-to-digital conversion with the same conversion accuracy to generate the conversion result adc_out1 and the conversion result adc_out2.
When the main control module 130 performs conversion precision setting on the analog-to-digital conversion module 140, the analog-to-digital conversion module 140 performs analog-to-digital conversion of the first conversion precision according to the conversion enabling signal adc_en1 sent by the main control module 130 and generates the conversion result adc_out1, so as to complete accurate measurement of the external detection signal, and performs analog-to-digital conversion of the second conversion precision according to the conversion enabling signal adc_en2 sent by the auxiliary control module 150 and generates the conversion result adc_out2, so as to complete rapid measurement of the external detection signal.
The auxiliary control module 150 is respectively connected with the low-frequency oscillation module 110, the high-frequency oscillation module 120 and the main control module 130, and is configured to trigger and generate a conversion enabling signal adc_en2 and a comparison enabling signal cmp_en according to the received low-frequency oscillation signal LRC after the main control module 130 sends out an auxiliary control enabling signal ac_en; the auxiliary control module 150 also triggers generation of the high-frequency enable signal hrc_en2 according to the received low-frequency oscillation signal LRC.
As an example, the high-frequency enable signal hrc_en2, the conversion enable signal adc_en2 and the comparison enable signal cmp_en sent by the auxiliary control module 150 are periodic enable signals, the main control module 130 is further configured to set the clock numbers of the three periodic enable signals that are high and low, and the auxiliary control module 150 is configured to trigger the generation of the three periodic enable signals by counting the low-frequency oscillation signal LRC, and to set the high-level duration of the three periodic enable signals by counting the high-frequency oscillation signal HRC.
Specifically, the main control module 130 sets, for the high-frequency enable signal hrc_en2, the number of clocks that last at a low level in one period to a first preset value and the number of clocks that last at a high level to a second preset value; setting the number of clocks which are continuous at a low level and the number of clocks which are continuous at a high level in one period as a third preset value and a fourth preset value for the conversion enable signal ADC_EN2; for the comparison enable signal cmp_en, the number of clocks that the low level continues for one period is set to a fifth preset value and the number of clocks that the high level continues to is set to a sixth preset value.
The auxiliary control module 150 includes a first signal generating unit, a second signal generating unit, and a third signal generating unit (not shown in the figure); the first signal generating unit is configured to generate a periodic high-frequency enabling signal hrc_en2, where in one period, the length of the low level is obtained by performing clock counting on the low-frequency oscillating signal LRC to a first preset value and jumping to the high level after the corresponding counting is completed, and the length of the high level is obtained by performing clock counting on the high-frequency oscillating signal HRC to a second preset value; the second signal generating unit is configured to generate a periodic conversion enable signal adc_en2, where in one period, the length of the low level is obtained by performing clock counting on the low frequency oscillation signal LRC to a third preset value and jumping to the high level after the corresponding counting is completed, and the length of the high level is obtained by performing clock counting on the high frequency oscillation signal HRC to a fourth preset value; the third signal generating unit is configured to generate a periodic comparison enable signal cmp_en, wherein in one period, a length of the low level is obtained by counting the low frequency oscillation signal LRC to a fifth preset value and jumping to the high level after the corresponding counting is completed, and a length of the high level is obtained by counting the high frequency oscillation signal HRC to a sixth preset value.
For example, for the high-frequency enable signal hrc_en2, the low-level length is 1s and the high-level length is 10ms in one period; for the conversion enable signal ADC_EN2, the low level length is 1s and the high level length is 10ms in one period; for the comparison enable signal cmp_en, the low level length is 1s, the high level length is 0.1ms, and the like in one period; of course, the high and low level lengths are only given as an example, and other values can be designed according to practical application requirements, which has no substantial effect on the present embodiment. However, when the high and low level lengths are designed, the high level lengths of the high-frequency enable signal hrc_en2 and the conversion enable signal adc_en2 should be enough for the analog-to-digital conversion module 140 to output a relatively stable value, and the performance and average power consumption of the analog-to-digital conversion module 140 can be considered comprehensively, and the high level length of the comparison enable signal cmp_en should be kept as much as possible before the falling edge of the conversion enable signal adc_en2, so that the output value of the analog-to-digital conversion module 140 is relatively stable.
The comparison module 160 is respectively connected to the main control module 130, the analog-to-digital conversion module 140 and the auxiliary control module 150, and is configured to compare the conversion result adc_out2 sent by the analog-to-digital conversion module 140 with the set threshold DREF to generate a comparison result cmp_out after the auxiliary control module 150 sends the comparison enable signal cmp_en, and send the comparison result cmp_out to the main control module 130.
As an example, the comparison module 160 is implemented with a comparator; the control end of the comparator is connected with a comparison enabling signal CMP_EN sent by the auxiliary control module 150, the non-inverting input end of the comparator is connected with a conversion result ADC_OUT2 output by the analog-to-digital conversion module 140, the inverting input end of the comparator is connected with a set threshold DREF output by the threshold module 170, and the output end of the comparator generates a comparison result CMP_OUT.
In this embodiment, the comparator is controlled by the comparison enable signal cmp_en being turned on, and compares the conversion result adc_out2 with the set threshold DREF; when the conversion result adc_out2 is greater than the set threshold DREF, outputting a high level pulse, and at this time, the high level pulse is used as an effective wake-up trigger signal to trigger the wake-up main control module 130; when the conversion result adc_out2 is smaller than the set threshold DREF, a low level signal is output, and the main control module 130 is not triggered to wake up.
The threshold module 170 is coupled to the comparison module 160 for providing a set threshold DREF. Further, the threshold module 170 is further connected to the main control module 130, and is configured to set and write the set threshold DREF through the main control module 130.
As an example, the threshold module 170 is implemented using a threshold register in which a set threshold value stored is set and written by the main control module 130.
The present embodiment also provides a working method of the metering circuit described above, and referring to fig. 2, fig. 3 and fig. 4, the working method of the present embodiment is described below; the working method comprises the following steps.
Step 1) before the main control module 130 enters the sleep state, the main control module 130 controls the auxiliary control module 150 to be turned on and allows the comparison module 160 to wake up, so as to transfer the control rights periodically enabled by the high-frequency oscillation module 120, the analog-to-digital conversion module 140 and the comparison module 160 to the auxiliary control module 150. Further, the main control module 130 is further configured to write the set threshold DREF to the threshold module 170.
Step 2), after the main control module 130 enters the sleep state, the auxiliary control module 150 periodically controls the high-frequency oscillation module 120, the analog-to-digital conversion module 140 and the comparison module 160 to work, so as to periodically detect the external environment change and determine whether to wake up the main control module 130 according to the comparison result; for example, when the comparison result is a low level signal (i.e. the external environment is not changed), the main control module 130 is not awakened to keep the sleep state, so as to reduce the overall power consumption, and the high-frequency oscillation module 120, the analog-to-digital conversion module 140 and the comparison module 160 are continuously awakened periodically to quickly detect the external environment change; when the comparison result is a high level pulse (i.e. the external environment changes), the main control module 130 is awakened.
Step 3) after the main control module 130 is awakened and enters into a working state, the main control module 130 controls the auxiliary control module 150 to be closed, and controls the high-frequency oscillation module 120 and the analog-to-digital conversion module 140 to work so as to measure and process the external environment change.
In the above-described operation method, the two analog-to-digital conversions in step 2) and step 3) are performed by the analog-to-digital conversion module 140 with the same conversion accuracy, which may reduce the response speed. In design, the analog-to-digital conversion module 140 can complete the two analog-to-digital conversions with different conversion accuracy, and the second conversion accuracy related to the step 2) is lower than the first conversion accuracy related to the step 3). At this time, the following adjustments are made to the above working method:
In step 1), before the main control module 130 enters the sleep state, the main control module 130 further sets the conversion accuracy of the analog-to-digital conversion module 140 to the second conversion accuracy, for example, the main control module 130 configures the conversion accuracy of the analog-to-digital conversion module 140 to the second conversion accuracy through the generated second conversion configuration signal.
In step 2), after the main control module 130 enters the sleep state, the auxiliary control module 150 periodically controls the high-frequency oscillation module 120, the analog-to-digital conversion module 140 and the comparison module 160 to work, wherein the analog-to-digital conversion module 140 performs analog-to-digital conversion on the external detection signal with the second conversion precision so as to realize rapid measurement.
In step 3), after the main control module 130 is awakened and enters the working state, the main control module 130 starts the analog-to-digital conversion module 140 and sets the conversion precision thereof to the first conversion precision, for example, the main control module 130 configures the conversion precision of the analog-to-digital conversion module 140 to the first conversion precision through the generated first conversion configuration signal; then, the analog-to-digital conversion module 140 performs analog-to-digital conversion on the external detection signal with the first conversion precision so as to realize accurate measurement; wherein the first conversion accuracy is higher than the second conversion accuracy.
Example two
As shown in fig. 5, the present embodiment further provides an electronic device 10, including: the metering circuit 100 and the sensor 200 according to the first embodiment are described. Wherein,
The sensor 200 is used to detect external environmental changes and generate an external detection signal. It should be noted that the type of the sensor 200 should be selected according to the practical application requirement, which is not limited in this embodiment; for example, the electronic device 10 is an electronic scale, the sensor 200 is a load cell, and the like.
The metering circuit 100 periodically detects the external environment change through the auxiliary control module 150, the fast frequency oscillation module 120, the analog-to-digital conversion module 140 and the comparison module 160, and wakes the main control module 130 to measure and process the external detection signal when the external environment changes. The specific operation principle of the metering circuit 100 can be referred to as the first embodiment, and will not be described herein.
In summary, according to the metering circuit, the working method and the electronic system thereof, the control right of periodic detection is handed over from the main control module to the auxiliary control module, the high-frequency oscillation module, the analog-to-digital conversion module and the comparison module are used for periodically detecting the external environment change, and the main control module is awakened when the external environment changes, so that the time of the main control module in a sleep state can be prolonged, the larger standby power consumption caused by frequent awakening of the main control module is avoided, the quick response is maintained, and meanwhile, the lower power consumption is realized. Compared with the prior art, the invention has lower power consumption on the premise of the same response speed; on the premise of equal power consumption, the invention has faster response speed. Therefore, the invention effectively overcomes various defects in the prior art and has high industrial utilization value.
The above embodiments are merely illustrative of the principles of the present invention and its effectiveness, and are not intended to limit the invention. Modifications and variations may be made to the above-described embodiments by those skilled in the art without departing from the spirit and scope of the invention. Accordingly, it is intended that all equivalent modifications and variations of the invention be covered by the claims, which are within the ordinary skill of the art, be within the spirit and scope of the present disclosure.