04.01.2015 Views

CR1000 Manual - Campbell Scientific

CR1000 Manual - Campbell Scientific

CR1000 Manual - 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 7. Installation<br />

'3) sample time to three string forms using the TableName.FieldName notation.<br />

'Form 1: "mm/dd/yyyy hr:mm:ss<br />

UTTime(1) = TimeTable.TimeLong(1,1)<br />

'Form 2: "dd/mm/yyyy hr:mm:ss<br />

UTTime(2) = TimeTable.TimeLong(3,1)<br />

'Form 3: "ccyy-mm-dd hr:mm:ss (ISO 8601 Int'l Date)<br />

UTTime(3) = TimeTable.TimeLong(4,1)<br />

NextScan<br />

EndProg<br />

7.8.11 Bool8 Data Type<br />

Boolean variables are used to represent conditions that have only two states -- true<br />

or false -- such as program-control flags and hardware-control ports. A<br />

BOOLEAN data-type variable uses the same four-byte integer format as a LONG<br />

data type, but it can be set to only one of two values. To save data-storage space<br />

and data transmission bandwidth, consider using BOOL8 format to store data in<br />

final-storage data tables. BOOL8 is a one-byte variable that holds eight bits of<br />

information (8 states * 1 bit per state). To store the same information using the<br />

32-bit BOOLEAN data type, 256 bits are required (8 states * 32 bits per state).<br />

When programming with BOOL8, repetitions in the output processing<br />

DataTable() instruction must be divisible by two, since an odd number of bytes<br />

cannot be stored. Also note that when the <strong>CR1000</strong> converts a LONG or FLOAT<br />

data type to BOOL8, only the least significant eight bits of the binary equivalent<br />

are used, i.e., only the binary representation of the decimal integer modulo divide<br />

(p. 458) 256 is used.<br />

Example:<br />

Given: LONG integer 5435<br />

Find: BOOL8 representation of 5435<br />

Solution:<br />

5435 / 256 = 21.2304687<br />

0.2304687 * 256 = 59<br />

Binary representation of 59 = 00111011 (<strong>CR1000</strong> stores<br />

these bits in reverse order)<br />

When datalogger support software (p. 77) retrieves the BOOL8 data type, it splits it<br />

apart into eight fields of -1 or 0 when storing to an ASCII file. Consequently,<br />

more memory is required for the ASCII file, but <strong>CR1000</strong> memory is conserved.<br />

The compact BOOL8 data type also results in less use of telecommunications<br />

band width when data are collected.<br />

CRBasic example Bool8 and Bit-Shift Operators (p. 229) programs the <strong>CR1000</strong> to<br />

monitor the state of 32 'alarms' as a tutorial exercise. The alarms are toggled by<br />

manually entering zero or non-zero (e.g., 0 or 1) in each public variable<br />

representing an alarm as shown in figure Alarms Toggled in Bit-Shift Example (p.<br />

228) . Samples of the four public variables FlagsBool(1), FlagsBool(2),<br />

FlagsBool(3), and FlagsBool(4) are stored in data table "Bool8Data" as four onebyte<br />

values. However, as shown in figure Bool8 Data from Bit-Shift Example<br />

(Numeric Monitor) (p. 228) , when viewing the data table in a numeric monitor , data<br />

are conveniently translated into 32 values of True or False. In addition, as shown<br />

in figure Bool8 Data from Bit-Shift Example (PC Data File) (p. 229) , when<br />

datalogger support software (p. 77) stores the data in an ASCII file, it is stored as<br />

32 columns of either 0 or -1, each column representing the state of an alarm.<br />

227

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

Saved successfully!

Ooh no, something went wrong!