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 />

TRUE is safe, it may not always be the best programming technique. Consider the<br />

expression<br />

If Condition(1) then...<br />

Since = True is omitted from the expression, Condition(1) is considered true if it<br />

equals any non-zero value.<br />

Table 19. Binary Conditions of TRUE and FALSE<br />

Condition<br />

CRBasic Instruction(s)<br />

Used<br />

Memory Location of Binary<br />

Result<br />

Time TimeIntoInterval() Variable, System<br />

IfTime()<br />

Variable, System<br />

Control Port Trigger WaitDigTrig() System<br />

Communications VoiceBeg() System<br />

ComPortIsActive()<br />

PPPClose()<br />

Variable<br />

Variable<br />

Measurement Event DataEvent() System<br />

Using TRUE or FALSE conditions with logic operators such as AND and OR,<br />

logical expressions can be encoded to perform one of the following three general<br />

logic functions. Doing so facilitates conditional processing and control<br />

applications:<br />

1. Evaluate an expression, take one path or action if the expression is true (= -1),<br />

and / or another path or action if the expression is false (= 0).<br />

2. Evaluate multiple expressions linked with AND or OR.<br />

3. Evaluate multiple AND or OR links.<br />

The following commands and logical operators are used to construct logical<br />

expressions. CRBasic example Logical Expression Examples (p. 146) demonstrate<br />

some logical expressions.<br />

• IF<br />

• AND<br />

• OR<br />

• NOT<br />

• XOR<br />

• IMP<br />

• IIF<br />

Table 20. Logical Expression Examples<br />

If X >= 5 then Y = 0<br />

Sets the variable Y to 0 if the expression "X >= 5" is true, i.e. if X is greater than or equal to 5. The <strong>CR1000</strong> evaluates the<br />

expression (X >= 5) and registers in system memory a -1 if the expression is true, or a 0 if the expression is false.<br />

If X >= 5 OR Z = 2 then Y = 0<br />

Sets Y = 0 if either X >= 5 or Z = 2 is true.<br />

146

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

Saved successfully!

Ooh no, something went wrong!