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.

Full CFcard and MaxFiles = -1


Otemohu Nov 13, 2012 01:55 PM

Dear all,

I use a NL115 and CF2Go attached to a CR3000 (OS24). The CR3000 is connected in RS232 to an Eddy covariance system.
The scanrate is fixed at 50ms (20hz).

I generate files halfhourly, files that are copied on the CFcard with the TableFile instruction.
In this instruction ,the command MaxFiles is set to -1.

Anyway, when the CFcard is full, the oldest file is not deleted prior to the newest.

On the other hand, the program takes some times to write the halfhourly files on the CFcard. Sometimes, it takes more than 1 minutes and then, the MM (minutes) in the filename are not 00 or 30 but 01 or 31. I think I have to use the MOD function but I don't know how to write it.

Here is the program I use:
'*************************************************************************************
'CR3000 Datalogger S/N 5488
'Name: EddyFlux
'Program Author: Daniel Berveiller
'Program Name: Eddy-HS50Li7200.CR3
'Date of creation: 05/07/11
'Date of last change: 12/07/11

'Description: Programme de recuperation et de traitement des donnees de l'anemometre
' Gill HS-50 et de l'analyseur LiCor Li7200 pour la mesure des flux par
' Eddy Covariance. Connexion en RS232.

'Wiring: RS232 cable avec un cote DSub 9 pin vers
' ----- CR3000 G (blue)
' ----- CR3000 C1 TX (yellow)
' ----- CR3000 C2 RX (white)
'*************************************************************************************
'Program changes:

'Date MaJ: 12/07/11
' - Modification du format de donnees de FP2 en IEE4 car FP2 non reconnu dans le
' logiciel EddyPro (info LiCor Israel Begashaw du 08/07/11)

'Date MaJ:
' - Ajout de commandes pour la creation d'un fichier toutes les demi-heures a
' enregistrer dans la carte CF de 2Go.

'
'*************************************************************************************

'Variables and Table definitions
Public Sonic_U : Units Sonic_U = m_s
Public Sonic_V : Units Sonic_V = m_s
Public Sonic_W : Units Sonic_W = m_s
Public Sonic_T : Units Sonic_T = degC
Public DensCO2_V : Units DensCO2_V = volts
Public DensCO2 : Units DensCO2 = mmol_m3
Public DensH2O_V : Units DensH2O_V = volts
Public DensH2O : Units DensH2O = mmol_m3
Public PressTot_V : Units PressTot_V = volts
Public PressTot : Units PressTot = kPa
Public TempIn_V : Units TempIn_V = volts
Public TempIn : Units TempIn = degC
Public FlowRate_V : Units FlowRate_V = volts
Public FlowRate : Units FlowRate = slpm
Public ConcCO2_V : Units ConcCO2_V = volts
Public ConcCO2 : Units ConcCO2 = ppmv


Public rTime(9)
Alias rTime(5) = Minute
Alias rTime(6) = Second
Alias rTime(9) = DOY
Public timevalue As String * 8
Public File As Long
Public Stat
Const fileconfig="usr:chemin_enr.txt"
Public DataFile As String * 256
Public DataFile2 As String * 256
Public DataFile_rec As String * 256
Public OutStat As String * 256
Public LastFileName As String * 256

Dim HHMM As Long
Dim HHMM$ As String
Public DD As String, MM As String, YYYY As String

'Declare Other Variables
Dim Sonic_string As String * 256
Dim Sonic_sub_string(11) As String * 8
Public nbr_bytes_return

'If you want to change the Com port change only here
Const Sonic_Port = Com1

'Define Data Tables
'Online Eddy_Rawdata at 20 Hz

DataTable (Eddydata,true,-1)
DataInterval (0,50,mSec,50)
'commente le cardout si tu ne veux pas de fichier concatene
'CardOut (0 ,-1)
Sample(1,Sonic_U,IEEE4)
Sample(1,Sonic_V,IEEE4)
Sample(1,Sonic_W,IEEE4)
Sample(1,Sonic_T,IEEE4)
Sample(1,DensCO2,IEEE4)
Sample(1,DensH2O,IEEE4)
Sample(1,PressTot,IEEE4)
Sample(1,TempIn,IEEE4)
Sample(1,FlowRate,IEEE4)
Sample(1,ConcCO2,IEEE4)
'Creation du fichier avec 36000 enregistrement
'TableFile ("CRD:EddyData_",1,1,36000,0,min,OutStat,LastFileName)
'version 30 minutes
TableFile ("CRD:EddyData_",1,-1,0,30,min,OutStat,LastFileName)
EndTable

'Main Program
BeginProg
'creation du premier nom de fichier
''''''''''''''''''
SerialOpen(Sonic_Port,115200,0,0,1024)
Scan (50,mSec,0,0)
SerialInRecord(Sonic_Port,Sonic_string,&h02,0,&h03,nbr_bytes_return,0)
'test Sonic_string="1111111,22222222,33333333333,44444444444444,55555555555,6666666666,7777777777777,88888888888,9999999999,10100000000000,111011111011110"
SplitStr(Sonic_sub_string(),Sonic_string,",",11,6)
Sonic_U =Sonic_sub_string(2)
Sonic_V =Sonic_sub_string(3)
Sonic_W =Sonic_sub_string(4)
Sonic_T =Sonic_sub_string(5)
DensCO2_V =Sonic_sub_string(6)
DensH2O_V =Sonic_sub_string(7)
PressTot_V =Sonic_sub_string(8)
TempIn_V =Sonic_sub_string(9)
FlowRate_V =Sonic_sub_string(10)
ConcCO2_V =Sonic_sub_string(11)

