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.

scan interval optimisation


firmin Apr 4, 2016 08:06 AM

Hello,

I'm using CR1000 datalogger on the field with sampling frequency > 1Hz.

Actually i'm trying to minimize the following status tables fields ( Stations status):

-  Measure Time =  16 mSec  ( set by the number of meausuring channels used)

-  Process Time = 110 mSec ( optimization of the CrBasic code)

- MaxProctime = 360 mSec ( maybe beacause i'm using CardOut intsruction and NL116).

I still have skipped scan and measurement even if the MaxProcTime is lower than the scan interval.

Is it the good way to approach to this issue? 

I join the CrBasic code below.

Best Regards,

Firmin Fontaine

 

' CrBasic code for CR1000 logger              autor = firmin.fontaine@irstea.fr
' Sations : 
' loading date : 




'====================================================================================
'VARIABLES & CONSTANTS
'====================================================================================


'**********  Station parameters  ***********
StationName(Test)
Const concentration_bassin = 15 'Min
Public Batt_volt
Public rTime(9)
Const Freq  =  250 'Ms

'***********  Rainfall  ***********
Public Pluie
Public Pluie15
  Alias Pluie15 = Cumul_Pluie_15min
Public Pluie5a, Pluie5b, Pluie5c
Dim PluieCum
'Rain gauge calibration
Const CalibrePluvio = 0.254 'mm


'**********  Flow heigt  ***********
Public Hauteur_US
  Units Hauteur_US = mm
Const PEH1 = 5500.
Const MultH1 = PEH1/1600.
Const OffsetH1 = -1345.


'***********  Seismic signals  ***********
'Geo 1
Public Geo_1_brute 
Public Geo_1_ampli
Public Geo_1_corr

'Geo 2
Public Geo_2_brute 
Public Geo_2_ampli
Public Geo_2_corr

'Geo 3
Public Geo_3_brute 
Public Geo_3_ampli
Public Geo_3_corr

'Geo 4
Public Geo_4_brute 
Public Geo_4_ampli
Public Geo_4_corr


'***********  Event mode  ***********
Public Even As Boolean
Public NbEven 
Public TestPort
'Circular memory settings
Const RecBefore = (concentration_bassin + 5) * (60 * 2)  ' (concentration_time + 5 min) * ( nbr record / min)
Const RecAfter = (concentration_bassin -10)* (60 * 2)  ' (concentration_time -10 min) * ( nbr record / min)

'**********  Image  **********
Public Image
Public NbImage As Long
Public Photoseuil As Boolean


'====================================================================================
' TABLE DECLARATION
'====================================================================================

DataTable (PluBatManival,True,-1)
	DataInterval(0,5,Min,0)
	CardOut (0, -1)
	Totalize (1,Pluie,FP2,0)
	Sample (1,Batt_volt,FP2)
	Sample (1,Hauteur_US,FP2)
	Maximum (1,Geo_1_corr(),IEEE4,False,False) 
	Maximum (1,Geo_2_corr(),IEEE4,False,False) 
	Maximum (1,Geo_3_corr(),IEEE4,False,False) 
	Maximum (1,Geo_4_corr(),IEEE4,False,False) 
	
EndTable

'______________________________________________________________________________________

DataTable (LaveManival,True,100000)
		DataEvent (RecBefore,Pluie15 >0,Pluie15 = 0,RecAfter)
      DataInterval(0,Freq,mSec,100)
        CardOut (0, -1)
        Sample (1,Hauteur_US,IEEE4)
        Sample (1,Geo_1_corr,IEEE4)
        Sample (1,Geo_2_corr,IEEE4)
        Sample (1,Geo_3_corr,IEEE4)
        Sample (1,Geo_4_corr,IEEE4)
EndTable

'===================================================================================
'SUBROUTINES
'====================================================================================


Sub Initialisation (APluieCum ,APluie15 , AEven,  ANbEven, ANbImage,APhotoseuil,APluie5b, APluie5c)
  
	 APluieCum = 0	 	 
	 APluie15 = 0
	 APluie5b = 0
	 APluie5c = 0
	 AEven = 0
	 ANbEven = 0	 
	 ANbImage = 0
	 APhotoseuil = False
EndSub

'______________________________________________________________________________________

Sub CumulPluie (APluieCum, APluie, APluie15, APluie5a, APluie5b, APluie5c)
  
	 APluieCum = APluieCum + APluie 
	 		APluie5a = APluieCum
	 		APluieCum = 0	
	 		APluie15 = APluie5a + APluie5b + APluie5c
	 		APluie5c = APluie5b
	 		APluie5b = APluie5a	 		 
EndSub

'______________________________________________________________________________________

Sub Evenement_image(ATestPort, AImage, APluie, AEven, ANbEven, APluie15, ArTime, ANbImage, APhotoseuil, APluieCum) 
	 
	 If (APluieCum >= 0.8) Then 		
			AEven = 1
			PortSet (6,1)	
	 EndIf	 
	 

   If (APluie15 >= 3)
      APhotoseuil = True
   EndIf
   
	 If TimeIntoInterval(0,4,Sec) AND (AEven = 1) AND (APhotoseuil = True)
			 If (ArTime>=4) AND (ArTime<=20) 		 
			   PortSet(3,1)
			   Delay (1,200,mSec)
			   PortSet(3,0)
			   AImage = 1
			   ANbImage = ANbImage + 1
			  EndIf			   
	 EndIf	 

	 If TimeIntoInterval(0,5,Min) AND AEven = 1 AND APluie15 < 1 Then
			PortSet (6,0)
			AEven = 0	
			APhotoseuil = False
			ANbEven = ANbEven +1
	 EndIf			
EndSub

'______________________________________________________________________________________

Sub TimeLapse (AEven, AImage, ANbImage)
	If (AEven = 0) AND TimeIntoInterval(12,24,Hr) Then 
			 PortSet (6,1)
	EndIf	
	
	If (AEven = 0) AND TimeIntoInterval(721,1440,Min) Then 
			 PortSet(3,1)
			 Delay (1,100,mSec)'70ms semble ok
			 PortSet(3,0)
			 AImage = 1
			 ANbImage = ANbImage + 1
	EndIf
	
	If (AEven = 0) AND TimeIntoInterval(722,1440,Min) Then 			 
			 PortSet (6,0)
	EndIf	
EndSub


'=====================================================================================
'MAIN PROGRAM
'====================================================================================
BeginProg
	'Reset rain gauge pulse
	PulseCountReset	
	'Load initial settings
	Call Initialisation (PluieCum ,Pluie15 , Even,  NbEven, NbImage, Photoseuil, Pluie5b, Pluie5c)
	

'______________________________________________________________________________________

	Scan (Freq,mSec,5000,0)			

	  Image = 0	   
		'********** Measurements **********
		'flow heigt
		VoltDiff (Hauteur_US,1,mV2500,1,True,0,0,MultH1,OffsetH1)
		'Rain gauge
		PulseCount(Pluie,1,1,2,0,CalibrePluvio,0)
		'geo_1
		VoltSe(Geo_1_brute,1,mV2500,5,True,0,0,1.0,0)	
    VoltSe(Geo_1_ampli,1,mV2500,5,True,0,0,1.0,0)
    'geo_2
		VoltSe(Geo_2_brute,1,mV2500,5,True,0,0,1.0,0)	
    VoltSe(Geo_2_ampli,1,mV2500,5,True,0,0,1.0,0)
    'geo_3
		VoltSe(Geo_3_brute,1,mV2500,5,True,0,0,1.0,0)	
    VoltSe(Geo_3_ampli,1,mV2500,5,True,0,0,1.0,0)
    'geo_4
		VoltSe(Geo_4_brute,1,mV2500,5,True,0,0,1.0,0)	
    VoltSe(Geo_4_ampli,1,mV2500,5,True,0,0,1.0,0)

		'********** Geophone correction *********
		If Geo_1_ampli < 1800 Then
      Geo_1_corr = Geo_1_ampli
  		ElseIf Geo_1_corr = Geo_1_brute * 200
		EndIf

		
    If Geo_2_ampli < 1800 Then
		  Geo_2_corr = Geo_2_ampli
	  ElseIf Geo_2_corr = Geo_2_brute * 200
    EndIf

		If Geo_3_ampli < 1800 Then
		  Geo_3_corr = Geo_3_ampli
		ElseIf Geo_3_corr = Geo_3_brute * 200
		EndIf  

		If Geo_4_ampli < 1800 Then
  		 Geo_4_corr = Geo_4_ampli
		ElseIf Geo_4_corr = Geo_4_brute * 200
		EndIf
		


  '**********  Calling SubSequences  **********
  Call Evenement_image (TestPort, Image, Pluie, Even, NbEven,  Pluie15, rTime(4), NbImage, Photoseuil, PluieCum)	
  Call CumulPluie (PluieCum, Pluie, Pluie15,Pluie5a, Pluie5b, Pluie5c)
  
  '**********  Calling DataTables  **********

  CallTable LaveManival
  
    
	NextScan
	

'______________________________________________________________________________________
	
SlowSequence

Scan (5,Min,3,0)
    '**********  Calling SubSequence  **********
    Call TimeLapse (Even,Image, NbImage)
    '**********  Calling Monitoring DataTable  **********
    CallTable PluBatManival 
    '**********  Checking Logger settings  **********
    Battery (Batt_volt)
	  RealTime(rTime) 
		PortGet(TestPort,6)
		
NextScan



EndProg

'______________________________________________________________________________________

 


aps Apr 4, 2016 10:47 AM

There are a couple of ways to avoid this but the simplest is to change your program to that is works in Pipelinemode and set the scan buffer parameter to 10 or so to allow the program to continue even if processing backs up for a couple of scans.

To make this happen you need to stop calling Portset conditionally (and also Portget in the slow sequence) which currently forces the logger to run in Sequential mode.   You can change these to WriteIO and ReadIO (see the help system).

One thing to understand before you do this though the port switching may then run out of sequence with the measurement (especially if the processing gets queued).  I am not sure if this is critical or not in this application.


firmin Apr 4, 2016 03:35 PM

Many thanks for your reply.

I changed the settings you suggested and for the moment it seems to work well.

I manage to rise the sampling freqency to 10Hz.

Best regards,

Firmin

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