Sample of CR3000 Control Program for the Portable System

!!!  On no event will FFPRI be liable to you for any damages arising out of the use or inability to use the sample program.

Program Code

'CR3000 Series Datalogger with CSAT3-SDM
'date: 2010-04-02
'program author: Takanashi, S. (For. Met. Lab., FFPRI)
'Declare Constants
Const StopMeasureMinutes  = 1419                  '23:39
Const StartZeroMinutes    = 1420                  '23:40
Const StartSpanMinutes    = StartZeroMinutes+5    '23:45
Const StartMeasureMinutes = StartSpanMinutes+5    '23:50
Const FileMarkMinutes     = StartMeasureMinutes+5 '23:55
Const Interval = 100 ' msec
Const DataLapse = 0  ' 0:every blank data will be timestamped
Const DataIntegration = 250 '250, _60Hz, _50Hz
Const VoltRange = mV5000
Const DataMax = 14
Const SDM_PER = 50
'Declare Public Variables
Public Diffch(DataMax)
Public IRGAData(4)
Public SATData(6)
Public TARHData(2)
Public OIRGAData(4)
Public Ptemp
Public Flow
'Define Data Tables
DataTable(FluxData,1,-1)
DataInterval(0,Interval,msec,DataLapse)
CardOut(1,-1)'CardOut(0:Ring 1:FillandStop, -1:Auto-allocate n:Size) 
Sample(DataMax,Diffch(1),IEEE4)
FieldNames("X:m/s,Y:m/s,Z:m/s,T:degC,H2O:mv,CO2:mv,Ti:mv,Pi:mv,Pa:mv,Ta:mv,RH:mv,Flow:mv,AUX2:mv,AUX3:mv")
EndTable
DataTable(IRGA,1,600)
Sample(4,IRGAData(1),IEEE4)
FieldNames("H2O:mmol/mol,CO2:ppm,Ti:degC,Pi:kPa")
EndTable
DataTable(SAT,1,600)
Sample(4,SATData(1),IEEE4)
FieldNames("X:m/s,Y:m/s,Z:m/s,T:degC")
EndTable
DataTable(VAISALA,1,600)
Sample(1,Diffch(4),IEEE4)
FieldNames("SATa_T:degC")
Sample(1,SATData(4),IEEE4)
FieldNames("SATd_T:degC")
Sample(2,TARHData(1),IEEE4)
FieldNames("HMP45A_T:degC,HMP45A_RH:%")
Sample(1,Ptemp,IEEE4)
FieldNames("PTemp:degC")
EndTable
DataTable(Flow,1,600)
Sample(1,Flow,IEEE4)
FieldNames("Flow:l/s")
EndTable
'Define Subroutines
Sub ZeroCalibration
PortSet(1,1)
PortSet(2,0)
PortSet(3,1)
PortSet(4,1)
PortSet(5,0)
EndSub
Sub SpanCalibration
PortSet(1,0)
PortSet(2,1)
PortSet(3,1)
PortSet(4,1)
PortSet(5,0)
EndSub
Sub StartMeasure
PortSet(1,0)
PortSet(2,0)
PortSet(3,0)
PortSet(4,0)
PortSet(5,1)
EndSub
'Main Program
BeginProg
Call StartMeasure
SDMSpeed (SDM_PER)  'The resolution of the bit period is 1 uSec.
Scan(Interval,msec,600,0)
  'VoltDiff(Dest,Reps,Range,Diffchan,RevDiff,Settlingtime,Integ,Mult,Offset)
  VoltDiff(Diffch(5),10,VoltRange,5,0,0,DataIntegration,1,0)
  'Set SDM bit period and get data from the CSAT3.
  CSAT3 (SATData(1),1,3,91,60)  'SDM address 3.
  Diffch(1)=SATData(1)
  Diffch(2)=SATData(2)
  Diffch(3)=SATData(3)
  Diffch(4)=SATData(4)
  IRGAData(1)=0.01*Diffch(5)-10
  IRGAData(2)=0.2*Diffch(6)-100
  IRGAData(3)=0.02*Diffch(7)
  IRGAData(4)=0.01*Diffch(8)+70
  TARHData(1)=Diffch(10)*0.1-40
  TARHData(2)=Diffch(11)*0.1
  Flow=Diffch(12)*0.004
  PanelTemp (Ptemp,250)
  If TimeIntoInterval(1320,1440,min) Then Call StartMeasure
  If TimeIntoInterval(StopMeasureMinutes,1440,min) Then Call EndMeasure
  If TimeIntoInterval(StartZeroMinutes,1440,min) Then Call ZeroCalibration
  If TimeIntoInterval(StartSpanMinutes,1440,min) Then Call SpanCalibration
  If TimeIntoInterval(StartMeasureMinutes,1440,min) Then Call StartMeasure
  CallTable IRGA
  CallTable SAT
  CallTable FluxData
  CallTable VAISALA
  CallTable Flow
NextScan
EndProg