Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 38

Thread: Teensy 4.0 Low Power

  1. #1
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    1,010

    Teensy 4.0 Low Power

    Hi All, just wanted to gauge the priority of low power operation of the Teeny 4.0? I have worked on it for Snooze off and on for a bit now and it's not exactly an easy thing to implement since it is much different than Kinetis M micro's (T3x/LC). So post here if you need this and if enough people want it I will work on it now. Also if anyone wants to help please do and follow-up on this thread.

  2. #2
    Junior Member
    Join Date
    Jan 2019
    Posts
    15
    Dear duff, thank you for your Snooze library. T4 is currently useless to me compared to T3.5/6 because of the vastly inferior 24mhz power consumption vs the T3.5/6 at 24mhz. It isn't even the same: it is actually worse than T3.5/6, when the processor datasheets' indications of mhz v. ma would have you believe it should be better (actually, vastly better).

    I am holding off on further T4 purchases until I can get a power optimization, not a power worsening, from it compared to T3.5/6. See this thread for further info:
    https://forum.pjrc.com/threads/57450...compared-to-3x

  3. #3
    Senior Member
    Join Date
    Aug 2019
    Location
    southwest USA
    Posts
    114
    Quote Originally Posted by duff View Post
    Hi All, just wanted to gauge the priority of low power operation of the Teeny 4.0? I have worked on it for Snooze off and on for a bit now and it's not exactly an easy thing to implement since it is much different than Kinetis M micro's (T3x/LC). So post here if you need this and if enough people want it I will work on it now. Also if anyone wants to help please do and follow-up on this thread.
    your Snooze library is fantastic!

    it will certainly be welcome when it happens for Teensy4. i have been compiling and running on Teensy4 for 3 weeks now and have become at least a little
    familiar with it. have been using Teensylc and Teensy3.6 and Arduino and Teensyduino for not quite 3 years. i am not a real programmer but have been doing
    assembly and c for embedded for several decades as a circuit designer and hack programmer and i have a complete test equipment bench. i have a small
    collection of Teensylc and Teensy3.6 programs that use the Snooze library to go slow or hibernate that i could compile, run, and test (or send to you).

    please let me know if i can be of help.

  4. #4
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    1,010
    Ok I'll work on this again, it's going to be a slow slog though, there are so many things with the M7 processor that you have consider that you didn't in the arm M0/M4!

  5. #5
    Senior Member
    Join Date
    Aug 2019
    Location
    southwest USA
    Posts
    114
    Quote Originally Posted by duff View Post
    Ok I'll work on this again, it's going to be a slow slog though, there are so many things with the M7 processor that you have consider that you didn't in the arm M0/M4!
    when you say this just after my post it makes me feel guilty!

  6. #6
    Junior Member
    Join Date
    Mar 2020
    Posts
    2
    Hi Duff,

    I am wondering how is your with Snooze library going for Teensy 4.0. I am thinking about upgrading my project, but I need a current draw of less than 200uA in hibernate mode (standalone). Is it possible?

    Thank you,

    Peter

  7. #7
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    1,010
    Quote Originally Posted by piotrek View Post
    Hi Duff,

    I am wondering how is your with Snooze library going for Teensy 4.0. I am thinking about upgrading my project, but I need a current draw of less than 200uA in hibernate mode (standalone). Is it possible?

    Thank you,

    Peter
    Currently I only have System Idle(sleep) mode working, next will be LowPower Idle (deepSleep) then Suspend (hibernate). Actually Low Power Idle is coded just haven't tested it yet.
    Current wakeup modules are digital, timer and working on compare then rtc.

    Have not measured any current draw yet either so can not really tell what the numbers will be.

  8. #8
    Senior Member
    Join Date
    Feb 2018
    Location
    Corvallis, OR
    Posts
    116
    I ran across the need for speed vs power issue on a logger in about 2005. I needed an ARM chip to do a bunch of cubic spline fits about once per minute. That would take a second or so. The rest of the time I wanted to collect that data with minimum power consumption. The solution I came up with was to use an Atmel ARM chip to do the number crunching and an MSP430 to do the data collection. The Atmel chip had the advantage of totally static internal operations, so you could stop the external clock input and the chip would go into low-power sleep. Start the clock again and the ARM chip took up where it left off. The MSP430 controlled the Atmel external clock generator and provided all the timing signals. It sent data and received results with serial ports at 115KB.

    The T4 has the capability to do much the same thing---but all the hardware is on the same chip. The shutdown process is complicated by the phase-locked loops that generate a lot of the peripheral clocks---and there are a lot more peripherals than on that 2005 ARM chip.

    That historic digression leads to my real point: There are at least two types of 'low power operation:
    There is the type that the snooze library tackles: You want the T4 to go into low-power sleep, then wake up intermittently and do some useful work. (The case I tackled with my 2005 multi-processor system).
    There is the type that Paul M. wants where the Teensy is awake and running at a reduced clock rate with the minimum possible power consumption. This requires some code to shut down the clocks to unused peripherals to eliminate their power drain.

    The best I've done on that is to figure out how to put the SD Card into idle mode between writes at a saving of about 30mA. For most logging operations, I don't need USB, most UARTS, audio, ethernet, the pixel pipeline, PWM, etc. etc. I think, but I'm not sure, that the T4 startup code starts up the clocks to most peripherals, whether they will be used or not. This would seem to be in line with the Arduino philosophy of doing most startup code before getting to the setup() function and having most peripherals ready to go with minimal startup code. This also eliminates the time lag an unlocked peripheral would experience on starting the clock and waiting for a PLL to stabilize.

    I think there is still a lot of work to be done to get the T4.0 to match the low-power continuous operation capability of the T3.6. i've been able to get the T3.6 to log 3 analog channels and a time stamp to SD card at 400 samples per second using less than 10mA average current. To do this, I have to run the T3.6 at 8MHz and make sure to put the SD card into idle mode after each write.

  9. #9
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    1,010
    The T4 has lots of clocks that you have to deal with when trying to lower the RUN mode power draw. For low power modes Low Power Idle (sleep) has the Arm CPU lowered down to 132MHz (arm pll) before shutting down all the PLL's and gating all the peripheral clocks for the myriad of functional blocks like serial, i2c etc except the ones needed for wakeup. The T4 inherits some of the peripherals from the IMX6 and some from the kinetis chips so it's challenge to do all the steps needed to keep the power down. One thing is clear is the change to the application processor design makes the low power sequence much more complicated from the rather easy low power design of the kinetis. There are so many clocks that you can use for each wakeup source it's been a hard to find the right one to use and in the upcoming Snooze T4 beta will probably use not the most power efficient clocks but it's what I had to do to make forward progress. Right now struggling to implement the xbar for the comparator (acmp) to bring out a few channels to top side pins. Might put that on the next beta since it's not a widely used wakeup form anyways.

  10. #10
    Junior Member
    Join Date
    May 2020
    Posts
    3
    Bumping this for Teensy 4.1. I've just got mine and have started exploring how to reduce the power draw while doing something periodically. Here are some numbers (collected via an Odroid Smart Power at 5V, powering via the Teensy's USB port, with sketches compiled with 24 MHz unless otherwise stated):

    - A simple sketch (see below) which uses asm volatile("wfi") in between wakeups via the IntervalTimer to blink an LED draws 213 mW while the LED is off and 225 mW while it is on.
    - The same sketch with asm volatile("wfi") uses 244 mW with the LED off and 255 mW with it on.
    - At 600 MHz, the LED-off power consumption with and without "wfi" are 286 and 480 mW, respectively.
    - At 24 MHz, the Snooze SkeletonDriver example draws about 240 mW while the LED is off and 244 while it is on (although it's perhaps not on long enough to measure this accurately). This is the first time I've used the Snooze library, maybe I'm holding it wrong.
    - For comparison, a similar sketch on a Feather M4 at 120 MHz draws about 68 mW in __WFI(), and 38 mW or less with USB disabled in setup() via a register. The Smart Power craps out below 38 mW so I can't measure lower power draws.

    Code:
    IntervalTimer mytimer;
    
    static volatile unsigned int wake = 0;
    static void increment_wake(void) { wake++; }
    
    void setup() {
      pinMode(LED_BUILTIN, OUTPUT);
      mytimer.begin(increment_wake, 1000000);
    }
    
    void loop() {
      if (!wake) {
        asm volatile("wfi");
        return;
      }  
      wake--;
    
      static char state = 0;
      digitalWrite(LED_BUILTIN, state);
      state = !state;
    }
    Last edited by campbell; 05-17-2020 at 06:15 PM. Reason: simplified code

  11. #11
    Quote Originally Posted by campbell View Post
    Bumping this for Teensy 4.1. I've just got mine and have started exploring how to reduce the power draw while doing something periodically.
    If anybody has numbers already for
    a) using Ethernet (with the OSH adapter) (target rate 1kHz UDP packets)
    b) using USB HID RAW over PJRC Host adapter cable (also 1kHz rate)

    I'd much appreciate it. I saw chip's rated at <70mA and board was measured <105mA but I'm at a loss with respect to impact of USB and Ethernet

    https://github.com/manitou48/DUEZoo/...ster/power.txt
    https://forum.pjrc.com/threads/24341...er-consumption

  12. #12
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,553
    Quote Originally Posted by b2020 View Post
    If anybody has numbers already for
    a) using Ethernet (with the OSH adapter) (target rate 1kHz UDP packets)
    ethernet power numbers here, table and graph

  13. #13
    Senior Member
    Join Date
    Aug 2019
    Location
    southwest USA
    Posts
    114

    T4 deep sleep problem ? limitation ? under td 1.52

    just installed td 1.52 over 1.48. had to delete the "utilities" folder in snooze lib when compiler said cannot use src and utility folder both - utility folder was i guess
    a leftover from 1.48 which did not get removed at install 1.52

    took from the examples folder deepSleep_all_wakeups.ino and removed all lines did not need for a simple test using deep sleep via rtc
    that subset of code is shown below.

    for some reason need to include usb in this line SnoozeBlock config_teensy40(usb, alarm) or it does not function even when plugged
    into PC usb port. stand alone (just power applied to +5 and gnd pins) it does not function even with usb included that line. Will not
    have a PC later in actual application.

    Am I misunderstanding something ? Is there a way for the T4 deepsleep to work stand alone ? I see the comment line about T4 and
    usb but do not understand it. Any help appreciated.


    Code:
    // subset of deepSleep_all_wakeups.ino example in td1.52 snooze lib
    
    #include <DogLcd.h>
    
    /***************************************
      This shows all the wakeups for deepSleep
    
      Supported Micros: T-LC/3.x/4.0
    ****************************************/
    #include <Snooze.h>
    // Load drivers
    SnoozeTimer timer;
    SnoozeUSBSerial usb;
    SnoozeAlarm  alarm;
    
    /***********************************************************
      Teensy 4.0 does not have a Touch Interface. Always use the
      SnoozeUSBSerial Driver.
    
      Teensy 3.6/LC can't use Timer Driver with either Touch or
      Compare Drivers and Touch can't be used with Compare.
    
      Teensy 3.5 does not Touch Interface.
    
      Teensy LC does not have a rtc so Alarm Driver can't be
      used as of yet.
    
      Teensy 3.2 can use any Core Drivers together.
    ***********************************************************/
    SnoozeBlock config_teensy40(usb, alarm);
    
    void setup() {
      pinMode(LED_BUILTIN, OUTPUT);
    
    //    Set RTC alarm wake up in (hours, minutes, seconds).
    
      alarm.setRtcTimer(0, 0, 20);// hour, min, sec
    
    }
    
    void loop() {
      int who;
      /********************************************************
        feed the sleep function its wakeup parameters. Then go
        to deepSleep.
      ********************************************************/
    
      who = Snooze.deepSleep( config_teensy40 );// return module that woke processor
    
      if (who == 35) { // rtc wakeup value
        for (int i = 0; i < 4; i++) {
          digitalWrite(LED_BUILTIN, HIGH);
          delay(200);
          digitalWrite(LED_BUILTIN, LOW);
          delay(200);
        }
      }
    
    }

  14. #14
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,931
    Quote Originally Posted by duff View Post
    Currently I only have System Idle(sleep) mode working, next will be LowPower Idle (deepSleep) then Suspend (hibernate). Actually Low Power Idle is coded just haven't tested it yet.
    Current wakeup modules are digital, timer and working on compare then rtc.

    Have not measured any current draw yet either so can not really tell what the numbers will be.
    Start with System Idle ...

  15. #15
    Senior Member
    Join Date
    Aug 2019
    Location
    southwest USA
    Posts
    114

    T4 deep sleep and sleep resolved

    thank you defragster - used sleep and found the real problem was mine.

    Both (sytem idle) sleep and deepsleep work just fine with just +5 and ground.

    I get the dumb*** of the day award - the usb to bench supply adapter with power only and built in banana jacks to lead to bench
    DVM I built 2-3 years ago and have used 1000 times had a cold solder joint.

    T4 deepsleep = 7.8 ma , sleep = 19.6 ma all done w 5.0 volts, TD1.52, ARD 1.8.5, WIN7pro64, TEENSY 4.0, waking up to rtc,
    numbers seem to be independent of clock speed. I will test hibernate as soon as Duff releases it.

  16. #16
    Senior Member
    Join Date
    Aug 2019
    Location
    southwest USA
    Posts
    114

    T4.0 deep sleep / sleep more data

    here is more data for T4 sleep all done w 5.0 volts, TD 1.52, ARD 1.8.5, WIN7pro64, TEENSY 4.0,
    currents are during snooze, currents seem independent of clock speed

    ---rtc--deepsleep= 9.8 ma---sleep=19.6 ma
    --lptmr-deepsleep=14.4 ma---sleep=24.3 ma

  17. #17
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,931
    Good to see it working! Are those numbers in the expected range?

    USB and SerMon with TD 1.52 working well it seems?

    Win7 ... what a trooper

  18. #18
    Senior Member duff's Avatar
    Join Date
    Jan 2013
    Location
    Las Vegas
    Posts
    1,010
    FYI, 'hibernate' sleep should work it just wakes with a reset. I'm not surprised by those numbers, thanks for posting. Currently I'm doing a huge home automation project so I'm not going to look at Low Power stuff anytime soon but I hope to revisit this to work on better power numbers. @dfragster do you know if the bootloader chip goes into low power mode yet? I never saw anything but I haven't been watching this forum closely lately.

  19. #19
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,931
    Quote Originally Posted by duff View Post
    FYI, 'hibernate' sleep should work it just wakes with a reset. I'm not surprised by those numbers, thanks for posting. Currently I'm doing a huge home automation project so I'm not going to look at Low Power stuff anytime soon but I hope to revisit this to work on better power numbers. @dfragster do you know if the bootloader chip goes into low power mode yet? I never saw anything but I haven't been watching this forum closely lately.
    @duff : Don't recall an update on "Bootloader going low power".

  20. #20
    Senior Member
    Join Date
    Aug 2019
    Location
    southwest USA
    Posts
    114
    Quote Originally Posted by duff View Post
    FYI, 'hibernate' sleep should work it just wakes with a reset. I'm not surprised by those numbers, thanks for posting. Currently I'm doing a huge home automation project so I'm not going to look at Low Power stuff anytime soon but I hope to revisit this to work on better power numbers. @dfragster do you know if the bootloader chip goes into low power mode yet? I never saw anything but I haven't been watching this forum closely lately.
    Is that to say that hib only wakes with a reset and not any timers? I can measure the hib current.
    Good luck w home automation.

  21. #21
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,931
    Quote Originally Posted by analog&RFmodels View Post
    Is that to say that hib only wakes with a reset and not any timers? I can measure the hib current.
    Good luck w home automation.
    Yes, good luck with automation @duff.

    @analog&RFmodels - there is a timed sleep method - it is good power down - but wakes going through reset/setup(). Not sure how that relates to snooze - but it was looked at when T_4 restart was failing.

  22. #22
    Senior Member
    Join Date
    Aug 2019
    Location
    southwest USA
    Posts
    114

    T4 snooze data including hibernate

    ---rtc--deepsleep= 9.8 ma---sleep=19.6 ma
    --lptmr-deepsleep=14.4 ma---sleep=24.3 ma

    hibernate with all references to timers and timer drivers turned off is 11.8 ma
    if i use code that was deepsleep waking from rtc and just replace
    who = Snooze.deepSleep with who = Snooze.hibernate drops to 7.4 ma

    all done w 5.0 volts, TD 1.52, ARD 1.8.5, WIN7pro64, TEENSY 4.0,
    currents are during snooze, currents seem independent of clock speed

  23. #23
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,931
    Here is the thread and a post where hibernate through a timed sleep was abused as a reset shortcut when it wasn't working.

    issue-to-reporogram-T4-0

    Time has to be given of at least 2 seconds - but larger should work as specified. T_4.x should power down except RTC unit that will wake through startup/setup().

  24. #24
    Senior Member
    Join Date
    Oct 2019
    Posts
    134
    Hi duff

    Was wondering if the Snooze library supports wake up from CAN bus frame or a wake up signal?
    I didn't see any mention of it on the Github readme.

    Also, is there any listing current draw for the T4/4.1 in the different sleep modes? I need power consumption to be as low as possible when in sleep mode (uA is the goal).

  25. #25
    Senior Member
    Join Date
    Aug 2019
    Location
    southwest USA
    Posts
    114
    Quote Originally Posted by Rezo View Post
    Hi duff

    Was wondering if the Snooze library supports wake up from CAN bus frame or a wake up signal?
    I didn't see any mention of it on the Github readme.

    Also, is there any listing current draw for the T4/4.1 in the different sleep modes? I need power consumption to be as low as possible when in sleep mode (uA is the goal).
    please look three posts up for all of those currents. if you can stand a cold start every time, see the link two posts up.
    i have used the cold start method w rtc on T4 and average "sleep" current is 220 ua. if you need lower than that and
    can stand a cold start you could use TLC and it's 5v output pin to drive a low threshold p channel mosfet of appropriate
    ron to power T4 when desired. good news is that during TLC hibernate it will only draw 11-14 ua and the "off" T4 will
    only draw maybe 1 ua due to mosfet off leakage. TLC hib time is controlled by lptmr so be prepared to put some tweak
    to it to get exact times.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •