Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Teensy 4.0 power button and brown-out detection?

  1. #1
    Junior Member
    Join Date
    Sep 2019
    Posts
    18

    Teensy 4.0 power button and brown-out detection?

    Hi,

    The onboard 3.3v regulator for the teensy 4.0 seems to be quite sensitive to spike overload current, so much so that i needed a standalone regulator for a project using a particularly power-hungry OLED display.

    Is there any way to detect brown-out on the Teensy? i was getting some deeply weird results when drawing too much power with random resets, repeated hard faults, etc, and i'd like to be able to detect it and report for debugging purposes, and possibly for some logic like reducing the CPU frequency to a minimum to carry out some emergency flash/eeprom writes before the power fully goes.

    For another project, I want to use the teensy battery-powered, with the power button.

    The other question i have is whether there is any elegant way to use the teensy power button as a normal button input whilst retaining the power off functionality. Paralleling another pin on the teensy and digitalRead doesn't work because the power pin seems to get stuck in pulldown state on powerdown rather than hi-Z, making it impossible to power up again.

    Also, the power button interrupts the main logic flow. I assume there is no way to continue processing while the button is pushed expect from an IntervalTimer call (which means I need to make most of my application reentrant, or at least rewrite my current cooperative multitasking logic). Reading the power pin from the main loop also seems to upset the IntervalTimer used by tone(), even though it is only reading one register(not that this is useful, as the main loop gets suspended if the power button is pushed anyway).

    I was hoping to implement a kind of time based logic.

    Short press (<5s) normal push button functionality.
    Long press (>5s<15s) controlled powerdown.
    Really long press (>15s) emergency (hard) powerdown.

    I don't really want to add a separate power button to my project, although that is my backup option. I also need to be able to lock out the power button(except for emergency power down), which seems to be possible with the power button library.

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,750
    Are p#1 last words referring to this library: github.com/FrankBoesing/T4_PowerButton

    That seems to allow much of what is noted - act immediately or ignore that signal for power down. It exposes much of what is possible - if other features are needed it would be in the manual if possible. It seems the power button _isr() could set a flag and put off the power down and then normal loop() code could monitor the flag and act accordingly perhaps either treat it as a button and continue, or set a second flag that the next press should instead power down in the _isr().

    Of course the only 'Button' "ON" a Teensy is the program Button - any other button could be anywhere.

    Not clear what OLED is in use - display can be demanding on power. Teensy can only expect 5V and 500ma from USB - and choice of regulator has to fit without creating too much heat and wasting too much power beyond supplying its own needed power and enough to interface to other elements that can live with that power budget, or have alternate power as needed.

  3. #3
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    387
    If you need more short-term power output, add capacitance.

  4. #4
    Senior Member
    Join Date
    Aug 2019
    Location
    southwest USA
    Posts
    110
    jonr is right - but if you have a scope check for oscillation on the regulator output after you add the
    cap - many low drop out regulators are sensitive to Cl and the esr of Cl ala they become unstable.
    if you have the part number get the datasheet - they normally describe the envelope of stability
    on a 2D graph - often esr one axis and C other axis, or they may just have in the spec table some
    drop dead values.

  5. #5
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    387
    I checked and you will be fine up to 200uf. Best to put it close to the load.

  6. #6
    Junior Member
    Join Date
    Sep 2019
    Posts
    18
    Quote Originally Posted by jonr View Post
    I checked and you will be fine up to 200uf. Best to put it close to the load.
    Tried extra capacitance- it's not a spike value- it's the overall draw being over 250mA when most of the display is lit (i.e more than 150mA for the display). I just put the display on a separate 3.3v regulator.

    I've has success with the T4_PowerButton library. It basically does what I need but I have to do some slightly convoluted set-up to get the button push into my application (like triggering an IntervalTimer that simulates a button press in a volatile bool variable read by the main application loop).

    Still wondering if the IMXRT1062 has a brown-out interrupt, though.

  7. #7
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    387
    > Still wondering if the IMXRT1062 has a brown-out interrupt, though.

    It has analog comparators which could be used to detect any voltage level. Could compare divided supply voltage to a voltage reference.

Posting Permissions

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