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.

Get average of last 1-minute of 5-minute cycle


texagg98 May 8, 2017 04:21 PM

I have a gas analysis system where we are sampling six ports.  Each port is activated for five minutes in sequence, but we only want to capture the instrument output for the last minute of that cycle to allow for concentrations to stabilize.

The scan rate is set at 1-s, which is what we want, however when I use a trigger variable for data storage, I can't seem to be able to store the average value at the end of the period.  The time stamp for the average data is at the beginning (minute 4 of the 5 second period) rather that at minute 5.

I can live with 1-s data, but if I can get the logger to average over the 1-min capture period, then it will significantly reduce the post processing effort required.  Any ideas on how to solve this dilemma would be appreciated.

My code is below:

DataTable (Test,DataFlag,-1)
DataInterval(1,1,Min,10)
Sample (1,ChNum,FP2)
Average (5,SeVolt(),FP2)
EndTable


'Main Program
BeginProg
Scan (1,Sec,0,0)


If IfTime (0,30,min) Then
'Prevent data being written to table during first four minutes of measurement cycle
DataFlag=false
'Set sampling ports
WriteIO(&B111111,&B000001)
'Set sample port number
ChNum=90
EndIf

'Initiate data storage to table with DataFlag
If TimeIntoInterval (4,30,Min) Then DataFlag=true

If IfTime (5,30,min) Then
DataFlag=false
WriteIO(&B111111,&B000010)
ChNum=91
EndIf


If TimeIntoInterval (9,30,Min) Then DataFlag=true

If IfTime(10,30,min) Then
DataFlag=false
WriteIO(&B111111,&B000100)
ChNum=70
EndIf


If TimeIntoInterval (14,30,Min) Then DataFlag=true

If IfTime (15,30,min) Then
DataFlag=false
WriteIO(&B111111,&B001000)
ChNum=71
EndIf

If TimeIntoInterval (19,30,Min) Then DataFlag=true

If IfTime(20,30,min) Then
DataFlag=false
WriteIO(&B111111,&B010000)
ChNum=50
EndIf


If TimeIntoInterval (24,30,Min) Then DataFlag=true

If IfTime (25,30,min) Then
DataFlag=false
WriteIO(&B111111,&B100000)
ChNum=51
EndIf

If TimeIntoInterval (29,30,Min) Then DataFlag=true

VoltSe (SeVolt(),5,mV5000,1,1,0,250,1.0,0)

CallTable Test

NextScan
EndProg


smh May 9, 2017 08:30 AM

Not sure which logger/OS you are using but I think if you move the CallTable and VoltSE instructions to the top of your scan you might be better off, setting the DataFlag just before calling the table in the "wrong" minute will cause the average to be calculated early and it's set to false just before the end of the "right" minute so your average instruction isn't being recorded.

I tested with CR1000, latest OS.

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