I am attempting to take an average reading over 30 seconds, once every 5 minutes. I am new to CRBasic, and I am a little confused about the sstructure of the scan and the data interval for the table. Which of these should I be adjusting(or both?) to get my desired outputs?
Thank you in advance.
I hope i have interpreted your requirement corrctly. The following shows the sensors are measured every1s. An average of both measurements is taken every 30s. This is only calculated and put in the output table depending on the state of the public variable "TorF".
This should get what you need or at least put you in the right direction :-
Public PTemp, Batt_volt
Public TorF As Boolean 'Define Data Tables
DataTable (Test,TorF,-1) 'TorF decides if the table is output or not
DataInterval (0,30,Sec,10)
Average (1,Batt_volt,FP2,False)
Average (1,PTemp,FP2,False)
EndTable
'Main Program
BeginProg
Scan (1,Sec,0,0)
PanelTemp (PTemp,15000)
Battery (Batt_volt)
If IfTime (0,5,Min) Then
TorF = True
Else
TorF = False
EndIf
CallTable Test
NextScan
EndProg
Thank you, this is clear! An additional question is if there is any way to only power the sensors for the 30 seconds of data collection?