energy metering for free: augmenting switching regulators for …prabal/pubs/papers/... · 2008....

7
Energy Metering for Free: Augmenting Switching Regulators for Real-Time Monitoring Prabal Dutta , Mark Feldmeier , Jay Taneja , Joseph Paradiso , and David Culler {prabal,taneja,culler}@cs.berkeley.edu {carboxyl,joep}@mit.edu Computer Science Division The Media Laboratory University of California, Berkeley Massachusetts Institute of Technology Berkeley, CA 94720 Cambridge, MA 02139 1. Contact Person: Prabal Dutta, +1 510 495 4932 (tel), +1 510 642 5775 (fax), [email protected]. 2. Designated Presenter: Prabal Dutta or Jay Taneja, TBD 3. An earlier version of this work appeared at IPSN’08 [1], which established the originality and distinguishing features of the design. Since that time, the iCount design has been integrated into a number of new hardware and software systems, which we would demonstate at ISLPED’08. Approval to submit this work to the ISLPED Design Contest was obtained from Yu Cao on May 22, 2008. 4. “All appropriate organizational approvals for the publication of this paper have obtained. If accepted the author(s) will select a designated speaker to present the paper at the Symposium.” /s/ Prabal K. Dutta

Upload: others

Post on 25-Aug-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Energy Metering for Free: Augmenting Switching Regulators for …prabal/pubs/papers/... · 2008. 10. 27. · Energy Metering for Free: Augmenting Switching Regulators for Real-Time

Energy Metering for Free:Augmenting Switching Regulators for Real-Time Monitoring

Prabal Dutta†, Mark Feldmeier‡, Jay Taneja†, Joseph Paradiso‡, and David Culler†

prabal,taneja,[email protected] carboxyl,[email protected]

†Computer Science Division ‡The Media LaboratoryUniversity of California, Berkeley Massachusetts Institute of Technology

Berkeley, CA 94720 Cambridge, MA 02139

1. Contact Person: Prabal Dutta, +1 510 495 4932 (tel), +1 510 642 5775 (fax), [email protected].

2. Designated Presenter: Prabal Dutta or Jay Taneja, TBD

3. An earlier version of this work appeared at IPSN’08 [1], which established the originality and distinguishing features ofthe design. Since that time, the iCount design has been integrated into a number of new hardware and software systems,which we would demonstate at ISLPED’08. Approval to submit this work to the ISLPED Design Contest was obtainedfrom Yu Cao on May 22, 2008.

4. “All appropriate organizational approvals for the publication of this paper have obtained. If accepted the author(s) willselect a designated speaker to present the paper at the Symposium.” /s/ Prabal K. Dutta

Page 2: Energy Metering for Free: Augmenting Switching Regulators for …prabal/pubs/papers/... · 2008. 10. 27. · Energy Metering for Free: Augmenting Switching Regulators for Real-Time

Abstract

We present iCount, a new energy meter design. For manysystems that have a built-in switching regulator, adding asingle wire between the regulator and the microcontrollerenables real-time energy metering. iCount measures energyusage by counting the switching cycles of the regulator. Weshow that switching frequency changes nearly linearly withload current for a variety of regulators.

1 The iCount Design

Many battery-operated devices use a switching regula-tor, as shown in Figure 1. Such regulators provide a con-stant output voltage and high conversion efficiency acrossa range of input voltages and load currents. Although avariety of regulator topologies (boost, buck, buck-boost),control modes (current-mode, voltage-mode) and modula-tion schemes (pulse-frequency modulated, pulse-width mod-ulated) exist, we focus on boost regulators that employcurrent-mode control using pulse frequency modulation.Such regulators allow single-cell operation, can supply highcurrents, and draw ultra-low quiescent currents, making themideal for low-power, battery-operated systems that exhibita wide dynamic range in power draws. Unless otherwisenoted, we use the terms switcher and regulator interchange-ably in the remainder of this paper to describe PFM regula-tors.

Cin Cout

Lx

LX

Vi Vo

GND

Vi

GND

Counter

Vin

SwitchingRegulator Micro-

controller

Figure 1. A typical system with switching regulator-based power supply, including the regulator, in-put capacitor, output capacitor, inductor, and load.Adding a single wire (the dashed line) between theregulator and a microcontroller counter input en-ables real-time energy metering.

A switcher goes through three stages during a switch-ing cycle, as Figure 2 shows. Each cycle delivers 1

2Li2 J,where i is the peak inductor current (i.e. the max value ofILX). A cycle begins when the switcher senses that the out-put has fallen below the regulation threshold. During thefirst stage of a cycle, the switch-side of the inductor (LX)is connected to ground. The resulting potential differenceacross the inductor gives rise to a steadily increasing current.When this current reaches a limit (or some maximum on-time has passed), the switch-side of the inductor is discon-

MA

X1

72

2/M

AX

17

23

/MA

X1

72

4

