Author Topic: Wake from listenmode causes VCC drop and system crash  (Read 2513 times)

davegravy

  • Jr. Member
  • **
  • Posts: 56
  • Country: ca
Wake from listenmode causes VCC drop and system crash
« on: May 31, 2016, 11:32:09 PM »
My moteino project (https://lowpowerlab.com/forum/index.php/topic,1832.msg13253.html#msg13253) is running off a 3V lithium coincell, internal oscillator, BOD=1.8V, no regulator, and uses the listenmode scheme.

When running off my lab supply with a 10Ohm shunt resistor (to mimic IR of the coin cell) all of this works fine, and current consumption within listenmode is a healthy 5uA or so. When running off the (brand new) coin cell however, the internal resistance kills things immediately upon the moteino waking from listenmode.

Something in the following code block is drawing more current than the cell (https://www.digikey.ca/product-detail/en/panasonic-bsg/BR-2477A-VAN/P030-ND/273650)can handle:

Code: [Select]
    Serial.println("Woke up!");
    uint8_t from = 0;
    long burstRemaining = 0;
    if (radio.DATALEN > 0) {
      Serial.println("Received a message in listen mode");
      Serial.println((char*)radio.DATA);
      Serial.flush();
      from = radio.SENDERID;
      burstRemaining = radio.LISTEN_BURST_REMAINING_MS;
    }

    // Radio goes back to standby, ready for normal operations
    radio.listenModeEnd();

    if (from) {
      while (burstRemaining > 0) {
        LowPower.powerDown(SLEEP_60MS, ADC_OFF, BOD_OFF);
        burstRemaining -= 60;
      }
      LowPower.powerDown(SLEEP_30MS, ADC_OFF, BOD_OFF);
      radio.send(from, "woke", 4);
    }

I'm guessing the culprit is the "woke" transmission, so tomorrow I'm going to try commenting it out and see if the crash gets averted.  I'm also going to capture the current consumption during wake with a scope to see what's happening. I'll post here when I have it.

I'm pretty sure I've read that coin cell users are using listenmode succesfully, so I'm curious as to how their implementation differs from the library example.
« Last Edit: May 31, 2016, 11:33:40 PM by davegravy »

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: Wake from listenmode causes VCC drop and system crash
« Reply #1 on: June 01, 2016, 02:01:36 AM »
Listen mode can definitely be done with coin cells - I do it all the time. You have to make sure that you're not stuck somewhere. In your code I notice that you flush the serial before putting the radio to sleep. While that's likely not fatal it's not good. Another typical problem is canSend, where high background noise can cause the radio to be stuck in rx for a full second.

Sending with four retries and the canSend issue could definitely cause what you're seeing. I typically don't retry if the send isn't essential. Or I sleep until voltage recovers between retries. I don't use carrier sensing ala canSend at all. If you do use it it would be better to put the radio and 328p to sleep for a period of time until retrying.

davegravy

  • Jr. Member
  • **
  • Posts: 56
  • Country: ca
Re: Wake from listenmode causes VCC drop and system crash
« Reply #2 on: June 01, 2016, 08:50:57 PM »
Listen mode can definitely be done with coin cells - I do it all the time. You have to make sure that you're not stuck somewhere. In your code I notice that you flush the serial before putting the radio to sleep. While that's likely not fatal it's not good. Another typical problem is canSend, where high background noise can cause the radio to be stuck in rx for a full second.

Sending with four retries and the canSend issue could definitely cause what you're seeing. I typically don't retry if the send isn't essential. Or I sleep until voltage recovers between retries. I don't use carrier sensing ala canSend at all. If you do use it it would be better to put the radio and 328p to sleep for a period of time until retrying.

Thanks Joe. I think the "4" in

Code: [Select]
radio.send(from, "woke", 4);

is actually the buffersize, not # of retries. The send function is defined in the RFM69 library as

Code: [Select]
void RFM69::send(uint8_t toAddress, const void* buffer, uint8_t bufferSize, bool requestACK)

For sending with retries I understand sendWithRetries() must be used instead.

Maybe the cansend issue is the culprit, but from the scope trace the voltage drop on wakeup is cliff-like or nearly instant. It's not like it's getting dragged down to 1.8V over a full second of being stuck in RX.

Didn't get to the testing I mentioned I'd try to do today... tomorrow I hope.

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: Wake from listenmode causes VCC drop and system crash
« Reply #3 on: June 02, 2016, 12:37:47 AM »
Quote
Maybe the cansend issue is the culprit, but from the scope trace the voltage drop on wakeup is cliff-like or nearly instant. It's not like it's getting dragged down to 1.8V over a full second of being stuck in RX.

That sounds strange. I was going to ask if you're using full tx power on a rfm69hw. But just checked with one of my cr2450 / hw based tino's (cell a couple months old) and it successfully sent at 20dBm reaching a minimum voltage of 2.36v. Normally I have them all on powerLevel 0 though.

Quote
is actually the buffersize, not # of retries.

Of course. Sorry, my bad.

davegravy

  • Jr. Member
  • **
  • Posts: 56
  • Country: ca
Re: Wake from listenmode causes VCC drop and system crash
« Reply #4 on: June 07, 2016, 03:32:43 PM »
Here's VCC during wake with the "woke" reply commented out. I did 3 wakes, and for some reason the drop is always longer for the first wake after boot.



Zoomed in on the first wake.



Here's VCC during during wake with the "woke" response uncommented (and resulting crash)



and zoomed on the crash:



Does my particular model of coin cell have too high an internal resistance? Is there something in the RFM69 library that I should need to change to support TX on a coin cell?
« Last Edit: June 07, 2016, 03:42:05 PM by davegravy »