
As Boolean
specifies the variable as a 4 byte Boolean. Boolean variables are typically used for
flags and to represent conditions or hardware that have only 2 states (e.g., On/Off, High/Low). A
Boolean variable uses the same 32 bit long integer format as a
Long
but can set to only one of
two values: True, which is represented as –1, and false, which is represented with 0. When a
Float
or
Long
integer is converted to a
Boolean
, zero is False (0), any non-zero value will set
the Boolean to True (-1). The Boolean data type allows application software to display it as an
On/Off, True/False, Red/Blue, etc.
The CR6 uses –1 rather than some other non-zero number because the
AND
and
OR
operators
are the same for logical statements and binary bitwise comparisons. The number -1 is expressed
in binary with all bits equal to 1, the number 0 has all bits equal to 0. When –1 is anded with any
other number the result is the other number, ensuring that if the other number is non-zero (true),
the result will be non-zero.
As String * size
specifies the variable as a string of ASCII characters, NULL terminated,
with an optional size specifying the maximum number of characters in the string. A string is
convenient in handling serial sensors, dial strings, text messages, etc. When size is not specified,
a default of 24 characters will be used (23 usable bytes and 1 terminating byte).
As a special case, a string can be declared
As String
* 1. This allows the efficient storage of a
single character. The string will take up 4 bytes in memory and when stored in a data table, but it
will hold only one character.
4.4.2 Data storage
Data can be stored in either IEEE4 or FP2 formats. The format is selected in the program
instruction that outputs the data, i.e. minimum, maximum, etc.
While
Float
(IEEE 4 byte floating point) is used for variables and internal calculations,
FP2
is
adequate for most stored data. Campbell Scientific 2 byte floating point (
FP2
)provides 3 or 4
significant digits of resolution, and requires half the memory space as
IEEE4
(2 bytes per value
vs 4).
Table 4-2: Resolution and range limits of FP2 data
Zero
Minimum magnitude Maximum Magnitude
0.000
±0.001
±7999.
The resolution of
FP2
is reduced to 3 significant digits when the first (left most) digit is 8 or
greater. Thus, it may be necessary to use
IEEE4
output or an offset to maintain the desired
resolution of a measurement. For example, if water level is to be measured and output to the
nearest 0.01 foot, the level must be less than 80 feet for
FP2
output to display the 0.01 foot
4. Working with data
52