cancel
Showing results for 
Search instead for 
Did you mean: 

Power Consumption Measurement

thetectivestm
Associate III

Hello everyone,

I need to get some information about the power consumption of the STM32 Nucleo-64 with STM32F401RE MCU.
The board is powered from the computer's USB port.

The board has a IDD jumper (JP6) for MCU current measurement so I attached a Parkside multimeter to get the current.

I created a project in which the main while loop is empty and all peripherals are disabled. In this case, the current shown on the display of the multimeter is fixed.

If I modify the project and I use the timer interrupts to acquire data from the sensors, the current shown is fixed. 

If I create another project without interrupts but acquiring data from the sensors in the main while loop, the current shown is fixed. If I add some "printf" (using USART2 and PuTTY) to show these data, the current is variable. 

If I create a project in which I execute some inferences of a neural network, the current is variable.
Why do I have a fixed value of the current on the display in some cases and a variable value in other cases?

 

Could anyone please help me?

17 REPLIES 17

(My idea would be same... @Andrew Neil  , you just been faster to write it.)

+

If low power here is worth something, use a more recent fast + low power cpu, maybe L series , stm32L431 (M4 core + FPU ) needs about 10mA at 80MHz , so 50ms/2s -> 1/40 -> 0.25 mA average and 50ms fast response to your calculation.

+

 @thetectivestm you can use your simple DMM , just put a big cap in parallel to the DMM, maybe 2200uF , to get a good average reading , if average is all you want to see.

If you feel a post has answered your question, please click "Accept as Solution".

@Andrew Neil , @AScha.3  Thank you for your replies.

For my task the target platform is the abovementioned board.

Running my application with a HCLK frequency of 84 MHz,  the current shown on the display of the multimeter varies within the range [6.7 mA ; 15.9 mA] (an average value in 5 seconds is 8.9 mA). To enter in sleep mode, I use:

"

HAL_SuspendTick();

HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);

 "

And in the HAL_TIM_PeriodElapsedCallback I use the HAL_ResumeTick() function.

In this way, when a timer interrupt gets triggered (each 31250 µs because the frequency is 32 Hz), the device will wakeup.

So, I have a lower current consumption at 4 MHz... 

 


@thetectivestm wrote:

Running my application with a HCLK frequency of 84 MHz,  the current shown on the display of the multimeter varies within the range [6.7 mA ; 15.9 mA] (an average value in 5 seconds is 8.9 mA). .. 


But the point is that it only takes that much current for a tiny fraction of the time (50ms).

By putting it to sleep for the rest of the time (1950ms), you end up with a lower overall energy consumption.

50ms awake in a 2s total cycle means that it is only awake & running at 84MHz for 2.5% of the time - it is asleep for 97.5% of the time!

I understand that the device is asleep for a longer time with HCLK at 84 MHz.

But, as I read on the multimeter, a 4 MHz clock requires less current to maintain the sleep state (0.9 mA vs 6 mA at 84 MHz).

My application continues to collect data at 32 Hz even during the inference. With equal time (es. 10 seconds), the device executes the same number of inference: the inference at 84 MHz is faster but the remaining time (1950 ms) is wasted. 

Considering a single inference without collecting other data for the next one, ending the task earlier at 84 MHz, the consumption is lower. But, if I run 1000 inferences the total consumption is lower at 4 MHz (execution_time = 2 seconds * 1000 + last_inference_time).

Do you agree?

 

@thetectivestm wrote:

But, as I read on the multimeter, a 4 MHz clock requires less current to maintain the sleep state (0.9 mA vs 6 mA at 84 MHz).


So don't run the 84MHz clock while it's asleep!

 


@thetectivestm wrote:

My application continues to collect data at 32 Hz even during the inference.


There's probably plenty of time for the processor to sleep between those acquisitions: 32Hz = 31ms between samples...

Or, as @AScha.3 suggested, a more recent low-power processor would have better facilities for acquiring data while the CPU sleeps ...

 


@thetectivestm wrote:

Considering a single inference without collecting other data for the next one, ending the task earlier at 84 MHz, the consumption is lower. But, if I run 1000 inferences the total consumption is lower at 4 MHz (execution_time = 2 seconds * 1000 + last_inference_time).

Do you agree?


I don't get what you're trying to say there. 

Again, with something like the X-NUCLEO-LPM01A or STLINK-V3PWR you would be able to see exactly what's going on, and measure the actual energy consumption in the different scenarios.

@Andrew Neil wrote:
So don't run the 84MHz clock while it's asleep!

But I've read in SLEEP mode only FPU core (CPU clock) is stopped (the CPU CLK is SYSCLK / HCLK, isn't it?), peripherals keep running. When I enter in SLEEP mode, the timer will not be stopped. APB1, APB2 clocks (used for peripherals, including timers) are still running. 

When the processor sleeps (between the acquisitions each 31ms) the current consumption increases proportionally to the HCLK frequency (see table below). So the current consumption at 4 MHz is lower than the consumption at 84 MHz.

 

sleep_clocks.JPG

 

@Andrew Neil wrote:
I don't get what you're trying to say there. 

 

If I execute 1000 inferences of the NN, I can calculate the execution time of the application in this way:

execution_time = 2 seconds * 1000 + last_inference_time, because I collect data every 2 seconds from the sensors. Since I need to run 1000 inference, the time spent on acquisition is 2 * 1000. Since the inference is performed during the acquisition, it doesn't add further time. Only the last inference add time (1200 ms at 4 MHz or 50 ms at 84 MHz) because I don't collect data for the next inference (there is no 1001st inference).

So, the execution time is slightly lower at 84 MHz because the last_inference_time is lower. But it might be more convenient to use 4 MHz because the current consumption is lower at this frequency.

----

P.S.: In STOP mode all clocks are stopped but also timers are stopped so I don't need to use this mode. 


@thetectivestm wrote:

But I've read in SLEEP mode only FPU core (CPU clock) is stopped (the CPU CLK is SYSCLK / HCLK, isn't it?), peripherals keep running.  . 


You control whether the other clocks & peripherals continue or not.

 

Some resources:

Application note AN4777, How to optimize power consumption on STM32 MCUs:

https://www.st.com/resource/en/application_note/an4777-how-to-optimize-power-consumption-on-stm32-mcus-stmicroelectronics.pdf

 

Getting started with PWR - stm32mcu - ST wiki:

https://wiki.st.com/stm32mcu/wiki/Getting_started_with_PWR 

 

Introduction to STM32L0 - 3 Low Power Modes:

https://www.youtube.com/watch?v=ZIp05wYYuOs

 

STM32L4 training: 03.3 Standard peripherals - Power Controller (PWR):

https://www.youtube.com/watch?v=GOc7vPEXVqs&list=PLnMKNibPkDnEEvQWrDqVuu1w_iQ214GXi&index=14 

Andrew Neil
Evangelist III

Another good way to save power is to choose sensors which can acquire data autonomously, and buffer it.

Thus the processor doesn't have to wake up for every single measurement - it only has to read out a "burst" of data from the buffer when it needs it (once every 2s, in your case).