Skip to content

Commit

Permalink
fine-tuning the moment at which we re-enable the radio to lower energ…
Browse files Browse the repository at this point in the history
…y consumption
  • Loading branch information
twatteyne committed Feb 18, 2017
1 parent fc47ece commit 7a3a178
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 8 deletions.
32 changes: 32 additions & 0 deletions backtracking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
L_D = 0.000320
D_D = 0.000677
L_A = 0.000192
D_A = 0.000590

backtracking = [
0,
L_D,
D_D+L_A,
D_D+D_A+L_D,
D_D+D_A+D_D+L_A,
D_D+D_A+D_D+D_A+L_D,
D_D+D_A+D_D+D_A+D_D+L_A,
D_D+D_A+D_D+D_A+D_D+D_A+L_D,
D_D+D_A+D_D+D_A+D_D+D_A+D_D+L_A,
D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+L_D,
D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+D_D+L_A,
D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+L_D,
D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+D_D+L_A,
D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+L_D,
D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+D_D+L_A,
D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+D_D+D_A+L_D,
]

output = []
for (k,v) in enumerate(backtracking):
output += ['{0:<27} = {1:>4}; // {2:>7}us'.format('app_vars.backtracking[{0}]'.format(k),int(v*32768.0),int(1000000*v))]
output = '\n'.join(output)

print output

raw_input('press enter to close.')
Binary file added frequencies.xlsx
Binary file not shown.
1 change: 1 addition & 0 deletions project/flashflood_local/flashflood_local.ewp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
<state>LIGHTPIN_ALLMOTES</state>
<state>ENABLE_LEDS</state>
<state>ENABLE_DEBUGPINS</state>
<state>LINEAR_TOPOLOGY</state>
</option>
<option>
<name>CCPreprocFile</name>
Expand Down
38 changes: 30 additions & 8 deletions project/flashflood_testbed_production/flashflood.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
#endif

// light sensor
#define LIGHT_SAMPLE_PERIOD 655 // @32kHz, 655=20.00ms
#define ONE_HOP_LATENCY 42 // @32kHz, 42= 1.28ms
#define RADIO_STARTUP_DURATION 30 // @32kHz, 30= 1.00ms
#define LIGHT_SAMPLE_PERIOD 655 // @32kHz, 655=20.000ms
#define ONE_HOP_LATENCY 42 // @32kHz, 42= 1.280ms
#define BACKTRACK_TUNING 41 // measured

#ifdef LOCAL_SETUP
#define SENSING_RADIO_OSC_SCHEDULE_TO_TURNON_OFFSET 29+5 // turn on oscillator a little later than hop 1, so hop 1 could hear the packet
Expand Down Expand Up @@ -119,6 +119,7 @@ typedef struct {
uint8_t cc2420_panid[2];
uint8_t cc2420_ieeeadr[16];
uint16_t hopping_sequence[16];
uint16_t backtracking[16];
} app_vars_t;

app_vars_t app_vars;
Expand Down Expand Up @@ -182,6 +183,24 @@ int main(void) {
app_vars.hopping_sequence[0x0f] = FREQUENCY_4; // ===
#endif

//DO NOT EDIT DIRECTLY. Generated by backtracking.py script
app_vars.backtracking[0] = 0; // 0us
app_vars.backtracking[1] = 10; // 320us
app_vars.backtracking[2] = 28; // 869us
app_vars.backtracking[3] = 52; // 1586us
app_vars.backtracking[4] = 69; // 2136us
app_vars.backtracking[5] = 93; // 2853us
app_vars.backtracking[6] = 111; // 3403us
app_vars.backtracking[7] = 135; // 4121us
app_vars.backtracking[8] = 153; // 4670us
app_vars.backtracking[9] = 176; // 5388us
app_vars.backtracking[10] = 194; // 5937us
app_vars.backtracking[11] = 218; // 6654us
app_vars.backtracking[12] = 236; // 7203us
app_vars.backtracking[13] = 259; // 7922us
app_vars.backtracking[14] = 277; // 8471us
app_vars.backtracking[15] = 301; // 9189us

//===== fire up board

// disable watchdog timer
Expand Down Expand Up @@ -607,6 +626,7 @@ void timer_b_cb_endFrame(uint16_t timestamp_timerA, uint16_t timestamp_timerB){
uint16_t newCompareValue;
uint8_t crcByte;
uint8_t i;
uint8_t my_hop;
//uint8_t reg_FSCTRL_byte0;

// determine when I've just receive a packet for me
Expand Down Expand Up @@ -892,13 +912,15 @@ void timer_b_cb_endFrame(uint16_t timestamp_timerA, uint16_t timestamp_timerB){
newCompareValue = timestamp_timerA;
newCompareValue += LIGHT_SAMPLE_PERIOD;
if (rxpkt_len==FRAME_ACK_LEN) {
// when I receive an ACK frame, I'm at at depth rx_hop+2
newCompareValue -= (rx_hop+2)*ONE_HOP_LATENCY;
my_hop = rx_hop+2;
} else {
// when I receive a DATA frame, I'm at at depth rx_hop+1
newCompareValue -= (rx_hop+1)*ONE_HOP_LATENCY;
my_hop = rx_hop+1;
}
if (my_hop>16) {
my_hop = 16;
}
newCompareValue -= RADIO_STARTUP_DURATION;
newCompareValue -= app_vars.backtracking[my_hop];
newCompareValue -= BACKTRACK_TUNING;

TACCR2 = newCompareValue;
TACCTL2 = CCIE;
Expand Down

0 comments on commit 7a3a178

Please sign in to comment.