1.5µA IQ, Step-Up DC-DC Convertersin Thin SOT23-5

4 _______________________________________________________________________________________

Typical Operating Characteristics(Figure 3 (MAX1723), Figure 7 (MAX1722), Figure 8 (MAX1724), VBATT = VIN = 1.5V, L = 10µH, CIN = 10µF, COUT = 10µF, TA = +25°C,unless otherwise noted.)

0

40

120

80

160

200

0 21 3 4 5

MAXIMUM OUTPUT CURRENT vs. INPUT VOLTAGE

MAX

1722

toc0

4

INPUT VOLTAGE (V)

I OUT

(MAX

) (m

A)

VOUT = 2.5V

VOUT = 5.0V

VOUT = 3.3V

10 100

0.8

1.0

1.2

1.4

1.6

2.0

1.8

2.2

2.4

0.01 0.1 1

STARTUP VOLTAGE vs. LOAD CURRENT

MAX

1722

toc0

5

LOAD CURRENT (mA)

STAR

TUP

VOLT

AGE

(V)

0.6

RESISTIVE LOADVOUT = 5.0V

0

0.4

0.2

0.8

0.6

1.2

1.0

1.4

1.8

1.6

2.0

1.0 2.0 2.5 3.01.5 3.5 4.0 4.5 5.0 5.5

MAX

1722

toc0

6

QUIE

SCEN

T CU

RREN

T (µ

A)

OUTPUT VOLTAGE (V)

QUIESCENT CURRENT INTO OUTvs. OUTPUT VOLTAGE

NO LOAD

100

0.01 0.1 1 10 100 1000

EFFICIENCY vs. LOAD CURRENT(VOUT = 5.0V)

MAX

1722

toc0

1

LOAD CURRENT (mA)

EFFI

CIEN

CY (%

)

60

80

50

70

90VIN = 2.0V

VIN = 3.3V VIN = 4.0V

VIN = 1.5V

VIN = 1.0V

L = DO1606

100

0.01 0.1 1 10 100 1000

EFFICIENCY vs. LOAD CURRENT(VOUT = 3.3V)

MAX

1722

toc0

2

LOAD CURRENT (mA)

EFFI

CIEN

CY (%

)

60

80

50

70

90 VIN = 2.0VVIN = 2.5V

VIN = 1.5V

VIN = 1.0V

L = DO1606

100

0.01 0.1 1 10 100 1000

EFFICIENCY vs. LOAD CURRENT(VOUT = 2.5V)

MAX

1722

toc0

3

LOAD CURRENT (mA)

EFFI

CIEN

CY (%

)

60

80

50

70

90

VIN = 1.5V

VIN = 2.0V

VIN = 1.0V L = DO1606

0

0.4

0.2

0.8

0.6

1.0

1.2

-40 85

STARTUP VOLTAGE vs.TEMPERATURE

MAX

1722

toc0

7

TEMPERATURE (°C)

STAR

TUP

VOLT

AGE

(V)

10-15 35 60

NO LOAD

1µs/div

ILX500mA/div

VOUT50mV/div

VLX2V/div

SWITCHING WAVEFORMS

MAX

1722

toc0

8

IOUT = 50mA, VOUT = 5.0V, VIN = 3.3V

Figure 2. The switching waveform of the MaximMAX1724 switcher. The inductor voltage, VLX,alternates between the input voltage (3.3 V), ground(0 V), and output voltage (5.0 V). Source: Maxim [2].

nected from ground. During the second stage of the cycle,the switch-side of the inductor is connected to the switcheroutput, which discharges the inductor energy into the out-put capacitor. When the inductor current ramps to zero, thedischarge stage is complete. Sometimes, the inductor andoutput capacitor form a resonant circuit and this stage endswith ringing oscillations. During the third stage, the switchermaintains a quiescent state while the load draws current fromthe output capacitor. A cycle repeats when the output fallsbelow the regulation threshold.

The iCount design is motivated by the simple observa-tion that many switchers exhibit a nearly linear relationshipbetween switching frequency and load current over a widedynamic range. Figure 3 shows how the switching frequencychanges with load current for several different commercialswitchers. In this figure, the bias, or no-load switching fre-quency, has been subtracted from each data point. Fortu-nately, such biases can be subtracted easily in software. Al-though the data appear linear over five decades, the data arelinear only if the lines have unit slope since they are plottedon a log-log scale. We investigate the linearity in Section 3.

Since switchers provide a constant output voltage, thenearly linear relationship between switching frequency andload current implies a fixed amount of energy is deliveredper cycle. Therefore, simply counting switching cycles ap-proximates the total energy used over the counting interval,and dividing the number of counts by the counting intervalgives the average power over that interval. However, be-cause switchers do not expose their internal control logic andsignals, one challenge is determining when the switcher ac-tually cycles using only the signals that are observable ex-ternally. Our solution is to monitor the switch-side voltage,VLX, of the inductor since it alternates between the inputvoltage, ground, and output voltage, as shown in Figure 2.

