Bluetooth Sensor#

The system to be analyzed in this tutorial is a very simple one: A battery operated Bluetooth sensor.
The system consists of the following components:

  • A CR2032 3V lithium battery

  • A MCU operating at 1.8V

  • A sensor that needs 5V to operate

To power the MCU and sensor from the 3V battery two converters are needed:

  • A boost converter that outputs 5V. The 5V is filtered with an RC filter to reduce switching noise.

  • A buck converter that outputs 1.8V

from sysloss.components import *
from sysloss.system import System

Define the system#

A sysloss system is defined using the System class. Components are added to the system, always starting with a Source component (in this case the battery). Each component must have a unique name.

Parameters for voltage, current, power and resistance are always in basic units of electricity (Volt, Ampere, Watt and Ohm).

bts = System("Bluetooth sensor", Source("CR2032", vo=3.0, rs=10))
bts.add_comp("CR2032", comp=Converter("Buck 1.8V", vo=1.8, eff=0.87))
bts.add_comp("Buck 1.8V", comp=PLoad("MCU", pwr=13e-3))
bts.add_comp("CR2032", comp=Converter("Boost 5V", vo=5.0, eff=0.82, iis=3e-6))
bts.add_comp("Boost 5V", comp=RLoss("RC filter", rs=6.8))
bts.add_comp("RC filter", comp=ILoad("Sensor", ii=6e-3))

That’s it - for the initial system! sysloss has two functions for summarizing the system:

  • .tree() that displays the power tree structure

  • .params() that lists all system parameters in a Pandas frame

bts.tree()
Bluetooth sensor
└── CR2032
    ├── Boost 5V
    │   └── RC filter
    │       └── Sensor
    └── Buck 1.8V
        └── MCU
bts.params()
Component Type vo (V) vdrop (V) rs (Ohm) rt (°C/W) eff (%) ig (A) iq (A) ii (A) iis (A) pwr (W) pwrs (W) loss
0 CR2032 SOURCE 3.0 10 0.0
1 Boost 5V CONVERTER 5.0 0.0 0.82 0.0 0.000003
2 RC filter SLOSS 6.8 0.0
3 Sensor LOAD 0.0 0.006 0.0 False
4 Buck 1.8V CONVERTER 1.8 0.0 0.87 0.0 0.0
5 MCU LOAD 0.0 0.013 0.0 False

Analyze#

We can now analyze the steady-state of this system with .solve(), which returns the system state in a Pandas frame.

bts.solve()
Component Type Parent Vin (V) Vout (V) Iin (A) Iout (A) Power (W) Loss (W) Efficiency (%) Warnings
0 CR2032 SOURCE 3.0 2.817088 0.018291 0.018291 0.054874 0.003346 93.902943
1 Boost 5V CONVERTER CR2032 2.817088 5.0 0.012987 0.006 0.036585 0.006585 82.0
2 RC filter SLOSS Boost 5V 5.0 4.9592 0.006 0.006 0.03 0.000245 99.184
3 Sensor LOAD RC filter 4.9592 0.0 0.006 0.0 0.029755 0.0 100.0
4 Buck 1.8V CONVERTER CR2032 2.817088 1.8 0.005304 0.007222 0.014943 0.001943 87.0
5 MCU LOAD Buck 1.8V 1.8 0.0 0.007222 0.0 0.013 0.0 100.0
6 System total 0.018291 0.054874 0.012118 77.915822

Voltage rails#

In this simple system there are three voltage rails:

  • Battery voltage

  • 1.8V

  • 5V

We can give these voltage rails a name when components are added to the system. The voltage rail names are added to the results table, which can be useful especially in large power trees.

Tip

The power rail name can be used instead of component name as parent parameter when adding components to the system.

Let’s redefine the system, adding voltage rail names:

