STM32F103C8T6 extreme low power consumption (frequency, periphery)

If you made your own board, post here, unless you built a Maple or Maple mini clone etc
marti159
Posts: 2
Joined: Wed Jun 08, 2016 3:02 pm

STM32F103C8T6 extreme low power consumption (frequency, periphery)

Postby marti159 » Wed Jun 08, 2016 3:13 pm

Hi I need to make STM32F103C8T6-based device which run on 2x AA battery (3V).
Device will be counting pulses on digital input pin (about 1-10 pulses each minute).
Device will send status each minute over 443MHz radio:
Image

I need *maximum* possible battery life.

STM32F103C8T6 will sleep all time. Pulse input will be on interrupt pin and wake up stm. After that stm go to sleep again.

Arduino ATmega328 has in datasheet:

Code: Select all

Power Consumption at 1MHz, 1.8V, 25°C
̶ Active Mode: 0.2mA
̶ Power-down Mode: 0.1µA
̶ Power-save Mode: 0.75µA (Including 32kHz RTC)

How is it on STM32F103C8T6? Lower frequency = lower power consumption?

How can I decrease frequency? Now I have blue pill with 8.0MHz crystal and ticks at 72MHz. Is possible to set frequency to for example 2 or 8 MHz instead of 72MHz? Can I use 8MHz crystal an reduce frequency in software like fuses on Atmel AVR? Is there any minimal frequency?

Is possible to disable peripheries like UART, I2C, ... to decrease power consumption?

I found only:

Code: Select all

#define CYCLES_PER_MICROSECOND    72
#define SYSTICK_RELOAD_VAL     (F_CPU/1000) - 1 /* takes a cycle to reload */

at file STM32F1/variants/generic_stm32f103c/board/board.h

Thank you for help and sorry for my bad English.

User avatar
mrburnette
Posts: 1779
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: STM32F103C8T6 extreme low power consumption (frequency, periphery)

Postby mrburnette » Wed Jun 08, 2016 3:23 pm

Please read this post: http://www.stm32duino.com/viewtopic.php?t=298


In addition, grab the STM32 Reference Manual - use Google to search for it. Read about the power domains in the chip. There are also Application Notes about power savings by chip architecture - again use Google.

Ray

User avatar
RogerClark
Posts: 5596
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: STM32F103C8T6 extreme low power consumption (frequency, periphery)

Postby RogerClark » Wed Jun 08, 2016 9:30 pm

Like Ray says..

You will need to read the manual for the chip.

You can change the PLL multiplier, to a lower value, but I dont know off the top of my head what the lowest multipler is.

There is also a 2 x prescaler on the clock, so I suspect the minimum frequency would may be 8Mhz / 2, assuming there is a x1 Pll multiplier setting ( you need to check the manual)

But if you change the master clock freq, all the timings in the core will be wrecked.
e.g. UART timings will be wrong, Systick e.g. millis will be wrong, delay() will be wrong etc etc

User avatar
ahull
Posts: 1470
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: STM32F103C8T6 extreme low power consumption (frequency, periphery)

Postby ahull » Wed Jun 08, 2016 11:38 pm

marti159 wrote:How is it on STM32F103C8T6? Lower frequency = lower power consumption?

How can I decrease frequency? Now I have blue pill with 8.0MHz crystal and ticks at 72MHz. Is possible to set frequency to for example 2 or 8 MHz instead of 72MHz? Can I use 8MHz crystal an reduce frequency in software like fuses on Atmel AVR? Is there any minimal frequency?

Be aware that lowering the clock frequency may not save as much power as you might think. The reason for this is that if you perform a particular task at regular intervals, then performing that task quickly and then sleeping may use the same amount of energy as performing the task slowly and then sleeping. In fact, in many cases you actually perform things more efficiently if you run the processor faster and sleep longer, as you then have the advantage of leaving peripherals and external circuitry (your radio for example) on for shorter periods than you would if you performed the task slowly.

You will need to think carefully about this, and it may only be by experimentation that you determine the best regime for maximum battery life for your particular use case.

... Is there any minimal frequency? ...

In theory you can run from the 32kHz watch crystal if fitted, or the internal 32kHz R/C source.

These may be too slow to allow you to transmit your data however.

I suspect that with care, you can run the blue pill at 72MHz, and, if only waking up for a few mS every event, and with events only occurring up to 10 times per minute, I would suggest that a relatively modest battery will last almost as long as its self discharge rate, i.e. several years.

In my experiments, I managed to get results that suggested a single 18650 LiPo (around 2000mAh) would last for several years, so long as the STM32F103 completed its task quickly and therefore slept as much as possible. As it happens, the on board power LED was consuming a significant amount of power in my experiments, and removing it would be a serious suggestion, assuming your soldering fu is up to the task.

You may find my Sunrise and Sunset timer project of interest as it also contains some insights into the use of the low power modes of the STM
http://www.stm32duino.com/viewtopic.php?f=19&t=380
- Andy Hull -

User avatar
zoomx
Posts: 379
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: STM32F103C8T6 extreme low power consumption (frequency, periphery)

