Campbell Scientific CR10X Measurement and Control System User Manual
Page 185

SECTION 12. PROGRAM CONTROL INSTRUCTIONS
12-3
When the same output processing is required
on values in sequential input locations, it must
be accomplished by using the repetitions
parameter of the Output Instruction, not by
indexing the input location within a loop.
An Output Instruction within a loop is allotted the
same number of Intermediate Storage locations
as it would receive if it were not in the loop. For
example, the average instruction with a single
repetition is allotted only two Intermediate
locations: one for the number of samples and
one for the running total. Each time through the
loop the sample counter is incremented and the
value in the referenced input location is added
to the total. If the input location is indexed, the
values from all input locations are added to the
same total.
Note that if the Output Flag is set prior to
entering the loop in the above example, 10
values will be output. The first will be the
average of all the readings in locations 1-10
since the previous output. Because the
Intermediate locations are zeroed each time an
output occurs, the next nine values will be the
current values (samples at the time of output) of
locations 2-10.
Loops can be nested. Indexed locations within
nested loops are indexed to the inner most loop
that they are within. The maximum nesting
level in the CR10X is 11 deep. This applies to If
Then/Else comparisons and Loops or any
combination thereof. An If Then/Else
comparison which uses the Else Instruction (94)
counts as being nested 2 deep.
PARAM.
DATA
NUMBER
TYPE
DESCRIPTION
01:
4
Delay
02:
4
Iteration count
The following example involves the use of the
Loop Instruction, without a delay, to perform a
block data transformation.
The user wants 1 hour averages of the vapor
pressure calculated from the wet- and dry-bulb
temperatures of 5 psychrometers. One
pressure transducer measurement is also
available for use in the vapor pressure
calculation.
1.
The input locations are assigned as follows:
a) pressure
Location 10
b) dry-bulb temperatures
Location 11-15
c)
wet-bulb temperatures
Location 16-20
d) calculated vapor pressure
Location 21-25
(Vapor pressure is written over the
wet-bulb temperatures.)
2.
The program flow is as follows:
a) Enter the Loop Instruction (#87) with
Delay=0 and iteration count=5.
b) Calculate the vapor pressure with
Instruction 57 using a normal location
entry of 10 for atmospheric pressure
and Indexed locations of 11, 16 and 16
for the dry-bulb, wet-bulb, and
calculated vapor pressure, respectively.
c)
End loop with Instruction 95.
d) Use the If Time Instruction (#92) to set
the Output Flag every hour.
e) Use the Average Instruction (#71) with
5 repetitions starting at input location 21
to average the vapor pressure over the
hour.
The actual keyboard entries for the examples
are shown below with the first example
Instruction location equal to 10. The Input
Instructions to make the pressure and
temperature measurements are assumed.
TABLE 12-3. Loop Example: Block Data
Transform
10:
P87
Beginning of Loop
01:
0
Delay
02:
5
Loop Count
11:
P57
Wet/Dry Bulb Temp to VP
01:
10
Pressure Loc
02:
11--
Dry Bulb Temp Loc DRY BLB#1
03:
16--
Wet Bulb Temp Loc VP #1
04:
21--
Loc [:VP #1 ]
12:
P95
End
13:
P92
If time is
01:
0
minutes into a
02:
60
minute interval
03:
10
Set high Flag 0 (output)
14:
P71
Average
01:
5
Reps
02:
21
Loc VP #1