bts = System("Bluetooth sensor", Source("CR2032", vo=3.0, rs=10), rail="VBat")
bts.add_comp("VBat", comp=Converter("Buck 1.8V", vo=1.8, eff=0.87), rail="SYS_1V8")
bts.add_comp("SYS_1V8", comp=PLoad("MCU", pwr=13e-3))
bts.add_comp("VBat", comp=Converter("Boost 5V", vo=5.0, eff=0.82, iis=3e-6), rail="SYS_5V")
bts.add_comp("SYS_5V", comp=RLoss("RC filter", rs=6.8), rail="5V_quiet")
bts.add_comp("5V_quiet", comp=ILoad("Sensor", ii=6e-3))
bts.solve()
Component Type Rail in Vin (V) Vout (V) Rail out Iin (A) Iout (A) Power (W) Loss (W) Efficiency (%) Warnings
0 CR2032 SOURCE 3.0 2.817088 VBat 0.018291 0.018291 0.054874 0.003346 93.902943
1 Boost 5V CONVERTER VBat 2.817088 5.0 SYS_5V 0.012987 0.006 0.036585 0.006585 82.0
2 RC filter SLOSS SYS_5V 5.0 4.9592 5V_quiet 0.006 0.006 0.03 0.000245 99.184
3 Sensor LOAD 5V_quiet 4.9592 0.0 0.006 0.0 0.029755 0.0 100.0
4 Buck 1.8V CONVERTER VBat 2.817088 1.8 SYS_1V8 0.005304 0.007222 0.014943 0.001943 87.0
5 MCU LOAD SYS_1V8 1.8 0.0 0.007222 0.0 0.013 0.0 100.0
6 System total 0.018291 0.054874 0.012118 77.915822

When one or more voltage rails have been defined, the rail_rep() (rail report) can be used to get a summary per voltage rail:

bts.rail_rep()
Rail Voltage (V) Current (A) Power (W) Loss (W) Efficiency (%) Warnings
0 VBat 2.817088 0.018291 0.051528 0.008528 85.800046
1 SYS_5V 5.000000 0.006000 0.030000 0.000245 99.190605
2 5V_quiet 4.959200 0.006000 0.029755 0.000000 100.000000
3 SYS_1V8 1.800000 0.007222 0.013000 0.000000 100.000000

Notice here that the total power on the VBat rail is less than the system total power reported by bts.solve(). The difference equals the power loss in the battery series resistance, which is not part of the VBat rail power consumption.

Load phases#

Very few systems operate with constant power. Most systems will have two or more operating modes, where different parts of the system is shut-down or operating at lower or higher power. Our Bluetooth sensor will acquire and transmit sensor data once per hour and stay in sleep mode otherwise.

sysloss captures these operating modes with load phases. We define three phases:

  • “sleep”: the 5V boost converter is shut-down (and the sensor with it). MCU is sleeping.

  • “acquire”: the 5V boost converter is enabled, MCU is acquiring sensor data.

  • “transmit”: the MCU uses higher power to transmit sensor data, while the 5V boost converter is shut-down.

Load phases in sysloss are defined in a dict with name and duration (seconds) of each phase. The duration values are used to calculate time-averaged power numbers. We start by defining the load phases on system level.

bts_phases = {"sleep": 3600, "acquire": 2.5, "transmit": 2e-3}
bts.set_sys_phases(bts_phases)

To define which load phases a converter is active in, we set the converter parameter active_phases, which is a list of phases.

Tip

When a converter is shut-down, the output voltage is 0.0, and all components connected to it will be off too. There is no need to define load phases for those components.

bts.set_comp_phases("Boost 5V", phase_conf=["acquire"])

Next, we set the load phases for the MCU, which has different power for each phase. For load components the load phase power consumption is defined as a dict.

mcu_pwr = {"sleep": 12e-6, "acquire": 15e-3, "transmit": 35e-3}
bts.set_comp_phases("MCU", phase_conf=mcu_pwr)

The .phases() function returns a DataFrame with the load phases summarized:

bts.phases()
Component Type Active phase rs (Ohm) ii (A) pwr (W)
0 CR2032 SOURCE N/A
1 Boost 5V CONVERTER acquire
2 RC filter SLOSS N/A
3 Sensor LOAD N/A 0.006
4 Buck 1.8V CONVERTER N/A
5 MCU LOAD sleep 0.000012
6 MCU LOAD acquire 0.015
7 MCU LOAD transmit 0.035

