XB24-ZB cyclic sleep does not behave as expected

Reading the manual a few times I got an idea that if an end device is set up to cycle-sleep, it will wake up every SPx10ms, beacon to router and if there’s data awaiting, it will start ST timer, deassert ON/SLEEP pin and start communicating. This is not what happens in reality however. Imaging I got SP set to 1 second and SN set to 3. ST is also a second (that huge for troubleshooting). I also got an MCU connected that gets data, processes and sends a reply.

So the thing is that the MCU is woken by this ON/SLEEP pin and it wakes up only every 3 seconds - irrespectively to if there’s data waiting or not. My intention is to have XBEE wake MCU only once a day if no request for data is received. Is that possible or I got a wrong impression? Any advise is appreciated.

Here are the profiles for XBEEs:
Coordinator:

XB24-ZB_20A7.mxi
80
0
251
20A7
0
[A]ID=2404
[A]SC=FFFF
[A]SD=3
[A]ZS=0
[A]NJ=FF
[A]DH=13A200
[A]DL=4079B270
[A]NI= 
[A]NH=1E
[A]BH=0
[A]AR=FF
[A]DD=30000
[A]NT=3C
[A]NO=0
[A]CR=3
[A]SE=E8
[A]DE=E8
[A]CI=11
[A]PL=4
[A]PM=1
[A]EE=0
[A]EO=0
[A]BD=7
[A]NB=0
[A]SB=0
[A]RO=3
[A]D7=1
[A]D6=0
[A]CT=64
[A]GT=3E8
[A]CC=2B
[A]SP=64
[A]SN=1
[A]D0=1
[A]D1=0
[A]D2=0
[A]D3=0
[A]D4=0
[A]D5=1
[A]P0=1
[A]P1=0
[A]P2=0
[A]PR=1FFF
[A]LT=0
[A]RP=28
[A]DO=1
[A]IR=0
[A]IC=0
[A]V+=0

End device:

XB24-ZB_28A7.mxi
80
0
251
28A7
0
[A]ID=2404
[A]SC=FFFF
[A]SD=3
[A]ZS=0
[A]NJ=FF
[A]JN=0
[A]DH=0
[A]DL=0
[A]NI= 
[A]NH=1E
[A]BH=0
[A]DD=30000
[A]NT=3C
[A]NO=0
[A]CR=3
[A]SE=E8
[A]DE=E8
[A]CI=11
[A]PL=4
[A]PM=1
[A]EE=0
[A]EO=0
[A]BD=7
[A]NB=0
[A]SB=0
[A]RO=3
[A]D7=1
[A]D6=0
[A]CT=64
[A]GT=3E8
[A]CC=2B
[A]SM=4
[A]ST=3E8
[A]SP=64
[A]SN=2
[A]SO=6
[A]PO=0
[A]D0=1
[A]D1=0
[A]D2=0
[A]D3=0
[A]D4=0
[A]D5=1
[A]P0=1
[A]P1=0
[A]P2=0
[A]PR=1FFF
[A]LT=0
[A]RP=28
[A]DO=1
[A]IR=0
[A]IC=0
[A]V+=0

I don’t think it ever works that way. My understanding is that the SLEEP pin will assert/wake your MCU regardless of if there is data to move or not.

Keep in mind that MOST systems work in revervse - the XBEE+MCU wake and then decide to send something upstream or not. You will find it very difficult to poll or talk to sleeping devices regularly since generally the packets you send will expire before yoru waking devcie can see than.

In your example, you have the end-device sleeping twice as long as the parent holds the request (the parents holds only SP=64 and SN=1) while the child only wakes every SP=64/SN=2, so 1/2 the time your message to the end-devcie will be discarded by the parent.

Hi lynnl,

