beautypg.com

Program examples – Campbell Scientific CR200/CR200X-series Dataloggers User Manual

Page 123

background image

Section 11. Programming Resource Library

CRBASIC EXAMPLE 17.

CRBASIC EXAMPLE. Radio Power Minimization Program

Examples

‘Pin Enabled Radio Program Example Program for CR1000

'Pakbus Address = 2

Public Rx(6), Tx, Result

Alias Rx(1)=VWC_1: Alias Rx(2)=VWC_2 ‘Alias used to give meaningful names to

Alias Rx(3)=VWC_3: Alias Rx(4)=VWC_4 ‘data received from remote datalogger

Alias Rx(5)=Tsoil_C: Alias Rx(6)=Batt_206_V

Alias Tx=Batt_CR1K_V

DataTable (Test,1,-1)

DataInterval (0,60,Min,10)

Average (6,Rx(),FP2,False)

Minimum (1,Batt_CR1K_V,FP2,False,False)

EndTable

BeginProg

Scan (15,Sec,0,0)

Battery (Batt_CR1K_V)

CallTable Test

NextScan

'Send Network command every 5 minutes

SlowSequence

Scan (5,Min,0,0)

Network (Result,1,3,15,60,0,6,Rx(),1,Tx)

NextScan

EndProg

------------------------------------------------------------------------------------------

'Pin Enabled Radio Example for CR206X

'Pakbus address 3

Public Time, TxData(6)

Public Period_uS(4), Response, Rx

Alias TxData(1)=VWC_1: Alias TxData(2)=VWC_2: Alias TxData(3)=VWC_3

Alias TxData(4)=VWC_4: Alias TxData(5)=T109_C: Alias TxData(6)=Batt_Volt

Alias Rx = CR1K_Batt_Volt

Dim LoopCnt

Units Batt_Volt=Volts

Units Period_uS()=uSec

Units T109_C=Deg C

DataTable(VWC_pin,True,-1)

DataInterval(0,60,Min)

Average(5,TxData(),False)

Minimum (1,Batt_Volt,False,0)

EndTable

BeginProg

SetStatus (RfPwrMode,RFpinEn) 'Configure CR200(X) power mode to pin enabled

Scan(1,sec)

If IfTime (0,15,Min) Then 'Take readings every 15 minutes

Battery(Batt_Volt)

Therm109(T109_C,1,5,1,1.0,0.0)

SWBatt (1 ) 'Power CS625 sensors up

PeriodAvg(Period_uS(1),1,0,100,10,1,1,0)

PeriodAvg(Period_uS(2),2,0,100,10,1,1,0)

PeriodAvg(Period_uS(3),3,0,100,10,2,1,0)

PeriodAvg(Period_uS(4),4,0,100,10,2,1,0)

SWBatt (0) 'Power CS625 sensors down

For LoopCnt = 1 To 4 'convert raw values to volumetric water content

TxData(LoopCnt)=-0.0663-0.0063*Period_uS(LoopCnt)+0.0007*Period_uS(

Next LoopCnt

EndIf

Time = TimeUntilTransmit(1) 'copy countdown time to public variable

If Time = 0 Then 'when countdown reaches zero power radio and transmit

SendGetData (Response,Rx,TxData(),1,2,2,00000)

EndIf

CallTable(VWC_Pin)

NextScan

EndProg

111