WO2022012261A1 - 一种设备剩余电量的计量方法及装置 - Google Patents

一种设备剩余电量的计量方法及装置 Download PDF

Info

Publication number
WO2022012261A1
WO2022012261A1 PCT/CN2021/100762 CN2021100762W WO2022012261A1 WO 2022012261 A1 WO2022012261 A1 WO 2022012261A1 CN 2021100762 W CN2021100762 W CN 2021100762W WO 2022012261 A1 WO2022012261 A1 WO 2022012261A1
Authority
WO
WIPO (PCT)
Prior art keywords
register
value
timer
module
power consumption
Prior art date
Application number
PCT/CN2021/100762
Other languages
English (en)
French (fr)
Inventor
陆舟
于华章
Original Assignee
飞天诚信科技股份有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 飞天诚信科技股份有限公司 filed Critical 飞天诚信科技股份有限公司
Priority to US17/799,563 priority Critical patent/US20230128424A1/en
Publication of WO2022012261A1 publication Critical patent/WO2022012261A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01RMEASURING ELECTRIC VARIABLES; MEASURING MAGNETIC VARIABLES
    • G01R31/00Arrangements for testing electric properties; Arrangements for locating electric faults; Arrangements for electrical testing characterised by what is being tested not provided for elsewhere
    • G01R31/36Arrangements for testing, measuring or monitoring the electrical condition of accumulators or electric batteries, e.g. capacity or state of charge [SoC]
    • G01R31/382Arrangements for monitoring battery or accumulator variables, e.g. SoC
    • G01R31/3842Arrangements for monitoring battery or accumulator variables, e.g. SoC combining voltage and current measurements
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01RMEASURING ELECTRIC VARIABLES; MEASURING MAGNETIC VARIABLES
    • G01R31/00Arrangements for testing electric properties; Arrangements for locating electric faults; Arrangements for electrical testing characterised by what is being tested not provided for elsewhere
    • G01R31/36Arrangements for testing, measuring or monitoring the electrical condition of accumulators or electric batteries, e.g. capacity or state of charge [SoC]
    • G01R31/3644Constructional arrangements
    • G01R31/3646Constructional arrangements for indicating electrical conditions or variables, e.g. visual or audible indicators
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01RMEASURING ELECTRIC VARIABLES; MEASURING MAGNETIC VARIABLES
    • G01R31/00Arrangements for testing electric properties; Arrangements for locating electric faults; Arrangements for electrical testing characterised by what is being tested not provided for elsewhere
    • G01R31/36Arrangements for testing, measuring or monitoring the electrical condition of accumulators or electric batteries, e.g. capacity or state of charge [SoC]
    • G01R31/385Arrangements for measuring battery or accumulator variables
    • G01R31/387Determining ampere-hour charge capacity or SoC
    • G01R31/388Determining ampere-hour charge capacity or SoC involving voltage measurements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/04Generating or distributing clock signals or signals derived directly therefrom
    • G06F1/14Time supervision arrangements, e.g. real time clock
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/26Power supply means, e.g. regulation thereof
    • G06F1/28Supervision thereof, e.g. detecting power-supply failure by out of limits supervision

