04.01.2015 Views

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Section 7. Installation<br />

7.7.3 Syntax<br />

7.7.3.1 Numerical Formats<br />

Four numerical formats are supported by CRBasic. Most common is the use of<br />

base-10 numbers. <strong>Scientific</strong> notation, binary, and hexadecimal formats may also<br />

be used, as shown in table Formats for Entering Numbers in CRBasic (p. 112). Only<br />

standard, base-10 notation is supported by <strong>Campbell</strong> <strong>Scientific</strong> hardware and<br />

software displays.<br />

Table 8. Formats for Entering Numbers in CRBasic<br />

Format Example Base-10 Equivalent Value<br />

Standard 6.832 6.832<br />

<strong>Scientific</strong> notation 5.67E-8 5.67X10 -8<br />

Binary &B1101 13<br />

Hexadecimal &HFF 255<br />

Binary format (1 = high, 0 = low) is useful when loading the status of multiple<br />

flags or ports into a single variable, e.g., storing the binary number &B11100000<br />

preserves the status of flags 8 through 1. In this case, flags 1 – 5 are low, 6 – 8 are<br />

high. CRBasic example Load binary information into a variable (p. 112) shows an<br />

algorithm that loads binary status of flags into a LONG integer variable.<br />

CRBasic Example 5.<br />

Public FlagInt As Long<br />

Public Flag(8) As Boolean<br />

Public I<br />

DataTable(FlagOut,True,-1)<br />

Sample(1,FlagInt,UINT2)<br />

EndTable<br />

BeginProg<br />

Scan(1,Sec,3,0)<br />

Load binary information into a variable<br />

FlagInt = 0<br />

For I = 1 To 8<br />

If Flag(I) = true Then<br />

FlagInt = FlagInt + 2 ^ (I - 1)<br />

EndIf<br />

Next I<br />

CallTable FlagOut<br />

NextScan<br />

EndProg<br />

7.7.3.2 Structure<br />

Table CRBasic Program Structure (p. 113) delineates CRBasic program structure.<br />

CRBasic example Program Structure (p. 113) demonstrates the proper structure of a<br />

CRBasic program.<br />

112

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

Saved successfully!

Ooh no, something went wrong!