# Create simple runtime accumulator

**URL:** <https://forum.inductiveautomation.com/t/create-simple-runtime-accumulator/107801>\
**Category:** Ignition\
**Tags:** perspective, scripting, ignition81\
**Created:** [June 25, 2025, 8:14pm UTC](https://forum.inductiveautomation.com/t/create-simple-runtime-accumulator/107801 "2025-06-25T20:14:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![janderson1](https://avatars.discourse-cdn.com/v4/letter/j/439d5e/32.png) [@janderson1](https://forum.inductiveautomation.com/u/janderson1)\
**Post date:** [June 25, 2025, 8:14pm UTC](https://forum.inductiveautomation.com/t/create-simple-runtime-accumulator/107801/1 "2025-06-25T20:14:48Z")

</div>

Hello! I imagine there is a simple solution here, and after reading multiple threads that are close, but not quite the same, I thought I'd ask myself.

I am trying to create a runtime accumulator for a Blower VFD that is not currently being read into the PLC. The client has a future site visit planned to bring the runtime into the logic, but wants something now so they don't need to visit the site themselves to read the meter directly.

The Blower VFD has a boolean tag read by the PLC for when it is ON, and I imagine simply creating a memory type tag that begins accumulating seconds whenever the blower is running, and stops when the blower is off, would be the simplest solution. I understand this would only work when the gateway is up and running, but the client is okay with that for a temporary fix.

Basically- is there an easy way to use ignition scripting to accumulate runtime in seconds (converted to hours) for a memory tag based on when an OPC boolean tag is set to 1?

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 25, 2025, 8:20pm UTC](https://forum.inductiveautomation.com/t/create-simple-runtime-accumulator/107801/2 "2025-06-25T20:20:37Z")

</div>

Do you have the historian module?

---

<div class="post-metadata">

**Author:** ![janderson1](https://avatars.discourse-cdn.com/v4/letter/j/439d5e/32.png) [@janderson1](https://forum.inductiveautomation.com/u/janderson1)\
**Post date:** [June 25, 2025, 8:46pm UTC](https://forum.inductiveautomation.com/t/create-simple-runtime-accumulator/107801/3 "2025-06-25T20:46:04Z")

</div>

Yes, they have the historian module.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 25, 2025, 8:54pm UTC](https://forum.inductiveautomation.com/t/create-simple-runtime-accumulator/107801/4 "2025-06-25T20:54:18Z")

</div>

I like to use the DurationOn from the [system.tag.queryTagCalculations | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-tag/system-tag-queryTagCalculations).

What we have done, is have the boolean running tag historized, and set the history configuration on the tag to look something like this:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/6/86c2889c15bc6073417cfac322be209d6a249536.png)

You should at least get every 15 minutes an entry in the historian that the motor is running or not, and then the DurationOn will give you how long that tag was on.

---

<div class="post-metadata">

**Author:** ![janderson1](https://avatars.discourse-cdn.com/v4/letter/j/439d5e/32.png) [@janderson1](https://forum.inductiveautomation.com/u/janderson1)\
**Post date:** [June 25, 2025, 9:29pm UTC](https://forum.inductiveautomation.com/t/create-simple-runtime-accumulator/107801/5 "2025-06-25T21:29:31Z")

</div>

I will give this a shot! Thank you.

---

<div class="post-metadata">

**Author:** ![janderson1](https://avatars.discourse-cdn.com/v4/letter/j/439d5e/32.png) [@janderson1](https://forum.inductiveautomation.com/u/janderson1)\
**Post date:** [June 26, 2025, 1:55pm UTC](https://forum.inductiveautomation.com/t/create-simple-runtime-accumulator/107801/6 "2025-06-26T13:55:31Z")

</div>

I feel rather silly now.

I fired up Ignition, went to the tag and changed the history to enabled- and then have no idea how to run this "DurationOn" tag calculation you mentioned.

The article you linked shows this:

system.tag.queryTagCalculations(paths, calculations, [startDate], [endDate], [rangeHours], [rangeMinutes], [aliases], [includeBoundingValues], [validatesSCExec], [noInterpolation], [ignoreBadQuality])

Where would I run this? And where is the "DurationOn" method? I'm rather lost, sorry!

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 26, 2025, 2:06pm UTC](https://forum.inductiveautomation.com/t/create-simple-runtime-accumulator/107801/7 "2025-06-26T14:06:57Z")

</div>

So first off, how are you wanting to display this accumulator? That will determine where you call for the data.

In Perspective you can use a [Tag History Bindings in Perspective | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/working-with-perspective-components/bindings-in-perspective/tag-history-bindings-in-perspective#aggregation-mode).

In vision, I would use a gateway timer script at a frequency that is acceptable and update a memory tag with the data.

An example script for a single tag would look like this:

```python
paths = ['[default]Motors/FVNR/C100/MTR/Status/Sts_RunningFwd']

endTime = system.date.now()
startTime = system.date.addDays(endTime, -30)
dataSet = system.tag.queryTagHistory(
	paths=paths, 
	startDate=startTime, 
	endDate=endTime, 
	returnSize=1, aggregationMode='DurationOn'
)

durationSec = dataSet.getValueAt(0,1)

```

The dataSet returned, is a single row with the first column as the startTime, and then each subsequent column as each tag included in the paths array.

---

<div class="post-metadata">

**Author:** ![janderson1](https://avatars.discourse-cdn.com/v4/letter/j/439d5e/32.png) [@janderson1](https://forum.inductiveautomation.com/u/janderson1)\
**Post date:** [June 26, 2025, 2:25pm UTC](https://forum.inductiveautomation.com/t/create-simple-runtime-accumulator/107801/8 "2025-06-26T14:25:18Z")

</div>

You've nailed it- it will be used in Perspective; probably as a simple LED Display with the label "Blower Runtime".

I will try this shortly and get back to you. Thanks again!

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 26, 2025, 2:29pm UTC](https://forum.inductiveautomation.com/t/create-simple-runtime-accumulator/107801/9 "2025-06-26T14:29:24Z")

</div>

Make sure that you are requesting the data at a pace that doesn't overwhelm your database or gateway.

If you have multiple of these, I would move it into a gateway timer script that queries all the ones that you want, and then update a tag for each one so that the perspective views aren't doing this query for each device.