Definitions

  • the invention relates to a method and a device for measuring the remaining electric quantity of equipment, belonging to the field of electric quantity measurement.
  • the display of the remaining power can remind the user to replace or charge them in time, and the accurate display of the remaining battery power has become an important performance indicator.
  • the purpose of the present invention is to provide a method and device for measuring the remaining power of a device, which can improve the measurement accuracy of the remaining power without adding additional components, more accurately reflect the actual value of the remaining power of the battery, and do not add extra Power consumption; device lifetime is unaffected and low cost.
  • a method for measuring the remaining power of a device which includes:
  • Step S1 Detect the state of the flag bit, when the first flag bit is set, execute step S2, and when the second flag bit is set, execute step S4;
  • Step S2 turn on the timer to start counting, calculate the password, close the timer when the password calculation is completed, stop counting to obtain the password calculation time, reset the timer, accumulate the password calculation time into the fourth register, and execute step S3;
  • Step S3 display the password and the remaining power, reset the first flag bit, and return to step S1;
  • Step S4 Detecting the battery voltage, obtaining the preset wake-up current value, password calculation current value, and displaying the current value according to the detected battery voltage and the pre-stored first data table, and comparing the wake-up current value with the data in the first register.
  • the product, the product of the password calculation current value and the data in the fourth register, and the product of the displayed current value and the result of subtracting the data in the fourth register from the first preset value are added to obtain the total power consumption;
  • Step S5 update the remaining power according to the total power consumption and the second preset value, reset the second flag bit, and return to step S1;
  • step S1 to step S5 when the real-time clock interruption is detected, step A1 to step A4 are executed, and the real-time clock interruption is triggered once every first preset time;
  • Step A1 Turn on the timer to start counting, and update the result of adding the first preset time to the data in the second register and the sixth register to the second register and the sixth register, when the data in the sixth register is equal to the fourth register.
  • execute step A2 when the preset value, execute step A2;
  • Step A2 set the first flag bit, clear the data in the sixth register, and execute Step A4;
  • Step A3 set the second flag bit, and execute Step A4;
  • Step A4 The timer is turned off to stop counting, and the wake-up time is obtained, and the wake-up time is accumulated into the first register.
  • a device for measuring the remaining power of a device comprising:
  • the detection module is used to detect the status of the flag bit, and when the first flag bit is set, the calculation password module is triggered, and when the second flag bit is set, the calculation of the total power consumption module is triggered;
  • the password calculation module is used to start the timer and start counting, calculate the password, close the timer when the password calculation is completed, stop counting to get the password calculation time, reset the timer, accumulate the password calculation time into the fourth register, and trigger the display module ;
  • the display module is used to display the password and the remaining power, reset the first flag bit, and trigger the detection module;
  • the module for calculating the total power consumption is used to detect the battery voltage, obtain the preset wake-up current value, password calculation current value, and display current value according to the detected battery voltage and the pre-stored first data table, and compare the wake-up current value with the first data table.
  • the product of the data in the register, the product of the password calculation current value and the data in the fourth register, and the product of the displayed current value and the result of subtracting the data in the fourth register from the first preset value are added to obtain the total power consumption;
  • the device further includes: a real-time clock module for measuring the time of the device, and triggering the wake-up module every first preset time;
  • the wake-up module is used to start the timer and start counting, and update the data in the second register and the sixth register with the result of adding the first preset time to the second register and the sixth register respectively.
  • the data in the sixth register is equal to
  • the fourth preset value the first flag bit is set, the data in the sixth register is cleared, the timer is turned off to stop counting, and when the wake-up time is obtained, the wake-up time is accumulated into the first register;
  • the data in the second register is equal to When the first preset value is set, the second flag bit is set, the timer is turned off to stop counting, and the wake-up time is obtained, and the wake-up time is accumulated into the first register.
  • a method for measuring the remaining power of a device including:
  • Step S1 Detect the state of the flag bit, when the first flag bit is set, execute step S2, and when the second flag bit is set, execute step S4;
  • Step S2 start the timer to start counting, calculate the password, close the timer when the password calculation is completed, stop counting to obtain the password calculation time, reset the timer, and accumulate the password calculation time into the fourth register, Execute step S3;
  • Step S3 display the password and the remaining power, reset the first flag bit, and return to step S1;
  • Step S4 Detecting the battery voltage, querying the pre-stored first data table according to the detected battery voltage, obtaining a preset current value, and calculating the total power consumption according to the current value and the corresponding time;
  • Step S5 Update the remaining power according to the total power consumption and the second preset value, reset the second flag, and return to step S1.
  • a device for measuring the remaining power of a device including:
  • the detection module is used to detect the status of the flag bit, and when the first flag bit is set, the calculation password module is triggered, and when the second flag bit is set, the calculation of the total power consumption module is triggered;
  • the password calculation module is used to start the timer and start counting, calculate the password, close the timer when the password calculation is completed, stop counting to obtain the password calculation time, reset the timer, and accumulate the password calculation time to In the fourth register, trigger the display module;
  • the display module is used to display the password and the remaining power, reset the first flag bit, and trigger the detection module;
  • the calculating total power consumption module is used to detect the battery voltage, query the pre-stored first data table according to the detected battery voltage, obtain a preset current value, and calculate the total power consumption according to the current value and the corresponding time;
  • the module for updating the remaining power is configured to update the remaining power according to the total power consumption and the second preset value, reset the second flag bit, and trigger the detection module.
  • the present invention has the following advantages:
  • a method for measuring the remaining power of a device which can improve the measurement accuracy of the remaining power without adding additional components, more accurately reflect the actual value of the remaining power of the battery, and does not increase additional power consumption; The service life of the equipment is not affected and the cost is low.
  • FIG. 1 is a flowchart of a method for measuring the remaining power of a device according to Embodiment 1 of the present invention
  • FIG. 2 is a flowchart of a method for measuring the remaining power of a device according to Embodiment 3 of the present invention
  • FIG. 3 is a flowchart of a method for measuring the remaining power of a device according to Embodiment 5 of the present invention.
  • FIG. 4 is a block diagram of an apparatus for measuring the remaining power of a device according to Embodiment 7 of the present invention.
  • FIG. 5 is a block diagram of an apparatus for measuring the remaining power of a device according to Embodiment 8 of the present invention.
  • FIG. 6 is a block diagram of a device for measuring the remaining power of a device according to Embodiment 9 of the present invention.
  • Embodiment 1 of the present invention provides a method for measuring the remaining power of a device, which is applied to an always-displayed dynamic token, as shown in FIG. 1 , including:
  • Step S1 Detect the state of the flag bit, when the first flag bit is set, execute step S2, and when the second flag bit is set, execute step S4;
  • Step S2 turn on the timer to start counting, calculate the password, close the timer when the password calculation is completed, stop counting to obtain the password calculation time, reset the timer, accumulate the password calculation time into the fourth register, and execute step S3;
  • the timer when the password calculation is completed, the timer is turned off, and the count is stopped to obtain the password calculation time, and the reset timer is specifically: when the password calculation is completed, stop the count, and obtain the third value from the timer register. , obtain the password calculation time according to the third value, and clear the third value.
  • Step S3 display the password and the remaining power, reset the first flag bit, and return to step S1;
  • Step S4 Detecting the battery voltage, obtaining the preset wake-up current value, password calculation current value, and displaying the current value according to the detected battery voltage and the pre-stored first data table, and comparing the wake-up current value with the data in the first register.
  • the product, the product of the password calculation current value and the data in the fourth register, and the product of the displayed current value and the result of subtracting the data in the fourth register from the first preset value are added to obtain the total power consumption;
  • total power consumption wake-up current value ⁇ data in the first register + password calculation current value ⁇ data in the fourth register + display current value ⁇ (first preset value - fourth register data in);
  • the pre-stored first data table is as follows:
  • the third display current password calculation The first password calculates the current
  • the second password calculates the current
  • the third password calculates the current wake first wake-up current Second wake-up current third wake-up current
  • Step S5 update the remaining power according to the total power consumption and the second preset value, reset the second flag bit, and return to step S1;
  • step S5 specifically includes:
  • Step S5-1 determine whether the total power consumption is less than the second preset value, if yes, store the total power consumption in the power consumption count register, and execute step S5-2, otherwise update the result of subtracting the third preset value from the remaining power For the remaining power, the difference between the total power consumption and the second preset value is stored in the power consumption count register, and step S5-2 is performed;
  • Step S5-2 Determine whether the value in the power consumption count register is less than the second preset value, if yes, restore the value in the second register to the initial value, reset the second flag bit, and return to step S1, otherwise the remaining power
  • the result of subtracting the third preset value is updated to the remaining power
  • the difference between the value in the power consumption register and the second preset value is updated to the power consumption count register
  • the value in the second register is restored to the initial value
  • the The second flag is reset, and the process returns to step S1.
  • step S1 to step S5 when the real-time clock interruption is detected, step A1 to step A4 are executed, and the real-time clock interruption is triggered once every first preset time;
  • Step A1 Turn on the timer and start counting, and update the result of adding the first preset time to the data in the second register and the sixth register to the second register and the sixth register, when the data in the sixth register is equal to the fourth register.
  • execute step A2 when the preset value, execute step A2;
  • Step A2 set the first flag bit, clear the data in the sixth register, and execute Step A4;
  • Step A3 set the second flag bit, and execute Step A4;
  • Step A4 The timer is turned off to stop counting, and the wake-up time is obtained, and the wake-up time is accumulated into the first register.
  • turning off the timer to stop counting, and obtaining the wake-up time specifically includes: turning off the timer to stop counting, obtaining the first value from the timer register, and clearing the first value when the wake-up time is obtained according to the first value .
  • Embodiment 2 is a diagrammatic representation of Embodiment 1:
  • the second embodiment of the present invention provides a method for measuring the remaining power of a device, which is applied to an always-displayed dynamic token, including:
  • Step 101 Power on the dynamic token, initialize the clock source frequency, frequency division coefficient, and initial count value of the timer, and enter the sleep state;
  • the dynamic token battery is set to a fully charged state
  • Step 102 when the real-time clock interruption of the dynamic token is detected, start the timer to start counting, when the real-time clock interruption ends, close the timer and stop counting, obtain the first value from the timer register, according to the first value, the timer
  • the real-time clock interrupt time is obtained from the clock source frequency, frequency division coefficient, and initial value of the count as the wake-up time, and the wake-up time is accumulated into the first register, and the first value is cleared; respectively, add the data in the second register and the sixth register
  • the result of a preset time is updated to the second register and the sixth register, and step 103 is executed; the real-time clock interrupt is triggered every first preset time;
  • the first preset time is 1 second
  • Step 103 The dynamic token judges whether the value in the sixth register is equal to the fourth preset value, if yes, executes step 104, otherwise executes step 106;
  • the fourth preset value is 60s, and the first preset value is 86400s;
  • Step 104 The dynamic token starts the timer and starts counting, calculates the password, closes the timer and stops counting when the password calculation is completed, obtains a third value from the timer register, obtains the password calculation time according to the third value, and accumulates the password calculation time To the fourth register, clear the third value;
  • password calculation time (third value-count initial value+1) ⁇ (frequency division coefficient+1)/clock source frequency;
  • Step 105 the dynamic token displays the password and remaining power, clears the data in the sixth register, and executes step 106;
  • Display the password and display the remaining power for example, set a battery symbol, set five grids, each grid represents 20% of the battery, and display the battery grid according to the specific value of the remaining battery;
  • a battery symbol which is divided into full power, half power, and low power state, corresponding to 2 grids, 1 grid, and empty boxes. Assuming that the remaining power is more than 1/3 of the nominal capacity, the two grids of the battery symbol are both displayed. Display, indicating that the current state is fully charged, when it is between 1/3-2/3, it is considered to be half power, and only one bar is displayed. When the power is lower than 1/3, it means low power, and an empty box is displayed at this time. , and flashes to remind the user that the battery power is low;
  • wake-up time (first value-count initial value+1) ⁇ (frequency division factor+1)/clock source frequency
  • Step 106 The dynamic token judges whether the value in the second register is equal to the first preset value, if yes, executes step 107, otherwise returns to step 102;
  • the first preset value is 86400 seconds, that is, every 24 hours is a cycle
  • Step 107 The dynamic token detects the battery voltage, searches the pre-stored battery voltage-current data table according to the detected battery voltage, determines the current value corresponding to each module, calculates the total power consumption, and executes step 108;
  • the third display current password calculation The first password calculates the current
  • the second password calculates the current
  • the third password calculates the current wake first wake-up current Second wake-up current third wake-up current
  • the current value corresponding to the display module is the first display current
  • the current value corresponding to the password calculation module is the first password calculation current
  • the current value corresponding to the wake-up module is the first wake-up current
  • the current value corresponding to the display module is the second display current
  • the current value corresponding to the password calculation module is the second password calculation current
  • the current value corresponding to the wake-up module is the second wake-up current current
  • the current value corresponding to the display module is the third display current
  • the current value corresponding to the password calculation module is the third password calculation current
  • the current value corresponding to the wake-up module is the third wake-up current
  • the current value corresponding to the display module is the first display current
  • the current value corresponding to the password calculation module is the first password calculation current
  • the current value corresponding to the wake-up module is the first wake-up current.
  • Display module power consumption first display current ⁇ (first preset value - password calculation time);
  • Power consumption of password calculation module first password calculation current ⁇ password calculation time
  • the password calculation time is the data in the fourth register
  • Power consumption of wake-up module first wake-up current ⁇ (wake-up duration - password calculation time);
  • the wake-up duration is the data in the first register
  • Total power consumption power consumption of display module + power consumption of password calculation module + power consumption of wake-up module
  • Step 108 The dynamic token judges whether the total power consumption is less than the second preset value, if yes, the total power consumption is stored in the power consumption count register, and step 109 is executed; otherwise, the result of subtracting the third preset value from the remaining power is updated as remaining power, store the difference between the total power consumption and the second preset value in the power consumption count register, and execute step 109;
  • Step 109 The dynamic token determines whether the value in the power consumption count register is less than the second preset value, if yes, clears the data in the second register, and returns to step 102, otherwise updates the result of subtracting the third preset value from the remaining power For the remaining power, the difference between the value in the power consumption counting register and the second preset value is updated into the power consumption counting register, the data in the second register is cleared, and the process returns to step 102 .
  • Embodiment 3 of the present invention provides a method for measuring the remaining power of a device, which is applied to a button-type dynamic token, as shown in FIG. 2 , including:
  • Step Q1 Detect the state of the flag bit, when the first flag bit is set, execute step Q2, and when the second flag bit is set, execute step Q4;
  • Step Q2 start the timer to start counting, calculate the password, close the timer when the password calculation is completed, stop counting to obtain the password calculation time, reset the timer, accumulate the password calculation time into the fourth register, and execute step Q3;
  • Step Q3 Turn on the timer to start counting, display the password and remaining power, when the display ends, turn off the timer to stop counting, get the display time, reset the timer, accumulate the display time into the fifth register, and reset the first flag bit , return to step Q1;
  • Step Q4 Detect the battery voltage, obtain the preset wake-up current value, password calculation current value, button current value, display current value and sleep current value according to the detected battery voltage and the pre-stored first data table, and the wake-up current value will be The product of the data in the first register, the product of the password calculation current value and the data in the fourth register, the product of the key current value and the data in the third register, the product of the display current value and the data in the fifth register, The total power consumption is obtained by adding the product of the sleep current value and the first preset value minus the result of the data in the first register, the fourth register, the third register, and the fifth register;
  • total power consumption wake-up current value ⁇ data in the first register + password calculation current value ⁇ data in the fourth register + key current value ⁇ data in the third register + display current ⁇ data in the fifth register + sleep current ⁇ (first preset value - data in the first register - data in the fourth register - data in the third register - data in the fifth register);
  • the pre-stored first data table is as follows:
  • the third display current password calculation The first password calculates the current The second password calculates the current The third password calculates the current hibernate first sleep current second sleep current third sleep current wake first wake-up current Second wake-up current third wake-up current
  • Step Q5 update the remaining power according to the total power consumption and the second preset value, reset the second flag bit, and return to step Q1;
  • step Q1 to step Q5 when the real-time clock interruption is detected, step B1 to step B2 are executed, and the real-time clock interruption is triggered once every first preset time;
  • Step B1 start the timer to start counting, update the result of adding the data in the second register to the first preset time to the second register, and determine whether the data in the second register is equal to the first preset value, The second flag bit is set, and step B2 is performed, otherwise, step B2 is performed;
  • Step B2 turn off the timer and stop counting, get the wake-up time, and accumulate the wake-up time into the first register;
  • step Q1 to step Q5 it also includes: when a key-press interruption is detected, start the timer to start counting, set the first flag bit, turn off the timer and stop counting when the second level is detected, and obtain the key-press duration , save the duration of the keypress to the third register, and exit the keypress interrupt.
  • the timer when the password calculation is completed, the timer is turned off, and the count is stopped to obtain the password calculation time, and the reset timer is specifically: when the password calculation is completed, stop the count, and obtain the third value from the timer register. , obtain the password calculation time according to the third value, and clear the third value.
  • turning off the timer to stop counting, and obtaining the wake-up time specifically includes: turning off the timer to stop counting, obtaining a first value from the timer register, and clearing the first value when the wake-up time is obtained according to the first value .
  • the timer when the display ends, the timer is stopped to obtain the display time, and the reset of the timer is specifically: stop the count when the display ends, obtain a fourth value from the timing register, and according to the fourth value Get the display duration, accumulate the display duration into the fifth register, and clear the fourth value.
  • step Q3 further includes: when the first level is detected, the display ends, the timer is turned on to start counting, when the second level is detected, the timer is turned off to stop counting, and the timer is turned off from the timer.
  • the second value is obtained from the register, the duration of the keypress is obtained according to the second value, the duration of the keypress is accumulated into the third register, and the second value is cleared.
  • the timer when the second level is detected, the timer is turned off to stop counting, and the obtained key duration is specifically: when the second level is detected, the timer is turned off and stops counting, and the first timer is obtained from the timer register. Two values, according to the second value to get the duration of the key, and clear the second value.
  • step Q3 is replaced with: start the timer to start counting, display the password, stop counting when the display ends, obtain the display time, accumulate the display time into the fifth register, and set the first flag bit Reset and return to step Q1.
  • step Q3 further includes: when the first level is detected, start the second timer to start counting; when the second level is detected, turn off the second timer and stop counting; Obtain the fifth value from the timer register, obtain the key duration according to the fifth value, accumulate the key duration into the third register, clear the fifth value, and switch the screen to display the remaining battery if the key duration is greater than or equal to the fifth preset value; If the duration of the key press is less than the fifth preset value, the timer is turned off to stop counting, the fourth value is obtained from the timing register, the display duration is obtained according to the fourth value, the display duration is accumulated into the fifth register, and the fourth value is cleared.
  • step Q5 specifically includes:
  • Step Q5-1 determine whether the total power consumption is less than the second preset value, if yes, store the total power consumption in the power consumption count register, and execute step Q5-2, otherwise, update the result of subtracting the third preset value from the remaining power For the remaining power, the difference between the total power consumption and the second preset value is stored in the power consumption count register, and step Q5-2 is performed;
  • Step Q5-2 Determine whether the value in the power consumption count register is less than the second preset value, if yes, restore the value in the second register to the initial value, reset the second flag bit, and return to step Q1, otherwise the remaining power will be reset.
  • the result of subtracting the third preset value is updated to the remaining power, the difference between the value in the power consumption register and the second preset value is updated to the power consumption count register, the value in the second register is restored to the initial value, and the The second flag bit is reset, and the process returns to step Q1.
  • Embodiment 4 is a diagrammatic representation of Embodiment 4:
  • Embodiment 4 of the present invention provides a method for measuring the remaining power of a device, which is applied to a key-type dynamic token, including:
  • Step 201 The dynamic token is powered on, and the clock source frequency, frequency division coefficient, and initial count value of the timer are initialized;
  • the dynamic token battery is set to a fully charged state
  • Step 202 the dynamic token enters a dormant state
  • Step 203 The dynamic token judges whether the real-time clock interruption occurs, and if yes, starts the timer and starts counting.
  • the real-time clock interruption ends, closes the timer and stops counting, obtains the first value from the timer register, and according to the first value and timing
  • the real-time clock interrupt time is obtained from the clock source frequency, frequency division coefficient, and initial count value of the controller, and the real-time clock interrupt time is used as the wake-up time.
  • the wake-up time is accumulated in the first register, the first value is cleared, and step 204 is performed, otherwise, step 205 is performed; Triggered once every first preset time;
  • wake-up time (first value-count initial value+1) ⁇ (frequency division factor+1)/clock source frequency
  • Step 204 The dynamic token updates the result of adding the value in the second register to the first preset time to the second register, and when the value in the second register is equal to the first preset value, execute step 209;
  • the first preset value is 86400 seconds, that is, every 24 hours is a cycle
  • Step 205 The dynamic token judges whether the button is triggered by the user, if yes, executes step 206, otherwise returns to step 203;
  • Step 206 Turn on the timer and start counting.
  • the second level When the second level is detected, turn off the timer and stop counting.
  • the clock source frequency of the timer, the frequency division coefficient, and the initial count The value gets the duration of the keystroke, and the keystroke duration is accumulated into the third register, and the second value is cleared;
  • the second level when the second level is a high level, a low level is detected when the button is triggered by the user; when the second level is a low level, a high level is detected when the button is triggered by the user;
  • the duration of the keypress (the second numerical value ⁇ the initial count value+1) ⁇ (frequency division coefficient+1)/the frequency of the clock source;
  • Step 207 the dynamic token starts the timer and starts counting, calculates the password, closes the timer and stops counting after the password calculation is completed, obtains the third value from the timer register, and obtains the third value from the timer register, according to the third value, the clock source frequency of the timer, and the frequency division
  • the coefficient and the initial value of the count get the password calculation time, and the password calculation time is accumulated and stored in the fourth register, and the third value is cleared;
  • password calculation time (third value-count initial value+1) ⁇ (frequency division coefficient+1)/clock source frequency;
  • Step 208 The dynamic token starts the timer and starts counting, displays the password and the remaining power, and determines whether the user's key trigger is received. If yes, the timer is turned off to stop counting, and a fourth value is obtained from the timer register. According to the fourth value, The clock source frequency, frequency division coefficient, and initial count value of the timer are used to obtain the display duration. The display duration is accumulated into the fifth register, the fourth value is cleared, and the process returns to step 203. Otherwise, the preset display duration is accumulated into the fifth register. Clear the value in the timing register, and return to step 203;
  • display password duration (fourth numerical value-count initial value+1) ⁇ (frequency division coefficient+1)/clock source frequency
  • the method further includes: the dynamic token starts the timer and starts counting, when the second level is detected, the timer is turned off and stops counting, and the second value is obtained from the timer register, according to the second level.
  • the value, the clock source frequency of the timer, the frequency division coefficient, and the initial count value get the button duration, and the button duration is accumulated and stored in the third register, and the second value is cleared;
  • the user key trigger when the second level is a high level, the user key trigger is a low level; when the second level is a low level, the user key trigger is a high level;
  • the password is displayed while the remaining power is displayed.
  • a battery symbol is set, five grids are set, each grid represents 20% of the battery, and the battery grid is displayed correspondingly according to the specific value of the remaining battery;
  • a battery symbol which is divided into full power, half power, and low power state, and display 2 grids, 1 grid, and empty boxes respectively. Assuming that the remaining power is above 1/3 of the nominal capacity, the battery symbol has two grids. Both are displayed, indicating that the current state is full power. When it is between 1/3 and 2/3, it is considered to be half power, and only one bar is displayed. When the power is less than 1/3, it means low power, and an empty display is displayed. box, and flashes to remind the user that the battery power is low;
  • step 208 can be replaced by: the dynamic token starts the timer to start timing, displays the password, stops counting when the display ends, obtains the fourth value from the timing register, obtains the display duration according to the fourth value, and stores the display duration in an accumulated manner. To the fifth register, clear the fourth value;
  • step 208 further includes:
  • the second timer When the first level is detected, the second timer is turned on to start timing, and when the second level is detected, the second timer is turned off to stop timing, and the fifth value is obtained from the second timer register, and the button duration is obtained according to the fifth value, Accumulate the keypress duration into the third register. If the keypress duration is greater than or equal to the fifth preset value, switch the screen to display the remaining power; if the keypress duration is less than the fifth preset value, turn off the timer and stop counting, and obtain the first key from the timer register.
  • the display duration is obtained according to the fourth numerical value, the display duration is accumulated into the fifth register, and the fourth numerical value is cleared;
  • the fifth preset value is 3s
  • the second level when the first level is a high level, the second level is a low level, and when the first level is a low level, the second level is a high level;
  • the duration of the keypress (the second numerical value ⁇ the initial count value+1) ⁇ (frequency division coefficient+1)/the frequency of the clock source;
  • Step 209 the dynamic token detects the battery voltage, searches the pre-stored battery voltage-current data table according to the detected battery voltage, determines the current value corresponding to each module, calculates the total power consumption, and executes step 210;
  • the mean value filtering method is used to continuously take a plurality of sampling values for arithmetic average operation
  • the pre-stored battery voltage-current data table is shown below:
  • the third button current show first display current Second display current
  • the third display current password calculation The first password calculates the current
  • the second password calculates the current
  • the third password calculates the current hibernate first sleep current second sleep current third sleep current wake first wake-up current Second wake-up current third wake-up current
  • the current value corresponding to the button module is the first button current value
  • the current value corresponding to the display module is the first display current value
  • the password is the first password calculation current
  • the current value corresponding to the sleep module is the first sleep current value
  • the current value corresponding to the wake-up module is the first wake-up current
  • the current value corresponding to the key module is the second key current value
  • the current value corresponding to the display module is the second display current value
  • the current value corresponding to the password calculation module is the second password calculation module.
  • current, the current value corresponding to the sleep module is the second sleep current value
  • the current value corresponding to the wake-up module is the second wake-up current;
  • the current value corresponding to the button module is the third button current
  • the current value corresponding to the display module is the third display current
  • the current value corresponding to the password calculation module is the third password calculation current
  • the corresponding current value of the sleep module is the third password calculation current.
  • the current value is the third sleep current
  • the current value corresponding to the wake-up module is the third wake-up current
  • the current value corresponding to the button module is the first button current value
  • the current value corresponding to the display module is the first display current value
  • the current value corresponding to the password calculation module is the first password calculation current value
  • the current value corresponding to the sleep module is the first sleep current
  • the current value corresponding to the wake-up module is the first wake-up current
  • the power consumption of the five functional modules is calculated respectively;
  • the power consumption of the button module the current of the first button ⁇ the total duration of the button;
  • the total duration of the key press is the data in the third register
  • Display module power consumption first display current ⁇ total display time
  • the display total duration is the data in the fifth register
  • Power consumption of password calculation module first password calculation current ⁇ password calculation time
  • the password calculation time is the data in the fourth register
  • Power consumption of wake-up module first wake-up current ⁇ wake-up duration
  • the wake-up duration is the data in the second register
  • Power consumption of the sleep module first sleep current ⁇ (first preset value - total display time - total key press time - password calculation time - wake-up time);
  • Total power consumption power consumption of button module + power consumption of display module + power consumption of password calculation module + power consumption of sleep module + power consumption of wake-up module;
  • Step 210 The dynamic token determines whether the total power consumption is less than the second preset value. If yes, the total power consumption is stored in the power consumption count register, and step 211 is executed. Otherwise, the result of subtracting the third preset value from the remaining power is updated as remaining power, store the difference between the total power consumption and the second preset value in the power consumption count register, and execute step 211;
  • the second preset value is 2700000uAs
  • the third preset value is 1%
  • Step 211 The dynamic token determines whether the value in the power consumption count register is less than the second preset value, if yes, clears the data in the second register, and returns to step 203, otherwise updates the result of subtracting the third preset value from the remaining power For remaining power, the difference between the value in the power consumption counting register and the second preset value is updated into the power consumption counting register, the data in the second register is cleared, and the process returns to step 203 .
  • Embodiment 5 is a diagrammatic representation of Embodiment 5:
  • Embodiment 5 of the present invention provides a method for measuring the remaining power of a device, which is applied to a Bluetooth card, as shown in FIG. 3 , including:
  • Step M1 detect the flag bit state, when the first flag bit is set, execute step M2, and when the second flag bit is set, execute step M4;
  • Step M2 start the timer and start counting, calculate the password, close the timer when the password calculation is completed, stop counting to obtain the password calculation time, reset the timer, accumulate the password calculation time into the fourth register, start the timer and start counting, Perform Bluetooth pairing with the host computer.
  • the pairing is successful, turn off the timer and stop counting to get the Bluetooth pairing time.
  • Reset the timer add the Bluetooth pairing time to the eighth register, start the timer and start counting, and send the password to the host computer through Bluetooth.
  • turn off the timer and stop counting to obtain the Bluetooth communication time and accumulate it into the seventh register, reset the timer, and execute step M3;
  • Step M3 Turn on the timer and start counting, display the password and the remaining power, when the display ends, turn off the timer and stop counting, get the display time, reset the timer, accumulate the display time into the fifth register, and reset the first flag bit , return to step M1;
  • Step M4 Detect the battery voltage, and obtain the preset wake-up current value, password calculation current value, button current value, display current value, Bluetooth communication current value, and Bluetooth pairing current according to the detected battery voltage and the pre-stored first data table value, sleep current value, the product of the wake-up current value and the data in the first register, the product of the password calculation current value and the data in the fourth register, the product of the key current value and the data in the third register, the display current value
  • the product of the results of the data in the register, the fourth register, the third register, the fifth register, the seventh register, and the eighth register is added to obtain the total power consumption;
  • total power consumption wake-up current value x data in the first register + password calculation current value x data in the fourth register + key current value x data in the third register + display current ⁇ data in the fifth register + Bluetooth communication current value ⁇ data in the seventh register + Bluetooth pairing current value ⁇ data in the eighth register + sleep current ⁇ (first preset value - data in the first register - the first data in the fourth register - data in the third register - data in the fifth register - data in the seventh register - data in the eighth register);
  • the pre-stored first data table is as follows:
  • Step M5 update the remaining power according to the total power consumption and the second preset value, reset the second flag bit, and return to step M1;
  • step M1 to step M5 it also includes: when detecting that the real-time clock is interrupted, execute step B1 to step B2, and the real-time clock interrupt is triggered once every first preset time;
  • Step B1 start the timer to start counting, update the result of adding the data in the second register to the first preset time to the second register, and determine whether the data in the second register is equal to the first preset value, The second flag bit is set, and step B2 is performed, otherwise, step B2 is performed;
  • Step B2 turn off the timer and stop counting, get the wake-up time, and accumulate the wake-up time into the first register;
  • step M1 to step M5 it also includes: when the key-press interruption is detected, start the timer to start counting, set the first flag bit, turn off the timer and stop counting when the second level is detected, and obtain the key-press duration , save the duration of the keypress to the third register, and exit the keypress interrupt.
  • obtaining the Bluetooth pairing time is specifically: obtaining the seventh numerical value from the timer, and obtaining the Bluetooth pairing time according to the seventh numerical value;
  • the obtaining of the Bluetooth communication time is specifically: obtaining the sixth numerical value from the timing register, and obtaining the Bluetooth communication time according to the sixth numerical value.
  • the timer when the password calculation is completed, the timer is turned off, and the count is stopped to obtain the password calculation time, and the reset timer is specifically: when the password calculation is completed, stop the count, and obtain the third value from the timer register. , obtain the password calculation time according to the third value, and clear the third value.
  • turning off the timer to stop counting, and obtaining the wake-up time specifically includes: turning off the timer to stop counting, obtaining a first value from the timer register, and clearing the first value when the wake-up time is obtained according to the first value .
  • the timer when the display ends, the timer is stopped to obtain the display time, and the reset timer is specifically: stop the count when the display ends, obtain the fourth value from the timing register, and obtain the display according to the fourth value. duration, the display duration is accumulated and stored in the fifth register, and the fourth value is cleared.
  • step M3 further includes: when the first level is detected, the display ends, the timer is turned on to start counting, when the second level is detected, the timer is turned off to stop counting, and the timer is turned off from the timer.
  • the second value is obtained from the register, the duration of the keypress is obtained according to the second value, the duration of the keypress is accumulated into the third register, and the second value is cleared.
  • the timer when the second level is detected, the timer is turned off to stop counting, and the obtained key duration is specifically: when the second level is detected, the timer is turned off and stops counting, and the first count is obtained from the timer register. Two values, according to the second value to get the duration of the key, and clear the second value.
  • step M3 is replaced with: start the timer to start counting, display the password, stop counting when the display ends, obtain the display time, accumulate the display time into the fifth register, and set the first flag bit Reset and return to step S1.
  • step M3 further includes:
  • the second timer When the first level is detected, the second timer is turned on to start counting, when the second level is detected, the second timer is turned off to stop counting, the fifth value is obtained from the second timer register, and the key-press duration is obtained according to the fifth value , accumulate the keypress duration into the third register, clear the fifth value, if the keypress duration is greater than or equal to the fifth preset value, switch the screen to display the remaining power; if the keypress duration is less than the fifth preset value, turn off the timer and stop counting , obtain the fourth value from the timing register, obtain the display duration according to the fourth value, accumulate the display duration into the fifth register, and clear the fourth value.
  • step M5 specifically includes:
  • Step M5-1 Determine whether the total power consumption is less than the second preset value, if yes, store the total power consumption in the power consumption count register, and execute Step M5-2, otherwise update the result of subtracting the third preset value from the remaining power For the remaining power, the difference between the total power consumption and the second preset value is stored in the power consumption count register, and step M5-2 is performed;
  • Step M5-2 Determine whether the value in the power consumption count register is less than the second preset value, if yes, restore the value in the second register to the initial value, reset the second flag bit, and return to step M1, otherwise the remaining power will be reset.
  • the result of subtracting the third preset value is updated to the remaining power, the difference between the value in the power consumption register and the second preset value is updated to the power consumption count register, the value in the second register is restored to the initial value, and the The second flag is reset, and the process returns to step M1.
  • Embodiment 6 is a diagrammatic representation of Embodiment 6
  • Embodiment 6 of the present invention provides a method for measuring the remaining power of a device, which is applied to a Bluetooth card, including:
  • Step 301 The Bluetooth card is powered on, and the clock source frequency, frequency division coefficient, and initial count value of the timer are initialized;
  • the battery of the Bluetooth card is set to a fully charged state
  • Step 302 the Bluetooth card enters a dormant state
  • Step 303 The Bluetooth card determines whether the real-time clock interrupt occurs, and if so, starts the timer and starts counting. When the real-time clock interrupt ends, the timer is turned off to stop counting, and the first value is obtained from the timer register. According to the first value, the timer The clock source frequency, frequency division coefficient, and initial count value are obtained from the real-time clock interrupt time as the wake-up time, and the wake-up time is accumulated in the first register, the first value is cleared, and step 304 is performed, otherwise, step 305 is performed; Triggered at the first preset time;
  • the first preset time is 1 second
  • wake-up time (first value-count initial value+1) ⁇ (frequency division factor+1)/clock source frequency
  • Step 304 the Bluetooth card updates the result of adding the value in the second register to the first preset time to the second register, and when the value in the second register is equal to the first preset value, execute step 309;
  • the first preset value is 86400 seconds, that is, every 24 hours is a cycle
  • Step 305 the Bluetooth card determines whether the button is triggered by the user, and if yes, executes step 306, otherwise returns to step 303;
  • Step 306 Turn on the timer to start counting, turn off the timer and stop counting when the second level is detected, obtain the second value from the timer register, and according to the second value, the clock source frequency of the timer, the frequency division coefficient, and the initial count The value gets the duration of the keystroke, and the keystroke duration is accumulated and stored in the third register, and the second value is cleared;
  • the duration of the keypress (the second numerical value ⁇ the initial count value+1) ⁇ (frequency division coefficient+1)/the frequency of the clock source;
  • Step 307 The Bluetooth card starts the timer and starts counting, calculates the password, closes the timer and stops counting when the password is calculated, and obtains a third value from the timer register, according to the third value, the clock source frequency of the timer, and the frequency division coefficient ⁇ Count the initial value to get the password calculation time, accumulate the password calculation time into the fourth register, clear the third value, start the timer to start counting, pair with the host computer via Bluetooth, when the pairing is successful, close the timer and stop counting, and start the timer from the timer.
  • the seventh value is obtained from the register, and the Bluetooth pairing time is obtained according to the seventh value, the clock source frequency of the timer, the frequency division coefficient, and the initial count value.
  • the Bluetooth pairing time is accumulated into the eighth register, the seventh value is cleared, and the timer is turned on. Start counting, send the password to the host computer through Bluetooth, close the timer to stop counting, obtain the sixth value from the timing register, and obtain the Bluetooth communication time according to the sixth value, the clock source frequency of the timer, the frequency division coefficient, and the initial count value. , accumulate the Bluetooth communication time into the seventh register, and clear the sixth value;
  • password calculation duration (third value-count initial value+1) ⁇ (frequency division coefficient+1)/clock source frequency
  • Bluetooth pairing time (seventh numerical value ⁇ count initial value+1) ⁇ (frequency division coefficient+1)/clock source frequency;
  • Bluetooth communication time (sixth numerical value ⁇ count initial value+1) ⁇ (frequency division coefficient+1)/clock source frequency;
  • the remaining power is displayed while the data is displayed.
  • a battery symbol is set, five grids are set, each grid represents 20% of the power, and the battery grid is correspondingly displayed according to the specific value of the remaining power;
  • a battery symbol which is divided into full power, half power, and low power state, and display 2 grids, 1 grid, and empty boxes respectively. Assuming that the remaining power is above 1/3 of the nominal capacity, the battery symbol has two grids. Both are displayed, indicating that the current state is full power. When it is between 1/3 and 2/3, it is considered to be half power, and only one bar is displayed. When the power is less than 1/3, it means low power, and an empty display is displayed. box, and flashes to remind the user that the battery power is low;
  • Step 308 The Bluetooth card starts the timer and starts counting, displays the password and the remaining power, and determines whether the user's key trigger is received. If yes, the timer is turned off to stop counting, and the fourth value is obtained from the timer register. According to the fourth value, timing The clock source frequency, frequency division coefficient, and initial count value of the device are used to obtain the display duration. The display duration is accumulated and stored in the fifth register, the fourth value is cleared, and the process returns to step 303. Otherwise, the preset display duration is accumulated into the fifth register. Clear the value in the timing register, and return to step 303;
  • display duration (fourth numerical value-count initial value+1) ⁇ (frequency division coefficient+1)/clock source frequency;
  • the method further includes: the Bluetooth card starts the timer and starts counting, when the second level is detected, the timer is turned off and stops counting, and the second value is obtained from the timer register, according to the second value.
  • the clock source frequency, frequency division coefficient, and initial count value of the timer get the duration of the keystroke, accumulate the keystroke duration into the third register, and clear the second value;
  • step 308 can be replaced with: the Bluetooth card starts the timer to start timing, displays the password, stops counting when the password is displayed, and obtains the fourth value from the timing register, obtains the display duration according to the fourth value, and accumulates the display duration to In the fifth register, clear the fourth value;
  • step 308 further includes:
  • the second timer When the first level is detected, the second timer is turned on to start timing, and when the second level is detected, the second timer is turned off to stop timing, and the fifth value is obtained from the second timer register, and the button duration is obtained according to the fifth value, Accumulate the keypress duration into the third register. If the keypress duration is greater than or equal to the fifth preset value, switch the screen to display the remaining power; if the keypress duration is less than the fifth preset value, turn off the timer and stop counting, and obtain the first key from the timer register.
  • the display duration is obtained according to the fourth numerical value, the display duration is accumulated and stored in the fifth register, and the fourth numerical value is cleared;
  • the fifth preset value is 3s
  • the second level when the first level is a high level, the second level is a low level, and when the first level is a low level, the second level is a high level;
  • the duration of the keypress (the second numerical value ⁇ the initial count value+1) ⁇ (frequency division coefficient+1)/the frequency of the clock source;
  • Step 309 the Bluetooth card detects the battery voltage, searches the pre-stored battery voltage-current data table according to the detected battery voltage, determines the current value corresponding to each module, calculates the total power consumption, and executes step 310;
  • the mean value filtering method is used to continuously take a plurality of sampling values for arithmetic average operation
  • the pre-stored battery voltage-current data table is shown below:
  • the third button current show first display current Second display current
  • the third display current hibernate first sleep current second sleep current third sleep current wake first wake-up current Second wake-up current third wake-up current password calculation
  • the first password calculates the current
  • the second password calculates the current
  • the third password calculates the current Bluetooth communication
  • the current value corresponding to the button module is the first button current value
  • the current value corresponding to the display module is the first display current value
  • the current value corresponding to the sleep module is the first sleep current value
  • the current value corresponding to the wake-up module is the first wake-up current value
  • the current value corresponding to the password calculation module is the first password calculation current value
  • the current value corresponding to the Bluetooth communication module is the first Bluetooth communication value.
  • Current, the current value corresponding to the Bluetooth pairing module is the first Bluetooth pairing current;
  • the current value corresponding to the button module is the second button current
  • the current value corresponding to the display module is the second display current
  • the current value corresponding to the sleep module is the second sleep current value
  • the current value corresponding to the wake-up module is the second wake-up current
  • the current value corresponding to the password calculation module is the second password calculation current
  • the current value corresponding to the Bluetooth communication module is the second Bluetooth communication current
  • the current value corresponding to the Bluetooth pairing module is the second current value.
  • the current value corresponding to the button module is the third button current value
  • the current value corresponding to the display module is the third display current value
  • the current value corresponding to the sleep module is the third sleep current value
  • the current value corresponding to the wake-up module is the third wake-up current
  • the current value corresponding to the password calculation module is the third password calculation current
  • the current value corresponding to the Bluetooth communication module is the third Bluetooth communication current
  • the current value corresponding to the Bluetooth pairing module is the third Bluetooth pairing current;
  • the current value corresponding to the button module is the first button current value
  • the current value corresponding to the display module is the first display current value
  • the current value corresponding to the sleep module is the first sleep current value
  • the wake-up module is the first sleep current value.
  • the corresponding current value is the first wake-up current
  • the current value corresponding to the password calculation module is the first password calculation current
  • the current value corresponding to the Bluetooth communication module is the first Bluetooth communication current
  • the current value corresponding to the Bluetooth pairing module is the first Bluetooth pairing current. current, calculate the power consumption of the seven functional modules respectively;
  • the power consumption of the button module the current of the first button ⁇ the total duration of the button;
  • the total duration of the key press is the data in the third register
  • Display module power consumption first display current ⁇ total display time
  • the display total duration is the data in the fifth register
  • Power consumption of wake-up module first wake-up current ⁇ wake-up duration
  • the wake-up duration is the data in the second register
  • Power consumption of password calculation module first password calculation current ⁇ total password calculation time
  • the password calculation total duration is the data in the fourth register
  • Power consumption of the Bluetooth communication module first Bluetooth communication current ⁇ Bluetooth communication time
  • the Bluetooth communication time is the data in the seventh register
  • Bluetooth pairing module power consumption first Bluetooth pairing current ⁇ Bluetooth pairing time
  • the Bluetooth pairing time is the data in the eighth register
  • the power consumption of the sleep module the first sleep current ⁇ (the first preset value - the total display time - the total key press time - the wake-up time - the total password calculation time - Bluetooth communication time - Bluetooth pairing time);
  • Total power consumption power consumption of button module + power consumption of display module + power consumption of sleep module + power consumption of wake-up module + power consumption of password calculation module + power consumption of Bluetooth communication module + power consumption of Bluetooth pairing module;
  • Step 310 The Bluetooth card determines whether the total power consumption is less than the second preset value, if yes, the total power consumption is stored in the power consumption count register, and step 311 is executed; otherwise, the result of subtracting the third preset value from the remaining power is updated to the remaining power power, and store the difference between the total power consumption and the second preset value in the power consumption count register, and execute step 311;
  • the second preset value is 2700000uAs
  • the third preset value is 1%
  • Step 311 The Bluetooth card judges whether the value in the power consumption count register is less than the second preset value, if yes, clears the data in the second register, and returns to step 303, otherwise the result of subtracting the third preset value from the remaining power is updated to For the remaining power, the difference between the value in the power consumption count register and the second preset value is updated to the power consumption count register, the data in the second register is cleared, and the process returns to step 303 .
  • Embodiment 7 is a diagrammatic representation of Embodiment 7:
  • Embodiment 7 of the present invention provides a device for measuring the remaining power of a device, which is applied to a normally-displayed dynamic token, as shown in FIG. 4 , including:
  • the detection module 11 is used to detect the status of the flag bit, when the first flag bit is set, the password calculation module 12 is triggered, and when the second flag bit is set, the total power consumption calculation module 14 is triggered;
  • the password calculation module 12 is used to start the timer and start counting, calculate the password, close the timer when the password calculation is completed, stop counting to obtain the password calculation time, reset the timer, accumulate the password calculation time into the fourth register, and trigger the display module 13;
  • the display module 13 is used to display the password and the remaining power, reset the first flag bit, and trigger the detection module 11;
  • the total power consumption calculation module 14 is used to detect the battery voltage, obtain the preset wake-up current value, password calculation current value, and display current value according to the detected battery voltage and the pre-stored first data table, and compare the wake-up current value with the first data table.
  • the product of the data in one register, the product of the password calculation current value and the data in the fourth register, and the product of the display current value and the result of subtracting the data in the fourth register from the first preset value are added to obtain the total power consumption;
  • the device further includes: a real-time clock module for measuring the time of the equipment, and triggering the wake-up module every first preset time;
  • the wake-up module is used to start the timer and start counting, and update the data in the second register and the sixth register with the result of adding the first preset time to the second register and the sixth register respectively.
  • the data in the sixth register is equal to
  • the fourth preset value the first flag bit is set, the data in the sixth register is cleared, the timer is turned off to stop counting, and when the wake-up time is obtained, the wake-up time is accumulated into the first register;
  • the data in the second register is equal to When the first preset value is set, the second flag bit is set, the timer is turned off to stop counting, and the wake-up time is obtained, and the wake-up time is accumulated into the first register.
  • the password calculation module 12 is further configured to stop counting when the password calculation is completed, obtain a third value from the timer register, obtain the password calculation time according to the third value, and clear the third value.
  • the wake-up module is further configured to turn off the timer to stop counting, obtain the first value from the timer register, and clear the first value when the wake-up is obtained according to the first value.
  • updating the remaining power module 15 includes:
  • the first judgment sub-module is used to judge whether the total power consumption is less than the second preset value. If yes, the total power consumption is stored in the power consumption count register, and the second judgment sub-module is triggered. Otherwise, the remaining power is reduced by the third preset value. The result of the value is updated to the remaining power, and the difference between the total power consumption and the second preset value is stored in the power consumption count register, and the second judgment sub-module is triggered;
  • the second judging sub-module is used to judge whether the value in the power consumption counting register is less than the second preset value, if yes, restore the value in the second register to the initial value, reset the second flag bit, and trigger the detection module 11, Otherwise, the result of subtracting the third preset value from the remaining power is updated as the remaining power, the difference between the value in the power consumption register and the second preset value is updated to the power consumption count register, and the value in the second register is restored to Initial value, reset the second flag bit, and trigger the detection module 11 .
  • Embodiment 8 is a diagrammatic representation of Embodiment 8
  • the eighth embodiment of the present invention provides a device for measuring the remaining power of a device, which is applied to a button-type dynamic token, as shown in FIG. 5 , including:
  • the detection module 21 is used to detect the status of the flag bit, triggering the calculation password module 22 when the first flag bit is set, and triggering the calculation of the total power consumption module 24 when the second flag bit is set;
  • the password calculation module 22 is used to start the timer and start counting, calculate the password, close the timer when the password calculation is completed, stop counting to obtain the password calculation time, reset the timer, accumulate the password calculation time into the fourth register, and trigger the display module 23;
  • the display module 23 is used to turn on the timer and start counting, display the password and the remaining power, when the display ends, turn off the timer to stop counting, obtain the display time, reset the timer, accumulate the display time into the fifth register, and store the first The flag bit is reset, and the detection module 21 is triggered;
  • the total power consumption calculation module 24 is used to detect the battery voltage, and obtain the preset wake-up module current value, password calculation current value, key current value, display current value and sleep according to the detected battery voltage and the pre-stored first data table.
  • Current value, the product of the wake-up current value and the data in the first register, the product of the password calculation current value and the data in the fourth register, the product of the key current value and the data in the third register, the display current value and the fifth The product of the data in the register, the sleep current value and the first preset value minus the product of the data in the first register, the fourth register, the third register, and the fifth register are added to obtain the total power consumption;
  • the device further includes: a real-time clock module for measuring the time of the equipment, and triggering the wake-up module every first preset time;
  • the wake-up module is specifically used to start the timer to start counting, update the result of adding the data in the second register to the first preset time to the second register, and determine whether the data in the second register is equal to the first preset value, yes Then set the second flag bit, turn off the timer and stop counting, get the wake-up time, and accumulate the wake-up time into the first register; otherwise, turn off the timer and stop counting, get the wake-up time, and accumulate the wake-up time into the first register;
  • the key interrupt module is used to turn on the timer and start counting, set the first flag bit, turn off the timer and stop counting when the second level is detected, get the key duration, and save the key duration to the third register, and exit the key interrupt .
  • the password calculation module 22 is further configured to stop counting when the password calculation is completed, obtain a third value from the timer register, obtain the password calculation time according to the third value, and clear the third value.
  • the wake-up module is further configured to turn off the timer to stop counting, obtain the first value from the timer register, and clear the first value when the wake-up is obtained according to the first value.
  • the display module 23 is further configured to stop counting when the display ends, obtain the fourth value from the timing register, obtain the display duration according to the fourth value, and store the display duration in the fifth register. , clear the fourth value.
  • the display module 23 is further configured to end the display when the first level is detected, turn on the timer to start counting, and when the second level is detected, turn off the timer to stop counting, and start counting from the timer.
  • the second value is obtained from the register register, the duration of the keypress is obtained according to the second value, the duration of the keypress is accumulated into the third register, and the second value is cleared.
  • the key interrupt module is further configured to turn off the timer and stop counting when the second level is detected, obtain the second value from the timer register, obtain the key press duration according to the second value, and clear the second value.
  • the display module 23 is replaced with a second display module, which is used to start the timer to start counting, display the password, stop counting when the display ends, obtain the display time, and accumulate the display time to the fifth register , reset the first flag bit to trigger the detection module.
  • the second display module is further configured to turn on the second timer to start counting when the first level is detected, and turn off the second timer to stop counting when the second level is detected.
  • the fifth value is obtained from the second timer register, the duration of the key press is obtained according to the fifth value, the key duration is accumulated and stored in the third register, and the fifth value is cleared. If the key duration is greater than or equal to the fifth preset value, the screen display will be switched. Remaining power; if the duration of the key press is less than the fifth preset value, the timer is turned off to stop counting, the fourth value is obtained from the timing register, the display duration is obtained according to the fourth value, the display duration is accumulated and stored in the fifth register, and the first value is cleared.
  • updating the remaining power module 25 includes:
  • the first judgment sub-module is used to judge whether the total power consumption is less than the second preset value. If yes, the total power consumption is stored in the power consumption count register, and the second judgment sub-module is triggered; otherwise, the remaining power is reduced by the third preset value. The result of the value is updated to the remaining power, and the difference between the total power consumption and the second preset value is stored in the power consumption count register, and the second judgment sub-module is triggered;
  • the second judgment sub-module is used for judging whether the value in the power consumption count register is less than the second preset value, if yes, restore the value in the second register to the initial value, reset the second flag bit, and trigger the detection module 21, Otherwise, the result of subtracting the third preset value from the remaining power is updated as the remaining power, the difference between the value in the power consumption register and the second preset value is updated to the power consumption count register, and the value in the second register is restored to The initial value, reset the second flag bit, and trigger the detection module 21 .
  • Embodiment 9 is a diagrammatic representation of Embodiment 9:
  • Embodiment 9 of the present invention provides a device for measuring the remaining power of a device, which is applied to a Bluetooth card, as shown in FIG. 6 , including:
  • the detection module 31 is used to detect the status of the flag bit, when the first flag bit is set, the password calculation module 32 is triggered, and when the second flag bit is set, the total power consumption calculation module 34 is triggered;
  • the password calculation module 32 is used to start the timer and start counting, calculate the password, close the timer when the password calculation is completed, stop counting to obtain the password calculation time, reset the timer, accumulate the password calculation time into the fourth register, and trigger the Bluetooth module 36 and display module 33;
  • the Bluetooth module 36 is used to start the timer and start counting, and perform Bluetooth pairing with the host computer.
  • the pairing is successful, close the timer and stop counting to obtain the Bluetooth pairing time, reset the timer, accumulate the Bluetooth pairing time into the eighth register, and start the timer.
  • the timer starts counting, sends the password to the host computer through Bluetooth, closes the timer and stops counting to get the Bluetooth communication time and accumulates it in the seventh register, and resets the timer;
  • the display module 33 is used to turn on the timer and start counting, display the password and the remaining power, when the display ends, turn off the timer to stop counting, obtain the display time, reset the timer, accumulate the display time into the fifth register, and store the first The flag bit is reset, and the detection module 31 is triggered;
  • the total power consumption calculation module 34 is used to detect the battery voltage, and obtain the preset wake-up module current value, password calculation current value, button current value, display current value, bluetooth current value according to the detected battery voltage and the pre-stored first data table Communication current value, Bluetooth pairing current value, sleep current value, the product of the wake-up current value and the data in the first register, the product of the password calculation current value and the data in the fourth register, the key current value and the data in the third register.
  • a product of a preset value minus the data in the first register, the fourth register, the third register, the fifth register, the seventh register, and the data in the eighth register is added to calculate the total power consumption;
  • the device also includes:
  • the real-time clock module is used to measure the time of the device, and trigger the wake-up module every first preset time;
  • the wake-up module is used to start the timer to start counting, update the result of adding the data in the second register and the first preset time to the second register, and determine whether the data in the second register is equal to the first preset value, if so Set the second flag bit, turn off the timer and stop counting, and add the wake-up time to the first register when the wake-up time is obtained; otherwise, turn off the timer and stop counting, get the wake-up time, and accumulate the wake-up time into the first register;
  • the key interrupt module is used to turn on the timer and start counting, set the first flag bit, turn off the timer and stop counting when the second level is detected, get the key duration, and save the key duration to the third register, and exit the key interrupt .
  • the Bluetooth module is further configured to obtain the seventh value from the timer, and obtain the Bluetooth pairing time according to the seventh value; specifically, the Bluetooth module is further configured to obtain the sixth value from the timer register, according to the sixth value The value gets the Bluetooth communication time.
  • the password calculation module is further configured to stop counting when the password calculation is completed, obtain a third value from the timer register, obtain the password calculation time according to the third value, and clear the third value.
  • the wake-up module is further configured to turn off the timer to stop counting, obtain the first value from the timer register, and clear the first value when the wake-up is obtained according to the first value.
  • the display module is further configured to stop counting when the display ends, obtain a fourth value from the timing register, obtain the display duration according to the fourth value, and store the display duration in the fifth register. , to clear the fourth value.
  • the display module is further configured to end the display when the first level is detected, turn on the timer to start counting, when the second level is detected, turn off the timer to stop counting, and start the timer from the timer.
  • the second value is obtained from the register, the duration of the keypress is obtained according to the second value, the duration of the keypress is accumulated into the third register, and the second value is cleared.
  • the button interrupt module is further configured to turn off the timer and stop counting when the second level is detected, obtain the second value from the timer register, obtain the button duration according to the second value, and clear the second value.
  • the display module is replaced with a second display module, which is used to start the timer to start counting, display the password, stop counting when the display ends, obtain the display time, and accumulate the display time into the fifth register , reset the first flag bit, and trigger the detection module.
  • the second display module is further configured to turn on the second timer to start counting when the first level is detected, and turn off the second timer to stop counting when the second level is detected.
  • the fifth value is obtained from the second timer register, the duration of the key press is obtained according to the fifth value, the key duration is accumulated and stored in the third register, and the fifth value is cleared. If the key duration is greater than or equal to the fifth preset value, the screen display will be switched. Remaining power; if the duration of the key press is less than the fifth preset value, the timer is turned off to stop counting, the fourth value is obtained from the timing register, the display duration is obtained according to the fourth value, the display duration is accumulated and stored in the fifth register, and the first value is cleared.
  • updating the remaining power module includes:
  • the first judgment sub-module is used to judge whether the total power consumption is less than the second preset value. If yes, the total power consumption is stored in the power consumption count register, and the second judgment sub-module is triggered. Otherwise, the remaining power is reduced by the third preset value. The result of the value is updated to the remaining power, and the difference between the total power consumption and the second preset value is stored in the power consumption count register, and the second judgment sub-module is triggered;
  • the second judgment sub-module is used for judging whether the value in the power consumption counting register is smaller than the second preset value, and if so, restores the value in the second register to the initial value, resets the second flag bit, and triggers the detection module 31, Otherwise, the result of subtracting the third preset value from the remaining power is updated as the remaining power, the difference between the value in the power consumption register and the second preset value is updated to the power consumption count register, and the value in the second register is restored to The initial value is reset, and the second flag bit is reset to trigger the detection module 31 .