Analyzing again:

bts.solve()
Component Type Rail in Phase Vin (V) Vout (V) Rail out Iin (A) Iout (A) Power (W) Loss (W) Efficiency (%) Warnings
0 CR2032 SOURCE sleep 3.0 2.999924 VBat 0.000008 0.000008 0.000023 0.0 99.997467
1 Boost 5V CONVERTER VBat sleep 2.999924 0.0 SYS_5V 0.000003 0.0 0.000009 0.000009 0.0
2 RC filter SLOSS SYS_5V sleep 0.0 0.0 5V_quiet 0.0 0.0 0.0 0.0 100.0
3 Sensor LOAD 5V_quiet sleep 0.0 0.0 0.0 0.0 0.0 0.0 100.0
4 Buck 1.8V CONVERTER VBat sleep 2.999924 1.8 SYS_1V8 0.000005 0.000007 0.000014 0.000002 87.0
5 MCU LOAD SYS_1V8 sleep 1.8 0.0 0.000007 0.0 0.000012 0.0 100.0
6 System total sleep 0.000008 0.000023 0.000011 52.646258
7 CR2032 SOURCE acquire 3.0 2.808332 VBat 0.019167 0.019167 0.0575 0.003674 93.611075
8 Boost 5V CONVERTER VBat acquire 2.808332 5.0 SYS_5V 0.013027 0.006 0.036585 0.006585 82.0
9 RC filter SLOSS SYS_5V acquire 5.0 4.9592 5V_quiet 0.006 0.006 0.03 0.000245 99.184
10 Sensor LOAD 5V_quiet acquire 4.9592 0.0 0.006 0.0 0.029755 0.0 100.0
11 Buck 1.8V CONVERTER VBat acquire 2.808332 1.8 SYS_1V8 0.006139 0.008333 0.017241 0.002241 87.0
12 MCU LOAD SYS_1V8 acquire 1.8 0.0 0.008333 0.0 0.015 0.0 100.0
13 System total acquire 0.019167 0.0575 0.012745 77.834565
14 CR2032 SOURCE transmit 3.0 2.85927 VBat 0.014073 0.014073 0.042219 0.00198 95.309007
15 Boost 5V CONVERTER VBat transmit 2.85927 0.0 SYS_5V 0.000003 0.0 0.000009 0.000009 0.0
16 RC filter SLOSS SYS_5V transmit 0.0 0.0 5V_quiet 0.0 0.0 0.0 0.0 100.0
17 Sensor LOAD 5V_quiet transmit 0.0 0.0 0.0 0.0 0.0 0.0 100.0
18 Buck 1.8V CONVERTER VBat transmit 2.85927 1.8 SYS_1V8 0.01407 0.019444 0.04023 0.00523 87.0
19 MCU LOAD SYS_1V8 transmit 1.8 0.0 0.019444 0.0 0.035 0.0 100.0
20 System total transmit 0.014073 0.042219 0.007219 82.901156
21 System average 0.000021 0.000063 0.00002 52.663754

The result table now has a new column Phase, results for each phase and a system average row. Load phases are also added to the voltage rail report:

bts.rail_rep()
Phase Rail Voltage (V) Current (A) Power (W) Loss (W) Efficiency (%) Warnings
0 sleep VBat 2.999924 0.000008 0.000023 0.000011 67.864719
1 sleep SYS_5V 0.000000 0.000000 0.000000 0.000000 100.000000
2 sleep 5V_quiet 0.000000 0.000000 0.000000 0.000000 100.000000
3 sleep SYS_1V8 1.800000 0.000007 0.000012 0.000000 100.000000
4 acquire VBat 2.808332 0.019167 0.053827 0.008827 85.911806
5 acquire SYS_5V 5.000000 0.006000 0.030000 0.000245 99.190605
6 acquire 5V_quiet 4.959200 0.006000 0.029755 0.000000 100.000000
7 acquire SYS_1V8 1.800000 0.008333 0.015000 0.000000 100.000000
8 transmit VBat 2.859270 0.014073 0.040238 0.005238 88.481053
9 transmit SYS_5V 0.000000 0.000000 0.000000 0.000000 100.000000
10 transmit 5V_quiet 0.000000 0.000000 0.000000 0.000000 100.000000
11 transmit SYS_1V8 1.800000 0.019444 0.035000 0.000000 100.000000