The basic iCount design follows directly from the data

Page 3: Energy Metering for Free: Augmenting Switching Regulators for …prabal/pubs/papers/... · 2008. 10. 27. · Energy Metering for Free: Augmenting Switching Regulators for Real-Time

10−7

10−6

10−5

10−4

10−3

10−2

10−1

100

10−1

100

101

102

103

104

105

106

Load Current (A)

Sw

itch

ing

Fre

qu

ency

(H

z)

MAX1724TPS61020TPS61120TPS61200

Figure 3. The relationship between load current andswitching frequency for several switchers, after biascompensation. Some switchers are more linear thanothers (and sometimes over a wider dynamic range).Plotted on a log-log scale.

in Figures 2 and 3. Counting the rising edges of the VLXsignal is all that is required to accumulate energy usage.Since many battery-operated systems include a microcon-troller, and since most microcontrollers support counters thatcan be externally-clocked, simply adding a single wire be-tween the switcher and a the microcontroller’s counter en-ables real-time energy metering.

2 Implementation

To evaluate the feasibility and performance of our design,we implemented iCount using off-the-shelf hardware and asmall amount of driver software.

2.1 Hardware

Our implementation uses the Maxim MAX1724 [2] asthe switcher and the Moteiv Tmote [3] sensor platform’sMSP430 as the microcontroller. We chose the MaximMAX1724 because of its low bias and ultra-low quiescentcurrent. The majority of our experiments are based onthe Maxim MAX1724 evaluation kit. We used a 3.3 V,fixed-output switching regulator (MAX1724EZK33); a pairof 10 µF, 16 V X7R ceramic capacitors for Cin and Cout(TDK C3225X7R1C106MT); and a 10 µH inductor (Sum-ida CDR43-100MC).

iCount requires a dedicated hardware counter to accumu-late the switcher’s cycles. We use Timer A on the Tmote’sMSP430F1611 [4] for this purpose, since it is normally un-used. In addition to connecting the Tmote’s power supplylines to the switcher’s output and ground, we added a singlewire between the switch-side of the inductor and the Tmote’sport U2.7, as shown in Figure 4(a). We populated resis-tor R16 with a zero-ohm resistor on the Tmote to connectport U2.7 to the TAINCLK line, the external clock for theMSP430’s Timer A subsystem. Using this approach, each

stantial software. The wide diversity of valuable appli-cations made a wide variety of realistic pilot studies atmodest scale and modest investment essential, and thesehad to be well-enough executed to gain unprecedentedmeasurements. The maturing of the field meant bringingthe technology into production state, reducing cost, im-proving manufacturability, and obtaining very high reli-ability. And it is very important to preserve the learn-ings, investments, code, circuits, and so on in movingrapidly through these phases of development. Despitethe diversity of efforts, it is safe to say that none of theavailable options met all of these goals.

In this paper, we present a building-block approachto sensornet platform design represented by the Xmotefamily which we believe is the first to support all threephases of sensornet development – prototype, pilot, andproduction. It begins with a core module that inte-grates a state-of-the art microcontroller, IEEE 802.15.4radio, and large flash onto a small, inexpensive, single-sided board with excellent RF characteristics. It ex-poses essentially all the pins that might possibly be use-ful. It literally can be snapped into a standard socketfor prototyping, easily soldered to routine carrier boardsfor pilots, or in-lined for production. Complementingthis core module are a family of high-quality peripheralmodules that provide specific functions, such as powersupply conditioning, high speed communication inter-faces, or transducer circuits. These too can either besocketed, soldered, or melted in. The glue for thesemodules are application-specific carrier boards. For pro-totyping, development boards expose a wide array ofpins, allowing all sorts of designs to be implented withsimple jumper wiring. For pilots, inexpensive two-layercarrier boards are typically designed to fit a particularenclosure and set of mechanical constraints. Xmotemodules drop on just like chips. For production, themodules are eliminated by incorporating their contentsdirectly into the underlying board.

This paper documents the design and implementationof the current Xmote family. It discusses the family ofdesign options and trade-offs that were considered in theprocess of arriving at this design point. Section 2 beginsby decomposing and describing the two key elements ofthe Xmote architecture, the module and the carrier. Sec-tion 3 describes the Xmote core module, which is essen-tially the guts of a mote without the constraints on how itcan be used. It describes the internal subsystems, intro-ducing the key characteristics and revisiting part selec-tion with these in mind, looks at new alternatives sincethe core was designed, discusses manufacturing and me-chanical considerations, provides a quantitative analysisof core module performance, and outlines future direc-tions. Section 4 describes a supporting cast of special-ized peripheral modules that offer a catalog of optionsfor high quality complete systems, and a framework forforward going innovation. Section 5 explains our ap-proach for prototyping using the Xmote family, allowingnovice system builders to compose platforms using off-the-shelf jumper wires in a “try it and see” fashion and

