Sign in to follow this  
Followers 0
Ptolemies

Derived tags computation problem

4 posts in this topic

Hi guys!

I have a problem with derived tags in factorytalk view. I used the derived tags to read an input tag (unit in seconds), and convert it to HH:MM:SS format. The problem is, when I display the values using text display(insert numeric variable), the HH and MM are rounded up instead of being rounded down. Is there an option to round down the results? Thanks!

 

Edited by Ptolemies

Share this post


Link to post
Share on other sites

Is this for display purposes only? If so, you don't need to use Derived Tags.

Let's assume your tag (in seconds) is 'My_Seconds'

Create 3 numeric displays (2 digits each) separated by colons (text objects)

Put the following formulas in each of the 3 numeric displays...

My_Seconds%86400/3600       Hours

My_Seconds%3600/60              Minutes

My_Seconds%60                        Seconds

If by chance you need to display days too (such as down time indicator),

My_Seconds/86400                   Days       (Note, this will involve rounding but if used with the 3 values above shouldn't create any problems.)

 

If you DO need the data used elsewhere, you could employ these formulas with Derived Tags and there won't be rounding problems.

Share this post


Link to post
Share on other sites
5 hours ago, Filthy McNasty said:

Create 3 numeric displays (2 digits each) separated by colons (text objects)

The reason why I used derived tags is to insert and format all text within a single text display. I think it's a pain arranging the numeric displays and the text displays, because what you see when editing is not exactly displayed in the client. But thank you for the suggestion, I might just make it like this.

 

EDIT: It still rounds up when I put it on derived tags. However, using it on the numeric display doesn't. I will stick to using the numeric display and just take my time in editing. Thank you very much!

Edited by Ptolemies

Share this post


Link to post
Share on other sites

Actually solved the rounding up problem by using a rather complex expression for Hours and Minutes. Just gonna leave it here if someone else might need it. 

For Hours:

If (My_Seconds % 3600) / 60 >= 30
Then 
If My_Seconds / 3600 - 1 < 0
Then 0
Else My_Seconds / 3600 - 1
Else My_Seconds / 3600

For Minutes:

If My_Seconds % 60 > 30
Then 
If (My_Seconds % 3600) / 60 - 1 < 0
Then 0
Else (My_Seconds % 3600) / 60 - 1
Else (My_Seconds % 3600) / 60

 

Also, tweaked the expression for Hours, so that it will continue to count after 24 hrs.

Cheers.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0