Firmware budgets mix picojoules and nanojoules

Microcontroller data sheets often give current in milliamps and clock speed in megahertz, from which designers work out energy per cycle in picojoules. A memory or sensor vendor, in contrast, may list energy per read or per sample in nanojoules. When an embedded engineer adds up the cost of one measurement cycle, the line items arrive in both units. This page converts picojoules into nanojoules so that the whole budget can be written in a single column. It is a small step, a division by 1,000, but it is the step that gets dropped most often when a spreadsheet is built in a hurry. Students in an embedded-systems course meet the same pair in lab write-ups, where a measured current is turned into joules per cycle and then compared with a figure from the vendor.

A division by 1,000

Between 10^-12 and 10^-9 lies a factor of 10^3, which is one thousand picojoules per nanojoule. The formula is nJ = pJ × 0.001. Neither prefix needs rounding, because 1,000 is an exact ratio. Move the decimal point three places to the left: 2,500 pJ is 2.5 nJ, 40,000 pJ is 40 nJ and 625 pJ is 0.625 nJ. The conversion is the smallest jump in this family of pages, which makes errors less obvious. A result that looks only slightly different from the input, such as 0.01 versus 10, deserves a glance at the units to be sure the direction is right.

The 10 pJ starting value

The page begins with 10 pJ and returns 0.01 nJ, printed by the software as 0.009999999999999998 because of binary rounding. The intended value is 0.01. A 900 pJ event is 0.9 nJ, a 1,000 pJ event is 1 nJ, and a 15,000 pJ event is 15 nJ. The result helps decide which unit reads best. Values below 1 nJ are easier to read in picojoules, and values above a few thousand picojoules are easier to read in nanojoules. Choosing the unit that keeps the number between 1 and 1,000 avoids leading zeros and makes tables simpler to scan.

Energy per clock cycle of a microcontroller

Take an illustrative microcontroller that draws 5 mA from a 3 V supply while running at 16 MHz. Power is 3 V × 0.005 A = 15 mW. Energy per cycle is 0.015 W / 16,000,000 Hz = 9.375 × 10^-10 J, which is 937.5 pJ or 0.9375 nJ. A task of 20,000 cycles then costs 18.75 µJ. The picojoule figure reads better for one cycle, and the nanojoule figure for a few cycles or a function call. If a measurement in your own board gives a different current, replace the 5 mA and keep the method. The page performs the unit step and leaves the electrical measurement to you. Remember that supply current changes with clock speed and temperature, so a figure taken at 16 MHz does not carry over to 8 MHz. Halving the clock in this example roughly halves the current, and the energy per cycle depends on how much of the draw is fixed overhead.

Sensor samples and radio packets

A sensor sample may cost 50 nJ, which is 50,000 pJ, while the processor spends about 937.5 pJ per cycle in the example above. Reading the sample and running 100 cycles of processing costs 50 nJ + 93.75 nJ = 143.75 nJ. A radio packet usually costs far more, often tens of microjoules in small wireless designs, so the processor and the sensor can look minor next to it. Put the three on one scale and the ranking becomes plain, with the packet at tens of thousands of nanojoules and the processing at about 94 nJ in this example. The conversion lets you test such a ranking quickly before you commit time to optimizing the wrong part of the system.

Comparing two chips in a table

Suppose chip A is listed at 900 pJ per instruction and chip B at 1.4 nJ per instruction. Without a conversion the numbers look unrelated. In nanojoules A is 0.9 nJ and B is 1.4 nJ, so B uses about 56 percent more energy per instruction, since 1.4 / 0.9 = 1.556. Check the test conditions before drawing a conclusion: supply voltage, clock frequency and whether the figure includes memory access can differ between vendors. A converter keeps the arithmetic correct, and only the data sheets can say whether two numbers describe the same thing.

From nanojoules back to picojoules

Set nanojoules as the From unit and picojoules as the To unit. A value of 0.9375 nJ is 937.5 pJ, and 50 nJ is 50,000 pJ. Going the other direction, multiply by 1,000 and shift the point three places to the right. This direction fits data-sheet reading, where a vendor lists a memory write at 3.2 nJ and you want to compare it with a core instruction in picojoules. Keep the original unit beside the converted value in your notes, since a rounded picojoule number is harder to trace back to a published figure than the nanojoule value the vendor printed.

Measuring this kind of energy

Per-cycle and per-sample energies are rarely measured directly. They are derived from average current over a window, a supply voltage and a count of cycles or samples, and each of those carries some uncertainty. A current measurement with 5 percent error carries that error into every picojoule figure that follows. Averaging over many events and subtracting the idle current improves the estimate. Report the converted result with two or three significant figures. The unit step adds no uncertainty of its own, so the digits you keep should reflect the measurement.

A per-cycle figure ignores sleep and wake-up energy

Typing a per-cycle energy into the page changes its unit and leaves every other assumption in place. It does not simulate a program, include leakage during sleep, or say how long a battery will last. A per-cycle figure ignores peripherals, voltage regulators and the energy needed to wake from sleep, all of which matter in a device that spends most of its life idle. For lifetime estimates, use measured current profiles from your own hardware and the battery data sheet at your operating temperature. The converter keeps the powers of ten consistent along the way. A reader who needs the number for a school project can state the assumption plainly, such as a supply of 3 V and a current of 5 mA, and show the division that gives the picojoules per cycle, which is what a teacher will want to see in the working.