Thanks for your reply. Here’re the parts from manual that allowed me to hope I can get away with my design:

  1. In cyclic sleep, the module sleeps for a specified time, and then wakes and sends a poll request to its parent to
    discover if the parent has any pending data for the end device. If the parent has buffered data for the end
    device, or if serial data is received, the XBee will remain awake for a time. Otherwise, it will enter sleep mode
    immediately.
  2. In cyclic sleep mode (SM=4 or 5), if serial or RF data is received, the module will start a sleep timer (time
    until sleep). Any data received serially or over the RF link will restart the timer.
  3. The XBee ZB 2x6x firmware includes an adaptive polling enhancement where, if an end device receives RF data
    from its parent, it sends another poll after a very short delay to check for more data. The end device continues
    to poll at a faster rate as long as it receives data from its parent. This feature greatly improves data throughput
    to end devices. When the end device no longer receives data from its parent, it resumes polling every 100ms.
  4. The transmission timeout per attempt is:
    3 * ((unicast router timeout) + (end device sleep time)), or
    3 * ((50 * NH) + (1.2 * SP)), where SP is measured in 10ms units.
  5. SP and SN should be
    set on routers and coordinators such that (SP * SN) matches the longest expected sleep time. This configures
    the poll timeout so end devices are not expired from the child table unless a poll request is not received for 3
    consecutive sleep periods.
  6. All router and coordinator devices on the network should set SP to match SP on the end device. This ensures
    that RF packet buffering times and transmission timeouts will be set correctly.
    Since the end device wakes after each sleep period (ATSP), the SN command can be set to 1 on all routers and
    the coordinator.

Also, from here: http://www.digi.com/support/kbase/kbaseresultdetl?id=2193

The Coordinator will accept a message addressed to a specific remote 16 or 64 bit address and hold on to it in a buffer until the remote wakes and sends a poll requesting the information. These messages are referred to as indirect messages. The Coordinator will only queue one indirect message at a time. The Coordinator will hold on to the indirect message for a period of 2.5 times the sleeping period indicated by the SP (Cyclic Sleep Period) parameter. A remote in cyclic sleep will awaken once a period, and send a poll request to the Coordinator to ask for any indirect messages.

I don’t want the MCU to manage anything but a sensor reading. And I understand what I just cited is that the XBee will not wake the MCU up until either SN*SP time OR incoming transmission

I have no idea how you see what you do in that text. Anyway, I am certain that it won’t do what you want because I have worked with thes ethings for years and if you were correct, then my things would never work :slight_smile: i require the MCU to be woken every period and that’s what I see.

Thanks lynnl,

I believe this well may be the case when years of work may make you dismiss my question too fast.

I read the part carefully and I think I found my mistake (thanks for this). The bahaviour I’m looking for is in SHORT cyclic sleep, not EXTENDED.

Have a look, I think I dried it as much as possible:
Short Cyclic Sleep
…Since router and coordinator devices can buffer
data for end device children up to 30 seconds, the SP range (up to 28 seconds) allows the end device to poll
regularly enough to receive buffered data. If the parent has data for the end device, the end device will
start its sleep timer (ST) and continue polling every 100ms to receive data. If the end device wakes and
finds that its parent has no data for it, the end device can return to sleep immediately.
The SN command can be used to control when the On/Sleep line is asserted (high). If SN is set to 1
(default), the On/Sleep line will be set high each time the XBee wakes from sleep. Otherwise, if SN is
greater than 1, the On/Sleep line will only be set high if RF data is received, or after SN wake cycles occur.
This allows an external device to remain powered off until RF data is received, or until a number of sleep
periods have expired (SN sleep periods)…

Thanks again, I think I’m now in a good shape :slight_smile:

And it works. set up:
SO = 2, it’s ‘short’ sleep, and stays awake for full ST if woken
SP = 50, so the module pings coordinator every half a second. Module does not toggle nSLEEP pin if no data is pending.
SN = FFFF so if there were no requests from coordinator, module will toggle nSLEEP (and wake up MCU) only every 9,1 hours. Or if there was a request from coordinator - at the request.
If the module woke up (by receiving data or by cyclic timeout of 9 hrs), it will stay up for ST = 7D) (2 seconds).