1
\$\begingroup\$

I'm trying to figure out how to calculate energy consumed through my circuit. I can read the current and see the voltage, can obviously calculate the instant power, but I'm fairly certain that I don't just sum them up over intervals (I sample at 10 Hz) to get watt-seconds. I have a processor to do the work for me, and an ADC reading the current from an amplifier and reading the system voltage. What's the best method of calculating the energy I consume through the circuit for the duration that the power is on? It's been a while since college...

Update - I forgot to mention that I'm not drawing constant power. It varies between 0.8A and 2.5A, depending on what board functions are being run.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ You do just sum it up over intervals. Well, you can have more mathematically advanced approximations, but that's the general idea. \$\endgroup\$ Commented Mar 10, 2023 at 14:05

3 Answers 3

1
\$\begingroup\$

If you have \$N\$ samples of voltage \$V\$ and current \$I\$, taken at a rate of 10 samples-per-second, then there is an interval \$\Delta t = \frac{1}{10}=0.1s\$ between each pair of consecutive samples.

You have two long lists of voltage readings, \$V_0, V_1 \dots V_{N-1}\$, and the same number of current readings, \$I_0, I_1 \dots I_{N-1}\$), and for each, you can calculate instantaneous power, as you figured out for yourself: \$P = V \times I\$.

Power is the rate of delivery of energy, the number of Joules of energy delivered each second. In other words, if power remained constant at 20W, for a duration of 30s, that means that 20J of energy was delivered during each second, and the total energy delivered must therefore be \$20W \times 30s = 600J\$. The product of power and time tells you the total energy.

It helps to understand the units. Power, or rate of delivery of energy, has the units "joules per second", written \$\frac{J}{s}\$ or \$Js^{-1}\$, but it's rare that you see that. Usually we call that "watts", \$W\$, where "one watt" means "one joule per second", \$1W = 1Js^{-1}\$. They mean the same thing. Notice how if you multiply \$\frac{J}{s} \times s\$, you are left with just \$J\$, energy, so even the units are consistent.

That's why sometimes people use the term "watt-seconds", instead of "joules", because the product of power in watts, and time in seconds, gets you energy, in joules.

Anyway, if we (naively) assume that current and voltage remain constant between each sample, then so does power. To find the energy delivered during that interval it's the product of power \$P\$, and the duration of the interval \$\Delta t\$. So, assuming voltage and current remain constant from the instant we take sample number \$X\$ right up to just before the next sample, energy \$E\$ delivered during that interval is:

$$ \begin{aligned} E_X &= P_X \times \Delta t \\ \\ &= V_X \times I_X \times \Delta t \\ \\ \end{aligned} $$

If you perform that calculation for each sample, total energy will be the sum of all those individual "packets" of energy:

$$ \begin{aligned} E &= V_0I_0\Delta t + V_1I_1\Delta t + \dots + V_{N-1}I_{N-1}\Delta t\\ \\ &= \Delta t(V_0I_0 + V_1I_1 + \dots + V_{N-1}I_{N-1}) \\ \\ \end{aligned} $$

A neater way of writing that would be:

$$ E = \Delta t\sum^{N-1}_{m=0} V_mI_m \\ \\ $$

Before I go on, the big gotcha is that if you have \$N\$ samples, you might think you have \$N\$ intervals, but actually you only have \$N-1\$, so the total time elapsed between the first and last samples is only \$(N-1) \times \Delta t\$. Watch out for that.

Less naively, instead of assuming that voltage and current remained constant during the entire interval following a sample, we could take two samples, and assume that the voltage and current during the interval between them transitioned smoothly from one value to the next. To do this, we take the average of two consecutive samples, and sum all those averages:

$$ \begin{aligned} E =& \left(\frac{V_0+V_1}{2}\right)\left(\frac{I_0+I_1}{2}\right) \Delta t + \left(\frac{V_1+V_2}{2}\right)\left(\frac{I_1+I_2}{2}\right) \Delta t + \dots + \left(\frac{V_{N-2}+V_{N-1}}{2}\right)\left(\frac{I_{N-2}+I_{N-1}}{2}\right) \Delta t \\ \\ =& \frac{\Delta t}{4}\left[ \vphantom{\frac{}{}} (V_0+V_1)(I_0+I_1) + (V_1+V_2)(I_1+I_2) + ... + (V_{N-2}+V_{N-1})(I_{N-2}+I_{N-1}) \right] \\ \\ =& \frac{\Delta t}{4}\sum^{N-1}_{m=1} (V_{m-1} + V_m)(I_{m-1} + I_m) \\ \\ \end{aligned} $$

\$\endgroup\$
2
\$\begingroup\$

I can read the current and see the voltage, can obviously calculate the instant power

A good start.

but I'm fairly certain that I don't just sum them up over intervals

Well, it is basically summing up power over a time period such as one second to convert watts to watt-seconds and, that equals joules.

What's the best method of calculating the energy I consume through the circuit for the duration that the power is on?

You are almost there apart from your belief. You can calculate instantaneous power and you could low-pass filter that to get average power then integrate or, just start integrating with the raw values of instantaneous power.

One thing to watch though, if your current or voltage is cyclic (and maybe distorted), you should take the appropriate number of sample per second to ensure you capture power correctly. The higher the frequency of your voltage or current (and relevant harmonics), the higher the rate in which you need to calculate instantaneous power.

\$\endgroup\$
2
  • \$\begingroup\$ so if I sample 1 watt at let's say 10Hz, each sample could be representative of 1/10th watt second, summing all 10 samples gives me 1 watt second, etc etc...? That seems a little too simple. And I'm using a simple constant 1 Watt case... \$\endgroup\$ Commented Mar 10, 2023 at 15:43
  • \$\begingroup\$ Average the ten samples to get the watt seconds then accumulate the watt seconds in your MCU. Make sure you don't overrun the storage place during accumulation (integration). \$\endgroup\$
    – Andy aka
    Commented Mar 10, 2023 at 16:11
1
\$\begingroup\$

From the instant power, p(t), you can calculate the average power consumption:

$$ P = \frac{1}{T}\int_0^Tp(t).dt = \frac{1}{T}\int_0^Tv(t).i(t).dt $$

Then, divide by 1000 to get it in kW, and multiply it by hours to get the energy consumption in kWh.

\$\endgroup\$
4
  • \$\begingroup\$ This would be useful, except power consumption varies as the board is being used. \$\endgroup\$ Commented Mar 10, 2023 at 15:39
  • \$\begingroup\$ Do you want to calculate, or do you want to measure? I mean, you can plug some probes and create a few measurement circuits to capture the current and voltage in real-time. Then, put in a micro-controller (Arduino, arm, etc) and use the formula above to calculate power averages over time-samples. \$\endgroup\$ Commented Mar 10, 2023 at 15:57
  • \$\begingroup\$ I'd like to use my onboard processor to calculate as accurately as possible, how much energy I've used. Some functions use more energy than others, so from the look of that equation, I'd have to fit a curve to the data I read, then integrate it? \$\endgroup\$ Commented Mar 10, 2023 at 19:41
  • \$\begingroup\$ Summing and averaging, then multiplying by time gives you exactly that though. It's mathematically equivalent. The trick is to just define the period of time properly for a function and get the average power for only that time. \$\endgroup\$
    – Shredder
    Commented Mar 10, 2023 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.