'Pour le CO2 0V = 13.38 mmol/m3 et 5V = 26.76 mmol/m3 ce qui donne :
DensCO2 = 2.6760 * DensCO2_V + 13.3800
'Pour le H2O 0V = 0 mmol/m3 et 5V = 1561 mmol/m3 ce qui donne :
DensH2O = 312.0000 * DensH2O_V
'Pour la Press Tot 0V = 98 kPa et 5V = 104 kPa ce qui donne :
PressTot = 1.2000 * PressTot_V + 98.0000
'Pour la Temp In 0V = 0 degC et 5V = 40 degC ce qui donne :
TempIn = 8.0000 * TempIn_V
'Pour le FlowRate 0V = 10 slpm et 5V = 18 slpm ce qui donne :
FlowRate = 1.6000 * FlowRate_V + 10.0000
'Pour le CO2 ppmv 0V = 300 ppmv et 5V = 600 ppmv ce qui donne :
ConcCO2 = 60.0000 * ConcCO2_V + 300.0000

'Cration du nom fichier toutes les demi-heures enregistr sur la carte CF
'Format : EddyData-YYYY-MM-DD_HHMM.dat



If (OutStat=-1) Then
RealTime(rTime)
HHMM=rTime(4)*100+rTime(5)+10000
HHMM$="" + HHMM
timevalue=Public.Timestamp(3,1)
YYYY=Mid(timevalue,7,4)
DD=Mid(timevalue,1,2)
MM=Mid(timevalue,4,2)
DataFile="CRD:EddyData_" +YYYY + "-" +MM + "-" +DD+ "_" +Mid(HHMM$,2,4) + ".dat"
FileRename (LastFileName,DataFile)
EndIf

'Call Output Tables and Store Data
CallTable Eddydata


NextScan
'serialclose
EndProg


Sam Nov 15, 2012 12:16 AM

>> Anyway, when the CFcard is full, the oldest file is not deleted prior to the newest.

Because it has no files to delete. It is looking to manage files of the name CRD:EddyData_[counter].dat. You are renaming them to something else. So from the perspective of the logger, it has no files to manage / delete.

>> On the other hand, the program takes some times to write the halfhourly files on the CFcard.

The logger has to convert the large amount of data in memory to the TOB1 data format.


Otemohu Nov 15, 2012 08:06 AM

Ok. So how can I create files that will be
- first, delete automatically when CF card will be full?
- second, rename to the format I specified?

For the time the program takes to write, sure I know what's happen but how to resolve?


Otemohu Nov 15, 2012 08:06 AM

Ok. So how can I create files that will be
- first, delete automatically when CF card will be full?
- second, rename to the format I specified?

For the time the program takes to write, sure I know what's happen but how to resolve?


Sam Nov 16, 2012 03:06 AM

First -
Use the TableFile instruction as you have it, but do not yank it out from under the file management system. As you have it written, the logger will create a file following the name CRD:EddyData_[counter].dat every 30 minutes, where [counter] is a sequential file count. When the card gets full, the oldest file will be deleted before the next file is written.

TableFile ("CRD:EddyData_",1,-1,0,30,min,OutStat,LastFileName)

Second -
If you rename the file, you will need to develop your own file management system.

Following is a weak example. It does not actually read / take into account the real contents of the drive. It simply tracks files by what it thinks it has written. Something more robust could be created using FileList() and FileTime()

PreserveVariables

Public LastFileName As String * 31
Public OutStat As Boolean
Public FileWritten As Boolean
Const MaxFiles = 10
Public Files(MaxFiles) As String * 31

Public PTemp, BattV

DataTable (Test,True,1000)
DataInterval (0,5,Sec,10)
TableFile ("USR:Test_",9,2,0,30,Sec,OutStat,LastFileName)
Sample (1,PTemp,IEEE4)
Sample (1,BattV,FP2)
EndTable

BeginProg
SetStatus ("USRDriveSize",1000000)
Scan (1,Sec,0,0)
PanelTemp (PTemp,250)
Battery (BattV)
CallTable Test
If OutStat Then FileWritten = TRUE
NextScan

SlowSequence
Do
Delay (1,5,Sec)
If FileWritten Then
FileWritten = FALSE
FileManage (Files(1),8)
Move (Files(1),MaxFiles-1,Files(2),MaxFiles-1)
Files(MaxFiles) = LastFileName
EndIf
Loop
EndSequence

EndProg


Otemohu Nov 16, 2012 09:42 AM

Hi Sam,

Thank you for your help. I tested your program on the CRD card. It creates only two files that are replaced one after one. That's great.

I would like following your recommendation regarding FileList() and FileTime(). I understand the concept but I don't feel at ease with these command. I never used it. So If you could write me a code with these commands, I would be very grateful.

The best is that program use the total capacity of the CF card. A PC is connected permanently to the CR3000 trough Ethernet and download the new file every 30 mins through Loggernet admin. In the case of power down, the CR3000 is power safe and so continues to write on CRD. When the power is back, the PC turns on automatically as well as Loggernet.

Daniel

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