Support Forums
Totalizing analog calc within time interval

So i have an analog calculation tag that is logging data based upon the whole day. i need to to grab two values from this day, these values are from 6am- 2pm and 5:15pm-2am. What is the best way to do this? i have tried using totalizers, logging tags, triggers, history stats, but no luck. I have two digital tags setup for each shifts. They output on or off depending on if the current time is in-between the two time intervals mentioned above. How can i use these digital tags to read a tag value based on if they are high/low and reset when the new interval starts. Example: Digital tag goes from low to high --> data logged --> Digital tag goes from high to low ---> value stops logging but doesnt reset ---> Digital tag goes from low to high ---> value resets to zero and begin logging until the digital tag goes from high to low ---> constantly repeat this process.

Any help or guidance is appreciated

So i have an analog calculation tag that is logging data based upon the whole day. i need to to grab two values from this day, these values are from 6am- 2pm and 5:15pm-2am. What is the best way to do this? i have tried using totalizers, logging tags, triggers, history stats, but no luck. I have two digital tags setup for each shifts. They output on or off depending on if the current time is in-between the two time intervals mentioned above. How can i use these digital tags to read a tag value based on if they are high/low and reset when the new interval starts. Example: Digital tag goes from low to high --> data logged --> Digital tag goes from high to low ---> value stops logging but doesnt reset ---> Digital tag goes from low to high ---> value resets to zero and begin logging until the digital tag goes from high to low ---> constantly repeat this process. Any help or guidance is appreciated

Based on your shifts having downtime between each, couldn't you reset your Totalizers when both shifts are false (ie: 1400 to 1715 and 0200 to 0600). You can also set a parameter expression in the Zero Cut-off to make that value high in cases where you want to ensure you do not log data to the totalizer.

Another approach would be to create a custom tag type for this which would allow you to create more specific cases.

Based on your shifts having downtime between each, couldn't you reset your Totalizers when both shifts are false (ie: 1400 to 1715 and 0200 to 0600). You can also set a parameter expression in the Zero Cut-off to make that value high in cases where you want to ensure you do not log data to the totalizer. Another approach would be to create a custom tag type for this which would allow you to create more specific cases.

Trihedral Engineering Ltd.

Ive been playing with the zero cut off and it looks like it will be the solution to my problem.. how can i write and expression to that? would it be via the parameter expression mentioned? any guidance on how that can be done?

Ive been playing with the zero cut off and it looks like it will be the solution to my problem.. how can i write and expression to that? would it be via the parameter expression mentioned? any guidance on how that can be done?
edited Nov 30 '23 at 3:28 pm

You can right click on the cell and select parameter expression. An expression window will pop up. First deselect that the expression should only run on startup. then you will likely want a ternary expression in the format of:

[shiftA] ? 0 : 100

The expression above says that if a tag names shiftA in the same place in the tag tree is true or 1 then set the zero cutoff to 0, else set the zero cutoff to 100 (or something outside of the possible rate)

Note that the expression window has an expression builder assistant button on the right side of the window. You can use that to help get going with custom expressions.

I hope that helps.

You can right click on the cell and select parameter expression. An expression window will pop up. First deselect that the expression should only run on startup. then you will likely want a ternary expression in the format of: ```` [shiftA] ? 0 : 100 ```` The expression above says that if a tag names shiftA in the same place in the tag tree is true or 1 then set the zero cutoff to 0, else set the zero cutoff to 100 (or something outside of the possible rate) Note that the expression window has an expression builder assistant button on the right side of the window. You can use that to help get going with custom expressions. I hope that helps.

Trihedral Engineering Ltd.

In another comment, it was noted that you may not want both to reset. For that I made a totalizer for each shift and then added a third calculation tag (for display purposes) which sums the two values. Since one should always read 0 the total should always only show the current or last shift.

In another comment, it was noted that you may not want both to reset. For that I made a totalizer for each shift and then added a third calculation tag (for display purposes) which sums the two values. Since one should always read 0 the total should always only show the current or last shift.

Trihedral Engineering Ltd.

Dave,

so i have it functioning how I want when i manually manipulate the tags, but when i write the expression to "automate" the function, it disregards the value in zero cutoff and does what it wants. If i do the same thing as the function manually, it works as should.. could this be a bug?

For example i will manually turn my trigger off and set the cut off to be above the totalized value and it will stop, then when i manually turn the trigger on and set cutoff to zero it resets and starts totalizing again as it should. Using an expression to do exactly what i do manually completely disregards what is in the zero cutoff and continues to totalize.

Maybe i'm using the zero cut off incorrectly?

From my understanding if the zero cutoff is above the totalized value then it should stop totalizing, at least thats what it does when i manual execute the function.

Dave, so i have it functioning how I want when i manually manipulate the tags, but when i write the expression to "automate" the function, it disregards the value in zero cutoff and does what it wants. If i do the same thing as the function manually, it works as should.. could this be a bug? For example i will manually turn my trigger off and set the cut off to be above the totalized value and it will stop, then when i manually turn the trigger on and set cutoff to zero it resets and starts totalizing again as it should. Using an expression to do exactly what i do manually completely disregards what is in the zero cutoff and continues to totalize. Maybe i'm using the zero cut off incorrectly? From my understanding if the zero cutoff is above the totalized value then it should stop totalizing, at least thats what it does when i manual execute the function.
edited Nov 30 '23 at 4:30 pm

I got it to work! I had to uncheck "Optimize to only evaluate at tag initialization" within the tag parameter expression, thank you for steering me in right direction. If i have anymore issues with this i will certainly reply in this chain. Thanks again!

I got it to work! I had to uncheck "Optimize to only evaluate at tag initialization" within the tag parameter expression, thank you for steering me in right direction. If i have anymore issues with this i will certainly reply in this chain. Thanks again!
159
6
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft