Jump to content

Recommended Posts

Posted

Hello,
I have a rain bucket to monitor every 0.1mm of rainfall. I would like to display how much rain there has been within the last 24 hours, 7 days and month.

I thought the best way might be to use a data table and 'insert row' which would push out old values, but to then acquire the sum of the data table is a convoluted process. 

Any suggestions on how I could achieve my goal?

Posted

Lifo table, you could pretty easy build a UDFB that took as a "function in" the # of rows that you wanted to SUM the specified data, then with the help of an increment run through each row and sum to a temp local variable, then move that to function out and reset the increment. You could then just change the # of rows (which would be at a fixed sample rate) to get your 24h, 7d, 1M Function Outs.

Posted

Getting the values in to the data table is easy. Extracting it back out then using a formula to calculate the SUM of all the values requires a lot of logic. I guess sometimes there just no easy way hey.. 

 

A 'SUM' function that totals up the values within a data table would be nice. 

Posted
4 hours ago, wapcs said:

Extracting it back out then using a formula to calculate the SUM of all the values requires a lot of logic.

Read value and add to sum, then increment a counter to read next value and so on. Shouldn't be a massive code.

You can use "Jump to Region" to loop it so it is done in a single scan.

Posted
7 hours ago, Isakovic said:

Read value and add to sum, then increment a counter to read next value and so on. Shouldn't be a massive code.

You can use "Jump to Region" to loop it so it is done in a single scan.

This ^^

I think this could be done in less than 10 rungs. One idea of process flow is:

 

Function In: Last Row to read

Local Variable: Value1

variable SumTotal = 0;

RowIndex = 0

Do until RowIndex = last row to read

Get Value from current row index (built in function block)  and move it to local variable (store)

sum (SumTotal + Value1)

Index RowIndex

Loop

SumTotal = Function Out.

 

 

 

 

 

Posted

Or simply use three different tags, one for each period, updating (SUM) them in each scan or in a base time. This way, you have instant values for all your periods. Of course, you will need to reset those tags at the right time (daily, weekly, monthly).

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
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.