2 nesting – Campbell Scientific CR510 Basic Datalogger User Manual
Page 54

SECTION 3. INSTRUCTION SET BASICS
3-6
;Logical OR construction example:
11: If (X
!F) (P89)
1:
1
X Loc [ DO_ppm ]
2:
4
<
3:
3.5
F
4:
30
Then Do
12: Do (P86)
1:
41
Set Port 1 High
13: Else (P94)
14: If (X
!F) (P89)
1:
2
X Loc [ counter ]
2:
3
>=
3:
10
F
4:
30
Then Do
15: Do (P86)
1:
41
Set Port 1 High
16: End (P95)
17: End (P95)
A logical OR can also be constructed by setting
a flag high if a comparison is true. (The flag is
cleared or set low before making comparisons.)
After all comparisons have been made, execute
the desired instructions if the flag is set high.
The Begin Case Instruction 93 and If Case
Instruction 83 allow a series of tests on the
value in an input location. The case test is
started with Instruction 93 which specifies the
location to test. A series of Instruction 83s are
then used to compare the value in the location
with fixed values. When the value in the input
location is less than the fixed value specified in
Instruction 83, the command in that Instruction
83 is executed, and execution branches to the
END Instruction 95 which closes the case test
(see Instruction 93, Section 12).
;CASE Logic construction example:
18: CASE (P93)
1:
3
Case Loc [ Reading ]
19: If Case Location < F (P83)
1:
1.8
F
2:
30
Then Do
;See Section 9 for details of this Instruction
20: AC Half Bridge (P5)
21: End (P95)
22: If Case Location < F (P83)
1:
9.25
F
2:
30
Then do
;See Section 9 for details of this Instruction
23: Full Bridge (P6)
24: End (P95)
25: If Case Location < F (P83)
1:
280
F
2:
30
Then do
;See Section 9 for details of this Instruction
26: Full Bridge (P6)
27: End (P95)
28: End (P95)
3.8.2 NESTING
A branching or loop instruction which occurs
before a previous branch or loop has been
closed is nested. The maximum nesting level is
11 deep. Loop Instruction 87 and Begin Case
Instruction 93 both count as 1 level.
Instructions 83, 86, 88, 89, 91, and 92 each
count as one level when used with the
Command "30" which is the "Then Do"
command. Use of Else, Instruction 94, also
counts as one nesting level each time it is used.
For example, the AND construction above is
nested 2 deep while the OR construction is
nested 3 deep.
Subroutine calls do not count as nesting with
the above instructions, though they have their
own nesting limit (maximum of 6, see
Instruction 85, Section 12). Branching and loop
nesting start at zero in each subroutine.