This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to put Router into Deep Sleep Mode (PM2 or PM3) for CC2530

Other Parts Discussed in Thread: Z-STACK, CC2530, CC2430

Hi,  Guys,

I really could use some help here...  Have been struggling with this for several weeks now...

The issue is that I try to put a router into deep sleep mode.  I understand according to support document, it is not recommended to put router into deep sleep mode.  However, due to the requirements, I need to find a way to save energy used by the router.  The idea is that put router into deep sleep mode for 250ms, then stay awake for another 250ms.  End device will send signal to it and will retry up to 500ms, therefore the signal should be received by the router when it is awake.

Here is what I tried:

1.  Set POWER_SAVING flag

2.  Set RFD_RCVC_ALWAYS_ON to FALSE. 

3.  I also made sure osal_pwrmgr_device( PWRMGR_BATTERY ) is called.

However, when halSleep is called, it failed on MAC_PwrOffReq(MAC_PWR_SLEEP_DEEP).  And I could not trace into this function....  I know it must have something to do with "Router" configuration, but I wonder if there is way to make it work??

I searched the forum several times and read some discussions, but none of them seem to provide a solution....

I wonder if anyone can help please?  Share some insights?  I would really appreciate any help as I am out of idea by now....

Thanks

John

  • It is not possible to put into sleep a Z-Stack device, configured as a Router. What will be the over-all power savings of your system in this scenario in which the ZED might have to be actively TX-ing for 250 msec while the Router parent sleeps? This seems to be a non-sensical tradeoff, but probably I am missing something. And if the other Routers are sleeping, how will the message ever get routed to the final destination before it times out? What you would need is a Beacon Network, which is not supported by Z-Stack - you would have to go to a MAC-only solution to get Beacon network.

  • Hi Harry,

    Thanks for your reply!  I guess the requirement does look like confusing.

    Here may better describes what we try to achieve:

    1.  ZED is battery powered, but it only sends signal a few times a day and such signal is information purpose only.  We did think about if other routers are sleeping, so we basically cache the data on the parent router and eventually it will get to coordinator in a reasonable amount of time.  The network is not huge.

    2.  Router needs to conserve power too because it is kinda of battery powered ( image a super cheap low capacity rechargeable battery), except this battery can be recharged a few times per day.  We did some calculation that if we put router in RX mode all the time, there may not be enough power...

    So we are not really trying to save power, but try to make the whole system work in this very restricted environment.  That is why we try to put router into sleep mode to save its power usage.

    The reason why we try to use Z-Stack is because the router may have access to enough power in some environments, so we can expand the features and software can be dynamically configured and works cross different environments at run time.

    Thanks

    Jiang

  • I see, Jiang ... very interesting. I think that you will need to design a Quasar Pulse Network as follows:

    Configure the Routers to restore their network states after reset by adding this to f8wConfig.cfg:

    -DNV_RESTORE
    -DNV_INIT

    Then in OnBoard.c where the reset reason is checked, add logic such that if reset reason is a hard reset, just run. If the reset reason is a watchdog reset, then sleep for a long time. You cannot run any more initialization in order to get the OSAL Timers working, or else the network will be restored and the device will be a non-sleepable router again, so you must implement a special Dwarf Star Sleep right there. Easiest and fastest way to get a proof-of-concept running would be to read the Sleep Timer tick and set the wakeup for 1 tick less to sleep for 8.53 minutes (2^24 / 32768). Then the Dwarf Star Router will wakeup and run, accepting messages from its restored ZED's and transacting on the restored mesh network.

    When your Black Hole ZC is happy that it has received messages from all Dwarf Star ZR's, it will send the Quasar Pulse - a broadcast saying to go to sleep for 8.53 minutes. But you cannot just sleep, you have to first extinquish yourself with a HAL_SYSTEM_RESET() and then sleep on re-birth as described above.

     

  • Hi Harry,

    Really appreciate your suggestions!  I am definitely giving it a try, at least from the proof of concept level.

    Thanks so much!

    John

  • I have a bit of a longer rant about this.

    As Dirty Harry points out, one can't do sleeping routers with Z-Stack unless building on an ad-hoc high-level sleep/wakeup protocol which, at the end of the day, won't be very energy friendly.

    As he also rightfully points out, to really implement sleeping routers, one must go the beacon network route. All this occurs at the MAC level and above (eg. at the network or app level).

    However, beware: several issues stand in your way:

    a) a sleep/wakeup scheme for sleeping routers implies synchronisation among the nodes of your network.  To exchange messages, involved parties have to be awake, and not in sleep mode (PM2).  At the scale of the network, this implies a global sychronisation scheme where all nodes (both end-devices and routers) go to sleep to save power, then wake up "preferably synchronously" in order to exchange info. Preferably synchronously - because if they don't wake up synchronously, one ends up with out-of-sync and re-sync issues (one active device talking to a neighbour device in sleep mode which can't hear the messages sent to it) plus the management of buffered data and message retransmissions.

    b) The inter-node sync issue is central for sleeping nodes, and in particular for sleeping routers. As a user, you want additionally to be able to configure the sleep/wakup periods dynamically. i.e. to be able to configure at runtime the length of the night and the length of the day in a day/night cycle.

    c) Assuming you've sorted the sync aspects somehow, this somehow does imply a beacon network.  Now, by using a 802.15.4 MAC-level beacon network configuration, one will discover pretty soon that although there are provisions in 802.15.4 (TI-)MAC for inter-node synchronisation according to a master/slave scheme i) it's hard to scale that to the level of the network, ii) it's almost impossible to vary the duty cycle (day/night) without major network reconfiguration implying a reset of the MAC layer, iii) the re-sync issue is almost not solved (due to packet loss, difficult radio environment or too many collisions, once a node gets out of sync, it'll take time and energy to re-sync, which is a process performed by MAC over which one doesn't have much control), iv) basically one can't handle the synchronisation error cases gracefully because there's little knowledge of what's going on on the sync-side of things. One just has indications telling whether the device is in-sync or out-of-sync, but no more. And that's not enough.

    d) One will then try an alternative - build a beacon network manually at the network layer, that is on top of (TI-)MAC, with a duty-cycle scheduler with controls explicitly when the device is going to sleep (PM2) and is waking up. This way, all of the above issues can be sorted out because one has control over the process (sync, out-of-sync, pkt loss, beacon and data rtx, and even dynamic user-level control of the day-night periods within the duty cycle, the length of the latter being also configurable). This solution does lead to a somewhat proprietary network layer with added value over the standard Z-Stack network layer, because the devices can now have a sleep/wakeup duty-cycle profile, including the routers.

    e) Assuming all that is a given, you've got a "pulsing" network which sleeps (most of the time) and wakes-up regularily and synchronously to exchange and route messages from one node to another. And then, you'll want to get the most out of your network and you'll figure out pretty soon that a sleeping router (which is great but a contradictory notion anyway) will start dropping messages due to out of memory conditions resulting from too much buffered data (accumulating in some parts of the network partly because of the sleep periods) and you'll end up extending the (RAM) message queues to flash, by using flash a a secondary storage for the data to mitigate the situation.  Note that the amount of RAM persisting trough a PM2 sleep cycle is limited, hence the issue.

    f) Etc. etc., etc.

     I'll stop here, because there is so much more to be done in order to have sleeping routers... that you might really get discouraged by seeing how many cans of worms such a simple and intuitive concept can open :-)  If it's not provided with TI-MAC or Z-Stack - it's not an accident.

    Now, if I tell you that I've gone that route and I have all of the above implemented and working, and on top of this, I have it working on CC2430 devices which have at most half the ressources of CC2530 onces, I'll probably get some respect here <wink>, but that's not the point...

    The point is that sleeping routers are hard to do and for a proof of concept like yours, you're better off with the hunch of Dirty Harry.  And if it is not satisfactory, bear in mind that going the beacon network route requires, as a minimum, a ton of work.

    Good luck!

  • You can use the following code 

    if(BaseStationState==STATE_BS_IDLE)
    {
    unsigned char rxOnIdle;

    //turn off ZigBee task
    nwk_setStateIdle( TRUE );
    // turn MAC receiver off
    rxOnIdle = false;
    ZMacSetReq( ZMacRxOnIdle, &rxOnIdle );


    halSleep(20000); //20sec deep sleep

    //turn on ZigBee task
    rxOnIdle = true;
    ZMacSetReq( ZMacRxOnIdle, &rxOnIdle );
    // set NWK task to run
    nwk_setStateIdle( FALSE );
    }