Abstract

一种设备剩余电量的计量方法及装置,检测标志位状态,当第一标志位置位时计算口令,显示口令将第一标志位复位,返回检测标志位状态;当第二标志位置位时计算总消耗电量,根据总消耗电量与第二预设值更新剩余电量,将第二标志位复位,返回检测标志位状态。根据本发明,可以实现不增加额外器件的情况下提高剩余电量的计量精度,更精确地反应电池剩余电量的实际值,且不增加额外的功耗;设备的使用寿命不受影响且成本低。

Description

一种设备剩余电量的计量方法及装置 技术领域
本发明涉及一种设备剩余电量的计量方法及装置,属于电量计量领域。
背景技术
用户在使用动态令牌、蓝牙卡等带屏幕的低功耗设备时,剩余电量的显示能够提醒用户及时更换或充电,电池剩余电量的精确显示成为一个重要的性能指标。
现有技术中存在一种通过模数转化模块检测电池电压来判断电池容量的方法,其无法较为精确地反应电池剩余电量的实际值,误差较大;
现有技术中存在另一种采用电量计采集剩余电量的方法,其可以较为精确地反应电池剩余电量的实际值,但在带屏幕的显示设备中集成电量计会增加设备的功耗,缩短设备的使用寿命,且成本高。
发明内容
本发明的目的是提供一种设备剩余电量的计量方法及装置,其可以实现不增加额外器件的情况下提高剩余电量的计量精度,更精确地反应电池剩余电量的实际值,且不增加额外的功耗;设备的使用寿命不受影响且成本低。
为此,根据本发明的一个方面,提供了一种设备剩余电量的计量方法,其包括:
步骤S1:检测标志位状态,当第一标志位置位时,执行步骤S2,当第二标志位置位时,执行步骤S4;
步骤S2:开启定时器开始计数,计算口令,当口令计算完成时关闭定时器,停止计数得到口令计算时间,重置定时器,将口令计算时间累加至第四寄存器中,执行步骤S3;
步骤S3:显示口令和剩余电量,将第一标志位复位,返回步骤S1;
步骤S4:检测电池电压,根据检测到的电池电压和预先存储的第一数据表获取预置的唤醒电流值、口令计算电流值、显示电流值,将唤醒电流值与第一寄存器中的数据的乘积、口令计算电流值与第四寄存器中的数据的乘积、显示电流值与第一预设值减第四寄存器中的数据的结果的乘积相加得到总消耗电量;
步骤S5:根据总消耗电量与第二预设值更新剩余电量,将第二标志位复位,返回步骤S1;
在执行步骤S1至步骤S5的过程中,当检测到实时时钟中断时执行步骤A1至步骤A4,实时时钟中断每隔第一预设时间触发一次;
步骤A1:开启定时器开始计数,将第二寄存器和第六寄存器中的数据分别加第一预设时间的结果更新至第二寄存器和第六寄存器中,当第六寄存器中的数据等于第四预设值时,执行步骤A2,当第二寄存器中的数据等于第一预设值时执行步骤A3;
步骤A2:将第一标志位置位,清除第六寄存器中的数据,执行步骤A4;
步骤A3:将第二标志位置位,执行步骤A4;
步骤A4:关闭定时器停止计数,得到唤醒用时,将唤醒用时累加至第一寄存器中。
根据本发明的另外一个方面,提供了一种设备剩余电量的计量装置,其包括:
检测模块,用于检测标志位状态,当第一标志位置位时触发计算口令模块,当第二标志位置位时,触发计算总消耗电量模块;
计算口令模块,用于开启定时器开始计数,计算口令,当口令计算完成时关闭定时器,停止计数得到口令计算时间,重置定时器,将口令计算时间累加至第四寄存器中,触发显示模块;
显示模块,用于显示口令和剩余电量,将第一标志位复位,触发检测模块;
计算总消耗电量模块,用于检测电池电压,根据检测到的电池电压和预先存储的第一数据表获取预置的唤醒电流值、口令计算电流值、显示电流值,将唤醒电流值与第一寄存器中的数据的乘积、口令计算电流值与第四寄存器中的数据的乘积、显示电流值与第一预设值减第四寄存器中的数据的结果的乘积相加得到总消耗电量;
更新剩余电量模块,用于根据总消耗电量与第二预设值更新剩余电量,将第二标志位复位,触发检测模块;
装置还包括:实时时钟模块,用于计量设备的时间,每隔第一预设时间触发唤醒模块;
唤醒模块,用于开启定时器开始计数,将第二寄存器和第六寄存器中的数据分别加第一预设时间的结果更新至第二寄存器和第六寄存器中,当第六寄存器中的数据等于第四预设值时,将第一标志位置位,清除第六寄存器中的数据,关闭定时器停止计数,得到唤醒用时,将唤醒用时累加至第一寄存器中;当第二寄存器中的数据等于第一预设值时将第二标志位置位,关闭定时器停止计数,得到唤醒用时,将唤醒用时累加至第一寄存器中。
根据本发明的第三方面,还提供了一种设备剩余电量的计量方法,包括:
步骤S1:检测标志位状态,当第一标志位置位时,执行步骤S2,当第二标志位置位时,执行步骤S4;
步骤S2:开启定时器开始计数,计算口令,当口令计算完成时关闭所述定时器,停止计数得到口令计算时间,重置所述定时器,将所述口令计算时间累加至第四寄存器中,执行步骤S3;
步骤S3:显示所述口令和剩余电量,将所述第一标志位复位,返回步骤S1;
步骤S4:检测电池电压,根据检测到的电池电压查询预先存储的第一数据表,获取预置的电流值,根据电流值和相应的用时计算总消耗电量;
步骤S5:根据所述总消耗电量与第二预设值更新剩余电量,将所述第二标志位复位,返回步骤S1。
根据本发明的第四方面,还提供了一种设备剩余电量的计量装置,包括:
检测模块,用于检测标志位状态,当第一标志位置位时触发计算口令模块,当第二标志位置位时,触发计算总消耗电量模块;
所述计算口令模块,用于开启定时器开始计数,计算口令,当口令计算完成时关闭所述定时器,停止计数得到口令计算时间,重置所述定时器,将所述口令计算时间累加至第四寄存器中,触发显示模块;
所述显示模块,用于显示所述口令和剩余电量,将所述第一标志位复位,触发所述检测模块;
所述计算总消耗电量模块,用于检测电池电压,根据检测到的电池电压查询预先存储的第一数据表,获取预置的电流值,根据电流值和相应的用时计算总消耗电量;
更新剩余电量模块,用于根据所述总消耗电量与第二预设值更新剩余电量,将所述第二标志位复位,触发所述检测模块。
本发明与现有技术相比,具有以下优点:
根据本发明,提供了一种设备剩余电量的计量方法,可以实现不增加额外器件的情况下提高剩余电量的计量精度,更精确地反应电池剩余电量的实际值,且不增加额外的功耗;设备的使用寿命不受影响且成本低。
附图说明
图1为本发明实施例一提供的一种设备剩余电量计量方法的流程图;
图2为本发明实施例三提供的一种设备剩余电量计量方法的流程图;
图3为本发明实施例五提供的一种设备剩余电量计量方法的流程图;
图4为本发明实施例七提供的一种设备剩余电量计量装置的方框图;
图5为本发明实施例八提供的一种设备剩余电量计量装置的方框图;
图6为本发明实施例九提供的一种设备剩余电量计量装置的方框图。
具体实施方式
下面将结合附图,对本发明实施例进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域的技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
实施例一:
本发明实施例一提供一种设备剩余电量的一计量方法,应用于常显型动态令牌,如图1所示,包括:
步骤S1:检测标志位状态,当第一标志位置位时,执行步骤S2,当第二标志位置位时,执行步骤S4;
步骤S2:开启定时器开始计数,计算口令,当口令计算完成时关闭定时器,停止计数得到口令计算时间,重置定时器,将口令计算时间累加至第四寄存器中,执行步骤S3;
优选地,在本实施例一中,当口令计算完成时关闭定时器,停止计数得到口令计算时间,重置定时器具体为:当口令计算完成时停止计数,从定时器寄存器中获取第三数值,根据第三数值得到口令计算时间,清除第三数值。
步骤S3:显示口令和剩余电量,将第一标志位复位,返回步骤S1;
步骤S4:检测电池电压,根据检测到的电池电压和预先存储的第一数据表获取预置的唤醒电流值、口令计算电流值、显示电流值,将唤醒电流值与第一寄存器中的数据的乘积、口令计算电流值与第四寄存器中的数据的乘积、显示电流值与第一预设值减第四寄存器中的数据的结果的乘积相加得到总消耗电量;
优选地,在本实施一中,总消耗电量=唤醒电流值×第一寄存器中的数据+口令计算电流值×第四寄存器中的数据+显示电流值×(第一预设值-第四寄存器中的数据);
预存的第一数据表如下:
模块\电池电压 V>=2.8V 2.8V>V>=2.6V V<2.6V
显示 第一显示电流 第二显示电流 第三显示电流
口令计算 第一口令计算电流 第二口令计算电流 第三口令计算电流
唤醒 第一唤醒电流 第二唤醒电流 第三唤醒电流
步骤S5:根据总消耗电量与第二预设值更新剩余电量,将第二标志位复位,返回步骤S1;
优选地,在本实施例中,步骤S5具体包括:
步骤S5-1:判断总消耗电量是否小于第二预设值,是则将总消耗电量存入电量消耗计数寄存器中,执行步骤S5-2,否则将剩余电量减第三预设值的结果更新为剩余电量,将总消耗电量与第二预设值的差值存入电量消耗计数寄存器中,执行步骤S5-2;
步骤S5-2:判断电量消耗计数寄存器中的数值是否小于第二预设值,是则将第二寄存器中的数值恢复为初始值,将第二标志位复位,返回步骤S1,否则将剩余电量减第三预设值的结果更新为剩余电量,将电量消耗寄存器中的数值与第二预设值的差值更新到电量消耗计数寄存器中,将第二寄存器中的数值恢复为初始值,将第二标志位复位,返回步骤S1。
在执行步骤S1至步骤S5过程中,当检测到实时时钟中断时执行步骤A1至步骤A4,实时时钟中断每隔第一预设时间触发一次;
步骤A1:开启定时器开始计数,将第二寄存器和第六寄存器中的数据分别加第一预设时间的结果更新至第二寄存器和第六寄存器中,当第六寄存器中的数据等于第四预设值时,执行步骤A2,当第二寄存器中的数据等于第一预设值时执行步骤A3;
步骤A2:将第一标志位置位,清除第六寄存器中的数据,执行步骤A4;
步骤A3:将第二标志位置位,执行步骤A4;
步骤A4:关闭定时器停止计数,得到唤醒用时,将唤醒用时累加至第一寄存器中。
优选地,在本实施例一中,关闭定时器停止计数,得到唤醒用时具体包括:关闭定时器停止计数,从定时器寄存器中获取第一数值,根据第一数值得到唤醒用时,清除第一数值。
实施例二:
本发明实施例二提供一种设备剩余电量的计量方法,应用于常显型动态令牌,包括:
步骤101:动态令牌上电,初始化定时器的时钟源频率、分频系数、计数初始值,进入休眠状态;
具体地,动态令牌电池设定为满电状态;
步骤102:当检测到动态令牌实时时钟中断时,启动定时器开始计数,当实时时钟中断结束时,关闭定时器停止计数,从定时器寄存器中获取第一数值,根据第一数值、定时器的时钟源频率、分频系数、计数初始值得到实时时钟中断时间作为唤醒用时,将唤醒用时累加至第一寄存器中,清除第一数值;分别将第二寄存器和第六寄存器中的数据加第一预设时间的结果更新至第二寄存器和第六寄存器中,执行步骤103;实时时钟中断每隔第一预设时间触发;
具体地,第一预设时间为1秒;
步骤103:动态令牌判断第六寄存器中的数值是否等于第四预设值,是则执行步骤104,否则执行步骤106;
具体地,第四预设值为60s,第一预设值为86400s;
步骤104:动态令牌开启定时器开始计数,计算口令,当口令计算完成后关闭定时器停止计数,从定时器寄存器中获取第三数值,根据第三数值得到口令计算时间,将口令计算时间累加至第四寄存器中,清除第三数值;
具体地,口令计算时间=(第三数值-计数初始值+1)×(分频系数+1)/时钟源频率;
步骤105:动态令牌显示口令和剩余电量,清除第六寄存器中的数据,执行步骤106;
显示口令的同时显示剩余电量,例如,设置一个电池符号,设置五格,每格表示百分之二十电量,根据剩余电量的具体数值对应显示电池格;
或者设置一个电池符号,分为满电、半电、低电状态,分别对应显示2格、1格、空框,假设剩余电量在标称容量的1/3之上时,电池符号两格都显示,表示当前状态是满电状态,在1/3-2/3之间时,认为是半电,只显示一格,电量低于1/3时,表示低电,此时显示一个空框,并且闪烁提示用户,电池电量已不足;
或者设置一个电池符号,按比例显示剩余电量,并且显示剩余电量百分比,例如95%;
具体地,唤醒时间=(第一数值-计数初始值+1)×(分频系数+1)/时钟源频率;
步骤106:动态令牌判断第二寄存器中的数值是否等于第一预设值,是则执行步骤107,否则返回步骤102;
具体地,第一预设值为86400秒,即每24小时为一个周期;
步骤107:动态令牌检测电池电压,根据检测到的电池电压查找预先存储的电池电压-电流数据表,确定各个模块对应的电流值,计算总消耗电量,执行步骤108;
模块\电池电压 V>=2.8V 2.8V>V>=2.6V V<2.6V
显示 第一显示电流 第二显示电流 第三显示电流
口令计算 第一口令计算电流 第二口令计算电流 第三口令计算电流
唤醒 第一唤醒电流 第二唤醒电流 第三唤醒电流
具体地,读取预先存储的的电池电压-电流数据表,如果电池电压大于或等于2.8V,显示模块对应的电流值为第一显示电流,口令计算模块对应的电流值为第一口令计算电流,唤醒 模块对应的电流值为第一唤醒电流;
如果电池电压大于或等于2.6V且小于2.8V,则显示模块对应的电流值为第二显示电流,口令计算模块对应的电流值为第二口令计算电流,唤醒模块对应的电流值为第二唤醒电流;
如果电池电压小于2.6V,则显示模块对应的电流值为第三显示电流,口令计算模块对应的电流值为第三口令计算电流,唤醒模块对应的电流值为第三唤醒电流;
例如,动态令牌检测电池电压为3V,则显示模块对应的电流值为第一显示电流,口令计算模块对应的电流值为第一口令计算电流,唤醒模块对应的电流值为第一唤醒电流,分别计算三个功能模块的耗电量;
显示模块耗电量=第一显示电流×(第一预设值-口令计算时间);
口令计算模块耗电量=第一口令计算电流×口令计算时间;
具体地,口令计算时间为第四寄存器中的数据;
唤醒模块耗电量=第一唤醒电流×(唤醒时长-口令计算时间);
具体地,唤醒时长为第一寄存器中的数据;
总消耗电量=显示模块耗电量+口令计算模块耗电量+唤醒模块耗电量;
步骤108:动态令牌判断总消耗电量是否小于第二预设值,是则将总消耗电量存入电量消耗计数寄存器中,执行步骤109,否则将剩余电量减第三预设值的结果更新为剩余电量,将总消耗电量与第二预设值的差值存入电量消耗计数寄存器中,执行步骤109;
步骤109:动态令牌判断电量消耗计数寄存器中的数值是否小于第二预设值,是则将第二寄存器中的数据清除,返回步骤102,否则将剩余电量减第三预设值的结果更新为剩余电量,将电量消耗计数寄存器中的数值与第二预设值的差值更新到电量消耗计数寄存器中,将第二寄存器中的数据清除,返回步骤102。
实施例三:
本发明实施例三提供一种设备剩余电量计量方法,应用于按键型动态令牌,如图2所示,包括:
步骤Q1:检测标志位状态,当第一标志位置位时,执行步骤Q2,当第二标志位置位时,执行步骤Q4;
步骤Q2:开启定时器开始计数,计算口令,当口令计算完成时关闭定时器,停止计数得到口令计算时间,重置定时器,将口令计算时间累加至第四寄存器中,执行步骤Q3;
步骤Q3:开启定时器开始计数,显示口令和剩余电量,当显示结束时关闭定时器停止计数,得到显示时间,重置定时器,将显示时间累加至第五寄存器中,将第一标志位复位,返回步骤Q1;
步骤Q4:检测电池电压,根据检测到的电池电压和预先存储的第一数据表获取预置的唤醒电流值、口令计算电流值、按键电流值、显示电流值和休眠电流值,将唤醒电流值与第一寄存器中的数据的乘积、口令计算电流值与第四寄存器中的数据的乘积、按键电流值与第三寄存器中的数据的乘积、显示电流值与第五寄存器中的数据的乘积、休眠电流值与第一预设值减第一寄存器、第四寄存器、第三寄存器、第五寄存器中的数据的结果的乘积相加得到总消耗电量;
优选地,在本实施例中,总消耗电量=唤醒电流值×第一寄存器中的数据+口令计算电流值×第四寄存器中的数据+按键电流值×第三寄存器中的数据+显示电流×第五寄存器中的数据+休眠电流×(第一预设值-第一寄存器中的数据-第四寄存器中的数据-第三寄存器中的数据-第五寄存器中的数据);
预存的第一数据表如下:
模块\电池电压 V>=2.8V 2.8V>V>=2.6V V<2.6V
按键 第一按键电流 第二按键电流 第三按键电流
显示 第一显示电流 第二显示电流 第三显示电流
口令计算 第一口令计算电流 第二口令计算电流 第三口令计算电流
休眠 第一休眠电流 第二休眠电流 第三休眠电流
唤醒 第一唤醒电流 第二唤醒电流 第三唤醒电流
步骤Q5:根据总消耗电量与第二预设值更新剩余电量,将第二标志位复位,返回步骤Q1;
在执行步骤Q1至步骤Q5过程中,当检测到实时时钟中断时执行步骤B1至步骤B2,实时时钟中断每隔第一预设时间触发一次;
步骤B1:开启定时器开始计数,将第二寄存器中的数据加第一预设时间的结果更新至第二寄存器中,判断第二寄存器中的数据是否等于第一预设值,是则将第二标志位置位,执行步骤B2,否则执行步骤B2;
步骤B2:关闭定时器停止计数,得到唤醒用时,将唤醒用时累加至第一寄存器中;
在执行步骤Q1至步骤Q5的过程中,还包括:当检测到按键中断时,开启定时器开始计数,将第一标志位置位,当检测到第二电平时关闭定时器停止计数,得到按键时长,将按键时长累加保存至第三寄存器中,退出按键中断。
优选地,在本实施例三中,当口令计算完成时关闭定时器,停止计数得到口令计算时间,重置定时器具体为:当口令计算完成时停止计数,从定时器寄存器中获取第三数值,根据第三数值得到口令计算时间,清除第三数值。
优选地,在本实施例三中,关闭定时器停止计数,得到唤醒用时具体包括:关闭定时器停止计数,从定时器寄存器中获取第一数值,根据第一数值得到唤醒用时,清除第一数值。
优选地,在本实施例三中,当显示结束时停止计时,得到显示时间,重置所述定时器具体为:当显示结束时停止计数,从定时寄存器中获取第四数值,根据第四数值得到显示时长,将显示时长累加至第五寄存器中,清除第四数值。
优选地,在本实施例三中,步骤Q3中还包括:当检测到第一电平时,显示结束,开启定时器开始计数,当检测到第二电平时,关闭定时器停止计数,从定时器寄存器中获取第二数值,根据第二数值得到按键时长,将按键时长累加至第三寄存器中,清除第二数值。
优选地,在本实施例三中,当检测到第二电平时关闭定时器停止计数,得到按键时长具体为:当检测到第二电平时,关闭定时器停止计数,从定时器寄存器中获取第二数值,根据第二数值得到按键时长,清除第二数值。
优选地,在本实施例三中,步骤Q3替换为:开启定时器开始计数,显示口令,当显示结束时停止计数,得到显示时间,将显示时间累加至第五寄存器中,将第一标志位复位,返回步骤Q1。
优选地,在本实施例三中,步骤Q3中还包括:当检测到第一电平时,开启第二定时器开始计数,当检测到第二电平时关闭第二定时器停止计数,从第二定时器寄存器中获取第五数值,根据第五数值得到按键时长,将按键时长累加至第三寄存器中,清除第五数值,如按键时长大于或等于第五预设值则切换屏幕显示剩余电量;如按键时长小于第五预设值时则关闭定时器停止计数,从定时寄存器中获取第四数值,根据第四数值得到显示时长,将显示时长累加至第五寄存器中,清除第四数值。
优选地,在本实施例三中,步骤Q5具体包括:
步骤Q5-1:判断总消耗电量是否小于第二预设值,是则将总消耗电量存入电量消耗计数寄存器中,执行步骤Q5-2,否则将剩余电量减第三预设值的结果更新为剩余电量,将总消耗电量与第二预设值的差值存入电量消耗计数寄存器中,执行步骤Q5-2;
步骤Q5-2:判断电量消耗计数寄存器中的数值是否小于第二预设值,是则将第二寄存器中的数值恢复为初始值,将第二标志位复位,返回步骤Q1,否则将剩余电量减第三预设值的结果更新为剩余电量,将电量消耗寄存器中的数值与第二预设值的差值更新到电量消耗计数 寄存器中,将第二寄存器中的数值恢复为初始值,将第二标志位复位,返回步骤Q1。
实施例四:
本发明实施例四提供一种设备剩余电量的计量方法,应用于按键型动态令牌,包括:
步骤201:动态令牌上电,初始化定时器的时钟源频率、分频系数、计数初始值;
具体地,动态令牌电池设定为满电状态;
步骤202:动态令牌进入休眠状态;
步骤203:动态令牌判断实时时钟中断是否发生,是则启动定时器开始计数,当实时时钟中断结束时,关闭定时器停止计数,从定时器寄存器中获取第一数值,根据第一数值、定时器的时钟源频率、分频系数、计数初始值得到实时时钟中断时间作为唤醒用时,将唤醒用时累加至第一寄存器中,清除第一数值,执行步骤204,否则执行步骤205;实时时钟中断每隔第一预设时间触发一次;
具体地,唤醒用时=(第一数值-计数初始值+1)×(分频系数+1)/时钟源频率;
步骤204:动态令牌将第二寄存器中的数值加第一预设时间的结果更新至第二寄存器中,当第二寄存器中的数值等于第一预设值时,执行步骤209;
具体地,第一预设值为86400秒,即每24小时为一个周期;
步骤205:动态令牌判断按键是否被用户触发,是则执行步骤206,否则返回步骤203;
步骤206:开启定时器开始计数,当检测到第二电平时关闭定时器停止计数,从定时器寄存器中获取第二数值,根据第二数值、定时器的时钟源频率、分频系数、计数初始值得到按键时长,将按键时长累加至第三寄存器中,清除第二数值;
具体地,当第二电平为高电平时,按键被用户触发则检测到低电平;当第二电平为低电平时,按键被用户触发则检测到高电平;
具体地,按键时长=(第二数值-计数初始值+1)×(分频系数+1)/时钟源频率;
步骤207:动态令牌开启定时器开始计数,计算口令,当口令计算完成后关闭定时器停止计数,从定时器寄存器中获取第三数值,根据第三数值、定时器的时钟源频率、分频系数、计数初始值得到口令计算时间,将口令计算时间累加保存至第四寄存器中,清除第三数值;
具体地,口令计算时间=(第三数值-计数初始值+1)×(分频系数+1)/时钟源频率;
步骤208:动态令牌开启定时器开始计数,显示口令和剩余电量,判断是否接收到用户的按键触发,是则关闭定时器停止计数,从定时器寄存器中获取第四数值,根据第四数值、定时器的时钟源频率、分频系数、计数初始值得到显示时长,将显示时长累加至第五寄存器中,清除第四数值,返回步骤203,否则将预设显示时长累加至第五寄存器中,清除定时寄存器中的数值,返回步骤203;
具体地,当接收到用户的按键触发时,显示口令时长=(第四数值-计数初始值+1)×(分频系数+1)/时钟源频率;
具体地,步骤208中清除第四数值之后还包括:动态令牌开启定时器开始计数,当检测到第二电平时,关闭定时器停止计数,从定时器寄存器中获取第二数值,根据第二数值、定时器的时钟源频率、分频系数、计数初始值得到按键时长,将按键时长累加保存至第三寄存器中,清除第二数值;
具体地,当第二电平为高电平时,用户按键触发为低电平;当第二电平为低电平时,用户按键触发为高电平;
具体地,显示口令的同时显示剩余电量,例如,设置一个电池符号,设置五格,每格表示百分之二十电量,根据剩余电量的具体数值对应显示电池格;
或者,设置一个电池符号,分为满电、半电、低电状态,分别对应显示2格、1格、空框,假设剩余电量在标称容量的1/3之上时,电池符号两格都显示,表示当前状态是满电状态,在1/3-2/3之间时,认为是半电,只显示一格,电量低于1/3时,表示低电,此时显示一个空框,并且闪烁提示用户,电池电量已不足;
或者,设置一个电池符号,按比例显示剩余电量,并且显示剩余电量百分比,例如95%;
优选地,步骤208可替换为:动态令牌开启定时器开始计时,显示口令,当显示结束后停止计数,从定时寄存器中获取第四数值,根据第四数值得到显示时长,将显示时长累加保存至第五寄存器中,清除第四数值;
优选地,在本实施例四中,步骤208还包括:
当检测到第一电平时开启第二定时器开始计时,当检测到第二电平时关闭第二定时器停止计时,从第二定时器寄存器中获取第五数值,根据第五数值得到按键时长,将按键时长累加至第三寄存器中,如按键时长大于或等于第五预设值则切换屏幕显示剩余电量;如按键时长小于第五预设值则关闭定时器停止计数,从定时寄存器中获取第四数值,根据第四数值得到显示时长,将显示时长累加至第五寄存器中,清除第四数值;
具体地,第五预设值为3s;
具体地,当第一电平为高电平时,第二电平为低电平,当第一电平为低电平时,第二电平为高电平;
具体地,按键时长=(第二数值-计数初始值+1)×(分频系数+1)/时钟源频率;
步骤209:动态令牌检测电池电压,根据检测到的电池电压查找预先存储的电池电压-电流数据表,确定各个模块对应的电流值,计算总消耗电量,执行步骤210;
具体地,动态令牌检测电池电压时为避免因干扰产生的误差,采用均值滤波法连续取多个采样值进行算数平均运算;
预存的电池电压-电流数据表如下所示:
模块\电池电压 V>=2.8V 2.8V>V>=2.6V V<2.6V
按键 第一按键电流 第二按键电流 第三按键电流
显示 第一显示电流 第二显示电流 第三显示电流
口令计算 第一口令计算电流 第二口令计算电流 第三口令计算电流
休眠 第一休眠电流 第二休眠电流 第三休眠电流
唤醒 第一唤醒电流 第二唤醒电流 第三唤醒电流
具体地,读取预先存储的电池电压-电流数据表,如果电池电压大于或等于2.8V,则按键模块对应的电流值为第一按键电流,显示模块对应的电流值为第一显示电流,口令计算模块对应的电流值为第一口令计算电流,休眠模块对应的电流值为第一休眠电流,唤醒模块对应的电流值为第一唤醒电流;
如果电池电压大于或等于2.6V且小于2.8V,则按键模块对应的电流值为第二按键电流,显示模块对应的电流值为第二显示电流,口令计算模块对应的电流值为第二口令计算电流,休眠模块对应的电流值为第二休眠电流,唤醒模块对应的电流值为第二唤醒电流;
如果电池电压小于2.6V,则按键模块对应的电流值为第三按键电流,显示模块对应的电流值为第三显示电流,口令计算模块对应的电流值为第三口令计算电流,休眠模块对应的电流值为第三休眠电流,唤醒模块对应的电流值为第三唤醒电流;
例如,动态令牌检测电池电压为3V,则按键模块对应的电流值为的第一按键电流,显示模块对应的电流值为第一显示电流,口令计算模块对应的电流值为第一口令计算电流,休眠模块对应的电流值为第一休眠电流,唤醒模块对应的电流值为第一唤醒电流,分别计算五个功能模块的耗电量;
按键模块耗电量=第一按键电流×按键总时长;
具体地,按键总时长为第三寄存器中的数据;
显示模块耗电量=第一显示电流×显示总时长;
具体地,显示总时长为第五寄存器中的数据;
口令计算模块耗电量=第一口令计算电流×口令计算时间;
具体地,口令计算时间为第四寄存器中的数据;
唤醒模块耗电量=第一唤醒电流×唤醒时长;
具体地,唤醒时长为第二寄存器中的数据;
休眠模块耗电量=第一休眠电流×(第一预设值-显示总时长-按键总时长-口令计算时间-唤醒时长);
总消耗电量=按键模块耗电量+显示模块耗电量+口令计算模块耗电量+休眠模块耗电量+唤醒模块耗电量;
步骤210:动态令牌判断总消耗电量是否小于第二预设值,是则将总消耗电量存入电量消耗计数寄存器中,执行步骤211,否则将剩余电量减第三预设值的结果更新为剩余电量,将总消耗电量与第二预设值的差值存入电量消耗计数寄存器中,执行步骤211;
具体地,第二预设值为2700000uAs,第三预设值为1%;
例如,电池容量75mAh,百分之一的电池容量为0.75mAh,由于各功能模块耗电电流对应的都是uA级,所以将百分之一的电池容量换算成uAs即0.75mAh=2700000uAs;
步骤211:动态令牌判断电量消耗计数寄存器中的数值是否小于第二预设值,是则将第二寄存器中的数据清除,返回步骤203,否则将剩余电量减第三预设值的结果更新为剩余电量,将电量消耗计数寄存器中的数值与第二预设值的差值更新到电量消耗计数寄存器中,将第二寄存器中的数据清除,返回步骤203。
实施例五:
本发明实施例五提供一种设备剩余电量计量方法,应用于蓝牙卡,如图3所示,包括:
步骤M1:检测标志位状态,当第一标志位置位时,执行步骤M2,当第二标志位置位时,执行步骤M4;
步骤M2:开启定时器开始计数,计算口令,当口令计算完成时关闭定时器,停止计数得到口令计算时间,重置定时器,将口令计算时间累加至第四寄存器中,开启定时器开始计数,与上位机进行蓝牙配对,配对成功时关闭定时器停止计数得到蓝牙配对时间,重置定时器,将蓝牙配对时间累加至第八寄存器中,开启定时器开始计数,将口令通过蓝牙发送给上位机,关闭定时器停止计数得到蓝牙通信时间并累加至第七寄存器中,重置定时器,执行步骤M3;
步骤M3:开启定时器开始计数,显示口令和剩余电量,当显示结束时关闭定时器停止计数,得到显示时间,重置定时器,将显示时间累加至第五寄存器中,将第一标志位复位,返回步骤M1;
步骤M4:检测电池电压,根据检测到的电池电压和预先存储的第一数据表获取预置的唤醒电流值、口令计算电流值、按键电流值、显示电流值、蓝牙通信电流值、蓝牙配对电流值、休眠电流值,将唤醒电流值与第一寄存器中的数据的乘积、口令计算电流值与第四寄存器中的数据的乘积、按键电流值与第三寄存器中的数据的乘积、显示电流值与第五寄存器中的数据的乘积、蓝牙通信电流值与第七寄存器中的数据的乘积、蓝牙配对电流值与第八寄存器中的数据的乘积、休眠电流值与第一预设值减第一寄存器、第四寄存器、第三寄存器、第五寄存器、第七寄存器、第八寄存器中的数据的结果的乘积相加得到总消耗电量;
优选地,在本实施例五中,总消耗电量=唤醒电流值×第一寄存器中的数据+口令计算电流值×第四寄存器中的数据+按键电流值×第三寄存器中的数据+显示电流×第五寄存器中的数据+蓝牙通信电流值×第七寄存器中的数据+蓝牙配对电流值×第八寄存器中的数据+休眠电流×(第一预设值-第一寄存器中的数据-第四寄存器中的数据-第三寄存器中的数据-第五寄存器中的数据-第七寄存器中的数据-第八寄存器中的数据);
预存的第一数据表如下:
模块\电池电压 V>=2.8V 2.8V>V>=2.6V V<2.6V
按键 第一按键电流 第二按键电流 第三按键电流
显示 第一显示电流 第二显示电流 第三显示电流
休眠 第一休眠电流 第二休眠电流 第三休眠电流
唤醒 第一唤醒电流 第二唤醒电流 第三唤醒电流
口令计算 第一口令计算电流 第二口令计算电流 第三口令计算电流
蓝牙通信 第一蓝牙通信电流 第二蓝牙通信电流 第三蓝牙通信电流
蓝牙配对 第一蓝牙配对电流 第二蓝牙配对电流 第三蓝牙配对电流
步骤M5:根据总消耗电量与第二预设值更新剩余电量,将第二标志位复位,返回步骤M1;
在执行步骤M1至步骤M5过程中,还包括:当检测到实时时钟中断时执行步骤B1至步骤B2,实时时钟中断每隔第一预设时间触发一次;
步骤B1:开启定时器开始计数,将第二寄存器中的数据加第一预设时间的结果更新至第二寄存器中,判断第二寄存器中的数据是否等于第一预设值,是则将第二标志位置位,执行步骤B2,否则执行步骤B2;
步骤B2:关闭定时器停止计数,得到唤醒用时,将唤醒用时累加至第一寄存器中;
在执行步骤M1至步骤M5的过程中,还包括:当检测到按键中断时,开启定时器开始计数,将第一标志位置位,当检测到第二电平时关闭定时器停止计数,得到按键时长,将按键时长累加保存至第三寄存器中,退出按键中断。
优选地,在本实施例五中,得到蓝牙配对时间具体为:从定时器中获取第七数值,根据第七数值得到蓝牙配对时间;
得到蓝牙通信时间具体为:从定时寄存器中获取第六数值,根据第六数值得到蓝牙通信时间。
优选地,在本实施例为中,当口令计算完成时关闭定时器,停止计数得到口令计算时间,重置定时器具体为:当口令计算完成时停止计数,从定时器寄存器中获取第三数值,根据第三数值得到口令计算时间,清除第三数值。
优选地,在本实施例为中,关闭定时器停止计数,得到唤醒用时具体包括:关闭定时器停止计数,从定时器寄存器中获取第一数值,根据第一数值得到唤醒用时,清除第一数值。
优选地,在本实施例为中,当显示结束时停止计时,得到显示时间,重置定时器具体为:当显示结束时停止计数,从定时寄存器中获取第四数值,根据第四数值得到显示时长,将显示时长累加保存至第五寄存器中,清除第四数值。
优选地,在本实施例为中,步骤M3中还包括:当检测到第一电平时,显示结束,开启定时器开始计数,当检测到第二电平时,关闭定时器停止计数,从定时器寄存器中获取第二数值,根据第二数值得到按键时长,将按键时长累加至第三寄存器中,清除第二数值。
优选地,在本实施例为中,当检测到第二电平时关闭定时器停止计数,得到按键时长具体为:当检测到第二电平时,关闭定时器停止计数,从定时器寄存器中获取第二数值,根据第二数值得到按键时长,清除第二数值。
优选地,在本实施例为中,步骤M3替换为:开启定时器开始计数,显示口令,当显示结束时停止计数,得到显示时间,将显示时间累加至第五寄存器中,将第一标志位复位,返回步骤S1。
优选地,在本实施例为中,步骤M3中还包括:
当检测到第一电平时,开启第二定时器开始计数,当检测到第二电平时关闭第二定时器停止计数,从第二定时器寄存器中获取第五数值,根据第五数值得到按键时长,将按键时长累加至第三寄存器中,清除第五数值,如按键时长大于或等于第五预设值则切换屏幕显示剩余电量;如按键时长小于第五预设值时则关闭定时器停止计数,从定时寄存器中获取第四数值,根据第四数值得到显示时长,将显示时长累加至第五寄存器中,清除第四数值。
优选地,在本实施例为中,步骤M5具体包括:
步骤M5-1:判断总消耗电量是否小于第二预设值,是则将总消耗电量存入电量消耗计数寄存器中,执行步骤M5-2,否则将剩余电量减第三预设值的结果更新为剩余电量,将总消耗电量与第二预设值的差值存入电量消耗计数寄存器中,执行步骤M5-2;
步骤M5-2:判断电量消耗计数寄存器中的数值是否小于第二预设值,是则将第二寄存器中的数值恢复为初始值,将第二标志位复位,返回步骤M1,否则将剩余电量减第三预设值的结果更新为剩余电量,将电量消耗寄存器中的数值与第二预设值的差值更新到电量消耗计数寄存器中,将第二寄存器中的数值恢复为初始值,将第二标志位复位,返回步骤M1。
实施例六:
本发明实施例六提供一种设备剩余电量的计量方法,应用于蓝牙卡,包括:
步骤301:蓝牙卡上电,初始化定时器的时钟源频率、分频系数、计数初始值;
具体地,蓝牙卡电池设定为满电状态;
步骤302:蓝牙卡进入休眠状态;
步骤303:蓝牙卡判断实时时钟中断是否发生,是则启动定时器开始计数,当实时时钟中断结束时,关闭定时器停止计数,从定时器寄存器中获取第一数值,根据第一数值、定时器的时钟源频率、分频系数、计数初始值得到实时时钟中断时间作为唤醒用时,将唤醒用时累加至第一寄存器中,清除第一数值,执行步骤304,否则执行步骤305;实时时钟中断每隔第一预设时间触发;
具体地,第一预设时间为1秒;
具体地,唤醒用时=(第一数值-计数初始值+1)×(分频系数+1)/时钟源频率;
步骤304:蓝牙卡将第二寄存器中的数值加第一预设时间的结果更新至第二寄存器中,当第二寄存器中的数值等于第一预设值时,执行步骤309;
具体地,第一预设值为86400秒,即每24小时为一个周期;
步骤305:蓝牙卡判断按键是否被用户触发,是则执行步骤306,否则返回步骤303;
步骤306:开启定时器开始计数,当检测到第二电平时关闭定时器停止计数,从定时器寄存器中获取第二数值,根据第二数值、定时器的时钟源频率、分频系数、计数初始值得到按键时长,将按键时长累加保存至第三寄存器中,清除第二数值;
具体地,按键时长=(第二数值-计数初始值+1)×(分频系数+1)/时钟源频率;
步骤307:蓝牙卡开启定时器开始计数,计算口令,当口令计算完成后关闭定时器停止计数,从定时器寄存器中获取第三数值,根据第三数值、定时器的时钟源频率、分频系数、计数初始值得到口令计算时间,将口令计算时间累加至第四寄存器中,清除第三数值,开启定时器开始计数,与上位机进行蓝牙配对,配对成功时关闭定时器停止计数,从定时器寄存器中获取第七数值,根据第七数值、定时器的时钟源频率、分频系数、计数初始值得到蓝牙配对时间,将蓝牙配对时间累加至第八寄存器中,清除第七数值,开启定时器开始计数,将口令通过蓝牙发送给上位机,关闭定时器停止计数,从定时寄存器中获取第六数值,根据第六数值、定时器的时钟源频率、分频系数、计数初始值得到蓝牙通信时间,将蓝牙通信时间累加至第七寄存器中,清除第六数值;
具体地,口令计算时长=(第三数值-计数初始值+1)×(分频系数+1)/时钟源频率;
具体地,蓝牙配对时间=(第七数值-计数初始值+1)×(分频系数+1)/时钟源频率;
具体地,蓝牙通信时间=(第六数值-计数初始值+1)×(分频系数+1)/时钟源频率;
具体地,显示数据的同时显示剩余电量,例如,设置一个电池符号,设置五格,每格表示百分之二十电量,根据剩余电量的具体数值对应显示电池格;
或者,设置一个电池符号,分为满电、半电、低电状态,分别对应显示2格、1格、空框,假设剩余电量在标称容量的1/3之上时,电池符号两格都显示,表示当前状态是满电状态,在1/3-2/3之间时,认为是半电,只显示一格,电量低于1/3时,表示低电,此时显示一个空框,并且闪烁提示用户,电池电量已不足;
或者,设置一个电池符号,按比例显示剩余电量,并且显示剩余电量百分比,例如95%;
步骤308:蓝牙卡开启定时器开始计数,显示口令和剩余电量,判断是否接收到用户的按键触发,是则关闭定时器停止计数,从定时器寄存器中获取第四数值,根据第四数值、定时器的时钟源频率、分频系数、计数初始值得到显示时长,将显示时长累加保存至第五寄存器中,清除第四数值,返回步骤303,否则将预设显示时长累加至第五寄存器中,清除定时寄存器中的数值,返回步骤303;
具体地,当接收到用户的按键触发时,显示时长=(第四数值-计数初始值+1)×(分频系数+1)/时钟源频率;
具体地,步骤308中清除第四数值之后还包括:蓝牙卡开启定时器开始计数,当检测到第二电平时,关闭定时器停止计数,从定时器寄存器中获取第二数值,根据第二数值、定时器的时钟源频率、分频系数、计数初始值得到按键时长,将按键时长累加至第三寄存器中,清除第二数值;
优选地,步骤308可替换为:蓝牙卡开启定时器开始计时,显示口令,当显示口令结束后停止计数,从定时寄存器中获取第四数值,根据第四数值得到显示时长,将显示时长累加至第五寄存器中,清除第四数值;
优选地,在本实施例六中,步骤308还包括:
当检测到第一电平时开启第二定时器开始计时,当检测到第二电平时关闭第二定时器停止计时,从第二定时器寄存器中获取第五数值,根据第五数值得到按键时长,将按键时长累加至第三寄存器中,如按键时长大于或等于第五预设值则切换屏幕显示剩余电量;如按键时长小于第五预设值则关闭定时器停止计数,从定时寄存器中获取第四数值,根据第四数值得到显示时长,将显示时长累加保存至第五寄存器中,清除第四数值;
具体地,第五预设值为3s;
具体地,当第一电平为高电平时,第二电平为低电平,当第一电平为低电平时,第二电平为高电平;
具体地,按键时长=(第二数值-计数初始值+1)×(分频系数+1)/时钟源频率;
步骤309:蓝牙卡检测电池电压,根据检测到的电池电压查找预先存储的电池电压-电流数据表,确定各个模块对应的电流值,计算总消耗电量,执行步骤310;
具体地,蓝牙卡检测电池电压时为避免因干扰产生的误差,采用均值滤波法连续取多个采样值进行算数平均运算;
预先存储的电池电压-电流数据表如下所示:
模块\电池电压 V>=2.8V 2.8V>V>=2.6V V<2.6V
按键 第一按键电流 第二按键电流 第三按键电流
显示 第一显示电流 第二显示电流 第三显示电流
休眠 第一休眠电流 第二休眠电流 第三休眠电流
唤醒 第一唤醒电流 第二唤醒电流 第三唤醒电流
口令计算 第一口令计算电流 第二口令计算电流 第三口令计算电流
蓝牙通信 第一蓝牙通信电流 第二蓝牙通信电流 第三蓝牙通信电流
蓝牙配对 第一蓝牙配对电流 第二蓝牙配对电流 第三蓝牙配对电流
具体地,读取预先存储的的电池电压-电流数据表,如果电池电压大于或等于2.8V,则按键模块对应的电流值为第一按键电流,显示模块对应的电流值为第一显示电流,休眠模块对应的电流值为第一休眠电流,唤醒模块对应的电流值为第一唤醒电流,口令计算模块对应的电流值为第一口令计算电流,蓝牙通信模块对应的电流值为第一蓝牙通信电流,蓝牙配对模块对应的电流值为第一蓝牙配对电流;
如果电池电压大于或等于2.6V且小于2.8V,则按键模块对应的电流值为第二按键电流, 显示模块对应的电流值为第二显示电流,休眠模块对应的电流值为第二休眠电流,唤醒模块对应的电流值为第二唤醒电流,口令计算模块对应的电流值为第二口令计算电流,蓝牙通信模块对应的电流值为第二蓝牙通信电流,蓝牙配对模块对应的电流值为第二蓝牙配对电流;
如果电池电压小于2.6V,则按键模块对应的电流值为第三按键电流,显示模块对应的电流值为第三显示电流,休眠模块对应的电流值为第三休眠电流,唤醒模块对应的电流值为第三唤醒电流,口令计算模块对应的电流值为第三口令计算电流,蓝牙通信模块对应的电流值为第三蓝牙通信电流,蓝牙配对模块对应的电流值为第三蓝牙配对电流;
例如,蓝牙卡检测电池电压为3V,则按键模块对应的电流值为的第一按键电流,显示模块对应的电流值为第一显示电流,休眠模块对应的电流值为第一休眠电流,唤醒模块对应的电流值为第一唤醒电流,口令计算模块对应的电流值为第一口令计算电流,蓝牙通信模块对应的电流值为第一蓝牙通信电流,蓝牙配对模块对应的电流值为第一蓝牙配对电流,分别计算七个功能模块的耗电量;
按键模块耗电量=第一按键电流×按键总时长;
具体地,按键总时长为第三寄存器中的数据;
显示模块耗电量=第一显示电流×显示总时长;
具体地,显示总时长为第五寄存器中的数据;
唤醒模块耗电量=第一唤醒电流×唤醒时长;
具体地,唤醒时长为第二寄存器中的数据;
口令计算模块耗电量=第一口令计算电流×口令计算总时长;
具体地,口令计算总时长为第四寄存器中的数据;
蓝牙通信模块耗电量=第一蓝牙通信电流×蓝牙通信时间;
具体地,蓝牙通信时间为第七寄存器中的数据;
蓝牙配对模块耗电量=第一蓝牙配对电流×蓝牙配对时间;
具体地,蓝牙配对时间为第八寄存器中的数据;
休眠模块耗电量=第一休眠电流×(第一预设值-显示总时长-按键总时长-唤醒时长-口令计算总时长-蓝牙通信时间-蓝牙配对时间);
总消耗电量=按键模块耗电量+显示模块耗电量+休眠模块耗电量+唤醒模块耗电量+口令计算模块耗电量+蓝牙通信模块耗电量+蓝牙配对模块耗电量;
步骤310:蓝牙卡判断总消耗电量是否小于第二预设值,是则将总消耗电量存入电量消耗计数寄存器中,执行步骤311,否则将剩余电量减第三预设值的结果更新为剩余电量,将总消耗电量与第二预设值的差值存入电量消耗计数寄存器中,执行步骤311;
具体地,第二预设值为2700000uAs,第三预设值为1%;
例如,电池容量75mAh,百分之一的电池容量为0.75mAh,由于各功能模块耗电电流对应的都是uA级,所以将百分之一的电池容量换算成uAs即0.75mAh=2700000uAs;
步骤311:蓝牙卡判断电量消耗计数寄存器中的数值是否小于第二预设值,是则将第二寄存器中的数据清除,返回步骤303,否则将剩余电量减第三预设值的结果更新为剩余电量,将电量消耗计数寄存器中的数值与第二预设值的差值更新到电量消耗计数寄存器中,将第二寄存器中的数据清除,返回步骤303。
实施例七:
本发明实施例七提供一种设备剩余电量的计量装置,应用于常显型动态令牌,如图4所示,包括:
检测模块11,用于检测标志位状态,当第一标志位置位时触发计算口令模块12,当第二标志位置位时,触发计算总消耗电量模块14;
计算口令模块12,用于开启定时器开始计数,计算口令,当口令计算完成时关闭定时器,停止计数得到口令计算时间,重置定时器,将口令计算时间累加至第四寄存器中,触发显示 模块13;
显示模块13,用于显示口令和剩余电量,将第一标志位复位,触发检测模块11;
计算总消耗电量模块14,用于检测电池电压,根据检测到的电池电压和预先存储的第一数据表获取预置的唤醒电流值、口令计算电流值、显示电流值,将唤醒电流值与第一寄存器中的数据的乘积、口令计算电流值与第四寄存器中的数据的乘积、显示电流值与第一预设值减第四寄存器中的数据的结果的乘积相加得到总消耗电量;
更新剩余电量模块15,用于根据总消耗电量与第二预设值更新剩余电量,将第二标志位复位,触发检测模块11;
装置还包括:实时时钟模块,用于计量设备的时间,每隔第一预设时间触发唤醒模块;
唤醒模块,用于开启定时器开始计数,将第二寄存器和第六寄存器中的数据分别加第一预设时间的结果更新至第二寄存器和第六寄存器中,当第六寄存器中的数据等于第四预设值时,将第一标志位置位,清除第六寄存器中的数据,关闭定时器停止计数,得到唤醒用时,将唤醒用时累加至第一寄存器中;当第二寄存器中的数据等于第一预设值时将第二标志位置位,关闭定时器停止计数,得到唤醒用时,将唤醒用时累加至第一寄存器中。
优选地,在本实施例七中,计算口令模块12,还用于当口令计算完成时停止计数,从定时器寄存器中获取第三数值,根据第三数值得到口令计算时间,清除第三数值。
优选地,在本实施例七中,唤醒模块,还用于关闭定时器停止计数,从定时器寄存器中获取第一数值,根据第一数值得到唤醒用时,清除第一数值。
优选地,在本实施例七中,更新剩余电量模块15包括:
第一判断子模块,用于判断总消耗电量是否小于第二预设值,是则将总消耗电量存入电量消耗计数寄存器中,触发第二判断子模块,否则将剩余电量减第三预设值的结果更新为剩余电量,将总消耗电量与第二预设值的差值存入电量消耗计数寄存器中,触发第二判断子模块;
第二判断子模块,用于判断电量消耗计数寄存器中的数值是否小于第二预设值,是则将第二寄存器中的数值恢复为初始值,将第二标志位复位,触发检测模块11,否则将剩余电量减第三预设值的结果更新为剩余电量,将电量消耗寄存器中的数值与第二预设值的差值更新到电量消耗计数寄存器中,将第二寄存器中的数值恢复为初始值,将第二标志位复位,触发检测模块11。
实施例八:
本发明实施例八提供一种设备剩余电量计量装置,应用于按键型动态令牌,如图5所示,包括:
检测模块21,用于检测标志位状态,当第一标志位置位时触发计算口令模块22,当第二标志位置位时,触发计算总消耗电量模块24;
计算口令模块22,用于开启定时器开始计数,计算口令,当口令计算完成时关闭定时器,停止计数得到口令计算时间,重置定时器,将口令计算时间累加至第四寄存器中,触发显示模块23;
显示模块23,用于开启定时器开始计数,显示口令和剩余电量,当显示结束时关闭定时器停止计数,得到显示时间,重置定时器,将显示时间累加至第五寄存器中,将第一标志位复位,触发检测模块21;
计算总消耗电量模块24,用于检测电池电压,根据检测到的电池电压和预先存储的第一数据表获取预置的唤醒模块电流值、口令计算电流值、按键电流值、显示电流值和休眠电流值,将唤醒电流值与第一寄存器中的数据的乘积、口令计算电流值与第四寄存器中的数据的乘积、按键电流值与第三寄存器中的数据的乘积、显示电流值与第五寄存器中的数据的乘积、休眠电流值与第一预设值减第一寄存器、第四寄存器、第三寄存器、第五寄存器中的数据的结果的乘积相加得到总消耗电量;
更新剩余电量模块25,用于根据总消耗电量与第二预设值更新剩余电量,将第二标志位复位,触发检测模块21;
装置还包括:实时时钟模块,用于计量设备的时间,每隔第一预设时间触发唤醒模块;
唤醒模块,具体用于开启定时器开始计数,将第二寄存器中的数据加第一预设时间的结果更新至第二寄存器中,判断第二寄存器中的数据是否等于第一预设值,是则将第二标志位置位,关闭定时器停止计数,得到唤醒用时,将唤醒用时累加至第一寄存器中;否则关闭定时器停止计数,得到唤醒用时,将唤醒用时累加至第一寄存器中;
按键中断模块,用于开启定时器开始计数,将第一标志位置位,当检测到第二电平时关闭定时器停止计数,得到按键时长,将按键时长累加保存至第三寄存器中,退出按键中断。
优选地,在本实施例八中,计算口令模块22,还用于当口令计算完成时停止计数,从定时器寄存器中获取第三数值,根据第三数值得到口令计算时间,清除第三数值。
优选地,在本实施例八中,唤醒模块,还用于关闭定时器停止计数,从定时器寄存器中获取第一数值,根据第一数值得到唤醒用时,清除第一数值。
优选地,在本实施例八中,显示模块23,还用于当显示结束时停止计数,从定时寄存器中获取第四数值,根据第四数值得到显示时长,将显示时长累加保存至第五寄存器中,清除第四数值。
优选地,在本实施例八中,显示模块23,还用于当检测到第一电平时,显示结束,开启定时器开始计数,当检测到第二电平时,关闭定时器停止计数,从定时器寄存器中获取第二数值,根据第二数值得到按键时长,将按键时长累加至第三寄存器中,清除第二数值。
优选地,在本实施例八中,按键中断模块,还用于当检测到第二电平时,关闭定时器停止计数,从定时器寄存器中获取第二数值,根据第二数值得到按键时长,清除第二数值。
优选地,在本实施例八中,显示模块23替换为第二显示模块,用于开启定时器开始计数,显示口令,当显示结束时停止计数,得到显示时间,将显示时间累加至第五寄存器中,将第一标志位复位,触发检测模块。
优选地,在本实施例八中,第二显示模块,还用于当检测到第一电平时,开启第二定时器开始计数,当检测到第二电平时关闭第二定时器停止计数,从第二定时器寄存器中获取第五数值,根据第五数值得到按键时长,将按键时长累加保存至第三寄存器中,清除第五数值,如按键时长大于或等于第五预设值则切换屏幕显示剩余电量;如按键时长小于第五预设值时则关闭定时器停止计数,从定时寄存器中获取第四数值,根据第四数值得到显示时长,将显示时长累加保存至第五寄存器中,清除第四数值。
优选地,在本实施例八中,更新剩余电量模块25包括:
第一判断子模块,用于判断总消耗电量是否小于第二预设值,是则将总消耗电量存入电量消耗计数寄存器中,触发第二判断子模块;否则将剩余电量减第三预设值的结果更新为剩余电量,将总消耗电量与第二预设值的差值存入电量消耗计数寄存器中,触发第二判断子模块;
第二判断子模块,用于判断电量消耗计数寄存器中的数值是否小于第二预设值,是则将第二寄存器中的数值恢复为初始值,将第二标志位复位,触发检测模块21,否则将剩余电量减第三预设值的结果更新为剩余电量,将电量消耗寄存器中的数值与第二预设值的差值更新到电量消耗计数寄存器中,将第二寄存器中的数值恢复为初始值,将第二标志位复位,触发检测模块21。
实施例九:
本发明实施例九提供一种设备剩余电量的计量装置,应用于蓝牙卡,如图6所示,包括:
检测模块31,用于检测标志位状态,当第一标志位置位时触发计算口令模块32,当第二标志位置位时,触发计算总消耗电量模块34;
计算口令模块32,用于开启定时器开始计数,计算口令,当口令计算完成时关闭定时器, 停止计数得到口令计算时间,重置定时器,将口令计算时间累加至第四寄存器中,触发蓝牙模块36和显示模块33;
蓝牙模块36,用于开启定时器开始计数,与上位机进行蓝牙配对,配对成功时关闭定时器停止计数得到蓝牙配对时间,重置定时器,将蓝牙配对时间累加至第八寄存器中,开启定时器开始计数,将口令通过蓝牙发送给上位机,关闭定时器停止计数得到蓝牙通信时间并累加至第七寄存器中,重置定时器;
显示模块33,用于开启定时器开始计数,显示口令和剩余电量,当显示结束时关闭定时器停止计数,得到显示时间,重置定时器,将显示时间累加至第五寄存器中,将第一标志位复位,触发检测模块31;
计算总消耗电量模块34,用于检测电池电压,根据检测到的电池电压和预先存储的第一数据表获取预置的唤醒模块电流值、口令计算电流值、按键电流值、显示电流值、蓝牙通信电流值、蓝牙配对电流值、休眠电流值,将唤醒电流值与第一寄存器中的数据的乘积、口令计算电流值与第四寄存器中的数据的乘积、按键电流值与第三寄存器中的数据的乘积、显示电流值与第五寄存器中的数据的乘积、蓝牙通信电流值与第七寄存器中的数据的乘积、蓝牙配对电流值与第八寄存器中的数据的乘积、休眠电流值与第一预设值减第一寄存器、第四寄存器、第三寄存器、第五寄存器、第七寄存器、第八寄存器中的数据的结果的乘积相加计算得到总消耗电量;
更新剩余电量模块35,用于根据总消耗电量与第二预设值更新剩余电量,将第二标志位复位,触发检测模块31;
装置还包括:
实时时钟模块,用于计量设备的时间,每隔第一预设时间触发唤醒模块;
唤醒模块,用于开启定时器开始计数,将第二寄存器中的数据加第一预设时间的结果更新至第二寄存器中,判断第二寄存器中的数据是否等于第一预设值,是则将第二标志位置位,关闭定时器停止计数,得到唤醒用时,将唤醒用时累加至第一寄存器中;否则关闭定时器停止计数,得到唤醒用时,将唤醒用时累加至第一寄存器中;
按键中断模块,用于开启定时器开始计数,将第一标志位置位,当检测到第二电平时关闭定时器停止计数,得到按键时长,将按键时长累加保存至第三寄存器中,退出按键中断。
优选地,在本实施例九中,蓝牙模块,还用于从定时器中获取第七数值,根据第七数值得到蓝牙配对时间;具体还用于从定时寄存器中获取第六数值,根据第六数值得到蓝牙通信时间。
优选地,在本实施例九中,计算口令模块,还用于当口令计算完成时停止计数,从定时器寄存器中获取第三数值,根据第三数值得到口令计算时间,清除第三数值。
优选地,在本实施例九中,唤醒模块,还用于关闭定时器停止计数,从定时器寄存器中获取第一数值,根据第一数值得到唤醒用时,清除第一数值。
优选地,在本实施例九中,显示模块,还用于当显示结束时停止计数,从定时寄存器中获取第四数值,根据第四数值得到显示时长,将显示时长累加保存至第五寄存器中,清除第四数值。
优选地,在本实施例九中,显示模块,还用于当检测到第一电平时,显示结束,开启定时器开始计数,当检测到第二电平时,关闭定时器停止计数,从定时器寄存器中获取第二数值,根据第二数值得到按键时长,将按键时长累加至第三寄存器中,清除第二数值。
优选地,在本实施例九中,按键中断模块,还用于当检测到第二电平时,关闭定时器停止计数,从定时器寄存器中获取第二数值,根据第二数值得到按键时长,清除第二数值。
优选地,在本实施例九中,显示模块替换为第二显示模块,用于开启定时器开始计数,显示口令,当显示结束时停止计数,得到显示时间,将显示时间累加至第五寄存器中,将第一标志位复位,触发检测模块。
优选地,在本实施例九中,第二显示模块,还用于当检测到第一电平时,开启第二定时 器开始计数,当检测到第二电平时关闭第二定时器停止计数,从第二定时器寄存器中获取第五数值,根据第五数值得到按键时长,将按键时长累加保存至第三寄存器中,清除第五数值,如按键时长大于或等于第五预设值则切换屏幕显示剩余电量;如按键时长小于第五预设值时则关闭定时器停止计数,从定时寄存器中获取第四数值,根据第四数值得到显示时长,将显示时长累加保存至第五寄存器中,清除第四数值。
优选地,在本实施例九中,更新剩余电量模块包括:
第一判断子模块,用于判断总消耗电量是否小于第二预设值,是则将总消耗电量存入电量消耗计数寄存器中,触发第二判断子模块,否则将剩余电量减第三预设值的结果更新为剩余电量,将总消耗电量与第二预设值的差值存入电量消耗计数寄存器中,触发第二判断子模块;
第二判断子模块,用于判断电量消耗计数寄存器中的数值是否小于第二预设值,是则将第二寄存器中的数值恢复为初始值,将第二标志位复位,触发检测模块31,否则将剩余电量减第三预设值的结果更新为剩余电量,将电量消耗寄存器中的数值与第二预设值的差值更新到电量消耗计数寄存器中,将第二寄存器中的数值恢复为初始值,将第二标志位复位,触发检测模块31。
以上所述,仅为本发明较佳的具体实施方式,但本发明的保护范围并不局限于此,本领域的技术人员在本发明公开的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应该以所附权利要求书的保护范围为准。

