Specifications
Section 11. Programming Resource Library
11-35
EXAMPLE 11.10-1 lists CRBASIC code that uses TrigVar() rather than
DataIn
terval() to trigger data storage. TABLE 11.10-1 shows data produced by
the exam
ple code.
EXAMPLE 11.10-1. Using TrigVar to Trigger Data Storage
In this example, the variable “counter” is incremented by 1 each scan. The data table is called every
scan, which includes the Sample(), Average(), and Totalize() instructions. TrigVar is true when
counter = 2 or counter = 3. Data is stored when TrigVar is true. Data stored are the sample, average,
and total of the variable counter, which is equal to 0, 1, 2, 3, or 4 when the data table is called.
'CR1000 Series Datalogger
Public counter
DataTable (Test,counter=2 or counter=3,100)
Sample (1,counter,FP2)
Average (1,counter,FP2,False)
Totalize (1,counter,FP2,False)
EndTable
BeginProg
Scan (1,Sec,0,0)
counter = counter+1
If counter = 5 Then
counter = 0
EndIf
CallTable Test
NextScan
EndProg
TABLE 11.10-1. Data Generated by Code in EXAMPLE 11.10-1