SECTION 3. INSTRUCTION SET BASICS
3-5
3.8.1 IF THEN/ELSE COMPARISONS
Program Control Instructions can be used for If
then/else comparisons. When Command 30
(Then do) is used with Instructions 83 or 88-92,
the If Instruction is followed immediately by
instructions to execute if the comparison is true.
The Else Instruction (94) is optional and is
followed by the instructions to execute if the
comparison is false. The End Instruction (95)
ends the If then/else comparison and marks the
beginning of the instructions that are executed
regardless of the outcome of the comparison
(see Figure 3.8-1).
FIGURE 3.8-1. If Then/Else
Execution Sequence
;Logical ELSE construction example:
;Check condition
1: If (X
!
F) (P89)
1:
1
X Loc [ DO_ppm ]
2:
4
<
3:
3.5
F
4
30
Then Do
;Instruction(s) to execute if above condition is true
2: Do (P86)
1:
41
Set Port 1 High
3: Else (P94)
;Instruction(s) to execute if above condition is false
4: Do (P86)
1:
51
Set Port 1 Low
5: End (P95)
FIGURE 3.8-2. Logical AND Construction
;Logical AND construction example:
;Check first condition
6: If (X
!
F) (P89)
1:
1
X Loc [ DO_ppm ]
2:
4
<
3:
3.5
F
4:
30
Then Do
;AND check second condition
7: If (X
!
F) (P89)
1:
2
X Loc [ Counter ]
2:
3
>=
3:
10
F
4:
30
Then Do
;Instruction(s) to execute if both conditions are true
8: Do (P86)
1:
41 Set Port 1 High
9: End (P95)
10: End (P95)
If Then/Else comparisons may be nested to
form logical AND or OR branching. Figure 3.8-
2 illustrates an AND construction. If conditions A
and B are true, the instructions included
between IF B and the first End Instruction will
be executed.
If either of the conditions is false, execution will
jump to the corresponding End Instruction,
skipping the instructions between.
A logical OR construction is also possible.
Figure 3.8-3 illustrates the instruction sequence
that will result in subroutine X being executed if
either A or B is true.
Содержание CR510
Страница 1: ...CR510 DATALOGGER OPERATOR S MANUAL REVISION 2 03 COPYRIGHT c 1986 2003 CAMPBELL SCIENTIFIC INC ...
Страница 2: ...This is a blank page ...
Страница 4: ...This is a blank page ...
Страница 10: ...This is a blank page ...
Страница 44: ...SECTION 1 FUNCTIONAL MODES 1 14 This is a blank page ...
Страница 56: ...SECTION 3 INSTRUCTION SET BASICS 3 8 ...
Страница 104: ...SECTION 8 PROCESSING AND PROGRAM CONTROL EXAMPLES 8 8 This is a blank page ...
Страница 128: ...SECTION 10 PROCESSING INSTRUCTIONS 10 8 This is a blank page ...
Страница 144: ...SECTION 12 PROGRAM CONTROL INSTRUCTIONS 12 10 This is a blank page ...
Страница 172: ...SECTION 14 INSTALLATION AND MAINTENANCE 14 10 This is a blank page ...
Страница 176: ...APPENDIX A GLOSSARY A 4 This is a blank page ...
Страница 184: ...This is a blank page ...
Страница 188: ...APPENDIX D DATALOGGER INITIATED COMMUNICATIONS D 4 This is a blank page ...
Страница 196: ...APPENDIX F MODBUS ON THE CR10 X AND CR510 F 4 This is a blank page ...
Страница 197: ...APPENDIX G TD OPERATING SYSTEM ADDENDUM FOR CR510 CR10X AND CR23X MANUALS ...
Страница 198: ...This is a blank page ...
Страница 200: ...This is a blank page ...
Страница 206: ...TABLE DATA ADDENDUM AD 6 This is a blank page ...
Страница 222: ...TD ADDENDUM SECTION 1 FUNCTIONAL MODES AD 1 8 This is a blank page ...
Страница 238: ...TD ADDENDUM SECTION 8 PROCESSING AND PROGRAM CONTROL EXAMPLES AD 8 10 This is a blank page ...
Страница 240: ...This is a blank page ...