This application note describes how to schedule periodic activities in order to achieve low energy consumption.
Measurements are made with Otii Arc on Atmel ATmega328PB Xplained Mini evaluation board.
Sample application uses built-in ADC to measure voltage level at NTC thermistor. Each measurement is an average of 232 ADC samples. Measurements are taken periodically at different intervals: 100, 75, 50 and <50 ms.
CPU runs at 250 kHz and enters power-save mode between measurements.
Navigators, environment monitors and similar battery-powered devices usually do not keep their sensors powered all the time. Instead, they tend to have CPU sleeping and peripherals powered off and wake up at pre-programmed intervals to query the sensors, process and display or transmit sensor data.
A typical simplified algorithm looks like following from booting the device:
1. Turn peripherals off. 2. Schedule a timer. 3. Send CPU to sleep. 4. Wake up from timer. 5. Turn peripherals on. 6. Read and process data from peripherals. 7. Turn peripherals off. 8. Jump to 3.
Considering latency, accuracy and energy consumption, main aspects of such periodic activities are:
These aspects are tightly related and can be formulated as a ratio of duration of wakeup to duration of sleep.
Optimization of step 6, is out of scope of this application note. Common method is to turn off the sensors and CPU as soon as the job is done and to sleep until the next wakeup.
This method has limitations that will be demonstrated and discussed further on in this application note.
Measurements have been made using sample application for different wakeup intervals: 100, 75, 50 and <50 ms (timer’s counter was set to 12 for 50 ms and to 11 for <50 ms).
Tab. 1. Energy consumed by wakeup intervals
|No sleep||100 ms||75 ms||50 ms||<50 ms|
As can be seen from Tab. 1. with reduction of time between wakeups amount of consumed energy grows and at certain point it reaches the value when periodic sleep/wakeups become impractical.
It must be noticed (Fig. 2 and 3) that although wakeup interval <50 ms is short, it is still longer than activity time, ie periods of sleep and activity do not overlap, there is still some time between going to sleep and waking up: 57 ms for 100 ms interval and 5 ms for <50 ms.
To estimate the effect of periodic wakeup/sleep sequence, energy consumed during one wakeup/sleep cycle needs to be compared to system’s consumption during the same time if the system would stay on.
|State||periodic||active||idle (sleep)||turning on||running||always on|
For one period energy can be calculated as:
(1) Ep = Ea + Ei
a sum of energy consumptions during activity and idle, where
(2) Ea = En + Er
with En as energy spent on turning on and Er as energy spent on running.
(3) Ep = V(Intn + Irtr + Iiti )
And for a system that would be kept running during the same time:
(4) Eo = VIr(tn + tr + ti)
For periodic activities to give positive effect on energy consumption, expressions (3) and (4) must meet the following relation:
(5) Eo > Ep
Voltage can be assumed a constant thus (5) can be expressed as following:
(6) Always on Periodic Ir(tn + tr + ti) > Intn + Irtr + Iiti Irtn + Irtr + Irti > Intn + Irtr + Iiti Irtn + Irti > Intn + Iiti Irtn + Irti > tn(Ir + IΔn) + ti(Ir - IΔi) Irtn + Irti > Irtn + IΔntn + Irti - IΔiti IΔiti > IΔntn where IΔi = Ir - Ii and IΔn = In - Ir
Relation (6) can be formulated as a generic rule:
In order for periodic wakeup/sleep sequence to give positive energy saving effect, energy cost of wakeup must be lower than energy save in sleep mode.
In practice for every periodic process minimal duration of activity period that ensures required accuracy needs to be determined first. Then interval between wakeups is decided based on required latency. If relation (6) is not true for these timings, either the system should be kept awake all the time or requirements for accuracy and latency need to be changed.
When dealing with multiple periodic processes it is recommended to align them in time for their intervals of activity to overlap. This will help to avoid situations when the system wakes up for one process immediately after going to sleep for another.
If alignment in time is not possible, e.g. when there are non-periodic wakeup/sleep processes, it can be recommended before going to sleep to check time remaining until the nearest predictable wakeup and refrain from sleeping if the time is too short.
In this application note measurements of energy consumption for periodic processes with different periods of inactivity were presented, followed by theoretical background and practical advice on scheduling wakeup/sleep activities.