7.9.8 Data Output: Two Intervals in One Data Table
CRBasic Example 33. Two Data-Output Intervals in One Data Table
'This program example demonstrates the use of two time intervals in a data table. One time
'interval in a data table is the norm, but some applications require two.
'
'A table with two time intervals should be allocated memory as is done with a conditional table:
'rather than auto-allocate, set a fixed number of records.
'Declare Public Variables
Public PTemp, batt_volt, airtempC, deltaT
Public int_fast As Boolean
Public int_slow As Boolean
Public counter(4) As Long
'Declare Data Table
'
'Table is output on one of two intervals, depending on condition.
'Note the parenthesis around the TriggerVariable AND statements.
DataTable(TwoInt,(int_fast AND TimeIntoInterval(0,5,Sec)) OR (int_slow AND _
TimeIntoInterval(0,15,sec)),-1)
Minimum(1,batt_volt,FP2,0,False)
Sample(1,PTemp,FP2)
Maximum(1,counter(1),Long,False,False)
Minimum(1,counter(1),Long,False,False)
Maximum(1,deltaT,FP2,False,False)
Minimum(1,deltaT,FP2,False,False)
Average(1,deltaT,IEEE4,false)
EndTable
'Main Program
BeginProg
Scan(1,Sec,0,0)
PanelTemp(PTemp,250)
Battery(Batt_volt)
counter(1) = counter(1) + 1
'Measure thermocouple
TCDiff(AirTempC,1,mV2_5C,1,TypeT,PTemp,True,0,250,1.0,0)
'calculate the difference in air temperature and panel temperature
deltaT = airtempC - PTemp
'When the difference in air temperatures is >=3 turn LED on and trigger the faster of
'the two data-table intervals.
If deltaT >= 3 Then
PortSet(4,true)
int_fast = true
Else
PortSet(4,false)
int_fast = false
int_slow = true
EndIf
197