3 logical expressions – Campbell Scientific CR200/CR200X-series Dataloggers User Manual
Page 100

Section 9. Programming
CRBASIC EXAMPLE. Use of Variable Arrays to conserve Code
p. 88 shows
example code to convert five temperatures in a variable array from C to F:
CRBASIC EXAMPLE 15.
Use of Variable Arrays to Conserve Code Space
For I = 1 to 5
TempC(I) = TempC(I) * 1.8 + 32
Next I
9.10.3 Logical Expressions
Measurements can indicate absence or presence of an event. For example, an
RH measurement of 100% indicates a condensation event such as fog, rain, or
dew. The CR200(X) can render events into binary form for further processing,
i.e., events can either be TRUE, indicating the condition occurred or is
occurring, or FALSE, indicating the condition has not yet occurred or is over.
Several words are commonly interchanged with True / False such as High /
Low, On / Off, Yes / No, Set / Reset, Trigger / Do Not
Trigger. The CR200(X) understands only True / False or -1 /
0, however. The CR200(X) represents "true" with "-1"
because AND / OR operators are the same for logical
statements and binary bitwise comparisons.
In the binary number system internal to the CR200(X), "-1" is expressed with
all bits equal to 1 (11111111). "0" has all bits equal to 0
(00000000). When -1 is ANDed with any other number, the
result is the other number. This ensures that if the other
number is non-zero (true), the result is non-zero.
Using TRUE or FALSE conditions with logic operators such as AND and OR,
logical expressions can be encoded into a CR200(X) to perform three general
logic functions, facilitating conditional processing and control applications.
1. Evaluate an expression, then take one path or action if the expression is
true (= -1), and / or another path or action if the expression is false (=
0).
2. Evaluate multiple expressions linked with AND or OR.
3. Evaluate multiple and / or links.
88