beautypg.com

1 cr1000 programming – Campbell Scientific CS506 Fuel Moisture Sensor User Manual

Page 12

background image

CS506 Fuel Moisture Sensor

5.1 CR1000 Programming

The following program measures a CS506 fuel moisture sensor using the
CRBasic PeriodAvg() instruction. See Table 5-1 for wiring details that match
this program.

'CR1000

'CR1000 Program for CS506

'Declare Variables and Units
Public FuelM
Public PA_uS

Units FuelM=%
Units PA_uS=uSec

'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,60,Min,10)
Sample(1,FuelM,FP2)
Sample(1,PA_uS,FP2)
EndTable

'Main Program
BeginProg
Scan(10,Sec,1,0)

'CS506 Fuel Moisture Sensor measurement FuelM and PA_uS:

If

IfTime(0,1,Hr)

Then

PortSet

(1,1)

PeriodAvg(PA_uS,1,mV250,1,0,0,100,10,1,0)

PortSet (1,0)

If PA_uS <= 17.7 Then

FuelM = 7.6298* PA_uS - 130.0904

Else

FuelM= 0.0406* PA_uS ^2 + 3.7685 * PA_uS -73.7974

EndIf

EndIf

'Call Data Tables and Store Data

CallTable(Table1)
NextScan
EndProg

6