"Rainfall Counter" data display

Recommended Posts

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?

Share on other sites

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.

Share on other sites

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.

Share on other sites
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.

Share on other sites
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.

Share on other sites

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).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

×