Parameter interpolation#

The converters in the system have been defined with constant efficiency. Converter efficiency is a function of many factors, including output current and input voltage. sysloss supports interpolation of converter efficiency. This means that we can take data points from the converter data sheet (or measurement data from a lab test) and provide these data points to sysloss as an interpolated parameter. sysloss will then connect the dots with 1D or 2D linear interpolation.

Let us define the efficiency curve for the 1.8V buck converter. The data points are entered in a dict with a specific format:

buck_eff = {"vi": [3.0], "io": [1e-6, 1e-5, 1e-4, 1e-3, 1e-2], "eff": [[0.72, 0.89, 0.92, 0.925, 0.93]]}
bts.change_comp("Buck 1.8V", comp=Converter("Buck 1.8V", vo=1.8, eff=buck_eff))
bts.params()
Component Type vo (V) vdrop (V) rs (Ohm) rt (°C/W) eff (%) ig (A) iq (A) ii (A) iis (A) pwr (W) pwrs (W) loss
0 CR2032 SOURCE 3.0 10 0.0
1 Boost 5V CONVERTER 5.0 0.0 0.82 0.0 0.000003
2 RC filter SLOSS 6.8 0.0
3 Sensor LOAD 0.0 0.006 0.0 False
4 Buck 1.8V CONVERTER 1.8 0.0 interp 0.0 0.0
5 MCU LOAD 0.0 0.013 0.0 False

If we look in the parameter table now, the entry for “Buck 1.8V” efficiency is interp, which means an interpolated parameter. We can also plot the interpolation curve with the .plot_interp() method:

bts.plot_interp("Buck 1.8V");
../_images/2c4b77ba24a171a2999361858e48c21df94746ed0475e35b8d816d75a02b3bb7.png
bts.solve()
Component Type Rail in Phase Vin (V) Vout (V) Rail out Iin (A) Iout (A) Power (W) Loss (W) Efficiency (%) Warnings
0 CR2032 SOURCE sleep 3.0 2.999922 VBat 0.000008 0.000008 0.000024 0.0 99.997388
1 Boost 5V CONVERTER VBat sleep 2.999922 0.0 SYS_5V 0.000003 0.0 0.000009 0.000009 0.0
2 RC filter SLOSS SYS_5V sleep 0.0 0.0 5V_quiet 0.0 0.0 0.0 0.0 100.0
3 Sensor LOAD 5V_quiet sleep 0.0 0.0 0.0 0.0 0.0 0.0 100.0
4 Buck 1.8V CONVERTER VBat sleep 2.999922 1.8 0.000005 0.000007 0.000015 0.000003 82.703704
5 MCU LOAD sleep 1.8 0.0 0.000007 0.0 0.000012 0.0 100.0
6 System total sleep 0.000008 0.000024 0.000012 51.041607
7 CR2032 SOURCE acquire 3.0 2.812515 VBat 0.018748 0.018748 0.056245 0.003515 93.750503
8 Boost 5V CONVERTER VBat acquire 2.812515 5.0 SYS_5V 0.013008 0.006 0.036585 0.006585 82.0
9 RC filter SLOSS SYS_5V acquire 5.0 4.9592 5V_quiet 0.006 0.006 0.03 0.000245 99.184
10 Sensor LOAD 5V_quiet acquire 4.9592 0.0 0.006 0.0 0.029755 0.0 100.0
11 Buck 1.8V CONVERTER VBat acquire 2.812515 1.8 0.00574 0.008333 0.016145 0.001145 92.907407
12 MCU LOAD acquire 1.8 0.0 0.008333 0.0 0.015 0.0 100.0
13 System total acquire 0.018748 0.056245 0.01149 79.571099
14 CR2032 SOURCE transmit 3.0 2.868784 VBat 0.013122 0.013122 0.039365 0.001722 95.626137
15 Boost 5V CONVERTER VBat transmit 2.868784 0.0 SYS_5V 0.000003 0.0 0.000009 0.000009 0.0
16 RC filter SLOSS SYS_5V transmit 0.0 0.0 5V_quiet 0.0 0.0 0.0 0.0 100.0
17 Sensor LOAD 5V_quiet transmit 0.0 0.0 0.0 0.0 0.0 0.0 100.0
18 Buck 1.8V CONVERTER VBat transmit 2.868784 1.8 0.013119 0.019444 0.037634 0.002634 93.0
19 MCU LOAD transmit 1.8 0.0 0.019444 0.0 0.035 0.0 100.0
20 System total transmit 0.013122 0.039365 0.004365 88.911973
21 System average 0.000021 0.000063 0.000019 51.061426