Figure 1. A typical sensornet node designed fol-lowing the building block-approach to platform con-struction. A general-purpose module (small off-center blue square with light outline) is hand-soldered to an application-specific carrier (largegreen outer containing rectangle). The carrier alsoincludes a sensor interface (the large 2x3 and 2x5headers on left side), hosts a solar harvesting circuit(to the right of the core module), and conforms toa standard enclosure (overall dimensions and fourholes).

module developers to debug otherwise complex systemswith complete freedom to access all exposed and in-termediate signals. Section 6 evaluates the architectureby illustrating how these building blocks are utilized ina variety of simple, cost-effective, application-specificcarrier boards that are designed using freely availableCAD tools and are inexpensive to manufacture. Car-rier board design is so simple that it can be used evenin a classroom setting where students do application-specific design, fabricate the boards, and assemble a fi-nal solution in a matter of weeks. The final sections re-flect on how effectively the Xmote approach meets thesweet spot of the various contraposing design goals ofthe phases of sensor network application development.

2 ArchitectureAt the heart of our building-block approach to sensor-

net platforms are two architectural elements: the moduleand the carrier. Modules are self-contained systems orsubsystems in an integrated circuit (IC) package format.They are themselves composed of one or more packagedICs plus other electronic components typically found ona system board. Carriers are custom circuit board sub-strates that glue together general-purpose modules withapplication-specific sensors, power supplies, and me-chanical constraints. A sensornet platform constructedusing this building-block approach consists of at leastone module attached to at least one carrier board, asshown in Figure 1.

Our approach should sound familiar, and perhaps

(a) WaterWatch Board (b) PowerMeter Board (c) BenchMark Board

Figure 7. Three platforms for different applications have been built to evaluate the Xmote architecture: (a) anenvironmental monitoring node incorporating solar energy harvesting and application energy metering, (b) anAC electricity meter for measuring building energy use, and (c) a platform for sensornet testbeds with a USBinterface, application energy metering, and a FIFO buffer for collecting and streaming high-frequency data.Each platform was designed in less than a week using the same generalized core module while satisfying thespecific requirements of each application domain.

tion and use a 7-dBi omnidirectional antenna. The car-rier board, seen in Figure 1, incorporates an Xmote coremodule, a solar energy harvesting circuit with voltageand current monitoring, the iCount [20] system for mea-suring system energy consumption, and connections forthe sensors. Referring to Table 5, this design shareda significant number of parts with the Design Library.This 2-layer PCB was created using the freeware EA-GLE Layout Editor in less than two days and fabrica-tion cost of $10.83 each at a quantity of 60 boards witha turnaround time of five days. The board took undertwo hours to populate.

Previous incarnations of the WaterWatch node werebuilt around a Telos family mote, resulting in a largerform factor (2X enclosure size), insufficient exposedGIO and ADC pins (some desired measurements couldnot be taken), and a significantly higher cost (3X mote-only cost as compared to Xmote). The new WaterWatchnode design remedies these issues while achieving simi-lar RF and energy performance. In terms of board fabri-cation cost, the previous 2-layer WaterWatch PCB tookabout a week to design, took two revisions to becomeoperational, and cost $11.59 per board for a quantityof 54 boards with a turnaround of five days. Indeed,the Xmote platform design flow has improved designflexibility while reducing time-to-result with compara-ble fabrication cost to previous methods.

Incorporating Xmote has allowed us to arrive ata weatherproof microweather station design candidatethat can be replicated hundreds of times and used asa climate sensing platform in a wide range of environ-ments. Future work will be to generalize this platform toa broader suite of sensors, enabling rapid replication ofnodes for environmental applications with unique sens-ing requirements, decoupled from a stable core of pro-cessing, storage, and communication functionality.6.3 AC Power Monitoring

Building electricity consumption is an importantopportunity for savings in an increasingly energy-conscious era; in fact, many AC electricity measur-ing and control devices – some [29, 13] even network-

enabled – already exist on the market. However, sincethese are either commercially unavailable or cost pro-hibitive, we developed a platform for AC electricitymetering, seen in Figure 7(b), to support research inenergy-aware decision-making in datacenter and homeenvironments both at scale and inexpensively. Thisplatform includes a TRIAC for AC current control andXmote core module for communication.

The primary sensor of this platform is an industrystandard IC that measures real, apparent, and reactivepower by using a manganin current sensing resistor.Though the AC electricity presents a convenient andcopious power source, careful attention is required toisolate the much higher mains voltage from the DC cir-cuitry used for the Xmote core module and related com-ponents. A standard approach is to use a transformer anda bridge rectifier, a solution that has excellent electricalcharacteristics and provides isolation between AC andDC circuits. However, transformers are bulky compo-nents that do not fit well inside the enclosure. Recogniz-ing the minimal DC current requirements of our design,a more cost-effective and space-saving way is to simplyuse capacitor dividers and a pair of diodes to shave offa small amount of AC current. This specialized designeffort will not need to be repeated; this isolation circuitcan effortlessly be replicated in future AC-powered plat-forms.

