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.

Event based data table


FrederickleRoux Jul 27, 2011 10:57 AM

Anyone know how to feed samples to a data table base on a start event and output the maximum when a stop event is reached. DataInterval can not be used since the period is variable, something else is needed to flag the buffering of measurements and finally flag the record output(and max calculation). Thanks.


Dana Jul 27, 2011 06:11 PM

Hello,

Have you looked at the DataEvent instruction in the CRBasic Help?

I think this will do what you are asking.

Dana W.


jra Jul 27, 2011 09:28 PM

Frederick,
DataEvent, by itself, won't do what I think you're looking for. You'll need to use both a conditional table and the Disable Variable in the output instructions. You can use this combination with the DataEvent instruction or the Trigger Variable in the DataTable instruction. The program below uses the DataTable Trigger Variable because that is what I already had.

Also, make sure you specify the number of records in the DataTable instruction, do not auto-allocate an event driven table. See http://www.campbellsci.com/19_1_9999_153

Let me know if you have questions.
Janet

Public EventStarted As Boolean
Public EnableOutput As Boolean, DisableStats As Boolean
Public EventTrigger As Boolean ' this is the Event trigger

Public counter As Long, PTemp, AirTemp, DeltaTemp 'testing variables
Const one = 1 'testing constant

DataTable(Stats,EnableOutput,3000)'NOTE: must specify a table size, do NOT auto-allocate
Average(1,DeltaTemp,IEEE4,DisableStats)
Maximum (1,DeltaTemp,FP2,DisableStats,False)
Minimum (1,DeltaTemp,FP2,DisableStats,False)
Sample (1,counter,FP2)
Totalize (1,one,FP2,DisableStats)'this tell you how many samples are included in the output
EndTable

BeginProg

DisableStats=True

Scan(1,Sec,0,0)
'==================== testing section of code
counter=counter+1

PanelTemp (PTemp,_60Hz) 'measure reference temperature
TCDiff (AirTemp,1,mV2_5C,1,TypeT,PTemp,True ,0,_60Hz,1.0,0) 'measure air temperature
DeltaTemp = AirTemp-PTemp 'calculate the difference in temperatures

If DeltaTemp>=3 Then 'test for event condition(s)
EventTrigger = true
Else
EventTrigger = false
EndIf
'==================== End testing section of code

If EventStarted=False AND EventTrigger=true Then'EventStarted tells if it has started
EventStarted=True
DisableStats=False
EndIf

CallTable(Stats)

If EventStarted=True AND EventTrigger=False Then 'Event is over so output stats, and reset control variables for next event.
EventStarted=False
DisableStats=True
EnableOutput=True
CallTable(Stats)
EnableOutput=False
DisableStats=True
EndIf

NextScan

EndProg

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