tinyosnesc

Telosb Low Power Mode:


I'm working on a project that involves switching the state of the Telosb, i would like to know how to put the motes to "sleep" (low power) and how to wake the motes up.


Solution

  • A mote will be automatically put to sleep (low-power) mode by TinyOS scheduler when the task queue is empty (so basically when there is nothing to do - no code to execute). The mote is waked up by an interrupt, for instance, timer interrupt (timer event occured), radio interrupt (radio packet has been received), or external IO pin interrupt (a user pressed a button).

    However, microcontrollers have various low-power levels that differ in wake-up conditions, peripherals that can continue working, wake-up delay, and power consumption. Typically, in lower sleep levels, motes consume less power, but they can be woken up by only a few interrupts and most peripherals will stop operating. Sleep level is adjusted based on which peripherals are operating at the moment when the mote is about to sleep.

    Sleep level can be overridden. This is what drivers do, providing the lowest acceptable sleep level based on their state. For example, if radio packet reception is requested, the radio driver may prevent from entering deepest sleep levels, because a packet would be lost in that case (that is, radio interrupt notifying about packet reception wouldn't wake the mote up). To override sleep level, your module has to implement interface PowerOverride, so that it returns the lowest acceptable sleep level at the time lowestState is called:

    interface PowerOverride {
        async command mcu_power_t lowestState();
    }
    

    PowerOverride must be then wired to the component McuSleepC:

    component McuSleepC {
        provides interface McuSleep;
        provides interface PowerState;
        uses interface PowerOverride;
    }
    

    mcu_power_t is a chip-specific type describing possible power levels. In case of TelosB, which is based on MSP430 microcontroller, this type is defined in tos/chips/msp430/msp430hardware.h:

    enum {
        MSP430_POWER_ACTIVE = 0,
        MSP430_POWER_LPM0   = 1,
        MSP430_POWER_LPM1   = 2,
        MSP430_POWER_LPM2   = 3,
        MSP430_POWER_LPM3   = 4,
        MSP430_POWER_LPM4   = 5
    };
    

    The general conclusion is that if you only develop applications, you never have to worry about going to sleep or waking up.

    See also: Microcontroller Power Management