Claims (8)

  1. 一种设备剩余电量的计量方法,其特征在于,包括以下步骤:
    S1)检测标志位状态,当处于第一标志位置位时,执行步骤S2,当处于第二标志位置位时,执行步骤S4;
    S2)开启定时器开始计数,计算口令,当口令计算完成时关闭所述定时器,停止计数得到口令计算时间,重置所述定时器,将所述口令计算时间累加至第四寄存器中,执行步骤S3;
    S3)显示所述口令和剩余电量,将所述第一标志位复位,返回步骤S1;
    S4)检测电池电压,根据检测到的电池电压和预先存储的第一数据表获取预置的唤醒电流值、口令计算电流值、显示电流值,将所述唤醒电流值与第一寄存器中的数据的乘积、所述口令计算电流值与所述第四寄存器中的数据的乘积、所述显示电流值与第一预设值减所述第四寄存器中的数据的结果的乘积相加得到总消耗电量;
    S5)根据所述总消耗电量与第二预设值更新剩余电量,将所述第二标志位复位,返回步骤S1;
    在执行步骤S1至步骤S5的过程中,当检测到实时时钟中断时,执行步骤A1至步骤A4,实时时钟中断每隔第一预设时间触发一次;
    A1)开启定时器开始计数,将第二寄存器和第六寄存器中的数据分别加所述第一预设时间的结果更新至所述第二寄存器和所述第六寄存器中,当所述第六寄存器中的数据等于第四预设值时,执行步骤A2;当所述第二寄存器中的数据等于所述第一预设值时执行步骤A3;
    A2)将所述第一标志位置位,清除所述第六寄存器中的数据,执行步骤A4;
    A3)将所述第二标志位置位,执行步骤A4;
    A4)关闭定时器停止计数,得到唤醒用时,将所述唤醒用时累加至第一寄存器中。
  2. 如权利要求1所述的方法,其特征在于,所述当口令计算完成时关闭所述定时器,停止计数得到口令计算时间,重置所述定时器,具体为:
    当口令计算完成时停止计数,从定时器寄存器中获取第三数值,根据所述第三数值得到口令计算时间,清除所述第三数值。
  3. 如权利要求1所述的方法,其特征在于,所述关闭定时器停止计数,得到唤醒用时,具体包括:
    关闭定时器停止计数,从定时器寄存器中获取第一数值,根据所述第一数值得到唤醒用时,清除所述第一数值。
  4. 如权利要求1所述的方法,其特征在于,所述步骤S5具体包括:
    S5-1)判断所述总消耗电量是否小于第二预设值,是,则将所述总消耗电量存入电量消耗计数寄存器中,执行步骤S5-2;否,则将剩余电量减第三预设值的结果更新为所述剩余电量,将总消耗电量与第二预设值的差值存入电量消耗计数寄存器中,执行步骤S5-2;
    S5-2)判断所述电量消耗计数寄存器中的数值是否小于所述第二预设值,是,则将所述第二寄存器中的数值恢复为初始值,将第二标志位复位,返回步骤S1;否,则将所述剩余电量减第三预设值的结果更新为所述剩余电量,将电量消耗寄存器中的数值与第二预设值的差值更新到所述电量消耗计数寄存器中,将所述第二寄存器中的数值恢复为初始值,将第二标志位复位,返回步骤S1。
  5. 一种设备剩余电量的计量装置,其特征在于,包括:
    检测模块,用于检测标志位状态,当第一标志位置位时触发计算口令模块,当第二标志位置位时,触发计算总消耗电量模块;
    所述计算口令模块,用于开启定时器开始计数,计算口令,当口令计算完成时关闭所述定时器,停止计数得到口令计算时间,重置所述定时器,将所述口令计算时间累加至第四寄存器中,触发显示模块;
    所述显示模块,用于显示所述口令和剩余电量,将所述第一标志位复位,触发所述检测模块;
    所述计算总消耗电量模块,用于检测电池电压,根据检测到的电池电压和预先存储的第一数据表获取预置的唤醒电流值、口令计算电流值、显示电流值,将所述唤醒电流值与第一寄存器中的数据的乘积、所述口令计算电流值与所述第四寄存器中的数据的乘积、所述显示电流值与第一预设值减所述第四寄存器中的数据的结果的乘积相加得到总消耗电量;
    更新剩余电量模块,用于根据所述总消耗电量与第二预设值更新剩余电量,将所述第二标志位复位,触发所述检测模块;
    实时时钟模块,用于计量所述设备的时间,每隔第一预设时间触发唤醒模块;
    所述唤醒模块,用于开启定时器开始计数,将第二寄存器和第六寄存器中的数据分别加所述第一预设时间的结果更新至所述第二寄存器和所述第六寄存器中,当所述第六寄存器中的数据等于第四预设值时,将所述第一标志位置位,清除所述第六寄存器中的数据,关闭定时器停止计数,得到唤醒用时,将所述唤醒用时累加至第一寄存器中;当所述第二寄存器中的数据等于所述第一预设值时将所述第二标志位置位,关闭定时器停止计数,得到唤醒用时,将所述唤醒用时累加至第一寄存器中。
  6. 如权利要求5所述的装置,其特征在于,所述计算口令模块,还用于当口令计算完成时停止计数,从定时器寄存器中获取第三数值,根据所述第三数值得到口令计算时间,清除所述第三数值。
  7. 如权利要求5所述的装置,其特征在于,所述唤醒模块,还用于关闭定时器停止计数,从定时器寄存器中获取第一数值,根据所述第一数值得到唤醒用时,清除所述第一数值。
  8. 如权利要求5所述的装置,其特征在于,所述更新剩余电量模块包括:
    第一判断子模块,用于判断所述总消耗电量是否小于第二预设值,是则将所述总消耗电量存入电量消耗计数寄存器中,触发第二判断子模块,否则将剩余电量减第三预设值的结果更新为所述剩余电量,将总消耗电量与第二预设值的差值存入所述电量消耗计数寄存器中,触发所述第二判断子模块;
    所述第二判断子模块,用于判断所述电量消耗计数寄存器中的数值是否小于所述第二预设值,是则将所述第二寄存器中的数值恢复为初始值,将所述第二标志位复位,触发所述检测模块,否则将所述剩余电量减第三预设值的结果更新为所述剩余电量,将电量消耗寄存器中的数值与第二预设值的差值更新到所述电量消耗计数寄存器中,将所述第二寄存器中的数值恢复为初始值,将第二标志位复位,触发所述检测模块。
