What are embedded systems?Embedded systems are computer systems with a specific function within a larger system. This includes all computing systems, such as home appliances, digital watches, cameras, avionics, and medical devices, except for PCs and smartphones. When classifying embedded systems by their main computing component, two of the most common types are microcontroller (MCU) and a microprocessor (MPU/CPU) based systems. There are also DSP, FPGA and custom ASIC-based systems.
Microcontroller-based embedded systems are typically programmed either without an operating system, known as "bare metal," or with a real-time operating system (RTOS). Microcontrollers are cost-effective, single-chip computers that include a CPU, memory, and input/output capabilities on a single integrated circuit (IC). However, their specifications are limited compared to standard PCs, with less than 1MB of RAM and less than 8MB of flash memory, and typically only one CPU core with a frequency of less than 500MHz. Many 32-bit microcontrollers today are based on ARM Cortex-M CPUs.
In contrast, microprocessor-based systems, which are based on more powerful CPUs such as ARM Cortex-A, run Linux and have specifications more similar to PCs or smartphones. These systems, known as single-board computers, feature RAM, eMMC (flash), and various peripheral chips on the board, rather than on a single IC.
While microcontroller-based systems are generally more affordable and energy-efficient than embedded Linux devices, they also have more limited computing capabilities and feature sets. This blog post will focus on the unique characteristics of microcontroller-based embedded systems. However, as part of the Internet of Things (IoT) ecosystem, modern embedded systems are expected to have a range of features such as wireless communication, internet connectivity, and advanced sensors and actuators, all while maintaining cost and power efficiency. Careful consideration of both hardware and software is crucial for the successful design and development of these devices.
Optimizing power consumptionWhen selecting components for a wireless embedded device, it is important to consider factors such as suitability for the intended application, software and community support, market availability and cost. The microcontroller, RF communication chip, and sensors/actuators are the main components to evaluate. Factors like deep sleep functionality, communication interfaces, security options, processing speed, and memory of the microcontroller should all be taken into account to ensure that the device's requirements are met in the most optimal way possible.
MCULow-power MCUs on the market can typically achieve current consumption below 1 μA in their sleep modes. Some of these include ST's STM32L0xx, Silicon Labs' C8051F98x, Microchip's SAM Lx and TI's MSP430. In our recent project, we used STM32L051 MCU and in its Stop mode, we were able to achieve 1.3 μA with Low Power Timer and Watchdog running.
RF communication chipWhen choosing an RF communication chip, it's important to select an appropriate wireless communication protocol that takes into account factors such as power consumption, range, and throughput. Factors that will affect the power consumption of the device are protocol frequency (sub-GHz, 2.4 GHz, 5 GHz, etc.), data packet length, the number of messages being sent within a certain timeframe, and signal power. Operating frequency affects range, power consumption, and throughput. Lower frequencies (sub-GHz) have better range and lower power consumption, while higher frequencies have better throughput. It's essential to keep the number of messages sent within a certain timeframe as low as possible for battery-powered devices, usually 1-2 messages every 10+ minutes. Smaller data packet length increases the throughput and power efficiency of a protocol, as it takes less time to transmit information and keeps the RF transceiver in active mode. With greater power, the range is increased, but so is power consumption. Low-power RF chips on the market can typically achieve current consumption in the nA or few μA range in their sleep modes, making them a good choice for battery-powered devices. In our recent project, we used AX5243 sub-GHz RF chip at 868 MHz with a custom protocol. In its Powerdown mode, we were able to achieve 0.8 μA.
Besides hardware, software choices and optimizations can also greatly affect the power consumption of a device; choosing the appropriate sleep mode of the MCU and RF chip, minimizing time spent in running mode of the MCU and RF chip, using only the lowest-power MCU timer while the device is in idle mode, setting MCU peripherals in low-power mode, etc.
Here are some important takeaways from our recent project with STM32L051:
Wireless embedded devices transmit data in periodic intervals and spend the rest of the time in sleep mode, which minimizes the amount of time the microcontroller and RF transceiver are running and consuming power. However, if the running time is too long, it can significantly impact the average power consumption and shorten the device's battery life. To optimize power consumption, it's important to keep the duration of running time to a minimum, whether due to a periodic interval or an interrupt.
Here are some methods that we've used to minimize the duration of running time:
It's important to select an RTOS mode that is optimized for low power consumption, especially as the number of features increases, as RTOS is often required in such cases.
Finally, tools that we've used to measure current consumption are Otii Arc and a multimeter (just to double-check Otii Arc measurements). Also, it's useful to have measurement ports on PCB for measuring the current consumption of certain components separately (MCU, RF transceiver, sensors).
With whole PCB average current consumption being under 5 μA (idle mode consumption below 2.5 μA), these devices can ideally last on one e.g. CR2032 battery (~230 mAh) for more than 5 years.
Optimizing memory usageAs projects need to be profitable, prices of the components are very important. But with lower prices, MCUs usually also come with smaller amounts of RAM and Flash memory. For example, STM32L051 has 8 kB of RAM and 64 kB of Flash memory . As the complexity of the application increases and the feature set expands, optimizing memory usage becomes necessary for these microcontrollers.
Here are some methods of optimizing memory usage that we've used in our recent project:
That wraps up this blog post on memory and power consumption optimization for microcontroller-based embedded systems. We hope it'll turn out to be helpful in your current and future embedded projects too!
If you like this article, we're sure you'll love these!
Non-Fungible Tokens (NFTs) Explained
We want you to enter the world of non fungible tokens! A new type of blockchain based asset is taking some of the well established markets by storm. Find out why and what is our stake in it.
A Journey Through Designing a Smart Sensor Provisioning process: Bluetooth mesh
Step into the journey of developing a smart sensor provisioning app, as we shed light on the intricate design process, the critical role of user-centric design, and how collaboration led to an app that exceeded client expectations. A compelling case study for tech enthusiasts, app designers, and IoT professionals alike.