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.

Avgrun


NP Dec 18, 2013 09:19 AM

Hello,

Here's a very simple thing I'm trying to do with A CR1000:

Make a measurement 'Meas' from an analog 4-20 mA sensor and fill a table of this raw measurement every second - no probs

Make a simple 15 sec average of that same measurement every minute (from MM-7sec to MM+7sec) and store those averaged values every minute in another table

Ideally I would like the timestamp of each average to be set a the round minute instead of at MM:07

I have tried with the Avgrun function which seem to be the best one to use, but the programm below returns an "AvgTimeMeas" table that isn't what I'm looking for

In fact AvgMeas doesn't seem to be a simple 15 measurements average and is above my values stored in Meas

What am UI doing wong here ?


Public Meas, AvgMeas

DataTable(RealTimeMeas,True,-1)
DataInterval(0,1,Sec,10)
Sample(1,Meas,Float)
EndTable

DataTable(AvgTimeMeas,True,-1)
Sample(1,AvgMeas,Float)
EndTable


BeginProg
Scan(1,sec,1,0)
VoltDiff(Meas,1,mV2500,5,True,0,_50Hz,0.625,-250)

CallTable(RealTimeMeas)

If IfTime(7,60,sec) Then
AvgRun (AvgMeas,1,Meas,15)
CallTable(AvgTimeMeas)
EndIf

NextScan


NP Dec 18, 2013 03:06 PM

Okay, without the IfTime and a dataInterval in the table instead it's working, however is there a more efficient way of doing this ?

Also how to timestamp the averaged data at MM:00 (what the average represents) instead of MM:07 (when the average is done) ?


Public Meas, AvgMeas

DataTable(RealTimeMeas,True,-1)
DataInterval(0,1,Sec,10)
Sample(1,Meas,Float)
EndTable

DataTable(AvgTimeMeas,True,-1)
DataInterval(7,60,Sec,10)
Sample(1,AvgMeas,Float)
EndTable


BeginProg
Scan(1,sec,1,0)
VoltDiff(Meas,1,mV2500,5,True,0,_50Hz,0.625,-250)

CallTable(RealTimeMeas)

AvgRun (AvgMeas,1,Meas,15)
CallTable(AvgTimeMeas)

NextScan


Sam Dec 24, 2013 01:39 AM

It doesn't make sense to have a measurement that is stored at MM:07 to be timestamped MM:00. If you want a 15 second average with a timestamp of MM:00, then let it be the average of 15 seconds of measurements before the even minute. Otherwise the value is stored 7 seconds after the minute and will be timestamped as such. You can strip off the seconds with post processing.

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