For the enclosure, rather than formulating a customdesign, often both costly and time consuming, we se-lected the enclosure of an off-the-shelf AC power me-ter and designed our PCB within its restrictions. Thus,the board needed to accommodate not only a standardNEMA 5-15 AC plug and receptacle, but also a numberof holes and contact points imposed by the clip design ofthe off-the-shelf enclosure. Since the Xmote core mod-ule is a thin single-sided board, we were able to incor-porate it easily within our volume constraints withoutfacing the difficulty of connecting and accommodatinga separate, larger mote inside the enclosure.

Additionally, we included an optically coupledTRIAC (logically similar to a solid state relay) to enable

Figure 4. (a) An illustration of how simple iCountis to implement: a Maxim MAX1724 switcher isconnected to a Moteiv Tmote. (b) A sensor nodefor environmental monitoring includes iCount sup-port which allows expected energy usage to be com-pared with actual energy usage. (c) A testbed nodefor benchmarking applications includes iCount plusfive decades of precision calibration circuitry.

interface iCount

// Basic interfacecommand error_t reset();command error_t start();command error_t pause();command uint32_t read();

// Cycle-to-cycle feedbackcommand error_t enableCapture();command errot_t disableCapture();async event void captured(uint32_t timestamp);

// Quanta-based feedbackcommand error_t compare(uint32_t delta)async event void matched(uint32_t now);

Figure 5. The iCount TinyOS API.

cycle of the switcher increments the hardware counter auto-matically and does not require the microcontroller to executeany software. We also removed diode D22 which ensuresthat only the Tmote USB interface is powered by USB whenplugged into a computer and the microcontroller, radio, flash,sensors, and LEDs can be powered from a different source –in this case the switcher.

2.2 Software

We implemented our driver software in TinyOS, the defacto sensor network operating system. Our driver exposesthe application programming interface shown in Figure 5.The driver also handles hardware counter overflows, wrapsthe underlying 16-bit counter in software to increase its widthto 32-bits (or more), and ensures that counter state is ac-cessed and modified safely.

If available, iCount can use capture and compare registersattached to the dedicated hardware counter to provide addi-tional functionality. Since a capture records the value of thetimebase whenever a rising edge corresponding to a regulatorcycle occurs, it can be used to measure the interval betweentwo successive cycles, and hence the near-instantaneous cur-rent of the hardware. A compare register, in contrast, al-lows an interrupt to be generated when a certain quanta ofenergy has been used. Although the MSP430 supports these

Page 4: Energy Metering for Free: Augmenting Switching Regulators for …prabal/pubs/papers/... · 2008. 10. 27. · Energy Metering for Free: Augmenting Switching Regulators for Real-Time

10−7

10−6

10−5

10−4

10−3

10−2

10−1

100

100

101

102

103

104

105

106

107

Load Current (A)

Sw

itch

ing

Fre

qu

ency

(H

z)

MAX1724TPS61020TPS61120TPS61200

Figure 6. The relationship between load currentand switching frequency without bias compensa-tion shows significant non-linearity after three tofour decades. Plotted on a log-log scale.

features, the capture and compare functionality is currentlyunimplemented.

Switcher Bias Std Dev. Min MaxMAX1724 1.4 Hz 0.5 Hz 1 Hz 2 HzTPS61020 135 Hz 1 Hz 132 Hz 138 HzTPS61120 213 Hz 15 Hz 187 Hz 228 HzTPS61200 252 Hz 1 Hz 252 Hz 254 Hz

Table 1. The no-load minimum, average and max-imum bias, and its standard deviation. At least30 samples were taken, each with a gate period of1 second.

2.3 Calibration

Viewing iCount as an instrument, calibration is necessaryto establish the relationship between the input current andoutput frequency. Calibration requires measuring the biasand fitting a line to a set of current-frequency measurementpairs to minimize error.

Bias, or a switcher’s no-load switching frequency, mustbe compensated. Removing the bias is necessary to ensurehigh accuracy measurements at small load currents. The biasis determined by disconnecting all loads from the switcherand measuring the output frequency at the switch-side of theinductor. An Agilent Technologies 53132 Universal Counterwas used to measure the bias frequency using a gate periodof 1 second. Figure 6 shows the effect of bias on the switch-ing frequency vs. load current. The no-load bias for theseswitchers is shown in Table 1.

The relationship between input voltage and switching fre-quency is shown in Figure 7. An order of magnitude vari-ation occurs as the switcher’s input voltage is swept from1.0 V to 3.5 V. This voltage-dependent relationship can be

10−7

10−6

10−5

10−4

10−3

10−2

10−1

100

100

101

102

103

104

105

106

107

Load Current (A)

Sw

itch

ing

Fre

qu

ency

(H

z)

