Thursday, May 3, 2012

Measuring the current draw of the liquid level indicator

I breadboarded the liquid level indicator circuit to measure its current draw when operating in its different modes. I powered it using the PICkit2 set to 3.0V. I ran out of 1µF capacitors so C1 = 1.5µF. To simulate immersion in a water-based liquid I used 1K resistors.

VDD was measured using a Fluke 8842A. All current measurements were taken using a Fluke 87V set to high resolution, with MIN-MAX enabled, and with selector knob set to µA when measuring standby mode current and to mA range for all others. Reading was nulled (REL button pressed) before measurements were taken. The 87V probes were connected on the high side in series with the PICkit 2 VDD. The last significant digits of the average values when the transducer was buzzing kept jumping around--that's the reason for the approximation sign.  

Current draw @VDD = 3.01V, ambient temp. = 31°C
Mode/Condition Min Max Ave units
Standby mode 12.65 15.55 13.08 µA
only low probe immersed 0.137 3.827 ~2.01 mA
low and high probes immersed 0.328 3.654 ~2.00 mA
only high probe immersed 0.139 3.855 ~1.28 mA


Since WDT is always on and since it runs off the 31kHz LFINTOSC, both of these modules are always enabled in all modes even during sleep. Therefore the minimum current consumption of the circuit is the sum of these two. According to the datasheet typical current for the LFINTOSC is 4.0µA with a maximum of 22µA. WDT typical current is around 0.5µA. [See very important current measurements for these two and discussion below].

As I pored over the datasheet I noticed the brownout reset consumes a hefty amount of current--6.9µA typical. It also occurred to me that since I had disabled the MCLR (in the configuration word) this means pin RA3 is configured as a digital input, but is floating--it has no pull-up or pull-down resistor--which can only mean that it's drawing more current than it should. So I checked how the current consumption would change by first enabling MCLR and then disabling BOR. The following are the results. Values in the first row is just a control since the measurements below were made several hours after I had performed the ones above.

Current draw @VDD = 3.01V, ambient temp. = 30°C
Mode/Condition Min Max Ave units
Standby mode, MCLR disabled, BOR enabled 11.73 14.27 12.12 µA
Standby mode, MCLR enabled, BOR enabled 7.47 9.66 7.93 µA
Standby mode, MCLR enabled, BOR disabled 0.23 2.57 0.75 µA

Clearly, the reduction in power consumption is just incredible. From the averages we can infer that a floating RA3 pin wastes around 4µA, while BOR guzzles some 7µA--just as the datasheet says. With MCLR enabled and BOR disabled, I measured the currents for when low and high probes are immersed and they're practically the same as in the first table above.

With all these data we can now compute battery life. The Maxell CR2032 coin cell I'm using has a nominal capacity of 220mAh. Given the average current of  0.75µA when in standby mode the battery should be able to last for 220mAh / 0.75µA = 33.5 years! But of course I built the circuit to be used not displayed on the shelf. So let's say it's used thrice daily and its probes are immersed in liquid for 30 seconds each time. That's 1.5 minutes every 24 hours. In those 90 seconds the circuit is drawing an average current of 2.0mA. Therefore, everyday, the average current is:

(1.5 min / 60 min x 2000µA + 24 hrs x 0.75µA) / 24.025 hrs = 2.8uA

If you look at the graphs in the Maxell datasheet you'll see that the discharge capacity declines as the discharge current increases. Let's be conservative and take the 2.0mA as our discharge current. According to the graph discharge capacity will now only be around 200mAh. Thus the discharge duration of the liquid level indicator given our hypothetical conditions is:

200mAh / 2.8µA = 8 years.

Not bad. Even derating that by 50% still gives a very good battery lifespan.

----

With MCLR enabled and BOR disabled I proceeded to comment out void main() and used the following instead:

void main()
{
  IniReg();
  WDTCON = wdt512ms;
  while(1)
  {
    asm sleep
  }
}

With the voltage comparator, DAC, and weak pull-ups out of the picture average current dropped to 0.48µA.

Using the same main() I then disabled WDT in the configuration word. Average current fell to a mere 0.02µA (pretty much just as Microchip boasts). 20nA is practically the threshhold of the Fluke 87V's measurement capability!


Still with MCLR enabled and BOR disabled I tried the following to determine the amount of current the LFINTOSC uses while the MCU is continually awake.

void main()
{
  IniReg();
  WDTCON = wdt512ms;
  while(1) 
    asm clrwdt;
}

Average current was 4.11µA with WDT enabled. This agrees well with the datasheet spec for LFINTOSC current. Disabling WDT brought the average current marginally down to 4.03µA.

From the above measurements I gather that the LFINTOSC current of 4µA in the datasheet refers to when the MCU is awake. However, during sleep and if WDT is running this 4µA no longer applies. As we saw above it was a mere 0.48µA--the WDT current as per datasheet spec.

No comments:

Post a Comment