Hello all, I've been struggling with what should be very simple.
I am building a system for deployment and trying to minimize power usage. Basically, I am trying to do a 1-sec scan during 20min-30min period in a 60min interval, and output the average value during the 20-30min period.
This is the sequence of sampling in the 60 min period
15 min- PortSet (8,1) powers the pump and circulates water int the system. All probes are powered for warm-up as well.
20 min - Flag=1 :Data collection for 10 mins at 1 sec scan rate from all sensors
30 min - Data collection stops. Average is exported to Table1
35 min - PortSet (8,0)- powers off the pump and sesors
*My sensors also sometimes give NAN and it shouldn't be included in the average calculation.
** DataInterval(20,60, Min,10) seems to use the data collected during the first 20 minutes for averaging, rather that 20-60 minute window, am I correct?
This is what I have so far:
--------------------------------------
Dim Rs_6
Public BattV
Public Oxygen
Public Oxystr As String * 200
Public Oxysplit(5) As String
Public Nbytes1
Public Oxytemp
Public AirSat
Public Flag
Units BattV=Volts
Units Oxytemp=Degree C
Units Oxygen=uMol
Units AirSat=%
DataTable (interval,Flag,-1)
DataInterval (20,60,Min,10) 'how to you set the interval so that I am only using the data from 20-30min window
Average(1,Oxygen, FP2, NAN) 'I want to exclude NAN in my average
Minimum(1,Oxygen, FP2, False,1)
Maximum(1,Oxygen, FP2, False,1)
Average(1,AirSat,FP2, False)
Average(1,Oxytemp, FP2, False)
EndTable
BeginProg
SerialOpen(Com1, 9600, 0,0,300)
Scan(1, Sec, 1,0)
SerialInRecord(Com1,Oxystr, &H4D,0,&H0D0A,Nbytes1, 01)
SplitStr(Oxysplit(), Oxystr,"",5,0)
Oxygen=Oxysplit(3)
AirSat=Oxysplit(4)
Oxytemp=Oxysplit(5)
Battery(BattV)
If TimeIntoInterval (15,60, Min) Then
PortSet(8,1)
EndIf
If TimeIntoInterval (20,30, Min) Then
Flag=1 'Control Port 8 is now open and activates the relay. Pump should be running
EndIf
If TimeIntoInterval (30,60, Sec) Then
Flag=0
EndIf
If TimeIntoInterval (32,60, Min) Then
PortSet(8,0)
EndIf
CallTable interval
NextScan
EndProg
-------------
Any help would be greatly appreciated.
Set the datatable flag at 20 min into 60.
Then set flag low after table call at 30 min into 60.
Set datainterval for 30 min into 60.
Also set your disable variables for excliding NAN to var=NAN (like oxygen=nan)