Learning the difference between power and energy
Power matters in tinyML, and its target is in the milliwatt (mW) range or below, which means thousands of times more efficient than a traditional desktop machine.
Although there are cases where we might consider using energy harvesting solutions, such as solar panels, those could not always be possible because of cost and physical dimensions.
However, what do we mean by power and energy? Let’s discover these terms by giving a basic overview of the fundamental physical quantities governing electronic circuits. This knowledge will be crucial for building electronic circuits with microcontrollers in the following chapters.
Voltage versus current
Current is what makes an electronic circuit work, which is the flow of electric charges across surface A of a conductor in a given time, as described in the following diagram:
Figure 1.9: Current is a flow of electric charges across surface A at a given time
The current is defined as follows:
Here, we have the following:
- I: Current, measured in amperes (A)
- Q: The electric charges across surface A in a given time, measured in coulombs (C)
- t: Time, measured in seconds (s)
The current flows in a circuit under the following conditions:
- We have a conductive material (for example, copper wire) to allow the electric charge to flow.
- We have a closed circuit, so a circuit without interruption provides a continuous path to the current flow.
- We have a source of energy, which is a potential difference source called voltage.
The voltage is measured with volts (V) and produces an electric field to allow the electric charge to flow in the circuit. Both the USB port and battery are potential difference sources. The symbolic representation of a power source is given in the following figure:
Figure 1.10: Battery symbol representation
To avoid constantly referring to V+ and V-, we will define the battery’s negative terminal as a reference by convention, assigning it 0 V (GND).
Ohm’s law relates voltage and current, which says through the following formula that the current through a conductor is proportional to the voltage across a resistor:
A resistor is an electrical component used to reduce the current flow. This component, whose symbolic representation is reported in the following figure, has a resistance measured with Ohm () and identified with the letter R:
Figure 1.11: Resistor symbol representation
Resistors are essential components for any electronic circuit, and for those used in our projects, their value is reported through colored bands on the elements. Standard resistors have four, five, or six bands. The color on the bands denotes the resistance value, as illustrated in the following example via the different shades:
Figure 1.12: Example of a four-band resistor
To easily decode the color bands, we recommend using the online tool at Digi-Key (https://www.digikey.com/en/resources/conversion-calculators/conversion-calculator-resistor-color-code).
With an understanding of the main physical quantities governing electronic circuits, we are now prepared to talk about the difference between power and energy.
Power versus energy
Sometimes, we interchange the words power and energy because we believe they are the same. However, although they are related, they represent distinct physical quantities. Energy is the capacity for doing work (for example, using force to move an object), while power is the energy consumption rate.
In practical terms, power indicates how fast we drain the battery, so high power implies a faster discharge.
Power and energy are related to voltage and current through the following formulas:
The following table presents the physical quantities reported in the power and energy formulas:
Figure 1.13: Table reporting the physical quantities in the power and energy formulas
On microcontrollers, the voltage supply is in the order of a few volts (for example, 3.3 V), while the current consumption is in the range of microampere () or milliampere (mA). For this reason, we commonly refer to microwatt () or milliwatt (mW) for power and microjoule () or millijoule (mJ) for energy.
Now, consider the following problem to familiarize yourself with the presented concepts.
Suppose you have a processing task, and you have the option to run it on two different processors with the following power consumptions in the active state:
Figure 1.14: Table reporting two processing units with different power consumptions
What processor would you use to run the task?
Although PU1 has higher (4x) power consumption than PU2, this does not imply that PU1 is less energy efficient. On the contrary, PU1 could be more computationally performant than PU2 (for example, 8x), making it the best choice from an energy perspective, as demonstrated by the following calculations:
Based on the preceding example, we can conclude that PU1 is our better choice because it needs less energy from the battery under the same workload.
Commonly, we adopt OPS per Watt (arithmetic operations performed per Watt) to bind the power consumption to the computational resources of our processors.
In terms of power and energy concepts, that is all we need to know about it. Therefore, the only remaining aspect to discuss concerns the devices used for our tinyML projects: the microcontrollers.