# Historian On change mode doesn't work correctly in discrete deadband style

**URL:** <https://forum.inductiveautomation.com/t/historian-on-change-mode-doesnt-work-correctly-in-discrete-deadband-style/41275>\
**Category:** Ignition Early Access\
**Created:** [December 7, 2020, 8:04pm UTC](https://forum.inductiveautomation.com/t/historian-on-change-mode-doesnt-work-correctly-in-discrete-deadband-style/41275 "2020-12-07T20:04:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [December 7, 2020, 8:04pm UTC](https://forum.inductiveautomation.com/t/historian-on-change-mode-doesnt-work-correctly-in-discrete-deadband-style/41275/1 "2020-12-07T20:04:04Z")

</div>

Hi,  
I setup a history for some coordinate tags with following setting:  
Deadband Style: Discrete  
Sample mode: On change  
Min Time between Sample: 5 secs  
The tag will receive from GPS device every 3 to 4 sec and tags are constantly changing, so every 5 sec they are logged in the database.

But when I show it in a table the result show that every 5 seconds historian take two sample at exact same time. (even in milsec) I wonder why there two samples taken instead of one?  
I use ignition v8.0.12

 ![History](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/a/0af416724cf88ab4307db4b9fe34464895f7cc11.jpeg)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [December 7, 2020, 8:44pm UTC](https://forum.inductiveautomation.com/t/historian-on-change-mode-doesnt-work-correctly-in-discrete-deadband-style/41275/2 "2020-12-07T20:44:14Z")

</div>

The way these numbers repeat, I’m guessing that latitude and longitude don’t update at quite the same time.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/c/0c23a562c490fbd438a90c153e204119bdeac095.png)

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [December 7, 2020, 8:52pm UTC](https://forum.inductiveautomation.com/t/historian-on-change-mode-doesnt-work-correctly-in-discrete-deadband-style/41275/3 "2020-12-07T20:52:02Z")

</div>

After I get the data I put them to related tag one after each other with system.tag.write().  
By the way it doesn’t make sense to record two sample every 5 sec. What is wrong with my setting here?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [December 7, 2020, 8:58pm UTC](https://forum.inductiveautomation.com/t/historian-on-change-mode-doesnt-work-correctly-in-discrete-deadband-style/41275/4 "2020-12-07T20:58:16Z")

</div>

What do you get if you retrieve each one separately? If each separate tag gives a single point, then it's in the way you're combining it.

> [@nader.chinichian](#):
>
> ...one after each other with system.tag.write()

That doesn't really equate to simultaneous. If this happens at the edge of your sample size, I can see a race condition going on.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [December 7, 2020, 9:02pm UTC](https://forum.inductiveautomation.com/t/historian-on-change-mode-doesnt-work-correctly-in-discrete-deadband-style/41275/5 "2020-12-07T21:02:53Z")

</div>

Consider using _system.tag.storeTagHistory()_ if you really need to keep the timestamps the same.

[https://docs.inductiveautomation.com/display/DOC80/system.tag.storeTagHistory](https://docs.inductiveautomation.com/display/DOC80/system.tag.storeTagHistory)

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [December 7, 2020, 9:17pm UTC](https://forum.inductiveautomation.com/t/historian-on-change-mode-doesnt-work-correctly-in-discrete-deadband-style/41275/6 "2020-12-07T21:17:21Z")

</div>

If I read them separately same will happen twice log each 5 sec.  
I try to change to analog mode and every thing work ok. This is prove that my method is right.  
But for thing like coordinate I need to treat them as discrete and analog doesn’t suit here.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [December 7, 2020, 9:25pm UTC](https://forum.inductiveautomation.com/t/historian-on-change-mode-doesnt-work-correctly-in-discrete-deadband-style/41275/7 "2020-12-07T21:25:07Z")

</div>

Have you tried your min times to something lower than your tag updates?

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [December 7, 2020, 9:33pm UTC](https://forum.inductiveautomation.com/t/historian-on-change-mode-doesnt-work-correctly-in-discrete-deadband-style/41275/8 "2020-12-07T21:33:20Z")

</div>

Yes the same pattern happen again because for example is I set min time to 1 and I update my tag at 4 sec, there is no change in each 4 sec interval so nothing record until 4 sec pass

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [December 8, 2020, 9:32am UTC](https://forum.inductiveautomation.com/t/historian-on-change-mode-doesnt-work-correctly-in-discrete-deadband-style/41275/9 "2020-12-08T09:32:06Z")

</div>

Hi Jordan  
You are right about it except on thing.  
Even I set two tag value with same time stamp when I use as Store mode in table history query, because there are two data available there are two row.  
I wish ignition detect it and simply combine the result into single row if timestamp is equal.