PCT/CN2021/100762 2020-07-16 2021-06-18 一种设备剩余电量的计量方法及装置 WO2022012261A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US17/799,563 US20230128424A1 (en) 2020-07-16 2021-06-18 Method and apparatus for measuring remaining power level of device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010683762.1 2020-07-16
CN202010683762.1A CN111562502B (zh) 2020-07-16 2020-07-16 一种设备剩余电量计量方法及装置

Publications (1)

Publication Number Publication Date
WO2022012261A1 true WO2022012261A1 (zh) 2022-01-20

Family

ID=72075461

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/100762 WO2022012261A1 (zh) 2020-07-16 2021-06-18 一种设备剩余电量的计量方法及装置

Country Status (3)

Country Link
US (1) US20230128424A1 (zh)
CN (1) CN111562502B (zh)
WO (1) WO2022012261A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111562502B (zh) * 2020-07-16 2020-10-13 飞天诚信科技股份有限公司 一种设备剩余电量计量方法及装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103472744A (zh) * 2013-09-23 2013-12-25 天地融科技股份有限公司 动态令牌工作状态的控制方法、装置及动态令牌
US20140082580A1 (en) * 2012-06-18 2014-03-20 International Business Machines Corporation Current-aware floorplanning to overcome current delivery limitations in integrated circuits
CN105516901A (zh) * 2015-12-21 2016-04-20 飞天诚信科技股份有限公司 一种低功耗蓝牙设备及其工作方法
CN111562502A (zh) * 2020-07-16 2020-08-21 飞天诚信科技股份有限公司 一种设备剩余电量计量方法及装置

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105158695B (zh) * 2015-08-14 2018-03-16 国网浙江省电力公司丽水供电公司 一种车载蓄电池用电信息的测量和分析方法及分析设备
CN106556801B (zh) * 2016-10-09 2019-07-19 歌尔科技有限公司 一种获取电池电量的方法、装置和电子设备
CN107544029A (zh) * 2017-08-24 2018-01-05 苏州麦喆思科电子有限公司 一种基于锂电源的智能监测控制方法
CN108061857A (zh) * 2017-10-18 2018-05-22 深圳市沃特玛电池有限公司 中型储能装置的电池包soc估算方法及系统
JP7087799B2 (ja) * 2018-08-02 2022-06-21 株式会社デンソー 劣化状態推定装置及びこれを含む電源装置
CN111413623B (zh) * 2020-04-09 2022-05-31 苏州维伟思医疗科技有限公司 一种剩余电量计算方法、装置及计算机可读存储介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140082580A1 (en) * 2012-06-18 2014-03-20 International Business Machines Corporation Current-aware floorplanning to overcome current delivery limitations in integrated circuits
CN103472744A (zh) * 2013-09-23 2013-12-25 天地融科技股份有限公司 动态令牌工作状态的控制方法、装置及动态令牌
CN105516901A (zh) * 2015-12-21 2016-04-20 飞天诚信科技股份有限公司 一种低功耗蓝牙设备及其工作方法
CN111562502A (zh) * 2020-07-16 2020-08-21 飞天诚信科技股份有限公司 一种设备剩余电量计量方法及装置

