Author Topic: Using ListenMode as Wakeup timer  (Read 89567 times)

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Using ListenMode as Wakeup timer
« Reply #75 on: May 23, 2017, 12:57:50 PM »
I'll have to defer to someone else.  This doesn't sound like a problem I'm familiar with.

Neko

  • NewMember
  • *
  • Posts: 37
  • Country: us
Re: Using ListenMode as Wakeup timer
« Reply #76 on: May 23, 2017, 06:59:19 PM »
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

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Using ListenMode as Wakeup timer
« Reply #77 on: May 24, 2017, 07:56:16 AM »
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.

« Last Edit: May 24, 2017, 08:02:01 AM by WhiteHare »

Neko

  • NewMember
  • *
  • Posts: 37
  • Country: us
Re: Using ListenMode as Wakeup timer
« Reply #78 on: May 24, 2017, 02:59:01 PM »
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

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Using ListenMode as Wakeup timer
« Reply #79 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.

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/
« Last Edit: May 24, 2017, 09:14:46 PM by WhiteHare »

Neko

  • NewMember
  • *
  • Posts: 37
  • Country: us
Re: Using ListenMode as Wakeup timer
« Reply #80 on: May 24, 2017, 09:59:59 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.

Quote
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. 

Heaven forfend! No bodging.

Quote
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/

Ok. I will search for it. Thanks much.

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: Using ListenMode as Wakeup timer
« Reply #81 on: May 25, 2017, 08:57:46 AM »
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

  • NewMember
  • *
  • Posts: 37
  • Country: us
Re: Using ListenMode as Wakeup timer
« Reply #82 on: May 27, 2017, 04:06:53 PM »
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.