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.

Conditional data storage


Lleida Jul 22, 2009 06:01 PM

Dear Friends
I'm preparing a CRBASIC program for weigthing lysimeters with a CR800 datalogger who controls all the process. Up to now I've been using a CR10x to control it for more than 10 years.
As a regular basis I'm registering one record every hour, No problem up to this moment.
The problem comes to me when I want to record on my datatable (the same I'm using for hourly records) concret events that hapens, p.e. at 3:45:18. It has been impossible to me.
Any idea how to solve this problem?
here is a part of the program I'm preparing (the main part related to data storage):

DataTable (LisPoma,1,-1)
DataInterval (0,60,Min,0)
DataEvent (0,KFlag02,KFlag02,1)
Sample (1,DJ,String)
Sample (1,PesLisH,String)
Sample (1,Peslis24,String)
Sample (1,Perduapes,String)
Sample (1,PesLisR,String)
Sample (1, PerduaPesH,String)
Sample (1, ETc,String)
Sample (1, ETcH,String)
Sample (1, LDip,String)
EndTable

BeginProg
Scan (200,msec,3,0)
PanelTemp (PanelT,250)
VoltDiff (Vlis,1,mV2500,1,True ,0,250,1,0)
PesLis = 1.325 * Vlis - 530.96
PulseCount (ComptVol,1,1 ,2,0,10,0)
LDip = LDip + ComptVol
Battery (Batt_volt)
.........
DD()=PesLis
PerduaPes = PesLisR - PesLis
PerduaPesH = PesLisR - PesLisH
ETc = PerduaPes/(4.8 * 4)
ETcH = PerduaPesH / (4.8 * 4)

'Call Output Tables
CallTable LisPoma

NextScan
EndProg


aps Jul 23, 2009 09:08 AM

The Datainterval and Dataevent are mechanisms to control data storage. If you put them both in the same datatable, both would need to be true for anything to be output. As this is not what you want, if you definitely want both datasets in the same table then remove both instructions and control the output of the table from within the main body of the program, either using the TrigVar or calling the table conditionally.

Below I show bits of your program modified accordingly which use the Trigvar technique, when that variable is either set on an event or using the IF Timeinterval construct (similar to P92 in the older loggers).

There is one consequence of removing the Datainterval instruction and this is that the time stamp on every record is automatically written with the data, rather than the logger using an inferred time (which it will for data output at fixed intervals). This adds about 16 bytes per record to the data storage requirement.

If you were storing data more frequently this might be a problem for you, in which case you could store the regular (60 min data) in one table and the event driven data in another (just by calling that table when needed).

Program extracts:

....
'kflag02 used to allow datastorage
DataTable (LisPoma,kflag02,-1)
'No datainterval or dataevent
Sample (1,dj,String)
Sample (1,peslish,String)
Sample (1,peslis24,String)
Sample (1,perduapes,String)
Sample (1,peslisr,String)
Sample (1, perduapesh,String)
Sample (1, etc,String)
Sample (1, etch,String)
Sample (1, ldip,String)
EndTable
.........

'Call Output Tables
'Set flag kflag02 to TRUE every 60 mins to force data storage
'This flag may also be set by your own code above to force an event triggered data store
If TimeIntoInterval(0,60,min) Then kflag02=true
CallTable LisPoma
'Reset the flag after data has been stored so not continuously retriggerd
kflag02=false

* Last updated by: aps on 7/23/2009 @ 3:10 AM *

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