Postby zoomx » Thu Jun 09, 2016 7:27 am

I am not sure but I read that a short fast burst and longer sleep is not better for batteries. It seems that batteries (maybe not all type of batteries) prefer to have a bit longer operations but at a lower mA that a short burst at high mA.

But I never made an experiment nor I read about a similar experiment. Maybe it is only an opinion.

@marti159
usually boards are not designed for low power operation and you must design your board or you have to modify common boards. The only low power boards that I saw are the TI Launchpad (various models) and some specialised Arduino board.

marti159
Posts: 2
Joined: Wed Jun 08, 2016 3:02 pm

Re: STM32F103C8T6 extreme low power consumption (frequency, periphery)

Postby marti159 » Thu Jun 09, 2016 8:07 am

I found STM32CubeMX software, that can calculate power consumption with enabled peripheries. Screenshots of stm32cubemx.

If I generate some C code in STM32CubeMX how can I use it in "Arduino STM32"?

At this topis in this forum is Arduino code with STM C:

Code: Select all

#include <stdint.h>
#include <libmaple/pwr.h>
#include <libmaple/scb.h>

#define BOARD_LED_PIN 33
#define BOARD_BUTTON_PIN 32
#define BUTTON_DEBOUNCE_DELAY 1

// These are possibly defined somewhere but I couldn't find them. System Control Register
#define SCB_SCR_SLEEPDEEP 4       // Controls deepsleep(1) or sleep(0)
#define SCB_SCR_SLEEPONEXIT 2     // Controls sleeponexit (not used here)

volatile bool ledState = LOW;    // Used in ISR blinkState()

/...

void loop()
{
  //SerialUSB.println("HI!");  delay(100);    // Only works on first iteration, before stop mode

  // Clear PDDS and LPDS bits
  PWR_BASE->CR &= PWR_CR_LPDS | PWR_CR_PDDS;

  // set sleepdeep in the system control register
  SCB_BASE->SCR |= SCB_SCR_SLEEPDEEP;

  // Now go into stop mode, wake up on interrupt
  asm("    wfi");

  digitalWrite(BOARD_LED_PIN, ledState);
  togglePin(3);

}

Is possbile to use STM C in Arduino code? How? Is there any rules?

Is there any language reference for "arduino stm" as for "arduino avr"?

User avatar
mrburnette
Posts: 1779
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: STM32F103C8T6 extreme low power consumption (frequency, periphery)

Postby mrburnette » Thu Jun 09, 2016 11:52 am

zoomx wrote:I am not sure but I read that a short fast burst and longer sleep is not better for batteries. It seems that batteries (maybe not all type of batteries) prefer to have a bit longer operations but at a lower mA that a short burst at high mA.
<...>


I suspect that the internal Z of the battery and the chemistry would determine the best methodology - but, using a supercap essentially changes the equation significantly. A fully charged supercap across a new battery provides the ability to maintain low Z while essentially neglecting the internal Z of the battery; assuming the power consumption pulse is shorter than the RC constant of the battery + supercap.

The old 'mercury button cells' had long life but were rated only for a minuscule current draw. Replacement alkaline and silver (primary) chemistry have very different discharge curves.

Image


Ray

User avatar
ahull
Posts: 1470
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: STM32F103C8T6 extreme low power consumption (frequency, periphery)

Postby ahull » Fri Jun 10, 2016 9:59 am

There is a lot of good information regarding battery life and microcontrollers, but there is also quite a lot of dross (advertising for the latest fantoosh version of the big boy silicon players latest iteration of their take on low power microcontrollers using their in house magic sauce mainly).

This might whet your appetite, however for most small projects, it is fairly easy to set up your multimeter to watch the current being fed to the board(s) and get a reasonable ball park figure.
- Andy Hull -

keypunch
Posts: 38
Joined: Tue Aug 02, 2016 2:26 am

Re: STM32F103C8T6 extreme low power consumption (frequency, periphery)

Postby keypunch » Fri Apr 07, 2017 7:28 am

Interesting, insightful, thought/comments, and points for this thread of discussion.

What I am tring to find at moment is what sort of cable, jig or such one uses to measure the current and voltage? I have a sense a jig is what is likely needed. I suspect there are as many different ways to design a jig as are projects.

I am still trying to find out if makes sense to connect a battery to a pin directly or power via the USB. Many have commented the voltage regulators of many MCUs have low insertion related losses. So far the research reading I have done on this seems to have some mixed opinions. This would suggest to me additional tests to find out the current/battery profiles the MCU has in context of the complete solution. Perhaps compare direct vs via the regulator vs the pros/cons of.

I tend to find out the real world results and have the data for. Using the datasheets and prior research/projects as starting point of design. Sometimes there is a refinement/learning process that unfolds to improve design one feels or sees as issues. Sometimes one finds out prior experience gained means one was close or as close as can be. The other sometimes is just a varied combination of many factors.


Regards,

John L. Males
Toronto, Ontario
Canada
07 April 2017 03:28 EDT


Return to “Custom design boards”

Who is online

Users browsing this forum: No registered users and 1 guest