beautypg.com

Define constants, Define data tables constants, Beginprog ‘setup main program scan – Campbell Scientific CR9000X Measurement and Control System User Manual

Page 134: 2 crbasic programming, 1 fundamental elements of crbasic include

background image

Section 4. CRBasic – Native Language Programming

10) Put together what you know, and you have a working program:

‘Define Constants

Const TCMult = 1.8

: Const TCOffset = 32

Const P1Mult = 50

: Const P1Offset = 0

Const P2Mult = 200

: Const P2offset = 0

Define Public Variables

Public RefTemp, TC(3)

'Variable for ref temp & 3 Element array for temperatures

Public Press(2)

'Declare 2 Element array for pressures

Declare Units

Units RefTemp = degC : Units TC = degF : Units Press = psi

Declare Aliasess

Alias TC(1) = Ambient : Alias TC(2) = InletT : Alias TC(3) = OutletT
Alias Press(1) = InletP : Alias Press(2) = OutletP

‘Define Data Tables Constants

DataTable (Temps,1,-1)

CardOut (0 ,-1)

DataInterval

(0,100,mSec,10)

Sample

(1,RefTemp,IEEE4)

Sample

(3,TC(),IEEE4)

EndTable
DataTable
(Pressure,1,-1)

CardOut (0 ,-1)

DataInterval

(0,10,mSec,10)

Sample

(2,Press(),IEEE4)

EndTable

BeginProg

‘Setup Main Program Scan

Scan

(10,mSec,0,0)

ModuleTemp

(RefTemp,1,4,0)

TCDiff

(TC(),3,mV50C,4,1,TypeK,RefTemp,True ,40,100, TCMult,TCOffset)

BrFull

(Press(1),1,mV50,4,4,5,7,1,5000,True ,True ,30,100,P1Mult,P1Offset)

BrFull

(Press(2),1,mV50,4,4,5,7,1,5000,True ,True ,30,100,P2Mult,P2Offset)

CallTable

Temps

CallTable

Pressure

NextScan
EndProg

4.2 CRBasic Programming

4.2.1 Fundamental elements of CRBASIC include:

• Variables – named program elements, with reserved memory locations,

into which are stored values that may vary during program execution.
Values are typically the result of measurements and processing. Variables
are given an alphanumeric name and can be dimensioned into arrays of
related data.

• Constants – named program elements, with reserved memory locations,

into which are stored values that cannot vary during program execution.
Constants are given alphanumeric names and assigned values at the
beginning declaration section of a CRBASIC program.

4-6