How does puck js keep timer going in sleep mode?

Posted on
  • Hi there, I'm quite new to the puck js. I'm wondering about one of its features as claimed by a colleague of mine. Apparently it can keep an internal counter going even after waking up from sleep mode (correct me if I'm wrong).

    How does this work exactly?
    As far as I know it doesn't have an external RTC and supposedly the NRF sleep function shuts everything off including the real time counter module, so unless I'm wrong about something, what am I missing? Can someone help?

    Thanks in advance.

  • supposedly the NRF sleep function shuts everything off

    Not really, where did you find such information?
    https://www.espruino.com/Reference#l_NRF_sleep

    There is no such mode that could cause issues with 'keeping an internal counter going' except removing battery.

    Also you may check this for power consumption in various scenarios https://www.espruino.com/Puck.js#power-consumption

  • The actual processor can be put into a mode that shuts everything down and wakes on external inputs, but that's not something Puck.js does, since the normal sleep functionality (that keeps the internal RTC running as well as all contents of RAM) gets power consumption down to 3uA (6+ years on a CR2032) which seemed more than enough.

    So yes, effectively Puck.js does sleep while keeping any counters and the RTC in memory, but that's because the processor is efficient enough at sleeping that it doesn't have to shut everything off.

    It's worth noting that Puck.js and other Bluetooth Espruino devices put themselves to sleep automatically, for example:

    setInterval(function() {
      LED.toggle();
    }, 1000);
    

    Will end up with the processor asleep 99% of the time.

    All NRF.sleep() does is to turn off the Bluetooth advertising, which, when the processor isn't executing JS, is the main power drain (although even that, with the default config, is 40uA)

  • I see I was under the impression that NRF_sleep() was the equivalent of system off sleep mode and not system on sleep mode. In that case I understand the deal, although that means I have bigger consumption problems in my application than I thought I did, I'm already using system off and I get way too much consumption .
    Thank you for the clarification

  • thanks for the clarification, as I said to fanoush I had the wrong idea about what type of sleep mode NRF_sleep() was, I'm only familiar with NRF SDK development in C so I was trying to understand what the puck was doing to apply it to my application.

  • I'm only familiar with NRF SDK development in C

    for sleeping it calls sd_app_evt_wait
    https://github.com/espruino/Espruino/blob/master/targets/nrf5x/jshardware.c#L2717
    which should be as low power consumption as it can get without powering off

    If you have high power draw like 0.5mA or 1mA it may be that you left something powered on like I2C,SPI,UART

  • Do you have anything else connected to the Puck?

    If not, if you could send your code I can take a look and try and see what's causing the power draw.

    If you have high power draw like 0.5mA or 1mA it may be that you left something powered on like I2C,SPI,UART

    UART is a big power draw, but you may also find that having a pin in 'pullup' state, or that's driving an output against a pullup (or an external sensor that is unpowered) can easily increase current draw.

  • Perhaps I didn't make myself clear but I'm not actually using the Puck, I'm using the nRF52840 in a completely different setting, I just wanted to understand how the Puck was making use of its nRF chip to see if I could lower my high consumption values.

    But yeah I'm getting about 8mA current consumption while in operation and about 0.7 mA in sleep mode, I'm already using the deepest sleep mode (system off) so I'm not sure what can I be leaving on, I should be getting less than 100uA for sure.

    Anyway I think it's clear for me regarding the puck on what is being done, thank you both for your support @fanoush and @Gordon

  • Ok, yes, I don't think you mentioned that at all.

    If you want to ask questions about non-official Espruino devices in the future please can you ask in https://forum.espruino.com/microcosms/1085/ ?

    We have different forums because I'm trying to run a business, and while I give all the software I make away for free, I can't afford to support people in companies using that software for free in their products

  • I'm getting about 8mA current consumption while in operation and about 0.7 mA in sleep mode, I'm already using the deepest sleep mode (system off) so I'm not sure what can I be leaving on, I should be getting less than 100uA for sure.

    You may check values here
    https://infocenter.nordicsemi.com/topic/ps_nrf52840/_tmp/nrf52840/autodita/CURRENT/parameters.i_sleep.html?cp=5_0_0_4_1_0_0
    so yes, you should get about 100 times less both in sleep and system off. Such high power draw could be both software and hardware design issue. Anyway if this is not related to Espruino then there are better places for discussing this. I'd suggest Nordic devzone https://devzone.nordicsemi.com/

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

How does puck js keep timer going in sleep mode?

Posted by Avatar for user156858 @user156858

Actions