Vin = 1.0 VVin = 1.5 VVin = 2.0 VVin = 2.5 VVin = 3.0 VVin = 3.5 V

Figure 7. The relationship between input voltageand switching frequency. An order of magnitudevariation in switching frequency occurs as inputvoltage goes from 1.0 V to 3.5 V. Plotted on a log-logscale.

used to adjust the meter sensitivity at runtime as battery volt-age slowly changes.

Linearity describes how well a line approximates the re-lationship between switching frequency and load current. Alinear relationship is important for at least two reasons. First,iCount will be used in systems that exhibit a wide dynamicrange in power draws, so linearity across this range is neededto faithfully capture the energy usage across the operatingspectrum. Second, since iCount accumulates cycles, smallnon-linearities can result in large errors over time. These er-rors are bounded by the maximum non-linearity, so this fig-ure is important.

To calibrate our implementation, we loaded the switcherin round-robin fashion using six resistors, measured theswitching frequency for each value of the load resistance,and fit a line to the data using linear regression. We usedthe MAX1724 switcher with input voltage of 3.0 V and out-put voltage of 3.3 V. The six resistors had values of 33 Ω,330 Ω, 3.3 kΩ, 33 kΩ, 330 kΩ, and 3.9 MΩ, which pro-vided load currents ranging from about 1 µA to 100 mA.To weight these measurements equally during regression, wefirst took the logarithm of the current and frequency values,performed the linear regression, and then applied the expo-nential to complete the process.

3 Performance Metrics

In this section, we evaluate the performance of our iCountimplementation using a set of microbenchmarks. These mi-crobenchmarks assess the accuracy, resolution, overhead,read latency, responsiveness, precision, and stability of ourimplementation.

3.1 Accuracy

Figure 8 shows the accuracy of our implementation usingthe calibration coefficients previously described. We subtract

Page 5: Energy Metering for Free: Augmenting Switching Regulators for …prabal/pubs/papers/... · 2008. 10. 27. · Energy Metering for Free: Augmenting Switching Regulators for Real-Time

10−7

10−6

10−5

10−4

10−3

10−2

10−1

100

10−1

101

103

105

107

Fre

qu

ency

(H

z) RawFitErr

10−7

10−6

10−5

10−4

10−3

10−2

10−1

100

−0.2

−0.1

0

0.1

0.2

Current (A)

Rel

ativ

e E

rro

r

Figure 8. The accuracy and relative error. The rel-ative error is less than ±20% over five decades ofcurrent draw. Plotted on log-log and lin-log scales,respectively.

the true measurement from the line of best fit to determine theabsolute estimation error. To determine the relative error, wedivide the absolute error by the true value. The relative erroris less than ±20% across five decades of current draw. If weconsider the typical operating range of a mote, from 5 µA to50 mA, the relative error falls within ±15% range.

3.2 Resolution

Resolution refers to the smallest quanta of energy that thesystem can measure. To determine our implementation’s res-olution, we loaded the switcher in a round-robin fashion us-ing six resistors, measured the switching frequency for eachvalue of load resistance, and repeated across a total of fourdifferent voltages. The six resistors had values of 33 Ω,330 Ω, 3.3 kΩ, 33 kΩ, 330 kΩ, and 3.9 MΩ, which providedload currents ranging from about 1 µA to 100 mA. We usedan Agilent Technologies 53132 Universal Counter to mea-sure the output frequency for each value of load resistanceover a 1 second gate period. A Keithley 2400 sourcemeter,configured to use 4-wire sense mode to eliminate resistivelosses along the power supply lines, provided 1.5 V, 2.0 V,2.5 V, and 3.0 V. We estimated the energy delivered duringeach trial by squaring the output voltage, dividing by the loadresistance, and multiplying the gate time:

Etrial =V 2

out

RloadTgate (1)

To determine the resolution (in µJ) or sensitivity (inµJ/cycle), we divided Etrial by the number of cycles, minusthe no-load bias, during that trial. Figure 9 shows that theresolution of the system ranges from about 0.1µJ to 0.5µJ,depending primarily on input voltage and somewhat on loadcurrent. Note the significant reduction in resolution at highload currents. The root cause has not been determined butmay be due to resistive losses in the switcher’s current lim-iting circuitry, inductor saturation, or other losses associatedwith the damping circuitry. Since systems usually have a

10−7

10−6

10−5

10−4

10−3

10−2

10−1

100

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

Load Current (A)

Res

olu

tio

n (μJ

)

Vin=3.0VVin=2.5VVin=2.0VVin=1.5V

Figure 9. The resolution varies with input voltageand load current and exhibits high non-linearitiesat extreme load currents. Plotted on a lin-log scale.

safety factor in their design, and do not operate close to orat the rated limits of the power supply, these non-linearitiesmay not affect actual measurement performance but it is im-portant to be aware of their existence.

The meter resolution depends on the value of the switch-ing inductor. Each cycle of the switcher delivers 1

