Using ListenMode as Wakeup timer

Started by kobuki, September 26, 2015, 07:39:30 PM

WhiteHare

I'll have to defer to someone else.  This doesn't sound like a problem I'm familiar with.

Neko

On the oscilloscope, it looks like the pulse at the end of the delay period simply doesn't get made. So the moteino gets stuck in the third SLEEP command.

WhiteHare

#77
I'm using different homegrown code, so I can't help you with the library code.  However, at a basic level, it sounds as though either:
1.  Listen Mode was not in effect when you last went to sleep, or
2.  The DIO mapping changed.
If you want to debug it further, you might try checking for those conditions before going to sleep by looking at the corresponding register values.


Neko

1. I think Listen Mode is in effect. There are two 0.1-ms pulses on D2 about 2 ms apart at the start of every delay. Those are also there in the failed cases.

2. Perhaps. I'll try to check.

Would it be impolite to ask if you would share your homegrown code?

As I mentioned, the failures are happening with short (< 262 ms) delays. I'm currently testing with longer ones and it seems to be helping. In addition, I am going to add the 50 uS delay recommended by joelucid before turning off ListenMode.

WhiteHare

#79
Well, since you have an oscilliscope, you should be able to easily confirm/refute #1 and/or #2 by seeing whether there's a periodic pulse coming in on D2.  If Listen Mode is enabled and DIO0 is mapped to D2, you should see that pulse arriving at the expected periodicity regardless of whether or not your Moteino is waking up or not.  Of course, you're really only interested in whether it continues to arrive when your Moteino should have woken up but instead seems to be in infinite sleep.  If it *is* arriving under those conditions, then something is wrong with the ISR.  If it isn't arriving, then it's #1 or #2.

My code is different.  It runs off a different DIO pin that's connected to D3.  You'd have to bodge a wire to make it work.  I can't offer to support it, so just believe me when I say: you're better off sticking to a standard library.  When I wrote my code, either there wasn't a library, or if there was, I didn't realize it existed.

All that said, I think I may have published some code blocks from it in this thread:  https://lowpowerlab.com/forum/projects/a-solar-supercap-powered-moteino/

Neko

Quote from: WhiteHare on May 24, 2017, 06:11:57 PM
Well, since you have an oscilliscope, you should be able to easily confirm/refute #1 and/or #2 by seeing whether there's a periodic pulse coming in on D2.  If Listen Mode is enabled and DIO0 is mapped to D2, you should see that pulse arriving at the expected periodicity regardless of whether or not your Moteino is waking up or not.  Of course, you're really only interested in whether it continues to arrive when your Moteino should have woken up but instead seems to be in infinite sleep.  If it *is* arriving under those conditions, then something is wrong with the ISR.  If it isn't arriving, then it's #1 or #2.

Exactly. It isn't arriving.

QuoteMy code is different.  It runs off a different DIO pin that's connected to D3.  You'd have to bodge a wire to make it work.  I can't offer to support it, so just believe me when I say: you're better off sticking to a standard library. 

Heaven forfend! No bodging.

QuoteWhen I wrote my code, either there wasn't a library, or if there was, I didn't realize it existed.

All that said, I think I may have published some code blocks from it in this thread:  https://lowpowerlab.com/forum/projects/a-solar-supercap-powered-moteino/

Ok. I will search for it. Thanks much.

WhiteHare

Hopefully someone who actually uses the library will help you sort out your issue.  If you ever do solve it, be sure to post what it was for future users.

Good luck!

Neko

I haven't really solved the problem, but I have worked around it. When radio.delay is used to make delays that are less than 262 ms, then the crashes occur, as I said above, about once per 500 trials in about 1/3 of the nodes. When I increase the delay to be over 262 ms, then the crashing stops. I have no idea what the reason is.

I tried putting delayMicroseconds(128); in ListenModeEnd(), prior to:

  writeReg(REG_OPMODE, RF_OPMODE_SEQUENCER_ON | RF_OPMODE_LISTENABORT | RF_OPMODE_STANDBY);
  writeReg(REG_OPMODE, RF_OPMODE_SEQUENCER_ON | RF_OPMODE_STANDBY);

but this did not help on its own.