Saturday, August 29, 2015

Current optimization of wireless measurement sensors - part 3

After the previous post, I'm now satisfied with the current consumption of the measurement process. There however still remain a lot of things to optimize in the radio communication. See figure 1.
Figure 1. Current usage obtained in previous post. Smaller spikes are due to measurement while larger spikes are due to measurement and communication. Communication power consumption is targeted in this post.
The communication consists of transmitting the data and waiting to receive an acknowledgement of the data. Currently the processor remains active during transmission and the completion of the transmission is polled. The processor should be put in low clock frequency idle and a transmission complete interrupt should be used to wake to processor up. After transmission, while waiting for the acknowledgement, the processor currently also polls the radio for received data until time out. Here also the processor should be put to low clock frequency idle and a packet received interrupt as well as a timer interrupt for the time out should be used to wake the processor up. The time out value should also be made as short as possible. This requires some optimization also on the sink node side, to minimize the time required to transmit an acknowledgement.
Figure 2. Current consumption after implementing optimizations. Communication current consumption has reduced by one third. Wow.
After implementing the idle mode optimizations, the current profile is as shown in figure 2. The height of the communication current peak has reduced by one third. This is far more significant than I anticipated. The average current dropped by 7% percent, which gives a hypothetical battery life of 20.4 years (on CR2032 @ 250mAh). The time out optimization however still remains to be done.

While these optimization reduce the amount of current used when communicating, the most effective optimization might still be to just communicate less often by sending more measurements per communication. This has the flip side of having a lower success rate for transmission and thus requiring more retransmissions, which affect the real average current consumption in a non-predictable way. I might research this further later, but as the current consumption is already quite close to the lowest limit set by the power save mode current, the pay off may be very slight.

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.