Friday, August 28, 2015

Current optimization of wireless measurement sensors - part 2

In the last post I managed to reduce the average current consumption of my wireless temperature and humidity sensors by about 20% to 1.56 uA just by reducing the measurement resolution. Figure 1 shows the current profile after this optimization. In this post I try to reduce the current used in the measuring process, i.e. the smaller spikes, even further.
Figure 1. Current usage after optimizations implemented last time. Small spikes are humidity and temperature measurements and the large spike is measurement together with radio communication




I'm using the sensors in "hold master" mode, in which the sensor IC keeps SCL of the I2C bus low during the measurement. This is the fastest mode to get measurements out of the sensor as no polling or waiting is required. However, when an I2C line is pulled low, current flows through the pull-up resistor. In my case this resistor is 10 kilo-ohms, which produces a current of 300 uA. This current is equivalent to the amount used by the whole sensor IC itself. Furthermore, although the microcontroller (ATMEGA328P) is in idle sleep mode while the sensor IC measures, the idle mode current consumption is still greater than that of the sensor.

My plan is to switch the measurement mode to "no hold master" so that the sensor IC releases the I2C bus and to put the processor into power-save sleep mode in which only the 32.768 kHz low-power crystal oscillator runs. I don't want to mess with the timer prescale settings so that I still have accurate timestamps on the measurements. The prescaler is set to its maximum, which is divide by 1024. This gives a minimum sleep time of 31.25 ms. The measurement time is significantly shorter than this, but this shouldn't increase the power consumption as the sensor IC will go into sleep mode after it completes a measurement. Figure 2 shows the result of this.


Figure 2. Current usage using "no hold master" mode in measurements and putting CPU in power save mode during measurements.

It is evident that the current consumption increased as a result. I guessed that the reason was that it took such a long time to get the processor out of power save mode (start all the clocks and wait for them to stabilize etc.) that all benefit of that mode was lost. I reverted back to using the idle sleep mode of the processor, but lowered the CPU clock speed before doing so to save power. This is very unstatisfying as the internal RC oscillator of the microcontroller already takes about 100 uA of current. With that amount of current at hand, I can't waste time after the measurement has been completed. With this modification the we get the results shown in figure 3.
Figure 3. Current usage using "no hold master" mode in measurements and putting the CPU in low clock frequency idle mode during the measurements.
This modification had the side effect that I also used a lower CPU clock frequency while waiting to receive an acknowledgement of data over the radio. The current used for the radio communication thus also slightly decreased. Longer time period plots of the current usage before and after this optimization are shown in Figures 4 and 5, respectively.
Figure 4. Current usage before this optimization.
Figure 5. Current usage after this optimization.
With these modifications the hypothetical battery life (using CR2032 @ 250mAh) of the measurement devices has gone up from around 14 years to 17.5 years to 18.9 years. Of course this is probably nowhere near the actual battery life as real batteries have non-ideal behavior such as self discharge and high internal resistance, also these measurements assume a 100% success rate in radio transmission. I'm confident though that they'll last at least a couple of years.

Thursday, August 27, 2015

Current optimization of wireless measurement sensors - part 1

I've been developing wireless temperature and humidity sensors as commercially available ones are not good enough or too expensive, often both.

I'll post on the sensors perhaps later, but right now I'm working on reducing their power consumption. They have an approximately 1 uA sleep current, which I currently don't know how to reduce further.

Initially, when measuring every 5 minutes and transmitting 3 measurements at a time over the radio, I got an average current consumption of around 2 uA. Initial current consumption over time is show in figure 1. This was measured using the setup described in the previous post and using the data port of my UT61E.
Figure 1. Initial current usage.
The smaller spikes in figure 1 are due to measurement only while the larger spikes are due to both measurement and communication over radio.

The measurement time used by the sensor (Sensirion SHT20) is significantly reduced when the measurement resolution is lowered. According to the data sheet of SHT20, the measurement with full resolution takes a maximum of 350 uA for 114 ms, which translates to about 40 uC of charge. The measurement with the lowest resolution however takes a maximum of 350 uA for 15 ms, which translates to about 5 uC of charge. This was the first course of action to reduce current consumption. The result of the first try of this is shown in figure 2.
Figure 2. Current consumption with what I thought was reduced resolution measurements.
Surprisingly the measurement resolution didn't seem to have any impact on the current usage. I suspected some error in configuring the sensor, and sure enough, after a long time debugging, I found the problem. I had assumed the datasheet listed the configuration bits in order and didn't pay attention to the actual indexes... Figure 3 shows the current consumption when actually using reduced resolution measurements.
Figure 3. Current consumption with reduced resolution measurements.
As can be seen, the reduction while measuring is quite significant, bringing the average current down by about 20%. However, integrating over a single measurement spike gives around 20 uC (this is computed ignoring the background current of ~1 uA). This is quite large compared to the maximum of 5 uC used by the sensor, and suggests that the majority of the current is consumed elsewhere. This will be the course of investigation in the next part.

Wednesday, August 26, 2015

Measuring average current of low power devices

Low power devices often spend most of their time in some sort of sleep mode, in which the power supply current is very low (some hundreds of nanoamperes typical). However, at times they wake up and can draw very large currents for a short period of time. The average current of such devices is often of interest, for example to estimate battery life.

Measuring the current directly is infeasible, due to the very large current range as well as the short duration of the high current pulses. A simple solution however is to measure the current through a RC filter circuit as shown in figure 1.
Figure 1. Measurement setup.

There are a couple of things to consider though when doing this.
  • The time constant of the RC filter needs to be much longer than the measurement period of the multimeter used
  • Electrolytic capacitors initially exhibit large non-constant leakage currents
  • Resistive voltage drop
A nice trick is to use the measurement resistor of the multimeter as the R of the circuit and to choose the capacitance then accordingly. My UT61E updates twice per second and has a measurement resistance of 1 kilo-ohm in the microampere range. I've used a capacitance of around 15000 uF, which gives a time constant of 15 seconds. The time constant shouldn't be too long either, as it makes the required measurement time longer.

The leakage current of electrolytic capacitors may require a long time to stabilize. After 24 hours of operation my bank of 15000 uF still had 500 nA of leakage, but decreased to around 40 nA after 48 hours. Constant leakage currents due to the measurement setup are simply subtracted from the measured average current.

I've never had a problem with any significant voltage drops with this setup. However, the voltage drops can be made smaller by increasing the capacitance. Notice that the average voltage seen by the load is still dependent on the average current and the resistance.