The effect is not very large in this system, but the “sleep” efficiency is about 1.5% lower.

Saving and loading system from file#

A system can be saved to .json format with the .save() method. Restore the system from file with the .from_file() method.

bts.save("bts.json")
bts2 = System.from_file("bts.json")
bts2.solve()
Component Type Rail in Phase Vin (V) Vout (V) Rail out Iin (A) Iout (A) Power (W) Loss (W) Efficiency (%) Warnings
0 CR2032 SOURCE sleep 3.0 2.999922 VBat 0.000008 0.000008 0.000024 0.0 99.997388
1 Buck 1.8V CONVERTER VBat sleep 2.999922 1.8 0.000005 0.000007 0.000015 0.000003 82.703704
2 MCU LOAD sleep 1.8 0.0 0.000007 0.0 0.000012 0.0 100.0
3 Boost 5V CONVERTER VBat sleep 2.999922 0.0 SYS_5V 0.000003 0.0 0.000009 0.000009 0.0
4 RC filter SLOSS SYS_5V sleep 0.0 0.0 5V_quiet 0.0 0.0 0.0 0.0 100.0
5 Sensor LOAD 5V_quiet sleep 0.0 0.0 0.0 0.0 0.0 0.0 100.0
6 System total sleep 0.000008 0.000024 0.000012 51.041607
7 CR2032 SOURCE acquire 3.0 2.812515 VBat 0.018748 0.018748 0.056245 0.003515 93.750503
8 Buck 1.8V CONVERTER VBat acquire 2.812515 1.8 0.00574 0.008333 0.016145 0.001145 92.907407
9 MCU LOAD acquire 1.8 0.0 0.008333 0.0 0.015 0.0 100.0
10 Boost 5V CONVERTER VBat acquire 2.812515 5.0 SYS_5V 0.013008 0.006 0.036585 0.006585 82.0
11 RC filter SLOSS SYS_5V acquire 5.0 4.9592 5V_quiet 0.006 0.006 0.03 0.000245 99.184
12 Sensor LOAD 5V_quiet acquire 4.9592 0.0 0.006 0.0 0.029755 0.0 100.0
13 System total acquire 0.018748 0.056245 0.01149 79.571099
14 CR2032 SOURCE transmit 3.0 2.868784 VBat 0.013122 0.013122 0.039365 0.001722 95.626137
15 Buck 1.8V CONVERTER VBat transmit 2.868784 1.8 0.013119 0.019444 0.037634 0.002634 93.0
16 MCU LOAD transmit 1.8 0.0 0.019444 0.0 0.035 0.0 100.0
17 Boost 5V CONVERTER VBat transmit 2.868784 0.0 SYS_5V 0.000003 0.0 0.000009 0.000009 0.0
18 RC filter SLOSS SYS_5V transmit 0.0 0.0 5V_quiet 0.0 0.0 0.0 0.0 100.0
19 Sensor LOAD 5V_quiet transmit 0.0 0.0 0.0 0.0 0.0 0.0 100.0
20 System total transmit 0.013122 0.039365 0.004365 88.911973
21 System average 0.000021 0.000063 0.000019 51.061426

Summary#

This notebook demonstrates the basic use of sysLoss, including load phases, component parameter interpolation and saving and loading system from file.

The natural question now is: How long will the battery last for the bluetooth sensor? Find out in the Battery Life Simulation tutorial.