Description

Learn about the hour and event meters that can be used to trace the count or duration of events.

Video recorded using: Ignition 8.1

Transcript

(open in window)

[00:00] In this video, we're going to talk about event meters and hour meters, which are special item modes that can calculate useful meta information about a value coming into the group. Typically, these item modes are used with Boolean items, and can be used to count the number of times the value becomes true, in the case of event meters or calculate the duration of time the value is true in the case of hour meters. They can also be used with numeric values with zero translating to false and all other values translating to true. To demonstrate, I have some Boolean values coming into my historical transaction group. And to keep things simple, they're all tied straight to the same Boolean tag in the tag browser. So the items are pretty much identical apart from the names. I've set the names to reflect what I'd like to make each item show, but I haven't configured any of the items beyond tying them to the Boolean tag and renaming them. So I'll leave the tag value item alone here since I want that to represent the original value on the tag unmodified. We'll skip to the second item here, which is time on.

[01:05] I'll double click on the item to bring up its menu. And once we're in here, we want to find the value mode settings and the mode heading beneath that. My goal for this item is for it to reflect the amount of time in seconds that the tag has spent in the true state. So I'm going to change the mode here to hour meter, which we'll do precisely that. Rather than returning the value on the tag, the item will count up from zero every time the tag is set to true and be reset back to zero every time the tag is set to false. The unit for the count is decided by the units field here. So if I expand the dropdown, we can count up in milliseconds, seconds, minutes, and so on. And finally, since we now have a counter here, I'm going to find the data type in the upper right-hand corner and change it to Int4. So to see this in action, I can click OK at the bottom and then I can save my group. And we'll see that rather than showing our Boolean value, the time on item is counting up from zero.

[02:04] And if I toggle my tag off, we'll see that the counter gets reset to zero. And if I toggle back to true, the count begins again. For our next item, we'll look at a couple of ways of modifying this behavior further. I'll find my way into the total time off item. Double-clicking again to access the menu. And in here, we're going to take a couple of similar steps. I'll set the data type to Int4 and the mode to hour meter. From there, one change I'd like to make is that I want to monitor the time the tag is false rather than the time the tag is true. This change is pretty easy. I just need to check the on zero checkbox. So we'll look for a false or zero values rather than true or non-zero ones. The other change I'd like to make here is that I'd like the counter to not reset when the value goes to true. In essence, I want a cumulative account for the amount of time the value is false while the group is running, rather than just the count of the number of seconds since the tag was last set to false.

[03:07] To do this, I just need to check the retentive checkbox, which means that when the value gets set to true in this case, we'll pause the counter rather than reset it and pick it up at the same place when the tag value goes back to false. So with that done, I can click OK, and then I can save my project and we can see if I toggle the tag a few times, we'll see that the total time off value is sticking between separate runs as we intended. A configuration like this can be useful if we're looking to track something like downtime and uptime durations. We could just configure an hour meter on a status tag just like this. Finally, I'd like to take a look at this total events item. So I'll open it up by double clicking one last time. On this item, I just wanna count the number of times the tag value has transitioned from false to true, rather than calculating a duration. There is a mode suited for this and it's the event meter mode here.

[04:03] This mode will detect and count rising edges on my tag. Meaning changes from false to true or from zero to non zero. If we want to catch transitions in the other direction, meaning from true to false or non zero to zero, we could use the on zero checkbox to flip the logic. Note that the retentive option is not available here since we don't want to reset the counter if the value toggles. In fact our whole objective here is to count the number of times the toggle occurs. Effectively, whereas our meter is useful for tracking among other things uptime and downtime durations, the event meter is useful for counting the number of uptime or downtime events instead. So with that said, I'm just going to use the event meter mode and also take care to once more change my item data type to Int4 so that it can effectively represent a counter. And I'll conclude by clicking OK. And then I'll hit save, our group will start again. And I'll try toggling the tag a couple of times. And as we can see our event counter is increasing as we toggle the tag.

[05:05] That about wraps up our discussion on basic hour and event meters. They are great approach to getting specific metadata about the behavior of numeric or Boolean group items, and can be handy in a variety of group configurations.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.