Wednesday, July 2, 2008

Advanced Battery Monitor

Task Description:
"Modify the temperature sensing application described in task 5 to be battery aware. Rather than taking a temperature reading every 20 seconds, the frequency of the readings should be in proportion to the amount of battery the sensor has in comparison to the amount of battery its neighbors have. A sensor with a low battery that is connected to sensors with high batteries should take readings infrequently. Between readings, a sensor should be put into deep sleep."[1]

Analysis:
The major different part between this task and task 5 is to design an algorithm about reading-frequency calculation. I have to propose a good solution to determine how long a free-spot needs to report its battery remaining. I thought about three different solutions based on all kinds of possible situations. The following is my final strategy to get through this issue:

iThreshold_Power -- the voltage that indicates the battery remaining is enough
Its default value is 4000(Based on my observation)

iThresdhold_NoPower -- the voltage that indicates the battery is going to be dead
Its default value is 3400(Based on my observation)

These two variables can be reset by commands from the base station.



iVolt -- Current remaining voltage
iVoltMax -- Maximum value among the remaining voltage of its neighbor and itself


Rule:

iVolt > iThreshold_Power
The spot just needs to send its current remaining information to its neighbor each s without reporting it to the base station. In the test scenario, it also sends remaining to the base station.

iVolt <=
iThreshold_Power and iVolt > iThreshold_NoPower
The spot needs to not only send its current remaining information to its neighbor but also report it to the base station. In addition, the time-span between two times to read information is based on this formula:

Time-Span = 20000 *(iThreshold_Power/iVolt) * (iVoltMax/iVolt);

So there are two factors to determine the time-span: One is the given threshold ; The other is
the comparison to its neighbors' battery remaining.

iVolt < iThreshold_NoPower
The spot needs to report its remaining information to the base station. In addition, it should send its neighbor a trigger that make them report their current remaining to the base station one minute later.

The work-flow chart is similar to the one of task 5:


Implementation:
1. How to get battery remaining?
The same thing done in Task 6:
IPowerController ipc = Spot.getInstance().getPowerController();
... ipc.getVbatt();

2. How to make a spot deep sleep?
ISleepManager ism = Spot.getInstance().getSleepManager();
ism.enableDeepSleep();
try{
ism.ensureDeepSleep(iSleepTime);
}
catch (com.sun.spot.peripheral.UnableToDeepSleepException ex) {
ex.printStackTrace();
}

3. How to determine the reading frequency?
Just like what I talked about in Analysis Section.

Difficulty and Challenge:
The challenge involved in this task is to design a good algorithm about reading frequency. I designed 3 solutions and finally chose the most difficult one. But the performance about the chosen algorithm will be evaluated in the next task.

Time Distribution:

Task

Description

Deadline

End Date

Total Time (hrs)

7

Advanced Battery Information Monitor

08/06/2008

07/03/2008

17.7

Sub Task

Time

Design a algorithm for calculating reading frequency

6.2

Modify the code of task 5 based on the chosen algorithm

2.5

Carefully debug and check all source code of this task

1.5

Created some test cases and test this task

5

Miscellaneous Task (updating the blog, documents and so on)

2.5



[1]Quoted from the section "Task 7" of Class Requirement Document
Written by Professor Sami Rollins