Campbell Scientific CR10 CR10 Measurement and Control - Page 111

PanlTemp, 10smplav

Page 111 highlights

SECTION 8. PROCESSING AND PROGRAM CONTROL EXAMPLES The following examples are intended to illustrate the use of Processing and Program Control lnstructions, flags, dual Final Storage, and the capability to direct the results of Output Processing lnstructions to lnput Storage. The specific examples may not be as important as some of the techniques employed, for example: Directing Output Processing to Input Storage is used in the Running Average and Rainfall lntensity examples (8.1 and 8.2). Flag tests are used in the Running Average, lnterrupt Subroutine, Converting Wind Direction, and Saving Data Priorto Event examples (8.1,8.5,8.7 and 8.8). Control ports and the Loop are illustrated in the AM32 example (8.3). An algorithm for a down counter is used in the Saving Data Prior to Event example (8.8). As in Section 7 these examples are not complete programs to be taken verbatim. They need to be altered to fit specific needs. 8.1 COMPUTATION OF RUNNING AVERAGE It is sometimes necessary to compute a running average (i.e., the average covers a fixed number of samples and is continuously updated as new samples are taken). Because the output interval is shoder than the averaging period, lnstruction 71 cannot be used; the algorithm for computing this average must be programmed by the user. The following example demonstrates a program for computing a running average. In this example, each time a new measurement is made (in this case a thermocouple temperature) an average is computed for the 10 most recent samples. This is done by saving all 10 temperatures in contiguous input locations and using the SpatialAverage lnstruction (51) to compute the average. The temperatures are stored in locations 11 through 20. Each time the table is executed, the new measurement is stored in location 20 and the average is stored in location 2. The Block Move Instruction (5a) is then used to move the temperatures from locations 12 through 20 down by 1 location; the oldest measurement (in location 1 1) is lost when the temperature from location 12 is written over it. lnput Location Labels; 1:PanlTemp 2:10smplav 1 1:Temp l2:Temp i-9 i-8 13:Temp 14:Temp ii--76 1S:Temp i-5 16:Temp i-4 17:Temp i-3 18:Temp i-2 19:Temp i-1 2O:Temp i Where i is current reading, i-l is previous reading, etc. " 1 01: 10 TablelPrograms Sec. Execution lnterval 01: P17 01: 1 Panel Temperature Loc [:PanlTemp] 02: 01: 02; 03: 04: 05: 06: 07: 08: P14 1 1 1 1 1 20 1 0 Thermocouple Temp (DIFF) Rep 2.5 mV slow Range lN Chan Type T (Copper-Constantan) Ref Temp Loc Panl Temp i Loc [:Temp ] Mult Offset 03: P51 01: 10 02: 11 03: 2 SpatialAverage Swath First Loc Temp i-9 Avg Loc [:1Osmplav] 8-l

  • 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
8.
PROCESSING
AND
PROGRAM CONTROL EXAMPLES
The following examples
are
intended
to
illustrate the use of Processing and Program
Control
lnstructions,
flags, dual
Final
Storage,
and
the capability to direct
the
results of Output Processing
lnstructions to
lnput
Storage.
The
specific
examples
may
not
be as important
as
some
of
the
techniques
employed,
for example:
Directing
Output
Processing to
Input
Storage
is
used
in
the Running
Average and
Rainfall
lntensity
examples
(8.1
and
8.2).
Flag
tests
are
used
in
the Running
Average, lnterrupt
Subroutine,
Converting
Wind Direction,
and
Saving Data
Priorto
Event
examples
(8.1,8.5,8.7
and 8.8).
Control
ports
and
the Loop are illustrated
in
the
AM32
example
(8.3).
An algorithm
for
a
down counter
is
used
in
the Saving Data Prior to Event example
(8.8).
As
in
Section 7
these examples are not complete
programs
to
be
taken
verbatim.
They
need
to
be
altered to fit specific needs.
8.1
COMPUTATION OF
RUNNING
AVERAGE
It is
sometimes
necessary to compute
a
running
average (i.e., the average covers
a
fixed
number of samples
and
is
continuously
updated
as
new samples are
taken).
Because
the
output interval
is
shoder
than the averaging
period,
lnstruction 71
cannot
be used;
the
algorithm for computing this
average
must
be
programmed by
the
user.
The following
example
demonstrates a
program
for
computing
a running
average.
In
this
example,
each
time a
new measurement
is made (in
this
case
a
thermocouple
temperature)
an
average is computed for
the
10
most recent
samples.
This
is
done by saving all
10
temperatures
in
contiguous
input locations
and using
the SpatialAverage lnstruction
(51)
to compute
the
average.
The temperatures are
stored in locations
11
through
20.
Each
time
the
table
is executed,
the
new measurement
is
stored in location
20
and the
average
is
stored
in location
2.
The
Block Move Instruction (5a)
is
then
used
to
move the temperatures
from
locations
12
through 20 down
by
1
location; the
oldest
measurement (in
location
1
1)
is lost
when the temperature
from location
12
is
written
over
it.
lnput
Location Labels;
1:PanlTemp
1S:Temp i-5
2:10smplav
16:Temp i-4
1
1:Temp
i-9
17:Temp i-3
l2:Temp
i-8
18:Temp i-2
13:Temp
i-7
19:Temp
i-1
14:Temp
i-6
2O:Temp
i
Where i is current reading,
i-l
is
previous
reading,
etc.
"
1
TablelPrograms
01: 10
Sec. Execution
lnterval
01:
P17
01:
1
P14
1
1
1
1
1
20
1
0
P51
10
11
2
02:
01:
02;
03:
04:
05:
06:
07:
08:
03:
01:
02:
03:
Panel
Temperature
Loc
[:PanlTemp]
Thermocouple Temp
(DIFF)
Rep
2.5
mV
slow
Range
lN Chan
Type
T
(Copper-Constantan)
Ref
Temp Loc
Panl
Temp
Loc
[:Temp
i
]
Mult
Offset
SpatialAverage
Swath
First Loc
Temp
i-9
Avg
Loc
[:1Osmplav]
8-l