I am working on PI process book to detect Flat line i.e. a constant value for some time for ex last 10 min. Is there any function in process book which can directly detect it or I have to do VB coding for it. Please suggest.
You can create a data set inf ProcessBook where you can check if the tag is not updated. If it is not updated then that data set value can be used on a trend or on a multi state indicator on your ProcessBook Display. not sure if you have PI AF but the PI notifications is one good option to track the flat lines and this can even notify you through and email and also in ProcessBook.
Just to echo your response, both Data sets and AF are good approaches, I think the best approach depends on what you are aiming for exactly. Here are some thoughts on each:
If you want to be able to see in processbook whether or not a tag has flat lined then you can use a Data set as you mention, for example, something like this:
IF TagMax('Sinusoid','*-10m','*') = TagMin('Sinusoid','*-10m','*') THEN "No Change" ELSE "Change"
Which will show "Change" if there has been a change in the tag, or "No Change" otherwise. Note that this approach does not differentiate between constant values over a time range, and no data over the time range.
This approach is simple, and it is easily seen in Processbook displays. However, it has the disadvantage that it can only be used in Processbook and you can't make use of other parts of the PI system like Notifications which could be useful here.
The HasChanged() function returns True if an attribute has changed since the time specified, and False otherwise, so you could use something like:
The big advantage of this approach is that you can leverage the scalability/templatisation of AF as well as integrate this with features such as notifications depending on the importance. You can also historise the values so that you can easily look at past outages.
Why not just trend the data?
The use of a Dataset in PI Processbook is an easy way to test for a flat line. Datasets are available within PI Processbook and you would not need to do any VBA.
You could also try something like the following in a Dataset (select Value):
if tagval('cdt158') = tagval('cdt158','*-10m') then "Possible flatline for tag 'cdt158' " else " "
You can then remove the check for the Trace Format > select Pen > Display Format > uncheck the Tag Name. This means that on the display you will not see the text until it triggers for a possible flatline (it is unlikely that the point has the same value now and also 10 minutes ago with updates in between but it is possible).
It seems a relatively short time (10 minutes) to be checking for a flat line but I assume the data is updating very fast. Do you have a large exception setting for this point? If you need to be assured of frequent updates you could turn off exception and get possibly more data through.
Did any of the suggestions in this thread help with your request? If we can assume your question answered, please help us by selecting the [Correct Answer].
Retrieving data ...