The Banana Pi is a great little board for building low power NB-IoT connected applications. Its small form factor and all in one design makes it easy to design a commercial product around it. In line with the last post on intro to low power design we will see how we can tweak and hack the Banana Pi to make it last years on a humble battery.
1. Remove power LED
In section 1.1 in the previous post we saw how the design should be optimized for low power. There is one glitch in this board in this department. The surface mount red colored LED that turns on when power is applied is a culprit which gulps down more than 500uA. You can desolder that LED and save 500uA very easily.
2. Remove linear regulator
In section 1.2 in our previous post we discussed how components should be selected carefully. The Banana Pi has a LM1117 linear regulator to convert the 5V power rail to 3.3V. Digging into the datasheet we found out the following
The quiescent current is the current that the regulator consumes even at no load. This is where the real robbery happens for the Banana. If you supply power via the USB port there will be a current consumption close to 5mA even when the microcontroller and modem are turned off. Even if you power up the board via the battery connector a reverse current will flow into the output terminals of the LM1117 which will consume around the same current. This is a design glitch that s expected to be resolved in future Banana versions. Till then, if you are going anywhere near low power design desolder the regulator and supply 3.3V power via the battery terminal. The downside is that you cannot now power the board via USB which means that if you want to program the microcontroller you have to supply power to the 3.3V battery terminal separately even though the USB is connected. Connect the USB, connect the 3.3V power and your Banana will get detected in your PC
3. Choosing the right power soruce
The two main components in the Banana Pi are the microcontroller and the modem. The microcontroller can operate on any voltage between 2.0V and 3.9V. The modem can operate on any voltage between 3.3V and 4.2V Sadly, the Banana does not have any SMPS to up convert or down convert the voltage supplied to the battery in terminal. Therefore you have to careful in connecting a battery. The ideal battery voltage should be between 3.3V and 3.9V. It is safe to assume that you have to supply 3.3V so that everybody will be happy. The following options are available in the battery department.
3.1 Li-Ion cell
If you know about batteries you will know that a Li-Ion cell has a nominal voltage of 3.7V and can go up to 4.2V when fully charged. Therefore directly connecting a fully charged Li-Ion cell can spell out a death sentence for your Banana. If you want to run the Banana off a Li-Ion cell at least connect a Schottky diode in series so that when fully charged, the approx 0.25V forward drop will save the Banana. It is very naiive, inefficient and not professional at all and do not use diodes for dropping voltage unless when you are hacking. A better option would be to use a small buck converter (SMPS) to down convert the Li-Ion to 3.3V. You can get a small buck DC-DC converter like this for around $2 on ebay. Using an SMPS with a Li-Ion cell is a good option since cells are cheap and can be found in a variety of capacities.
3.2 Ni-MH battery
A Ni-MH cell has a nominal voltage of 1.2V. Therefore you will need at least 3 cells in series to keep the Banana working. Fully charged these cells go up to 1.25V which is still OK. Downside is that 3 Ni-MH cells are a bit bulky and it will be difficult to design a small form factor device. When compared with Li-Ion, Ni-MH has a lower energy density comparatively which makes it a bit inefficient space wise. However you can run the Banana with one Ni-MH cell if you use a buck-boost SMPS like this which is again around $2 on ebay. This SMPS converts any voltage between 0.8V and 6V to 3.3V. It can do this because it is a buck-boost converter which can up convert or down convert as required.
3.3 3V Coin cell (eg CR2032) or 2x1.5 cells (AA or AAA)
If you want to run the Banana's modem reliably you will need around 3.3V. Therefore you will again need the buck-boost converter to pump in 3.3V from these dry cells. The upside is that if you are designing a device which does not need rechargeable batteries you can go down this approach which will help to keep costs low. But remember these cells (specially CR2032) have lower capacities than typical Li-Ion and Ni-MH cells. Therefore you should be more careful about saving power.
3.4 LiFePo4 cell
It might be a bit more difficult to find this cell. I included this less poplar cell since it has a working voltage between 3.3V and 3.6V which fits in nicely to our requirement. You can avoid any SMPS DC-DC converters as well.
Battery technologies are a different black art which is not trivial at all. Calculating the battery life of a device is not as simple as dividing the average current consumption by the total battery capacity. Many factors such as the increase in internal resistance, ambient temperature should be considered in deriving an estimate.The fact that manufacturer stated capacities on most of the knock-off cells in the market are inaccurate does not make it any easier. Take a look at http://www.ganssle.com/reports/ultra-low-power-design.html#cr2032behavior for an in depth analysis of the CR2032 cell. There are some great research done on Li-Ion cells and Ni-MH cells as well. They are must look items if you designing a device running on such batteries.
However it is common sense that getting external power whenever possible is always preferred such as solar or any other energy harvesting method. I will try to cover this in the later post.
4. Lowering clock speed
The STM32F103 microcontroller can run typically up to 72MHz. You can even overclock it to 128MHz. But since we are low power dudes we are interested only in underclocking the processor.The following table in the reference manual in page 48 lists down the running currents at different clock speeds.Since our maple board configuration uses the external clock we are interested only in the top half of the table.
You can see that the current consumption goes down rapidly with the clock frequency. However it is not a trivial matter. The default maple configuration in your Arduino IDE is designed to run at 72MHz. It also offers 128MHz and 48MHz options. If you want to run at lower speeds you have to edit the board configuration and add your custom config. This is a bit tricky but not difficult. We tested the microcontroller at 12MHz and 3MHz and found significant reduction in power consumption. eg: at 3MHz the running current is around 6mA. In contrast at 72MHz the STM32 eats around 38mA! But due to the internal design of the microcontroller, you cannot use the USB for debugging (as COM port) at the 3MHz option since the USB needs a 48MHz clock to operate. For more info take a look at the clock tree in the reference manual. If you a hardware guy, lookup STM32cube tool by STMicroelectronics which will help you to adjust clock speeds without violating the compatibility requirements. Luckily we have done part of the work for you and all you need to do is edit the following files to add the 12MHz and 3MHz options.
4.1 boards.txt
You can find this file in a location like C:\Users\lenovo\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2018.2.13 Replace 'lenovo' with your username. Find out the "genericSTM32F103R" section and add the lines as shown below
4.2 boards_setup.cpp
This file is in a location like "C:\Users\lenovo\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2018.2.13\variants\generic_stm32f103r8\wirish" In this file you have to do few modifications to let the compiler know of the new speeds you added in the boards.txt previously.
- Define the PLL Multiplier values for the new speeds
- Setup the clock prescalers for the new speed
You can find the reference files at the Banana Pi GitLab at https://gitlab.com/akalankadesilva/bananapi
4. Going to low power modes whenever possible
The STM32 microcontroller in the Banana Pi has several low power modes as per its reference manual
Important things to note are:
- Sleep mode: In this mode the CPU is turned off. But the RAM and all other peripherals receive power. Therefore your program variables are retained. The current consumption can be reduced to less than half of the running mode.
- Stop mode: In this mode all 1.8V clocks are turn off as well as the main clock.
- Standby mode: this is the lowest power mode. Since the voltage regulator is turned off you lose the content in the RAM. But since this microcontroller has an inbuilt RTC it also has a battery backup input. In this mode only the battery backup domain is operational. This includes the RTC and the backup registers. Therefore you have to store variables that should be preserved in the backup register area in this mode. In this mode we saw that the Banana consumed only 5uA ! This is the sleep current of both the microcontroller and the modem. This is a huge win in the power department for a device which is expected to run a long time on a battery.
Of course it goes without saying that network communication should be minimized and as much as possible to save power. Even though the dynamics of the modem is complex the user does not have to deal with any of that since NB-IoT handles power saving automatically. Simply put if you don't send anything you won't have to spend any power because the sleep current of the modem is few micro amps. We will see how the NB-IoT Tx and Rx cycles operate in detail in a future post.
0 comments:
Post a Comment