2Li2 J,where L is the inductance and i is the peak inductor current.Our experiments are based on a 10 µH inductor but note thata smaller inductor will provide a higher resolution, and viceversa. Also, note that manufacturing variations of ±10% arecommon, suggesting that individualized calibration is useful.

3.3 Overhead

There are three primary sources of overhead in the iCountdesign. First, the microcontroller-based hardware countercontributes to a fixed increase in the power draw. Second,the act of counting itself contributes a frequency-dependentincrease in the power draw of the counter hardware due togates changing state at increasing rates and the resultingcharge/discharge cycles of the gate capacitance. Third, themicrocontroller must service counter overflows periodically,with an average period equal to the average frequency di-vided by the maximum value of the hardware counter.

To determine the fixed overhead due to enabling thecounter hardware, we programmed our mote with theTinyOS Null application, which forces all of the hardwarecomponents into their lowest power states. We poweredthe system using a Keithley 2400 sourcemeter configured touse 4-wire sense mode, to detect and eliminate any resistivelosses in the power supply lines. Using a Fluke 189 digi-tal multimeter, we measured the Null app current draw at8.87 µA (using the DC-µA range setting) and 0.006 mA (onthe DC-mA range setting), both averaged over one minute.This experiment established the baseline current draw of themote.

We then added the iCount driver logic to the Null ap-plication, added a wire between the switch-side of the in-ductor and the counter clock input. Repeating the mea-

Page 6: Energy Metering for Free: Augmenting Switching Regulators for …prabal/pubs/papers/... · 2008. 10. 27. · Energy Metering for Free: Augmenting Switching Regulators for Real-Time

10−6

10−5

10−4

10−3

10−2

10−1

100

10−8

10−7

10−6

10−5

10−4

Ove

rhea

d (

A) I

wireItotal

10−6

10−5

10−4

10−3

10−2

10−1

100

10−3

10−2

10−1

100

101

Load Current (A)

Ove

rhea

d (

%) I

wireItotal

Figure 10. The overhead ranges from 0.01% for a100 mA load to 1% for a 10 µA load, with a 3.0 Vinput. Plotted on a log-log scale.

surements, we found the current draw to be the same8.87 µA as before via the microcontroller’s power supplylines. But, we also found that a 90 nA current was beingsupplied by the switcher via the wire we added. This showsthat the fixed overhead in our implementation is about 1%(90 nA/8.87 µA) when the system is in its lowest power state.

We also found that in some cases, the current draw via thepower supply lines actually decreased, suggesting that somepower was supplied via the counter wire. Figure 10 showsthe overhead current across four decades of load current. Thetotal current, Itotal, is slightly lower than the current pass-ing through the wire connecting the switcher and microcon-troller, Iwire, because the total includes the decrease in cur-rent draw via the microcontroller power supply lines.

The iCount counter is implemented using the MSP430microcontroller’s 16-bit Timer A. Each time this hardwarecounter overflows, the microcontroller must increment alarger-width software counter by the maximum value of thehardware counter. Since this process requires writing thevalue of a variable in interrupt context, the write should beprotected with an atomic section. All interrupts are turnedoff during the atomic section but since the hardware counteris clocked asynchronously, no cycles are missed during exe-cution of the interrupt handler.

Since an overflow occurs after 65,536 cycles, and eachcycle delivers approximately 0.5 µJ, the counter overflowsonce per 32,768 µJ of energy consumed. A typical motedraws about 25 mA at 3 V, when active, and would there-fore draw about 750 µW running at a 1% duty cycle. Atthis 1% workload, the counter would overflow every 43 sec-onds (32,768 µJ/750 µW). In contrast, when fully active at a100% duty cycle, the counter would overflow less than threetimes per second, making the overhead of handling counteroverflows negligible.

3.4 Read Latency

Application software reads the hardware counter by call-ing iCount.read. This function, executed in an atomic

0 0.25 0.5 0.75 1 1.25 1.5 1.75 2Time (ms)

Sig

nal

RGBLX

Figure 11. The system responds quickly to changesin the load current. The system adjusts in less than125 µs to a load current decrease from about 10 mAto 2 mA.

section, disables the hardware counter, takes a snapshot,reenables the hardware counter, performs a 32-bit addition,and returns. The total time required to invoke this function,from call to return, is 15 µs. With this read latency, thecounter could be read at over 66 kHz. We determined theread latency by setting an I/O pin on the microcontroller im-mediately before the call, setting a second I/O pin immedi-ately after the call, and taking their difference. The overheadof setting an I/O pin was measured by setting two pins in suc-cession, measuring their difference (1 µs), and subtractingthis value from the prior uncalibrated measurement (16 µs).

3.5 Responsiveness