Also Published As

Publication number Publication date
US20230128424A1 (en) 2023-04-27
CN111562502A (zh) 2020-08-21
CN111562502B (zh) 2020-10-13

Similar Documents

Publication Publication Date Title
JP2708344B2 (ja) コンピュータ・システム
CN100568013C (zh) 一种通过检测开路电压来测定电池剩余电量的方法和系统
US20110313697A1 (en) Method and apparatus for monitoring battery life
JPH08136628A (ja) 電池容量監視装置
TW201333742A (zh) 應用程式狀態的檢測系統以及方法
CN103364735A (zh) 移动电源电池电量精确显示方法及装置
US20040113590A1 (en) Low battery detection on an electronic device
WO2022012261A1 (zh) 一种设备剩余电量的计量方法及装置
JP2003068312A (ja) 電池交換時期判別方法及び電池交換時期判別装置
US20100332880A1 (en) Mobile Electronic Device
JP5577838B2 (ja) バッテリパック、電子機器及びバッテリパックの検査方法
CN109040467A (zh) 界面电量确定方法、装置、存储介质及移动终端
JP4523099B2 (ja) 電池電圧検出回路及び電池電圧検出方法
WO2020042710A1 (zh) 一种提高电量测量准确性的方法
JP2023101509A (ja) 半導体装置、およびバッテリの残量の検出方法
US6339315B1 (en) Measuring counter of the state of charge of the powering battery of an electronic appliance
US20030169020A1 (en) Battery charge monitor
JP2014190727A (ja) 蓄電池の残量推定装置及び残量推定方法
US20030076231A1 (en) Method and apparatus for end of discharge indication based on critical energy requirement
EP2577336A1 (en) Method and apparatus for estimating remaining operating time
CN112946562B (zh) 双芯智能电表的掉电保护方法、装置和双芯智能电表
JP2018200306A (ja) バッテリの残量検出回路、それを用いた電子機器、バッテリ残量の検出方法
JP2003151645A (ja) 電池残量検知方法および電気機器
US7325153B2 (en) Obtaining configuration data for a data processing apparatus
CN208334596U (zh) 电池监测装置和电池模组

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21841978

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21841978

Country of ref document: EP

Kind code of ref document: A1