- Notifications
You must be signed in to change notification settings - Fork522
Power-saving possibilities using the arduino-pico core#1544
-
Hi, I know that sleep and dormant modes are not supported in this core and I don't want to talk about that here. There are more than enough threads on that by now. What I'm interested in is, what possibilities are there to save power using this core as it standsright now? Something like, disabling peripherals, not using the second core, downclocking the Pico as much as possible, etc. I know there are things like Feel free to delete this question if you had enough talking about that lol |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 6 comments 23 replies
-
Just to be clear, I'm not opposed to adding sleep stuff to the core. I just don't have the equipment to do any testing so wouldn't know if it was doing anything or not. So, if someone wants to submit the deep sleep stuff as a PR, I'd be a happy camper. :) FWIW the most important thing is not to start things you don't need. For example, once an There's also lots of interesting goodies in the RP2040 datasheet (not the SDK). You can power down individual SRAM banks, for example. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 4
-
Thanks for your input! |
BetaWas this translation helpful?Give feedback.
All reactions
-
Another easy way to reduce consumption, what I found out today, is to reduce the core voltage. I'm using the Pico at 50 MHz and can go as low as 0.90V and it saves me about 2mA compared to stock, which is pretty sweet. I'm using the Pico SDK's |
BetaWas this translation helpful?Give feedback.
All reactions
-
50MHz will cause it freeze when using 2 cores. Not test for 1 core codes. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Random kinda-off-topic thing I just noticed: I think clk_adc runs even without doing any analogRead(). Serial.begin();while (!Serial) {};delay(1000); Serial.println(clock_get_hz(clk_adc)); Serial.print("frequency_count_khz(CLOCKS_FC0_SRC_VALUE_CLK_ADC):"); Serial.println(frequency_count_khz(CLOCKS_FC0_SRC_VALUE_CLK_ADC));clock_stop(clk_adc); Serial.println(clock_get_hz(clk_adc)); Serial.print("frequency_count_khz(CLOCKS_FC0_SRC_VALUE_CLK_ADC):"); Serial.println(frequency_count_khz(CLOCKS_FC0_SRC_VALUE_CLK_ADC)); output: |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Works for me, even down to about 20 MHz. Although, at this point the USB connection drops out, but the Pico still works otherwise. With 50 MHz, even the serial USB connections works like normal for me.
Interesting! 👍🏻 |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
It is not a big deal to isolate few files from Pico-SDK (pico-extra) and build an Arduino library for RP2040 'dormant' mode like I did: then I can use the library as follows: However, the RP2040 does not look like a very power efficient SoC.
|
BetaWas this translation helpful?Give feedback.
All reactions
-
I see, but does this compile with the current core? Because AFAIK you have to build some extra dependencies into to core to get it to run. |
BetaWas this translation helpful?Give feedback.
All reactions
-
@lyusupov I use your code and run like this: Then the output stuck at "start sleep.", and never back from sleep... Any clue? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Just add a libray.json to it and add symlink to the dir will works in platformio. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Does this make sense for you ? - |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
FWIW, I have been trying various things in my sleep code to whittle down power consumption. I don't have dormant mode working yet, which ought to be the best possibility. But I did figure out that slowing the system clock before sleep is a huge win for power consumption in my fw. Right before sleep it goes to 18mhz:
And then returns to 133mhz on wakeup:
(It might be possible to go slower than 18mhz, but some lower values caused hangs/crashes so I stopped tuning it there.) I also pause PWM & DMA usage, and of course power down peripherals and LEDs and such. I haven't tried powering off the flash yet, but that's next. ATM, power consumption during sleep is 8ma . I also tried dormant mode, but I found that some interrupt kept waking it up prematurely. (If I call Or maybe it's a USB thing; I hadn't tried |
BetaWas this translation helpful?Give feedback.
All reactions
-
Which header files have to be included for using set_sys_clock_khz()? |
BetaWas this translation helpful?Give feedback.
All reactions
-
You only need |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Yesterday I managed to whittle the sleep consumption even lower, from 8ma down to 3ma. • I got the most improvement by halting the USB PLL during sleep and restarting it on wakeup. This drives the other main clock besides clock_sys. So far, this seems reliable, and it saved about 4ma. to sleep: to wake: • I'm pretty sure I'm not allowed to drop the sys_clk speed any lower than 18mhz with my 12mhz xtal, but I did turn the RPI's internal voltage regulator from 1.1v down to 0.9v during sleep, which saved maybe another 0.5ma. (This is done after slowing the system clock.) to sleep: to wake: • Putting my flash chip into power-down mode seems to save a tiny scrap of power; datasheet says 0.1-0.5ma . YMMV. Consult your flash chip datasheet and the sdk doc for With this, current consumption during sleep is down to 0.003A on my ammeter. I still haven't tried powering down SRAM. I'm not sure how to power down only the SRAM that I'm not using. Also I'm not sure how to estimate the potential power savings. But I'd love to hear about anybody else's experiments with that! |
BetaWas this translation helpful?Give feedback.
All reactions
👍 4
-
Sure, here is the relevant code section. It's all the tricks described above. Note that I get to 3ma sleep onmy custom board, the Pocket Integrator, which runs at 1.8v when awake. Other boards have other parts, drains, needs, etc. (Also, my ammeter is something I got cheap off of Amazon. It says 3ma, but I've never actually calibrated it.) |
BetaWas this translation helpful?Give feedback.
All reactions
👍 3
-
@myklemykle that's some nice work. Do you think it would make sense to include it in the core somehow? Also, just in general, if you're disabling the flash clocks then you're also going to need to move the code into RAM (i.e. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1❤️ 1
-
I'd be happy to contribute this to core in some format. However the way I'm doing the actual sleeping in the middle of this function -- sleeping until one of N pins is active -- might not be what most people need. So I'm not sure what options to put there instead. As for the flash thing ... I agree that makes sense, but OTOH I never did move the sleep function into RAM and it still works. Perhaps the entire function is loaded into the XIP cache before it runs? |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Also I have to admit that the sleep/wake of USB does not seem to me to be 100% solid. In my testing, if I sleep/wake USB more than 4 or 5 times in quick succession (like within a minute), the host OS (MacOS 11.7 in this case) seems to get grumpy and reject the device until it's unplugged/replugged. I'm not sure if this is an actual fault on the Pico side of if it's something caused by whatever Serial.end() and tusb_init() say to the host if you call them over and over. I'm not even sure that calling tusb_init() multiple times is supported by TinyUSB. So the USB sleep might want to be controlled by an option flag. |
BetaWas this translation helpful?Give feedback.
All reactions
-
The XIP cache wouldn't know what a function looks like, but it might have a large enough cache line/prefetch to keep things running in most cases with this code. I wouldn't like to count on that, though...a slightly different placement of the function might end up not making it into XIP before turning off the flash. Real pain in the butt to diagnose in the field after an OTA! |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Hi, I have added a few things to achieve a functionality similar to the ESP32's deep sleep mode: The example also addresses time-keeping using the integrated RTC. Cheers, |
BetaWas this translation helpful?Give feedback.
All reactions
-
@dlee99 Did it work? |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Yes, it did. Although I'm only getting down to 12mA, which could be from the previous power issues discussed before in this post and other posts or because I am using the Adafruit Feather rp2040 which may have other peripherals that are using power even when the RP2040 sleeps.
Also, I ended up not use your library you made. But it is a great reference to see how it's implemented on the arduino-pico core. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Did you try any of the options suggested in#1544 (comment)? |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Yes, I tried and only got 1mA difference. From 13mA to 12mA on my multimeter. This is what I have in place before I put the controller to sleep.
Interesting, nevertheless. |
BetaWas this translation helpful?Give feedback.
All reactions
-
@dlee99 I guess the MCP73931/2 LiPoly charger and the NeoPixel could be the extra current consumers on that board. But the NP is supposed to be only about 1ma at idle, and the charger is supposed to be less than that. |
BetaWas this translation helpful?Give feedback.