Responsiveness is a measure of how quickly the switch-ing frequency settles when the load changes. To illustrate theresponsiveness of the system, we instrumented the TinyOSBlink application and monitored the state of the red (R),green (G), and blue (B) LEDs as well as the cycles of theswitcher. The greatest change in the power draw of this ap-plication occurs when the three LEDs are all turned off si-multaneously. Figure 11 shows the change in the cycle rateof the switcher for a two millsecond period centered at thepoint when the LEDs are turned off. We see that the switch-ing frequency adjusts to the new rate in less than 125 µs asthe current draw falls from approximately 10 mA to 2 mA.

3.6 Precision

Precision characterizes the degree of mutual agreementamong a series of individual measurements, or the abilityto produce the same result given the same input conditions.To measure the precision of our implementation, we loadedthe switcher with a fixed resistor and captured the inductorswitching waveform over a two second window. This wave-form was post-processed to extract the cycle-to-cycle switch-ing period, and its reciprocal, the instantaneous frequency.

Page 7: Energy Metering for Free: Augmenting Switching Regulators for …prabal/pubs/papers/... · 2008. 10. 27. · Energy Metering for Free: Augmenting Switching Regulators for Real-Time

84 84.5 85 85.5 860

0.05

0.1

0.15

0.2

0.25

Instantaneous Frequency (1/dt, Hz)

Fra

ctio

n o

f S

amp

les

Figure 12. Measurement precision is better than±1.5%. The distribution of instantaneous (cycle-by-cycle) frequency measurements over a two sec-ond window.

Figure 12 shows the distribution of these frequency values(N = 167). The variations in the values are small, within±1.5%, so a small number of samples provides an accurateestimate of the near-instantaneous current.

3.7 Stability

While precision characterizes the degree of mutual agree-ment among a series of individual measurements over theshort term, stability refers to the agreement of these readingsover a much longer term. To evaluate the stability of our im-plementation, we loaded iCount with a fixed resistor and useda mote-based application to track the switching frequencyover a one week period. The measurement setup was placednear a window and experienced daily temperature variationsof more than 10 C. Figure 13 illustrates how the switchingfrequency changed over the course of the week. The range invariation falls within ±1% of the mean.

The data show both daily fluctuations in frequency as wellas a one-time “warmup” period. The daily variations may bedue to temperature- or humidity-dependent changes in the in-ductance or temperature-dependent changes in the measure-ment system (an uncalibrated 32 kHz crystal oscillator wasused). The one-time warmup period may be an artifact ofthe experimental setup: the iCount system was located neara laptop computer that vented warm air.

It might seem odd that our implementation exhibits a sta-bility of ±1% over one week while only exhibiting a pre-cision of ±1.5% over a two second window. One plausibleexplanation is that for the precision measurements, we pre-sented the instantaneous (or cycle-by-cycle) frequency butfor the stability measurements, we averaged over a one sec-ond period.

4 Conclusion

Traditional instrument-based power measurements, whichare useful for design-time laboratory testing, are impracti-

0 24 48 72 96 120 144 1687500

7525

7550

7575

7600

7625

7650

Time (Hrs)

Fre

qu

ency

(H

z)

Figure 13. The system is stable. The range in varia-tion is ±1% of the mean over a one week period.

cal for everyday in situ use due to the cost of instruments,their physical size, and their poor system integration. Ofcourse, dedicated power metering hardware can enable run-time adaptation, but this approach results in increased hard-ware costs and power draws. In this work, we demonstratethat energy metering is possible for free by simply countingthe cycles of a switching regulator.

Our particular implementation exhibits a maximum errorof less than ±20% over five decades of current draw, a reso-lution exceeding 1 µJ, a read latency of 15 µs, and a poweroverhead that ranges from 1% when the node is in standbyto 0.01% when the node is active, for a typical workload.The basic iCount design requires only a pulse frequencymodulated switching regulator and a microcontroller with anexternally-clocked counter. iCount enables practical, in situenergy metering for many systems which may not lend them-selves to traditional instrumentation techniques. We showthat with the addition of a single wire, iCount enables a de-vice to introspect its own energy usage with virtually no costor energy overhead.

References

[1] P. Dutta, M. Feldmeier, J. Paradiso, and D. Culler. Energy me-tering for free: Augmenting switching regulators for real-timemonitoring. In IPSN ’08: Proceedings of the 2008 Interna-tional Conference on Information Processing in Sensor Net-works (ipsn 2008), pages 283–294, 2008.

[2] Maxim Integrated Products. 1.5uA IQ, Step-Up DC-DC Converters in Thin SOT23-5. http://datasheets.maxim-ic.com/en/ds/MAX1722-MAX1724.pdf, July 2001.

[3] J. Polastre, R. Szewczyk, and D. Culler. Telos: Enablingultra-low power research. In Proceedings of the 4th Interna-tional Conference on Information Processing in Sensor Net-works (IPSN ’05), Apr. 2005.

[4] Texas Instruments. Mixed signal microcontroller (rev. e).http://www.ti.com/lit/gpn/msp430f1611, Aug. 2006.