# How to compare 2 data sets with either an integral or derivative

**URL:** <https://discourse.nodered.org/t/how-to-compare-2-data-sets-with-either-an-integral-or-derivative/59401>\
**Category:** General\
**Created:** [5 March 2022 16:21 UTC](https://discourse.nodered.org/t/how-to-compare-2-data-sets-with-either-an-integral-or-derivative/59401 "2022-03-05T16:21:34Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 March 2022 21:23 UTC](https://discourse.nodered.org/t/how-to-compare-2-data-sets-with-either-an-integral-or-derivative/59401/21 "2022-03-07T21:23:51Z")

</div>

> [@bkenobi](#):
>
> Obviously that won't work if the value is 65533 for hours and then all of a sudden the furnace kicks on and spins the wheel 20 times in a minute

Not perfectly, but a lot better than assuming zero or 1.3kW.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 March 2022 21:24 UTC](https://discourse.nodered.org/t/how-to-compare-2-data-sets-with-either-an-integral-or-derivative/59401/22 "2022-03-07T21:24:36Z")

</div>

> [@bkenobi](#):
>
> I can use that to determine if I can glom the 65533 and the next real reading together to mean anything. My guess is no

My guess it will be better, but not perfect.

---

<div class="post-metadata">

**Author:** ![bkenobi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bkenobi/32/59825_2.png) [@bkenobi](https://discourse.nodered.org/u/bkenobi)\
**Post date:** [7 March 2022 22:35 UTC](https://discourse.nodered.org/t/how-to-compare-2-data-sets-with-either-an-integral-or-derivative/59401/23 "2022-03-07T22:35:12Z")

</div>

I'll give it a try and update when I get a chance to figure out a method that works. I'm thinking keeping track of the gap if it maxes out and then only write when impulses increments. Presumably I should have a real value for gap if impulses increments so won't have to look at 2 values. Probably best to look at the data and let it guide me. Since I'm now recording gap directly, I can try some things on the old data in excel to see what matches and then implement something in NR.

---

<div class="post-metadata">

**Author:** ![bkenobi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bkenobi/32/59825_2.png) [@bkenobi](https://discourse.nodered.org/u/bkenobi)\
**Post date:** [9 March 2022 19:42 UTC](https://discourse.nodered.org/t/how-to-compare-2-data-sets-with-either-an-integral-or-derivative/59401/24 "2022-03-09T19:42:49Z")

</div>

It's too bad the kWh (impulses) isn't supplied at a higher rate. Looking at the data from the kW (gap) and kWh.derivative the curves look pretty good. But, the lower fidelity kills it's ability to be used directly. I suspect using a micro controller to send a message each time the wheel spins would give an excellent combination of high fidelity instantaneous usage as well as overall consumption. If I go beyond and build my own, I'm going to focus on that!

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/b/2b288595bb1762985adabbd52ed9dbed46088bcc.png)

The interesting thing I'm seeing with the impulses data is that the reader only outputs in increments of 4 (0, 4, 8, 16, etc). The data is the total pulses seen, but the delta appears to always be incremented by a factor of 4. That seems pretty odd. It's not an issue for this question, but something that I'll have to test by firing up a high load and manually counting wheel rotations to confirm.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 May 2022 19:43 UTC](https://discourse.nodered.org/t/how-to-compare-2-data-sets-with-either-an-integral-or-derivative/59401/25 "2022-05-08T19:43:46Z")

</div>

Closed on 8 May 2022 19:43 UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/how-to-compare-2-data-sets-with-either-an-integral-or-derivative/59401.md?page=1)
