Any updates on low power API for pyboard? (Is it OK to power pyboard with regulated 3.3v to the 3.3v pin, and no power at Vin or USB?)On 3/12 Damien says: Low power sleep modes are almost there... it just needs a decision on the API that the user sees, and some tidying up. The pyboard will do down to about 400uA in suspend mode where it can wake and continue where it left off.
low power support?
low power support?
Re: low power support?
It's in the very latest firmware image, so if you upgrade then you can get this functionality.manitou wrote: Any updates on low power API for pyboard? (Is it OK to power pyboard with regulated 3.3v to the 3.3v pin, and no power at Vin or USB?)
pyb.stop() will enter low power mode. Upon waking execution continues from where it left off.
To wake, any external interrupt on a pin (see ExtInt class) will do it. Also there is a RTC wakeup feature that wakes the chip at regular intervals; example:
Code: Select all
import pyb
rtc = pyb.RTC()
rtc.wakeup(2000) # wakeup every 2000 ms (2 seconds)
while True:
do_some_processing()
pyb.stop()
Re: low power support?
I've done a very quick test of the hardware to see if this is possible and it seems yes, it is possible.manitou wrote:Is it OK to power pyboard with regulated 3.3v to the 3.3v pin, and no power at Vin or USB?
I tried tying VIN to 3V3, and powering 3V3 by a 3.3v regulated source and it works. I also tried leaving VIN floating and it works. In both cases the current consumption was around 450uA in the pyb.stop() mode. (Of course, you can't power by USB with this configuration of power!)
One other thing, to get low power you need to disable USB. In boot.py put:
Code: Select all
pyb.usb_mode(None)
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: low power support?
Could you not do this with a 1-byte file? At the start you'd read the byte, then write 0, writing 1 before executing the standby(). If the program had terminated normally or been reset (hardware or software) you'd read 0, but after a standby you'd read 1.there's currently no way to tell if the MCU was reset first time or from waking from pyb.standby().
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: low power support?
Actually I found a way to do it: use the RTC backup registers. Eg:pythoncoder wrote:Could you not do this with a 1-byte file? At the start you'd read the byte, then write 0, writing 1 before executing the standby(). If the program had terminated normally or been reset (hardware or software) you'd read 0, but after a standby you'd read 1.there's currently no way to tell if the MCU was reset first time or from waking from pyb.standby().
Code: Select all
import stm
if stm.mem32[stm.RTC + stm.RTC_BKP1R] == 0:
# first boot
else:
# got out of standby mode
stm.mem32[stm.RTC + stm.RTC_BKP1R] = 1 # indicate that we are going into standby mode
pyb.standby() # we reset when woken
Re: low power support?
Here are results (milliamps from a DMM) for my pyboard low power tests.
The little test program can be configured for various power tests including disabling some of the IO
https://github.com/manitou48/pyboard/bl ... owpower.py
Data sheet for the chip suggests at 168MHz from flash and peripherals enabled power is 93ma, with no IO 46ma. Sleep mode 59 ma or 12ma. Stop mode 0.45 ma. Standby mode 3 ua.
Note, pyb.delay() uses wfi which lowers power during delay.
Code: Select all
Config clock 168Mhz 84 42 24 8
USB power
spin-loop 65ma 37 23 16 11 ma
some IO off 54ma 30
sleep/wfi 26 18 13 ma
some IO off 15ma 10
3.3v power
spin-loop 61ma
some IO off 52ma 29
sleep/wfi 24 16 13
some IO off 14ma 9 6 5 4 ma
stop 2.6ma (1.4ma at 3.3v)
standby 29ua (FLASH) 0.18ma (SD)
https://github.com/manitou48/pyboard/bl ... owpower.py
Data sheet for the chip suggests at 168MHz from flash and peripherals enabled power is 93ma, with no IO 46ma. Sleep mode 59 ma or 12ma. Stop mode 0.45 ma. Standby mode 3 ua.
Note, pyb.delay() uses wfi which lowers power during delay.
Last edited by manitou on Wed Apr 29, 2015 9:04 pm, edited 1 time in total.
Re: low power support?
I managed to get the pyboard down to around 300uA in stop mode and 30uA in standby mode using this script:
https://gist.github.com/dpgeorge/bf477eb883b6d189eae9
The 30uA in standby mode is as low as it'll go because it's limited by the quiescent current of the LDO (which is 25uA).
https://gist.github.com/dpgeorge/bf477eb883b6d189eae9
The 30uA in standby mode is as low as it'll go because it's limited by the quiescent current of the LDO (which is 25uA).
Re: low power support?
Is there any way to reduce the amount of time and/or current required to come out of pyb.standby()? I ran a do-nothing program to determine how much current (actually, charge) is consumed during the bootup after pyb.standby():
Here is the time pattern of current consumption during the boot-up:
If you need to wake up every 15 seconds to do something, this startup cost is pretty large. Its contribution to the average current consumption would be:
(63 mA * 0.125 s + 21 mA * 0.055 s) / 15 s = 0.602 mA, or 602 uA.
This dwarfs the very nice 32 uA sleep current. During the boot up, I see the green LED blink. Is there a way to stop that? Is that significantly lengthening the startup time? Any other ideas on how to make this more efficient?
Code: Select all
import pyb
rtc = pyb.RTC()
rtc.wakeup(2000)
pyb.standby()
If you need to wake up every 15 seconds to do something, this startup cost is pretty large. Its contribution to the average current consumption would be:
(63 mA * 0.125 s + 21 mA * 0.055 s) / 15 s = 0.602 mA, or 602 uA.
This dwarfs the very nice 32 uA sleep current. During the boot up, I see the green LED blink. Is there a way to stop that? Is that significantly lengthening the startup time? Any other ideas on how to make this more efficient?
Last edited by moose on Sat Nov 07, 2015 7:13 pm, edited 1 time in total.
Re: low power support?
During a normal boot, the green LED is turned on here:
https://github.com/micropython/micropyt ... ain.c#L317
and turned off here:
https://github.com/micropython/micropyt ... ain.c#L470
So that adds virtually no delay. I think you'd need to profile the boot to see where the time is being spent.
I'm going to guess that initializing the file system is a big chunk of it.
https://github.com/micropython/micropyt ... ain.c#L317
and turned off here:
https://github.com/micropython/micropyt ... ain.c#L470
So that adds virtually no delay. I think you'd need to profile the boot to see where the time is being spent.
I'm going to guess that initializing the file system is a big chunk of it.
Re: low power support?
@moose what did you use to measure/plot current?moose wrote:Is there any way to reduce the amount of time and/or current required to come out of pyb.standby()? I ran a do-nothing program to determine how much current (actually, charge) is consumed during the bootup after pyb.standby():