Wednesday, February 4, 2009

lemons

Embedded Systems exam at the Bucharest Polytechnic.
"A lemon battery can supply an average of 0.1mA at 1V for about an hour.
1. How many lemon batteries are needed to run a 100W light bulb?
2. How many instructions can an ATmega128L execute while running from a lemon battery? Assume that an ATmega128L uses an average of 4nJ to execute an instruction."
At the students' request, further (obvious) assumptions were specified:
a) To simplify, assume that the lemon has an ideal U-I characteristic (it can deliver anything up to 0.1mA at 1V).
b) It also has an ideal U-t characteristic (at 0.1mA, it holds 1V for one hour then suddenly drops to zero).
c) Assume there is an ideal DC-DC converter between the lemon and the ATmega128L, providing it with the required voltage.
After thinking about it, and after remembering the jokes about ideal spherical lemons in vacuum, I decided that additionally, the ATmega128L's clock frequency should be set such that it draws exactly 0.1mA from the 1V lemon supply, or that it should enter very low power sleep modes as needed.
Answers:
1. 100W/(1V*0.1mA) == one fucking million (whoa)
2. 1V*0.1mA*3600s/4nJ == 90 fucking million (yeah).
Required frequency for ATmega128L to complete 90Minstr in 3600s:
f = 90M/3600s = 25kHz.
Current drawn by ATmega128L at 2.7V (minimum operating voltage) in order to assure 0.1mA from lemon, given ideal converter: 0.1mA*1V/2.7V = 37uA.
Typical current drawn by real ATmega128L at 2.7V at 25kHz, extrapolated from datasheet graph: 50uA (pretty close actually).
So there you go: light a bulb long enough to take a shit, or execute 10 trillion 8-bit computer instructions. Meanwhile, a high-end "PC" processor would do maybe 4 trillion 64-bit instructions, making it better than the microcontrollers, but not that much better. Moral of story: do something useful -- turn off lights, run computers (*).