07.01.2015 Views

CR200/CR200X Series Dataloggers - Campbell Scientific

CR200/CR200X Series Dataloggers - Campbell Scientific

CR200/CR200X Series Dataloggers - Campbell Scientific

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Section 9. Programming<br />

NextScan<br />

EndProg<br />

If Flag = True Then<br />

DisableVar = True<br />

End If<br />

Else<br />

DisableVar = False<br />

EndIf<br />

'Call Data Tables and Store Data<br />

CallTable (OscAvgData)<br />

Read More! For a complete list of output processing instructions, see Data<br />

Storage Output Processing (p. 94).<br />

9.7.2 Subroutines<br />

Subroutines allow a section of code to be called by multiple processes in the<br />

main body of a program. Subroutines are defined before the main program body<br />

of a program. Program CRBASIC EXAMPLE. Use of a Subroutine p. 83 shows<br />

the use of a subroutine to repeatedly perform a calculation.<br />

CRBASIC EXAMPLE 10.<br />

'Declare Variables and Units<br />

Public Temp(4), I, Temp_F(4)<br />

Use of a Subroutine<br />

'Subroutine to convert temperature in degrees C to degrees F<br />

Sub ConvertCtoF<br />

For I = 1 to 4<br />

Temp_F = Temp(I)*1.8 + 32<br />

Next I<br />

EndSub<br />

'Main Program<br />

BeginProg<br />

Scan (1,Sec)<br />

Therm109 (Temp(),4,1,Ex1,1.0,0)<br />

'convert Temperatures to F using Subroutine:<br />

Call ConvertCtoF<br />

NextScan<br />

EndProg<br />

9.8 Program Execution Timing<br />

<strong>CR200</strong>(X) programs are built within a Scan () / NextScan structure, with only<br />

variable and data table declarations outside the Scan () / NextScan structure. In<br />

these programs, Scan () / NextScan creates an infinite loop, each periodic pass<br />

through the loop being synchronized to the <strong>CR200</strong>(X) clock. Scan () parameters<br />

allow modification of the period. As shown in CRBASIC EXAMPLE. BeginProg<br />

/ Scan / NextScan / EndProg Syntax (p. 84) , aside from declarations, the<br />

CRBASIC program may be relatively short.<br />

83

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!