[Contiki-developers] Using energest on MSB430

545 views
Skip to first unread message

Lander Casado

unread,
Mar 25, 2009, 5:41:55 AM3/25/09
to contiki-d...@lists.sourceforge.net
Hi all,

I have check the energest-demo example, but I am not sure if I understand properly how energest works. This is the code that I am going to use to measure the power consumption. Is it OK or I am missing something?

while(1)
{
    //Reset
    ENERGEST_OFF(ENERGEST_TYPE_CPU);
    ENERGEST_OFF(ENERGEST_TYPE_LPM);
    ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
    ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
    //Start
    ENERGEST_ON(ENERGEST_TYPE_CPU);
    ENERGEST_ON(ENERGEST_TYPE_LPM);
    ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
    ENERGEST_ON(ENERGEST_TYPE_LISTEN);

    /* Energy time init */
      last.cpu = energest_type_time(ENERGEST_TYPE_CPU);
      last.lpm = energest_type_time(ENERGEST_TYPE_LPM);
      last.transmit = energest_type_time(ENERGEST_TYPE_TRANSMIT);
      last.listen = energest_type_time(ENERGEST_TYPE_LISTEN);
    /*

    Whatever I want to measure
 
    */
    /* Energy time diff */
      diff.cpu = energest_type_time(ENERGEST_TYPE_CPU) - last.cpu;
      diff.lpm = energest_type_time(ENERGEST_TYPE_LPM) - last.lpm;
      diff.transmit = energest_type_time(ENERGEST_TYPE_TRANSMIT) - last.transmit;
      diff.listen = energest_type_time(ENERGEST_TYPE_LISTEN) - last.listen;

    printf("SICS , CPU=%li, LPM=%li, TRANSMIT=%li, LISTEN=%li\n", diff.cpu, diff.lpm, diff.transmit, diff.listen);
}

>From the Tmote Sky and CC1020 datasheets:
     
     - Current consumption: MCU on, Radio RX = 19.9 mA
     - Current consumption: MCU on, Radio TX = 20.5 mA ( with P = 0 dBm ? )
     - Current consumption: MCU on, Radio off = 1.8 mA  ( the same as Tmote Sky, because both MCU are MSP430x161x )
     - Current consumption: MCU idle, Radio off = 0.0545 mA ( the same as Tmote Sky, because both MCU are MSP430x161x )
     - Vcc = 3 V

Then, to denormalize the values I think I have to do this:

    power_consumption_CPU (mW) = (diff.cpu / TICKS_PER_SECOND) * ( 1.8 / UPDATE_PERIOD ) * Vcc;

I am not sure what is UPDATE_PERIOD, it should be UPDATE_PERIOD=1 ?

Finally, in energest.c and energest.h there are a lot of statements depending on the definition of ENERGEST_CONF_LEVELDEVICE_LEVELS. Do I need to define somewhere ENERGEST_CONF_LEVELDEVICE_LEVELS? What is the meaning of it?

Thanks in advance,

Lander



Nicolas Tsiftes

unread,
Mar 25, 2009, 3:46:18 PM3/25/09
to Contiki developer mailing list
Lander Casado skrev:

> Hi all,
>
> I have check the energest-demo example, but I am not sure if I
> understand properly how energest works. This is the code that I am
> going to use to measure the power consumption. Is it OK or I am
> missing something?
>
> while(1)
> {
> //Reset
> ENERGEST_OFF(ENERGEST_TYPE_CPU);
> ENERGEST_OFF(ENERGEST_TYPE_LPM);
> ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
> ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
> //Start
> ENERGEST_ON(ENERGEST_TYPE_CPU);
> ENERGEST_ON(ENERGEST_TYPE_LPM);
> ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
> ENERGEST_ON(ENERGEST_TYPE_LISTEN);
You shouldn't call ENERGEST_ON and ENERGEST_OFF. That's done in the
devices when they are activated and deactivated, respectively.

> Then, to denormalize the values I think I have to do this:
>
> power_consumption_CPU (mW) = (diff.cpu / TICKS_PER_SECOND) * ( 1.8
> / UPDATE_PERIOD ) * Vcc;
>
> I am not sure what is UPDATE_PERIOD, it should be UPDATE_PERIOD=1 ?
>

You can just remove UPDATE_PERIOD from the formula. It is set as "final"
to 1 in the energest example, but its purpose is unclear to me.


> Finally, in energest.c and energest.h there are a lot of statements
> depending on the definition of ENERGEST_CONF_LEVELDEVICE_LEVELS. Do I
> need to define somewhere ENERGEST_CONF_LEVELDEVICE_LEVELS? What is the
> meaning of it?

It is suitable when a device has several energy levels. An example of
its use is when changing radio transmission power, but its not needed in
most measurements.

Nicolas

------------------------------------------------------------------------------
_______________________________________________
Contiki-developers mailing list
Contiki-d...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/contiki-developers

Lander Casado

unread,
Mar 26, 2009, 11:24:46 AM3/26/09
to contiki-d...@lists.sourceforge.net
Hi Nicolas,

Thank you for your fast replies.


>> while(1)
>> {
>> //Reset
>> ENERGEST_OFF(ENERGEST_TYPE_CPU);
>> ENERGEST_OFF(ENERGEST_TYPE_LPM);
>> ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
>> ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
>> //Start
>> ENERGEST_ON(ENERGEST_TYPE_CPU);
>> ENERGEST_ON(ENERGEST_TYPE_LPM);
>> ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
>> ENERGEST_ON(ENERGEST_TYPE_LISTEN);

>You shouldn't call ENERGEST_ON and ENERGEST_OFF. That's done in the
>devices when they are activated and deactivated, respectively.

If I shouldn't call ENERGEST_ON and ENERGEST_OFF , certainly I do not understand these lines of code in energest-demo.c:

/* stop-start ongoing time measurements to retrieve the diffs
       during last interval */
    ENERGEST_OFF(ENERGEST_TYPE_CPU);
    ENERGEST_ON(ENERGEST_TYPE_CPU);
    mac->on();
    mac->off(0);

Regards,

Lander

Lander Casado

unread,
Apr 2, 2009, 3:02:38 PM4/2/09
to contiki-d...@lists.sourceforge.net

Nicolas Tsiftes

unread,
Apr 2, 2009, 6:01:51 PM4/2/09
to Contiki developer mailing list
Lander Casado skrev:

>
>
> If I shouldn't call ENERGEST_ON and ENERGEST_OFF , certainly I do not
> understand these lines of code in energest-demo.c:
>
> /* stop-start ongoing time measurements to retrieve the diffs
> during last interval */
>
> ENERGEST_OFF(ENERGEST_TYPE_CPU);
> ENERGEST_ON(ENERGEST_TYPE_CPU);
> mac->on();
> mac->off(0);

The purpose is probably to update the energest time counter in order to
get a fresh starting value. That is fine since the CPU is on in that
case, but if you do the same with the radio, leds, sensors, and other
devices that are off, you will attribute too much time to those. The
proper way to update all counters before a measurement is to call
energest_flush.

Reply all
Reply to author
Forward
0 new messages