# Heartbeat Signal in Perspective

**URL:** <https://forum.inductiveautomation.com/t/heartbeat-signal-in-perspective/109124>\
**Category:** General Discussion\
**Tags:** perspective\
**Created:** [July 30, 2025, 6:19am UTC](https://forum.inductiveautomation.com/t/heartbeat-signal-in-perspective/109124 "2025-07-30T06:19:35Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sfatimazahrak](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@sfatimazahrak](https://forum.inductiveautomation.com/u/sfatimazahrak)\
**Post date:** [July 30, 2025, 6:19am UTC](https://forum.inductiveautomation.com/t/heartbeat-signal-in-perspective/109124/1 "2025-07-30T06:19:35Z")

</div>

I have an OPC heartbeta tag that I want to monitor, and display status OK or NOT OK accordingly, based on whether I receive true from the tag after 30 seconds or not. Is there a way to monitor the tag value and using some time function add a script binding with mapping?  
Example case:  
if (time after 30 secs):  
if (heartbeat) == true:  
text = OK  
else:  
text = False

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [July 30, 2025, 7:16am UTC](https://forum.inductiveautomation.com/t/heartbeat-signal-in-perspective/109124/2 "2025-07-30T07:16:26Z")

</div>

Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [July 30, 2025, 7:25am UTC](https://forum.inductiveautomation.com/t/heartbeat-signal-in-perspective/109124/3 "2025-07-30T07:25:37Z")

</div>

> [@sfatimazahrak](#):
>
> based on whether I receive true from the tag after 30 seconds or not

Create an expression tag to monitor the heartbeta(!) tag.

```python
{[~]heartbeat}
&& 
(now() - {[~]heartbeat.Timestamp} > 30000)

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 30, 2025, 12:38pm UTC](https://forum.inductiveautomation.com/t/heartbeat-signal-in-perspective/109124/4 "2025-07-30T12:38:55Z")

</div>

I would monitor the tag's timestamp for being within the last 30 seconds.

---

<div class="post-metadata">

**Author:** ![sfatimazahrak](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@sfatimazahrak](https://forum.inductiveautomation.com/u/sfatimazahrak)\
**Post date:** [July 31, 2025, 7:01am UTC](https://forum.inductiveautomation.com/t/heartbeat-signal-in-perspective/109124/5 "2025-07-31T07:01:53Z")

</div>

Yes, but is there a function for getting the timestamp? .Timestamp doesnt seem to be working. Do i also enable history on the heartbeat signal?

---

<div class="post-metadata">

**Author:** ![sfatimazahrak](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@sfatimazahrak](https://forum.inductiveautomation.com/u/sfatimazahrak)\
**Post date:** [July 31, 2025, 7:21am UTC](https://forum.inductiveautomation.com/t/heartbeat-signal-in-perspective/109124/6 "2025-07-31T07:21:32Z")

</div>

Ok i did get somewhere but I dont understand how to utilize the property. The timestamp returns the exact date and time, and I just need to monitor the seconds. This is what the subtraction is giving me, I dont understand how to make use of it:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/e/eea823a9790c34a78fb970ce4cfa13a3fb659b9c.png)  
Timestamp returns:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/9/9993182bba23cd7587c19e728457f86fc16b8377.png)  
Now returns:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/3/9397ebab834c662a6f6ff9c362d7a2e7dc49b819.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [July 31, 2025, 7:30am UTC](https://forum.inductiveautomation.com/t/heartbeat-signal-in-perspective/109124/7 "2025-07-31T07:30:40Z")

</div>

> [@Transistor](#):
>
> `(now() - {[~]heartbeat.Timestamp} > 30000)`

Did you try what I suggested? It will return `true` if the timestamp is older than 30,000 ms (30 s).  
That's what you asked for, but I don't think that's what you want.

---

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [July 31, 2025, 7:34am UTC](https://forum.inductiveautomation.com/t/heartbeat-signal-in-perspective/109124/8 "2025-07-31T07:34:41Z")

</div>

> [@Transistor](#):
>
> That's what you asked for, but **I don't think that's what you want**.

@sfatimazahrak what is your current objective? Try explaining it so we can try to help you

---

<div class="post-metadata">

**Author:** ![sfatimazahrak](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@sfatimazahrak](https://forum.inductiveautomation.com/u/sfatimazahrak)\
**Post date:** [July 31, 2025, 9:32am UTC](https://forum.inductiveautomation.com/t/heartbeat-signal-in-perspective/109124/10 "2025-07-31T09:32:34Z")

</div>

I did, but the timestamp being returned is way larger, which is why Im confused. What im trying to do is monitor the value of the tag (RM\_VLD\_LLM), its a heartbeat signal sending a 1 after every 30 secs. I want to use that to display the status of the signal as text, i.e if heartbeat gives me 1 after 30 secs I want to display OK, otherwise i want to display FAULT. The condition needs to monitor the tag for every 30 secs, I have enabled history on the tag and given it a sampling rate of 30 secs.  
Essentially, every 30 secs I wanna check for a heartbeat and display the status accordingly.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [July 31, 2025, 9:50am UTC](https://forum.inductiveautomation.com/t/heartbeat-signal-in-perspective/109124/11 "2025-07-31T09:50:09Z")

</div>

> I did, but the timestamp being returned is way larger, which is why I'm confused.

A tag timestamp is the number of milliseconds since 1970-01-01 00:00:00, the dawn of Unix time. The timestamp for today will be a large number.

> What im trying to do is monitor the value of the tag (RM\_VLD\_LLM), its a heartbeat signal sending a 1 after every 30 secs.

What you should be doing is sending an alternating 0 - 1 - 0 - 1 ... signal, changing every 30 s.

> I want to use that to display the status of the signal as text, i.e if heartbeat gives me 1 after 30 secs I want to display OK, otherwise i want to display FAULT.

No, what you want is that if the tag timestamp is less than 30 s old you want the monitor tag to go `true`, else `false`.

> The condition needs to monitor the tag for every 30 secs,

No, it needs to monitor continuously - probably at the default rate of 1000 ms.

> I have enabled history on the tag and given it a sampling rate of 30 secs.

History is for recording history. You're not interested in history. You're interested in now. Disable the history.

> Essentially, every 30 secs I wanna check for a heartbeat and display the status accordingly.

Create an expression tag, say `heartbeatGood`, to monitor the heartbeat tag.  
Set the expression to,

```python
(now() - {[~]heartbeat.Timestamp}) < 30000

```

This tag will now turn `true` if the last heartbeat change was within the last 30 s and `false` if it doesn't change for more than 30 s.

On the label component text property create an expression binding:  
`if({[~]heartbeatGood, 'OK', 'FAULT')`

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 31, 2025, 12:18pm UTC](https://forum.inductiveautomation.com/t/heartbeat-signal-in-perspective/109124/12 "2025-07-31T12:18:22Z")

</div>

Is this tag coming from an external OPC server, like one built-in to a PLC? If so, that device's clock is the source of the timestamp, and if wrong, it will be broken.

---

<div class="post-metadata">

**Author:** ![rpulliam](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rpulliam/32/76557_2.png) [@rpulliam](https://forum.inductiveautomation.com/u/rpulliam)\
**Post date:** [July 31, 2025, 12:46pm UTC](https://forum.inductiveautomation.com/t/heartbeat-signal-in-perspective/109124/13 "2025-07-31T12:46:46Z")

</div>

> [@sfatimazahrak](#):
>
> I did, but the timestamp being returned is way larger

The number is elapsed time in milliseconds. Between your two screenshots there is 1hour 19min and 7 sec difference between the timestamps. That's 4,747,000 total milliseconds, which is close to what you got by a couple of minutes. Just take the result and divide by 1000 if you want it in seconds.
