Skip to main content
deleted 373 characters in body
Source Link

How to make your own coulomb counter (Amp*hours [Ahr] meter, or Watts*hours [Whr] energy meter) with an Arduino

Quick summary:

Jump straight down to the "Full coulomb counter example in code" section if you just want the final answer.

Details

A. Making the coulomb counter as good as possible

ExtraB. Extra: when is trapezoidal integration most beneficial?

You might call the following list my "5 hypotheses about the benefits of trapezoidal integration".

  1. The time sampling rate is super low.
  2. The rate of change of readings (ie: their derivative, or slope) is super high.
  3. The readings consistently have a rising slope (rectangular integration _under_estimates the area in this case) OR a consistently falling slope (rectangular integration _over_estimates in this case).
  4. When you care about real-time readings in this instant, not just overall trends or averages. This is because trapezoidal integration instantly removes overestimation and underestimation error which can accumulate over short periods but then "de-accumulates", or is negated, over long periods, when the opposite slope occurs in the data.
  5. [This may apply only when there is jitter in the sample rate--see @Edgar Bonet's comment here] When the readings consistently rise at a different rate than thethey fall, as this results in asymmetric accumulation of error. This means that the rectangular integration error accumulated by the values rising distance delta_y will NOT be fully negated by error in the opposite direction when the values fall distance delta_y. Therefore, even over long periods, rather than seeing the error negated, it will accumulate more and more over time. [Note: I'd need to analytically/numerically play with this hypothesis for a while to prove it conclusively to myself, but I'm pretty sure it is correct].

Full coulomb counter example in code:

Full coulomb counter example in code:

References:

References:

See also:

See also:

Extra: when is trapezoidal integration most beneficial?

  1. The time sampling rate is super low.
  2. The rate of change of readings (ie: their derivative, or slope) is super high.
  3. The readings consistently have a rising slope (rectangular integration _under_estimates the area in this case) OR a consistently falling slope (rectangular integration _over_estimates in this case).
  4. When you care about real-time readings in this instant, not just overall trends or averages. This is because trapezoidal integration instantly removes overestimation and underestimation error which can accumulate over short periods but then "de-accumulates", or is negated, over long periods, when the opposite slope occurs in the data.
  5. When the readings consistently rise at a different rate than the fall, as this results in asymmetric accumulation of error. This means that the rectangular integration error accumulated by the values rising distance delta_y will NOT be fully negated by error in the opposite direction when the values fall distance delta_y. Therefore, even over long periods, rather than seeing the error negated, it will accumulate more and more over time. [Note: I'd need to analytically/numerically play with this hypothesis for a while to prove it conclusively to myself, but I'm pretty sure it is correct].

Full coulomb counter example in code:

References:

See also:

How to make your own coulomb counter (Amp*hours [Ahr] meter, or Watts*hours [Whr] energy meter) with an Arduino

Quick summary:

Jump straight down to the "Full coulomb counter example in code" section if you just want the final answer.

Details

A. Making the coulomb counter as good as possible

B. Extra: when is trapezoidal integration most beneficial?

You might call the following list my "5 hypotheses about the benefits of trapezoidal integration".

  1. The time sampling rate is super low.
  2. The rate of change of readings (ie: their derivative, or slope) is super high.
  3. The readings consistently have a rising slope (rectangular integration _under_estimates the area in this case) OR a consistently falling slope (rectangular integration _over_estimates in this case).
  4. When you care about real-time readings in this instant, not just overall trends or averages. This is because trapezoidal integration instantly removes overestimation and underestimation error which can accumulate over short periods but then "de-accumulates", or is negated, over long periods, when the opposite slope occurs in the data.
  5. [This may apply only when there is jitter in the sample rate--see @Edgar Bonet's comment here] When the readings consistently rise at a different rate than they fall, as this results in asymmetric accumulation of error. This means that the rectangular integration error accumulated by the values rising distance delta_y will NOT be fully negated by error in the opposite direction when the values fall distance delta_y. Therefore, even over long periods, rather than seeing the error negated, it will accumulate more and more over time. [Note: I'd need to analytically/numerically play with this hypothesis for a while to prove it conclusively to myself, but I'm pretty sure it is correct].

Full coulomb counter example in code:

References:

See also:

added 152 characters in body
Source Link
added 600 characters in body
Source Link
added 24 characters in body
Source Link
Loading
fix some minor bugs in the operation of the run_coulomb_counter() func
Source Link
Loading
fix some minor bugs in the operation of the run_coulomb_counter() func
Source Link
Loading
added 10 characters in body
Source Link
Loading
added 9 characters in body
Source Link
Loading
added 604 characters in body
Source Link
Loading
added 889 characters in body
Source Link
Loading
added 17 characters in body
Source Link
Loading
added 14645 characters in body
Source Link
Loading
deleted 5 characters in body
Source Link
Loading
added 4 characters in body
Source Link
Loading
Source Link
Loading