• Hi,

    The title says it all: Is there any hope to get, at run time, the various instants at which all the run/sleep/deep sleep modes were entered by the interpreter? Cumulated times spents in each mode would be a way to quantify easily the power consumption...

    Ok, (re) found setBusyIndicator which should show when running and not sleeping: I have to test that...

    Aside of time measurements, it would also give an idea of the eventuals problems of lost data when getting out of deep sleep mode.

    Thanks for your attention.

  • There isn't a way to do it at the moment - it wouldn't be ideal because you'd have to use the RTC which is only accurate to 1/32768th of a second, but I know what you mean - it's better than nothing.

    Right now I'd say it's best to use setBusyIndicator/setSleepIndicator and an oscilloscope.

    also give an idea of the eventuals problems of lost data when getting out of deep sleep mode.

    What do you mean? Like issues waking up to respond to serial data?

  • Well, in some cases, at wake up some data can be lost due to the time it takes to re setup the peripherals links (usarts, spi...). That's from deep sleep.

  • Hi,

    So I connected a Pico to an Original Espruino and tried to monitor the Original Espruino from the Pico.
    So far, I ended up with results only for busy indicator as I am running the original espruino board from USB connection so there is no deep sleep available yet.

    The code on the Originla Espruino just includes

      setBusyIndicator(LED1); // A13
      setSleepIndicator(LED2);  // A14
    

    The code on the Pico is

    /*
                  Measure time spent on LED1/LED2 by an original Espuino board
                  */
    
    var onPin=B10; // Non deep sleep (1===running or simple sleep) led from Original Espruino Board
    var onTime=0;
    var busyPin=B13; // Busy (1=== running, neither simple sleep, nor deep sleep) led from Original Espruino Board
    var busyTime=0;
    var deepSleepTime=0;
    var startedAt=getTime();
    
    function log() {
      let runningFor=getTime()-startedAt;
      console.log("Running for",runningFor,"s");
      console.log("On time (Busy + Sleep)",onTime,"s",Math.floor(onTime*100­0/runningFor)/10,"%\tbusyTime (Busy)",busyTime,"s",Math.floor(busyTime­*1000/runningFor)/10,"%\tdeepSleepTime",­deepSleepTime,"s",Math.floor(deepSleepTi­me*1000/runningFor)/10,"%");
    }
    
    function resetChronos() {
      onPin=B10;
      onTime=0;
      OLED2=B13;
      busyTime=0;
      deepSleepTime=0;
      startedAt=getTime();
    }
    
    function onInit() {
      resetChronos();
      log();
    }
    
    var idOnTimeWatch=setWatch(function (e) {
      onTime+=e.time-e.lastTime;
    }, onPin, { repeat:true, edge:'falling' });
    
    var idBusyTimeWatch=setWatch(function (e) {
      busyTime+=e.time-e.lastTime;
      log();
    }, busyPin, { repeat:true, edge:'falling' });
    
    var idDeepSleepTimeWatch=setWatch(function (e) {
      deepSleepTime+=e.time-e.lastTime;
      log();
    }, onPin, { repeat:true, edge:'rising' });
    
    
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Measure times spent in run/sleep/deep sleep modes on STM32 boards

Posted by Avatar for asez73 @asez73

Actions