Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

CR1000 AvgRun Function help


Powers91 Jun 9, 2011 03:26 PM

Hello, Im having diffiulties using the Average Run function.

I need to make an alarm that will send an email whenever the Average Wind Speed is greater than 36 km/h over the last hour. The wind speeds are collected every 10 minutes, so I would need to calculate the average of the last 6 readings.

According to the manual, the syntax for AvgRun is:
AvgRun(Dest, Reps, Source, Number)

I am not sure what to put for destination, since it is only an alarm, I dont think I need an output.
Also, I am not sure of the difference between Reps and Number.

Any help would be greatly appreciated. Thanks!


Dana Jun 10, 2011 07:40 PM

The parameters for AvgRun are explained in the CRBasic help, and an example program is provided.

Based on the information you provided, I would think the instruction would look something like the following:

AvgRun(Dest, Reps, WindSpeed, 6)

Dest = the variable in which the results are stored.
Reps = Leave at 1 -- unless you have multiple wind sensors for which you want to calculate a running average.
Windspeed -- use whatever is the name of the variable you want to calculate the running avg for.
6 = the number of values to include in the running avg.

Dana W.


Powers91 Jun 13, 2011 02:37 PM

Thanks for the response! Can you show me where to find CRBasic help? I can't seem to find it on the website.


jra Jun 13, 2011 03:12 PM

Take a look at the CRBasic Help Tutorial from here:
http://www.campbellsci.com/19_1_773


Dana Jun 13, 2011 07:35 PM

CRBasic is shipped with our software packages (LoggerNet, PC400, RTDAQ). The help is included with the application.

Dana W.


Powers91 Jun 14, 2011 06:36 PM

Thank you.
However, I need to connect this AvgRun function with an alarm, and I only see the Alarm option in RMTC Pro Dev. Unfortunately, the alarm function here only takes one piece of data, whereas I need the average of the last 6.

Do you know a way around this?


IslandMan Jun 15, 2011 02:02 AM

Take a look at the "Expression" help in RTMCPro. AvgRun returns a running average of your data for use in the Alarm and you can specify the count.


Powers91 Jun 15, 2011 02:16 PM

So, is it possible to create an alarm that takes a running average of the last 6 measurements WITHOUT using CRBasic editor?

Under "general" in basic alarm properties, can I put the AvgRun function there under 'select data'?
In this case, would the parameters still be the same?

Thanks


Powers91 Jun 15, 2011 02:26 PM

OH, alright I just the AvgRun function and it says the syntax is AvgRun(Value, Count)

If i select the wind speed data for Value, and 6 for count, just to clarify, will it average the LAST 6 values for the wind speed?

EDIT: I just put

AvgRun("Server:CR1000.Table1.WS_kph_S_WVT",6) within the select data option of the alarm. I set the alarm to make a sound if the value exceeds 14.

I manually checked the average of the last 6 results which are:
12.68
14.01
11.46
10.65
14.32
14.87

Avg: 12.998
For some reason, even though this average is below 14, the alarm still sounded. When I had changed the option to >15, it didnt sound at all. Is there something wrong with my syntax?

* Last updated by: Powers91 on 6/15/2011 @ 8:45 AM *


Powers91 Jun 17, 2011 12:56 PM

Anyone?

It seems despite putting in the count, my AvgRun function still only takes the last value in the dataset.

Any help on this issue will be greatly appreciated!

* Last updated by: Powers91 on 6/17/2011 @ 8:32 AM *


tmecham Jun 17, 2011 08:33 PM

There was an AvgRun issue that was fixed in RTMC v3.2. What version are you running?


Powers91 Jun 20, 2011 02:13 PM

I am running version RTMC Pro version 3.1 unfortunately.

Is there another function you know of that will help me accomplish the same task?


tmecham Jun 20, 2011 02:24 PM

There is a free patch available here.

http://www.campbellsci.com/downloads


Powers91 Jun 20, 2011 05:27 PM

The patch says I need to already have VisualWeather installed for it to work. However, I am using LoggerNet 4.0 to obtain the data. Is there another patch for this?


ChipsNSalsa Jun 20, 2011 06:46 PM

If you started the project and left the project running for an hour the calculation would then be correct from that point on as long as the project remained running. By default RTMC only considers the last record in the table when the project is started. To get it to consider older data you need to use one of the "StartRelative..." function. Here's an example equation for getting the average temperature in degrees F for the last 6 hours of an hourly table:

StartRelativeToNewest(6*nSecPerHour,OrderCollected);AvgRun("Server:Logan.OneHour.AirTemp_Avg",6)*1.8+32

Yours should probably look something like this:

StartRelativeToNewest(1*nSecPerHour,OrderCollected);AvgRun("Server:CR1000.Table1.WS_kph_S_WVT",6)


Powers91 Jun 20, 2011 07:26 PM

^Thank you so much! I think it works now :)

Log in or register to post/reply in the forum.