Campbell Scientific CR10 CR10 Measurement and Control - Page 157

Program Control

Page 157 highlights

SECTION 12. PROGRAM CONTROL INSTRUCTIONS TABLE 12-1. Flag Description Flag 0 Flag 1 to 8 Flag 9 Output Flag User Flags lntermediate Processing Disable Flag TABLE 12-2. Command Godes O Go to end of program table3 11-90, -7199-98 Callsubroutinel-9,79-991 Set Flag 0-9 high 20-29 Set Flag 0-9 low 30 Then Do 31 Exit loop if true 32 Exit loop if false 41-48 Set Port 1-8 higha 51-58 Set Port 1-8low2 61-68 Toggle Port 1-82 71-78 Pulse Port 1-82 1 97 and 98 are special subroutines which can be called by Control ports 7 and 8 going high; see Instruction 85 for details. 2 The ports can be indexed to the loop counter (Section 8.4). 3 lf this command is executed while in a subroutine, execution jumps directly to the end of the table that called the subroutine. *** gtll lF cAsE x < F **' FUNCTION lf the value in the location specified in the Begin Case lnstruction 93 is less than the fixed value entered as parameter 1 then execute the command in parameter 2 then go to the end of the case statement when the next Instruction 83 occurs. Else, continue to next instruction. See lnstruction 93 for an example. PARAM. NUMBER TDAYTAPE 01: FP 02: 2 DESCRIPTION Fixed value Command t** 85 LABEL SUBROUTINE **T FUNCTION This instruction marks the start of a subroutine. Subroutines are a series of instructions beginning with Instruction 85 and terminated with lnstruction 95, END. Allsubroutines must be placed in Table 3 (Subroutine Table). When a subroutine is called by a command in a Program Control Instruction, the subroutine is executed, then program flow continues with the instruction following that which called the subroutine. Subroutines may be called from within other subroutines (nested). The maximum nesting level for subroutines is 7 deep. Attempts to nest more than 7 deep will not be detected at compilation, but will result in a run time error. When the seventh subroutine attempts to call the eighth, error 31 will be displayed. Execution will not branch to the eighth subroutine; it will continue with the Instruction following that calling the subroutine. 98, 97 PORT INTERRUPT SUBROUTINES. If subroutine 98 (97) is included in Table 3 then Port 8 (7) will cause an interrupt on the rising edge and the subroutine will be executed. These subroutines can also be called from any table. These subroutines can interrupt Table 1 or 2 or can occur when neither Table is being executed. When the port activating 97 or 98 goes high during the execution of a table, the instruction being executed is completed before the subroutine is run (i.e. it is as if the subroutine was called by the next instruction). The priority is 98, 97, Table 1, Table 2, lf both 97 and 98 are pending (Ports go high at the same time or both go high during the execution of the same instruction in one of the tables), 98 will be executed first. lf 97 or 98 has not interrupted a table then neither table can interrupt it. 97 and 98 cannot interrupt each other. However, when 97 or 98 interrupts a table, it is as if the subroutine were in the table (e.9., if 98 interrupts Table 2, either Table 1 or 97 can interrupt it). While 97 or 98 is being executed as a result of the respective port going high, that port interrupt is disabled (i.e., the subroutine must be completed before the poft going high will have any effect). 12-1

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238

SECTION
12.
PROGRAM CONTROL
INSTRUCTIONS
TABLE
12-1.
Flag
Description
Flag
0
Flag
1
to
8
Flag
9
Output
Flag
User Flags
lntermediate
Processing
Disable Flag
TABLE 12-2. Command
Godes
O
Go
to
end
of
program table3
1-9,
79-98
Callsubroutinel-9,79-991
10-19
Set Flag
0-9
high
20-29
Set Flag
0-9
low
30
Then
Do
31
Exit loop
if
true
32
Exit loop
if
false
41-48
Set
Port
1-8
higha
51-58
Set
Port 1-8low2
61-68
Toggle Port
1-82
71-78
Pulse Port
1-82
1
97 and 98 are special subroutines which
can be called by Control ports
7
and 8 going
high;
see
Instruction 85 for details.
2
The
ports
can
be indexed to
the
loop
counter
(Section 8.4).
3
lf
this
command
is executed
while
in a
subroutine, execution
jumps
directly to
the
end
of
the table that called
the
subroutine.
***
gtll
lF
cAsE x
<
F
**'
FUNCTION
lf
the
value
in
the
location specified
in
the
Begin
Case lnstruction
93 is less than the fixed value
entered as
parameter
1
then
execute
the
command
in parameter
2
then
go
to
the
end of
the case statement when
the next
Instruction 83
occurs.
Else, continue
to
next
instruction.
See
lnstruction 93 for an example.
PARAM.
DATA
NUMBER
TYPE
DESCRIPTION
01:
FP
Fixed
value
02:
2
Command
t**
85
LABEL SUBROUTINE
**T
FUNCTION
This instruction
marks
the
start of a subroutine.
Subroutines are
a
series
of instructions
beginning
with
Instruction 85 and terminated
with
lnstruction
95,
END. Allsubroutines
must
be
placed
in
Table 3
(Subroutine
Table).
When
a subroutine
is
called
by
a
command
in
a
Program
Control
Instruction,
the subroutine
is
executed,
then
program flow continues with
the
instruction following that which called
the
subroutine.
Subroutines may be called
from
within
other
subroutines
(nested).
The
maximum nesting
level
for
subroutines
is
7
deep.
Attempts
to
nest more than 7 deep
will
not be detected at
compilation,
but
will
result in
a
run
time error.
When
the
seventh subroutine attempts to call
the
eighth, error 31
will
be
displayed.
Execution
will
not branch to
the
eighth subroutine;
it
will
continue with
the
Instruction following
that
calling
the
subroutine.
98,
97
PORT INTERRUPT
SUBROUTINES.
If
subroutine 98 (97) is included
in
Table
3
then
Port
8
(7)
will cause
an
interrupt on
the
rising
edge and
the
subroutine
will
be executed.
These
subroutines can also be called
from
any
table.
These
subroutines
can
interrupt
Table
1
or 2 or
can occur
when
neither
Table
is being
executed.
When
the
port
activating
97 or 98
goes high during
the
execution of
a
table, the
instruction being
executed
is
completed
before
the
subroutine
is
run (i.e. it
is
as
if
the
subroutine was called by
the
next instruction).
The
priority
is
98, 97,
Table
1,
Table
2,
lf
both
97 and 98
are
pending (Ports
go
high
at
the
same
time
or both go high during
the
execution
of
the same
instruction
in
one of the tables), 98
will be executed
first.
lf 97 or 98 has not
interrupted
a
table
then
neither table can
interrupt
it.
97 and 98
cannot
interrupt each
other.
However,
when
97 or
98
interrupts
a
table,
it is as
if
the
subroutine
were
in
the table
(e.9.,
if
98
interrupts
Table
2, either
Table
1
or
97
can
interrupt
it).
While
97 or
98
is being
executed
as
a
result of
the
respective port going high,
that
port interrupt
is
disabled
(i.e.,
the subroutine
must be
completed
before
the
poft
going
high
will
have
any effect).
12-1